1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 25de18cdeSSam Ravnborg /* 35de18cdeSSam Ravnborg * bootstr.c: Boot string/argument acquisition from the PROM. 45de18cdeSSam Ravnborg * 55de18cdeSSam Ravnborg * Copyright(C) 1995 David S. Miller (davem@caip.rutgers.edu) 65de18cdeSSam Ravnborg * Copyright(C) 1996,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 75de18cdeSSam Ravnborg */ 85de18cdeSSam Ravnborg 95de18cdeSSam Ravnborg #include <linux/string.h> 105de18cdeSSam Ravnborg #include <linux/init.h> 115de18cdeSSam Ravnborg #include <asm/oplib.h> 125de18cdeSSam Ravnborg 135de18cdeSSam Ravnborg /* WARNING: The boot loader knows that these next three variables come one right 145de18cdeSSam Ravnborg * after another in the .data section. Do not move this stuff into 155de18cdeSSam Ravnborg * the .bss section or it will break things. 165de18cdeSSam Ravnborg */ 175de18cdeSSam Ravnborg 181cef94c3SDave Kleikamp /* We limit BARG_LEN to 1024 because this is the size of the 191cef94c3SDave Kleikamp * 'barg_out' command line buffer in the SILO bootloader. 201cef94c3SDave Kleikamp */ 211cef94c3SDave Kleikamp #define BARG_LEN 1024 225de18cdeSSam Ravnborg struct { 235de18cdeSSam Ravnborg int bootstr_len; 245de18cdeSSam Ravnborg int bootstr_valid; 255de18cdeSSam Ravnborg char bootstr_buf[BARG_LEN]; 265de18cdeSSam Ravnborg } bootstr_info = { 275de18cdeSSam Ravnborg .bootstr_len = BARG_LEN, 285de18cdeSSam Ravnborg #ifdef CONFIG_CMDLINE 295de18cdeSSam Ravnborg .bootstr_valid = 1, 305de18cdeSSam Ravnborg .bootstr_buf = CONFIG_CMDLINE, 315de18cdeSSam Ravnborg #endif 325de18cdeSSam Ravnborg }; 335de18cdeSSam Ravnborg 345de18cdeSSam Ravnborg char * __init prom_getbootargs(void)355de18cdeSSam Ravnborgprom_getbootargs(void) 365de18cdeSSam Ravnborg { 375de18cdeSSam Ravnborg /* This check saves us from a panic when bootfd patches args. */ 385de18cdeSSam Ravnborg if (bootstr_info.bootstr_valid) 395de18cdeSSam Ravnborg return bootstr_info.bootstr_buf; 405de18cdeSSam Ravnborg prom_getstring(prom_chosen_node, "bootargs", 415de18cdeSSam Ravnborg bootstr_info.bootstr_buf, BARG_LEN); 425de18cdeSSam Ravnborg bootstr_info.bootstr_valid = 1; 435de18cdeSSam Ravnborg return bootstr_info.bootstr_buf; 445de18cdeSSam Ravnborg } 45