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