xref: /openbmc/linux/arch/loongarch/kernel/env.c (revision 61f4d204)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Author: Huacai Chen <chenhuacai@loongson.cn>
4  *
5  * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
6  */
7 #include <linux/acpi.h>
8 #include <linux/efi.h>
9 #include <linux/export.h>
10 #include <linux/memblock.h>
11 #include <asm/early_ioremap.h>
12 #include <asm/bootinfo.h>
13 #include <asm/loongson.h>
14 #include <asm/setup.h>
15 
16 u64 efi_system_table;
17 struct loongson_system_configuration loongson_sysconf;
18 EXPORT_SYMBOL(loongson_sysconf);
19 
20 void __init init_environ(void)
21 {
22 	int efi_boot = fw_arg0;
23 	char *cmdline = early_memremap_ro(fw_arg1, COMMAND_LINE_SIZE);
24 
25 	if (efi_boot)
26 		set_bit(EFI_BOOT, &efi.flags);
27 	else
28 		clear_bit(EFI_BOOT, &efi.flags);
29 
30 	strscpy(boot_command_line, cmdline, COMMAND_LINE_SIZE);
31 	strscpy(init_command_line, cmdline, COMMAND_LINE_SIZE);
32 	early_memunmap(cmdline, COMMAND_LINE_SIZE);
33 
34 	efi_system_table = fw_arg2;
35 }
36 
37 static int __init init_cpu_fullname(void)
38 {
39 	int cpu;
40 
41 	if (loongson_sysconf.cpuname && !strncmp(loongson_sysconf.cpuname, "Loongson", 8)) {
42 		for (cpu = 0; cpu < NR_CPUS; cpu++)
43 			__cpu_full_name[cpu] = loongson_sysconf.cpuname;
44 	}
45 	return 0;
46 }
47 arch_initcall(init_cpu_fullname);
48 
49 static ssize_t boardinfo_show(struct kobject *kobj,
50 			      struct kobj_attribute *attr, char *buf)
51 {
52 	return sprintf(buf,
53 		"BIOS Information\n"
54 		"Vendor\t\t\t: %s\n"
55 		"Version\t\t\t: %s\n"
56 		"ROM Size\t\t: %d KB\n"
57 		"Release Date\t\t: %s\n\n"
58 		"Board Information\n"
59 		"Manufacturer\t\t: %s\n"
60 		"Board Name\t\t: %s\n"
61 		"Family\t\t\t: LOONGSON64\n\n",
62 		b_info.bios_vendor, b_info.bios_version,
63 		b_info.bios_size, b_info.bios_release_date,
64 		b_info.board_vendor, b_info.board_name);
65 }
66 
67 static struct kobj_attribute boardinfo_attr = __ATTR(boardinfo, 0444,
68 						     boardinfo_show, NULL);
69 
70 static int __init boardinfo_init(void)
71 {
72 	struct kobject *loongson_kobj;
73 
74 	loongson_kobj = kobject_create_and_add("loongson", firmware_kobj);
75 
76 	return sysfs_create_file(loongson_kobj, &boardinfo_attr.attr);
77 }
78 late_initcall(boardinfo_init);
79