Commit 849ee9b9 authored by Len Brown's avatar Len Brown

[ACPI] delete ACPI table parsing code from bootflags module

parent e707332d
......@@ -378,6 +378,25 @@ acpi_scan_rsdp (
return 0;
}
static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
{
struct acpi_table_sbf *sb;
if (!phys_addr || !size)
return -EINVAL;
sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size);
if (!sb) {
printk(KERN_WARNING PREFIX "Unable to map SBF\n");
return -ENODEV;
}
sbf_port = sb->sbf_cmos; /* Save CMOS port */
return 0;
}
#ifdef CONFIG_HPET_TIMER
extern unsigned long hpet_address;
......@@ -616,6 +635,8 @@ acpi_boot_init (void)
return error;
}
(void) acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
/*
* blacklist may disable ACPI entirely
*/
......
/*
* Implement 'Simple Boot Flag Specification 1.0'
*
* Implement 'Simple Boot Flag Specification 2.0'
*/
......@@ -11,6 +10,7 @@
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/acpi.h>
#include <asm/io.h>
#include <linux/mc146818rtc.h>
......@@ -23,56 +23,8 @@
#define SBF_PARITY (1<<7)
struct sbf_boot
{
u8 sbf_signature[4];
u32 sbf_len;
u8 sbf_revision __attribute((packed));
u8 sbf_csum __attribute((packed));
u8 sbf_oemid[6] __attribute((packed));
u8 sbf_oemtable[8] __attribute((packed));
u8 sbf_revdata[4] __attribute((packed));
u8 sbf_creator[4] __attribute((packed));
u8 sbf_crearev[4] __attribute((packed));
u8 sbf_cmos __attribute((packed));
u8 sbf_spare[3] __attribute((packed));
};
static int sbf_port __initdata = -1;
static int __init sbf_struct_valid(unsigned long tptr)
{
u8 *ap;
u8 v;
unsigned int i;
struct sbf_boot sb;
memcpy_fromio(&sb, (void *)tptr, sizeof(sb));
if(sb.sbf_len != 40 && sb.sbf_len != 39)
// 39 on IBM ThinkPad A21m, BIOS version 1.02b (KXET24WW; 2000-12-19).
return 0;
ap = (u8 *)&sb;
v= 0;
for(i=0;i<sb.sbf_len;i++)
v+=*ap++;
if(v)
return 0;
if(memcmp(sb.sbf_signature, "BOOT", 4))
return 0;
int sbf_port __initdata = -1; /* set via acpi_boot_init() */
if (sb.sbf_len == 39)
printk (KERN_WARNING "SBF: ACPI BOOT descriptor is wrong length (%d)\n",
sb.sbf_len);
sbf_port = sb.sbf_cmos; /* Save CMOS port */
return 1;
}
static int __init parity(u8 v)
{
......@@ -96,7 +48,7 @@ static void __init sbf_write(u8 v)
if(!parity(v))
v|=SBF_PARITY;
printk(KERN_INFO "SBF: Setting boot flags 0x%x\n",v);
printk(KERN_INFO "Simple Boot Flag 0x%x\n", v);
spin_lock_irqsave(&rtc_lock, flags);
CMOS_WRITE(v, sbf_port);
......@@ -125,15 +77,15 @@ static int __init sbf_value_valid(u8 v)
return 1;
}
static void __init sbf_bootup(void)
static int __init sbf_init(void)
{
u8 v;
if(sbf_port == -1)
return;
return 0;
v = sbf_read();
if(!sbf_value_valid(v))
printk(KERN_WARNING "SBF: Simple boot flag value 0x%x read from CMOS RAM was invalid\n",v);
printk(KERN_WARNING "Simple Boot Flag value 0x%x read from CMOS RAM was invalid\n",v);
v &= ~SBF_RESERVED;
v &= ~SBF_BOOTING;
v &= ~SBF_DIAG;
......@@ -141,112 +93,6 @@ static void __init sbf_bootup(void)
v |= SBF_PNPOS;
#endif
sbf_write(v);
}
static int __init sbf_init(void)
{
unsigned int i;
void *rsdt;
u32 rsdtlen = 0;
u32 rsdtbase = 0;
u8 sum = 0;
int n;
u8 *p;
for(i=0xE0000; i <= 0xFFFE0; i+=16)
{
p = phys_to_virt(i);
if(memcmp(p, "RSD PTR ", 8))
continue;
sum = 0;
for(n=0; n<20; n++)
sum+=p[n];
if(sum != 0)
continue;
/* So it says RSD PTR and it checksums... */
/*
* Process the RDSP pointer
*/
rsdtbase = *(u32 *)(p+16);
/*
* RSDT length is ACPI 2 only, for ACPI 1 we must map
* and remap.
*/
if(p[15]>1)
rsdtlen = *(u32 *)(p+20);
else
rsdtlen = 36;
if(rsdtlen < 36 || rsdtlen > 1024)
continue;
break;
}
if(i>0xFFFE0)
return 0;
rsdt = ioremap(rsdtbase, rsdtlen);
if(rsdt == 0)
return 0;
i = readl(rsdt + 4);
/*
* Remap if needed
*/
if(i > rsdtlen)
{
rsdtlen = i;
iounmap(rsdt);
rsdt = ioremap(rsdtbase, rsdtlen);
if(rsdt == 0)
return 0;
}
for(n = 0; n < i; n++)
sum += readb(rsdt + n);
if(sum)
{
iounmap(rsdt);
return 0;
}
/* Ok the RSDT checksums too */
for(n = 36; n+3 < i; n += 4)
{
unsigned long rp = readl(rsdt+n);
int len = 4096;
if(rp > 0xFFFFFFFFUL - len)
len = 0xFFFFFFFFUL - rp;
/* Too close to the end!! */
if(len < 20)
continue;
rp = (unsigned long)ioremap(rp, 4096);
if(rp == 0)
continue;
if(sbf_struct_valid(rp))
{
/* Found the BOOT table and processed it */
printk(KERN_INFO "SBF: Simple Boot Flag extension found and enabled.\n");
}
iounmap((void *)rp);
}
iounmap(rsdt);
sbf_bootup();
return 0;
}
......
......@@ -232,9 +232,28 @@ struct acpi_table_hpet {
u8 page_protect;
} __attribute__ ((packed));
/*
* Simple Boot Flags
* http://www.microsoft.com/whdc/hwdev/resources/specs/simp_bios.mspx
*/
struct acpi_table_sbf
{
u8 sbf_signature[4];
u32 sbf_len;
u8 sbf_revision;
u8 sbf_csum;
u8 sbf_oemid[6];
u8 sbf_oemtable[8];
u8 sbf_revdata[4];
u8 sbf_creator[4];
u8 sbf_crearev[4];
u8 sbf_cmos;
u8 sbf_spare[3];
} __attribute__ ((packed));
/*
* System Resource Affinity Table (SRAT)
* see http://www.microsoft.com/hwdev/design/srat.htm
* http://www.microsoft.com/whdc/hwdev/platform/proc/SRAT.mspx
*/
struct acpi_table_srat {
......@@ -381,6 +400,8 @@ extern int acpi_mp_config;
extern u32 pci_mmcfg_base_addr;
extern int sbf_port ;
#else /*!CONFIG_ACPI_BOOT*/
#define acpi_mp_config 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment