1 // SPDX-License-Identifier: GPL-2.0
3 * Implement 'Simple Boot Flag Specification 2.0'
5 #include <linux/types.h>
6 #include <linux/kernel.h>
7 #include <linux/init.h>
8 #include <linux/string.h>
9 #include <linux/spinlock.h>
10 #include <linux/acpi.h>
13 #include <linux/mc146818rtc.h>
15 #define SBF_RESERVED (0x78)
16 #define SBF_PNPOS (1<<0)
17 #define SBF_BOOTING (1<<1)
18 #define SBF_DIAG (1<<2)
19 #define SBF_PARITY (1<<7)
21 int sbf_port __initdata = -1; /* set via acpi_boot_init() */
23 static int __init parity(u8 v)
28 for (i = 0; i < 8; i++) {
36 static void __init sbf_write(u8 v)
45 printk(KERN_INFO "Simple Boot Flag at 0x%x set to 0x%x\n",
48 spin_lock_irqsave(&rtc_lock, flags);
49 CMOS_WRITE(v, sbf_port);
50 spin_unlock_irqrestore(&rtc_lock, flags);
54 static u8 __init sbf_read(void)
62 spin_lock_irqsave(&rtc_lock, flags);
63 v = CMOS_READ(sbf_port);
64 spin_unlock_irqrestore(&rtc_lock, flags);
69 static int __init sbf_value_valid(u8 v)
71 if (v & SBF_RESERVED) /* Reserved bits */
79 static int __init sbf_init(void)
87 if (!sbf_value_valid(v)) {
88 printk(KERN_WARNING "Simple Boot Flag value 0x%x read from "
89 "CMOS RAM was invalid\n", v);
95 #if defined(CONFIG_ISAPNP)
102 arch_initcall(sbf_init);