Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * bootstr.c:  Boot string/argument acquisition from the PROM.
0004  *
0005  * Copyright(C) 1995 David S. Miller (davem@caip.rutgers.edu)
0006  * Copyright(C) 1996,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
0007  */
0008 
0009 #include <linux/string.h>
0010 #include <linux/init.h>
0011 #include <asm/oplib.h>
0012 
0013 /* WARNING: The boot loader knows that these next three variables come one right
0014  *          after another in the .data section.  Do not move this stuff into
0015  *          the .bss section or it will break things.
0016  */
0017 
0018 /* We limit BARG_LEN to 1024 because this is the size of the
0019  * 'barg_out' command line buffer in the SILO bootloader.
0020  */
0021 #define BARG_LEN 1024
0022 struct {
0023     int bootstr_len;
0024     int bootstr_valid;
0025     char bootstr_buf[BARG_LEN];
0026 } bootstr_info = {
0027     .bootstr_len = BARG_LEN,
0028 #ifdef CONFIG_CMDLINE
0029     .bootstr_valid = 1,
0030     .bootstr_buf = CONFIG_CMDLINE,
0031 #endif
0032 };
0033 
0034 char * __init
0035 prom_getbootargs(void)
0036 {
0037     /* This check saves us from a panic when bootfd patches args. */
0038     if (bootstr_info.bootstr_valid)
0039         return bootstr_info.bootstr_buf;
0040     prom_getstring(prom_chosen_node, "bootargs",
0041                bootstr_info.bootstr_buf, BARG_LEN);
0042     bootstr_info.bootstr_valid = 1;
0043     return bootstr_info.bootstr_buf;
0044 }