#include <stdlib.h>
#include <assert.h>
#include <debug.h>
-#include <err.h>
#include <kernel/boot_params.h>
#include <platform/platform_p.h>
#include <common/ote_nv_uuid.h>
return offset;
}
-static int parse_cmdline(void)
-{
- boot_params *boot_params_ptr = (boot_params*)__bootarg_addr;
- char *str;
- int cmdline_len, i;
- struct cmdline_member members[] = {
- {CMDLINE_OS_BOOT_ADDR, &normal_os_coldboot_fn},
- {CMDLINE_DEVICE_UID0, &device_uid[0]},
- {CMDLINE_DEVICE_UID1, &device_uid[1]},
- {CMDLINE_DEVICE_UID2, &device_uid[2]},
- {CMDLINE_DEVICE_UID3, &device_uid[3]},
- {CMDLINE_DEBUG_UART_ID, &debug_uart_id},
- {CMDLINE_TFKEY_ADDR, &tf_key_addr},
- {CMDLINE_TFKEY_SIZE, &tf_key_size},
- {CMDLINE_DTB_ADDR, &dtb_addr}
- };
-
- if (!boot_params_ptr ||
- !boot_params_ptr->param_string[0])
- return ERR_INVALID_ARGS;
-
- /* Check whether parameters are passed as cmdline or structure */
- cmdline_len = boot_params_ptr->param_string_sz;
- if (cmdline_len == 0)
- return ERR_NOT_SUPPORTED;
-
- str = boot_params_ptr->param_string;
- for (i = 0; i < cmdline_len; i++) {
- if (*(str + i) == '\n') {
- *(str + i) = '\0';
- cmdline_len--;
- }
- }
-
- str = boot_params_ptr->param_string;
- while (cmdline_len > 0) {
- if (*str == '[')
- goto done;
-
- unsigned int offset = getoffsetof(str, ':');
-
- if (strlen(str) < offset)
- goto done;
-
- *(str + offset) = '\0';
- cmdline_len -= (strlen(str) + 1);
-
- for (i = 0; i < ARRAY_SIZE(members); i++) {
- if (!strncmp(str, (const char *)&members[i].name, strlen(members[i].name))) {
- str += strlen(str) + 2;
- *members[i].container = atoi(str);
- cmdline_len--;
- break;
- } else if (!strncmp(str, CMDLINE_DRAM_RANGE, strlen(CMDLINE_DRAM_RANGE))) {
- paddr_t base, size;
-
- /* format is "mem: <size>M@<base>M" in MBbytes */
- str += strlen(str) + 2;
- size = (paddr_t) atoui(str);
- base = (paddr_t) atoui(strchr(str, '@') + 1);
- cmdline_len--;
-
- tz_add_dram_range(base << 20, size << 20);
- break;
- } else if (!strncmp(str, CMDLINE_TSEC_CARVEOUT, strlen(CMDLINE_TSEC_CARVEOUT))) {
-
- /* format is "tsec: <size>M@<base>M" in MBbytes */
- str += strlen(str) + 2;
- tsec_carveout_size = (paddr_t) atoui(str);
- tsec_carveout_base = (paddr_t) atoui(strchr(str, '@') + 1);
- tsec_carveout_size <<= 20;
- tsec_carveout_base <<= 20;
- cmdline_len--;
- break;
- }
- }
-
- if (i == ARRAY_SIZE(members)) {
- str += strlen(str) + 2;
- cmdline_len--;
- }
-
-done:
- cmdline_len -= strlen(str);
- str += strlen(str) + 1;
- }
- return NO_ERROR;
-}
-
-static int parse_bootargs(void)
+void get_boot_params(void)
{
- boot_params_t *boot_params_ptr = (boot_params*)__bootarg_addr;
+ boot_params_t *boot_params_ptr = (boot_params_t*)__bootarg_addr;
uint64_t base, size;
- if (!boot_params_ptr || boot_params_ptr->version != 0)
- return ERR_INVALID_ARGS;
+ if (!boot_params_ptr)
+ return;
device_uid[0] = boot_params_ptr->chip_uid[0];
device_uid[1] = boot_params_ptr->chip_uid[1];
tsec_carveout_size <<= 20;
tsec_carveout_base <<= 20;
- return NO_ERROR;
-}
-
-void get_boot_params(void)
-{
- int32_t err = NO_ERROR;
-
- err = parse_cmdline();
- if (err)
- err = parse_bootargs();
}
int get_boot_args(task_t *task, uint32_t *argv)
__WEAK void platform_setup_keys(void)
{
- boot_params *boot_params_ptr;
boot_params_t *boot_params_ptr_args;
key_params *keys_ptr;
- int cmdline_len;
uint32_t reg, offset;
extern uint32_t __bootarg_addr;
/* keys immediately follow the boot params in DRAM */
- boot_params_ptr = (boot_params *) __bootarg_addr;
-
- cmdline_len = boot_params_ptr->param_string_sz;
-
- /* Check whether parameters are passed as cmdline or structure */
- if (cmdline_len == 0) {
- boot_params_ptr_args = (boot_params_t *) __bootarg_addr;
- offset = sizeof(boot_params_t);
- keys_ptr = (key_params *)((uintptr_t)boot_params_ptr_args + offset);
- } else {
- offset = ROUNDUP(boot_params_ptr->param_string_sz, sizeof(uint32_t));
- keys_ptr = (key_params *)((uintptr_t)boot_params_ptr->param_string + offset);
- }
+ boot_params_ptr_args = (boot_params_t *) __bootarg_addr;
+ offset = sizeof(boot_params_t);
+ keys_ptr = (key_params *)((uintptr_t)boot_params_ptr_args + offset);
/* ensure TZRAM clock is enabled */
reg = readl(TEGRA_CLK_RESET_BASE + CLK_OUT_ENB_V);