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