Patrick Venture | 54c3b53 | 2018-08-01 11:45:49 -0700 | [diff] [blame^] | 1 | /* |
| 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 "flash-ipmi.hpp" |
| 18 | #include "ipmi.hpp" |
| 19 | |
| 20 | ipmi_ret_t startTransfer(UpdateInterface* updater, const uint8_t* reqBuf, |
| 21 | uint8_t* replyBuf, size_t* dataLen) |
| 22 | { |
| 23 | /* Validate the request buffer. */ |
| 24 | if (sizeof(struct StartTx) > (*dataLen)) |
| 25 | { |
| 26 | return IPMI_CC_INVALID; |
| 27 | } |
| 28 | |
| 29 | auto request = reinterpret_cast<const struct StartTx*>(reqBuf); |
| 30 | |
| 31 | if (!updater->start(request->length)) |
| 32 | { |
| 33 | return IPMI_CC_INVALID; |
| 34 | } |
| 35 | |
| 36 | /* We were successful and set the response byte to 0. */ |
| 37 | replyBuf[0] = 0x00; |
| 38 | (*dataLen) = 1; |
| 39 | return IPMI_CC_OK; |
| 40 | } |