blob: 36f4662f8b0bec8dc9424dd359c99e3b5f7d7ff1 [file] [log] [blame]
Patrick Ventureaccc9172018-07-24 10:51:58 -07001/*
2 * Copyright 2017 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "host-ipmid/ipmid-api.h"
18#include "host-ipmid/oemrouter.hpp"
19
20/* TODO: Once OEM IPMI number placement is settled, point to that. */
21namespace oem
22{
23namespace google
24{
25constexpr int number = 11129;
26constexpr int flashOverBTCmd = 127;
27} // namespace google
28} // namespace oem
29
30static ipmi_ret_t flashControl(ipmi_cmd_t cmd, const uint8_t* reqBuf,
31 uint8_t* replyCmdBuf, size_t* dataLen)
32{
33 /* Verify it's at least as long as the shortest message. */
34 if ((*dataLen) < 1)
35 {
36 return IPMI_CC_INVALID;
37 }
38
39 return IPMI_CC_INVALID;
40}
41
42static ipmi_ret_t ipmiFlashControl(ipmi_netfn_t netFn, ipmi_cmd_t cmd,
43 ipmi_request_t request,
44 ipmi_response_t response,
45 ipmi_data_len_t dataLen,
46 ipmi_context_t context)
47{
48 /* request_t, response_t are void*. ipmi_data_len_t is a size_t* */
49 auto reqBuf = static_cast<const uint8_t*>(request);
50 auto replyCmdBuf = static_cast<uint8_t*>(response);
51
52 return flashControl(cmd, reqBuf, replyCmdBuf, dataLen);
53}
54
55void setupGlobalOemFlashControl() __attribute__((constructor));
56
57void setupGlobalOemFlashControl()
58{
59#ifdef ENABLE_GOOGLE
60 oem::Router* router = oem::mutableRouter();
61
62 fprintf(stderr, "Registering OEM:[%#08X], Cmd:[%#04X] for Flash Update\n",
63 oem::google::number, oem::google::flashOverBTCmd);
64
65 router->registerHandler(oem::google::number, oem::google::flashOverBTCmd,
66 flashControl);
67#endif
68
69 ipmi_register_callback(NETFUN_FIRMWARE, oem::google::flashOverBTCmd, NULL,
70 ipmiFlashControl, PRIVILEGE_USER);
71}