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