162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * bootstr.c:  Boot string/argument acquisition from the PROM.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright(C) 1995 David S. Miller (davem@caip.rutgers.edu)
662306a36Sopenharmony_ci * Copyright(C) 1996,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/string.h>
1062306a36Sopenharmony_ci#include <linux/init.h>
1162306a36Sopenharmony_ci#include <asm/oplib.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* WARNING: The boot loader knows that these next three variables come one right
1462306a36Sopenharmony_ci *          after another in the .data section.  Do not move this stuff into
1562306a36Sopenharmony_ci *          the .bss section or it will break things.
1662306a36Sopenharmony_ci */
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/* We limit BARG_LEN to 1024 because this is the size of the
1962306a36Sopenharmony_ci * 'barg_out' command line buffer in the SILO bootloader.
2062306a36Sopenharmony_ci */
2162306a36Sopenharmony_ci#define BARG_LEN 1024
2262306a36Sopenharmony_cistruct {
2362306a36Sopenharmony_ci	int bootstr_len;
2462306a36Sopenharmony_ci	int bootstr_valid;
2562306a36Sopenharmony_ci	char bootstr_buf[BARG_LEN];
2662306a36Sopenharmony_ci} bootstr_info = {
2762306a36Sopenharmony_ci	.bootstr_len = BARG_LEN,
2862306a36Sopenharmony_ci#ifdef CONFIG_CMDLINE
2962306a36Sopenharmony_ci	.bootstr_valid = 1,
3062306a36Sopenharmony_ci	.bootstr_buf = CONFIG_CMDLINE,
3162306a36Sopenharmony_ci#endif
3262306a36Sopenharmony_ci};
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_cichar * __init
3562306a36Sopenharmony_ciprom_getbootargs(void)
3662306a36Sopenharmony_ci{
3762306a36Sopenharmony_ci	/* This check saves us from a panic when bootfd patches args. */
3862306a36Sopenharmony_ci	if (bootstr_info.bootstr_valid)
3962306a36Sopenharmony_ci		return bootstr_info.bootstr_buf;
4062306a36Sopenharmony_ci	prom_getstring(prom_chosen_node, "bootargs",
4162306a36Sopenharmony_ci		       bootstr_info.bootstr_buf, BARG_LEN);
4262306a36Sopenharmony_ci	bootstr_info.bootstr_valid = 1;
4362306a36Sopenharmony_ci	return bootstr_info.bootstr_buf;
4462306a36Sopenharmony_ci}
45