env.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Author: Huacai Chen <[email protected]>
  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. u64 efi_system_table;
  15. struct loongson_system_configuration loongson_sysconf;
  16. EXPORT_SYMBOL(loongson_sysconf);
  17. void __init init_environ(void)
  18. {
  19. int efi_boot = fw_arg0;
  20. char *cmdline = early_memremap_ro(fw_arg1, COMMAND_LINE_SIZE);
  21. if (efi_boot)
  22. set_bit(EFI_BOOT, &efi.flags);
  23. else
  24. clear_bit(EFI_BOOT, &efi.flags);
  25. strscpy(boot_command_line, cmdline, COMMAND_LINE_SIZE);
  26. early_memunmap(cmdline, COMMAND_LINE_SIZE);
  27. efi_system_table = fw_arg2;
  28. }
  29. static int __init init_cpu_fullname(void)
  30. {
  31. int cpu;
  32. if (loongson_sysconf.cpuname && !strncmp(loongson_sysconf.cpuname, "Loongson", 8)) {
  33. for (cpu = 0; cpu < NR_CPUS; cpu++)
  34. __cpu_full_name[cpu] = loongson_sysconf.cpuname;
  35. }
  36. return 0;
  37. }
  38. arch_initcall(init_cpu_fullname);
  39. static ssize_t boardinfo_show(struct kobject *kobj,
  40. struct kobj_attribute *attr, char *buf)
  41. {
  42. return sprintf(buf,
  43. "BIOS Information\n"
  44. "Vendor\t\t\t: %s\n"
  45. "Version\t\t\t: %s\n"
  46. "ROM Size\t\t: %d KB\n"
  47. "Release Date\t\t: %s\n\n"
  48. "Board Information\n"
  49. "Manufacturer\t\t: %s\n"
  50. "Board Name\t\t: %s\n"
  51. "Family\t\t\t: LOONGSON64\n\n",
  52. b_info.bios_vendor, b_info.bios_version,
  53. b_info.bios_size, b_info.bios_release_date,
  54. b_info.board_vendor, b_info.board_name);
  55. }
  56. static struct kobj_attribute boardinfo_attr = __ATTR(boardinfo, 0444,
  57. boardinfo_show, NULL);
  58. static int __init boardinfo_init(void)
  59. {
  60. struct kobject *loongson_kobj;
  61. loongson_kobj = kobject_create_and_add("loongson", firmware_kobj);
  62. return sysfs_create_file(loongson_kobj, &boardinfo_attr.attr);
  63. }
  64. late_initcall(boardinfo_init);