1*5225e6b1SAndroid Build Coastguard Worker /* 2*5225e6b1SAndroid Build Coastguard Worker * Copyright (C) 2021 The Android Open Source Project 3*5225e6b1SAndroid Build Coastguard Worker * 4*5225e6b1SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*5225e6b1SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*5225e6b1SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*5225e6b1SAndroid Build Coastguard Worker * 8*5225e6b1SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*5225e6b1SAndroid Build Coastguard Worker * 10*5225e6b1SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*5225e6b1SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*5225e6b1SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*5225e6b1SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*5225e6b1SAndroid Build Coastguard Worker * limitations under the License. 15*5225e6b1SAndroid Build Coastguard Worker */ 16*5225e6b1SAndroid Build Coastguard Worker 17*5225e6b1SAndroid Build Coastguard Worker #ifndef LIBXBC_H_ 18*5225e6b1SAndroid Build Coastguard Worker #define LIBXBC_H_ 19*5225e6b1SAndroid Build Coastguard Worker 20*5225e6b1SAndroid Build Coastguard Worker // memcpy and strncmp 21*5225e6b1SAndroid Build Coastguard Worker #include <common.h> 22*5225e6b1SAndroid Build Coastguard Worker 23*5225e6b1SAndroid Build Coastguard Worker /* 24*5225e6b1SAndroid Build Coastguard Worker * Add a string of boot config parameters to memory appended by the trailer. 25*5225e6b1SAndroid Build Coastguard Worker * This memory needs to be immediately following the end of the ramdisks. 26*5225e6b1SAndroid Build Coastguard Worker * The new boot config trailer will be written to the end of the entire 27*5225e6b1SAndroid Build Coastguard Worker * parameter section(previous + new). The trailer contains a 4 byte size of the 28*5225e6b1SAndroid Build Coastguard Worker * parameters, followed by a 4 byte checksum of the parameters, followed by a 12 29*5225e6b1SAndroid Build Coastguard Worker * byte magic string. 30*5225e6b1SAndroid Build Coastguard Worker * 31*5225e6b1SAndroid Build Coastguard Worker * @param params pointer to string of boot config parameters 32*5225e6b1SAndroid Build Coastguard Worker * @param params_size size of params string in bytes 33*5225e6b1SAndroid Build Coastguard Worker * @param bootconfig_start_addr address that the boot config section is starting 34*5225e6b1SAndroid Build Coastguard Worker * at in memory. 35*5225e6b1SAndroid Build Coastguard Worker * @param bootconfig_size size of the current bootconfig section in bytes. 36*5225e6b1SAndroid Build Coastguard Worker * @return number of bytes added to the boot config section. -1 for error. 37*5225e6b1SAndroid Build Coastguard Worker */ 38*5225e6b1SAndroid Build Coastguard Worker int addBootConfigParameters(const char *params, uint32_t params_size, 39*5225e6b1SAndroid Build Coastguard Worker uint64_t bootconfig_start_addr, 40*5225e6b1SAndroid Build Coastguard Worker uint32_t bootconfig_size); 41*5225e6b1SAndroid Build Coastguard Worker 42*5225e6b1SAndroid Build Coastguard Worker /* 43*5225e6b1SAndroid Build Coastguard Worker * Add the boot config trailer to the end of the boot config parameter section. 44*5225e6b1SAndroid Build Coastguard Worker * This can be used after the vendor bootconfig section has been placed into 45*5225e6b1SAndroid Build Coastguard Worker * memory if there are no additional parameters that need to be added. 46*5225e6b1SAndroid Build Coastguard Worker * The new boot config trailer will be written to the end of the entire 47*5225e6b1SAndroid Build Coastguard Worker * parameter section at (bootconfig_start_addr + bootconfig_size). 48*5225e6b1SAndroid Build Coastguard Worker * The trailer contains a 4 byte size of the parameters, followed by a 4 byte 49*5225e6b1SAndroid Build Coastguard Worker * checksum of the parameters, followed by a 12 byte magic string. 50*5225e6b1SAndroid Build Coastguard Worker * 51*5225e6b1SAndroid Build Coastguard Worker * @param bootconfig_start_addr address that the boot config section is starting 52*5225e6b1SAndroid Build Coastguard Worker * at in memory. 53*5225e6b1SAndroid Build Coastguard Worker * @param bootconfig_size size of the current bootconfig section in bytes. 54*5225e6b1SAndroid Build Coastguard Worker * @return number of bytes added to the boot config section. -1 for error. 55*5225e6b1SAndroid Build Coastguard Worker */ 56*5225e6b1SAndroid Build Coastguard Worker int addBootConfigTrailer(uint64_t bootconfig_start_addr, 57*5225e6b1SAndroid Build Coastguard Worker uint32_t bootconfig_size); 58*5225e6b1SAndroid Build Coastguard Worker 59*5225e6b1SAndroid Build Coastguard Worker #endif /* LIBXBC_H_ */ 60