blob: 0cb325734cfbb729ce0a3d027a73f5d4022d582e [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Yinghai Lu8fee13a42010-08-02 16:21:22 -07002#include "misc.h"
3
Kees Cook8ab38202013-10-10 17:18:14 -07004#if CONFIG_EARLY_PRINTK || CONFIG_RANDOMIZE_BASE
Gokul Caushikbd448d42012-07-19 18:04:42 -07005
Yinghai Lu8fee13a42010-08-02 16:21:22 -07006static unsigned long fs;
7static inline void set_fs(unsigned long seg)
8{
9 fs = seg << 4; /* shift it back */
10}
11typedef unsigned long addr_t;
12static inline char rdfs8(addr_t addr)
13{
14 return *((char *)(fs + addr));
15}
16#include "../cmdline.c"
Baoquan Hed52e7d52017-05-13 13:46:28 +080017unsigned long get_cmd_line_ptr(void)
Yinghai Luf1da8342013-01-24 12:19:57 -080018{
Kees Cook6655e0a2016-04-18 09:42:12 -070019 unsigned long cmd_line_ptr = boot_params->hdr.cmd_line_ptr;
Yinghai Luf1da8342013-01-24 12:19:57 -080020
Kees Cook6655e0a2016-04-18 09:42:12 -070021 cmd_line_ptr |= (u64)boot_params->ext_cmd_line_ptr << 32;
Yinghai Luee92d812013-01-28 20:16:44 -080022
Yinghai Luf1da8342013-01-24 12:19:57 -080023 return cmd_line_ptr;
24}
Yinghai Lu8fee13a42010-08-02 16:21:22 -070025int cmdline_find_option(const char *option, char *buffer, int bufsize)
26{
Yinghai Luf1da8342013-01-24 12:19:57 -080027 return __cmdline_find_option(get_cmd_line_ptr(), option, buffer, bufsize);
Yinghai Lu8fee13a42010-08-02 16:21:22 -070028}
29int cmdline_find_option_bool(const char *option)
30{
Yinghai Luf1da8342013-01-24 12:19:57 -080031 return __cmdline_find_option_bool(get_cmd_line_ptr(), option);
Yinghai Lu8fee13a42010-08-02 16:21:22 -070032}
Gokul Caushikbd448d42012-07-19 18:04:42 -070033
34#endif