dmi_scan.c
来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 638 行 · 第 1/2 页
C
638 行
#include <linux/types.h>#include <linux/kernel.h>#include <linux/string.h>#include <linux/init.h>#include <linux/module.h>#include <linux/slab.h>#include <asm/acpi.h>#include <asm/io.h>#include <linux/pm.h>#include <asm/system.h>#include <linux/dmi.h>#include <linux/bootmem.h>int es7000_plat = 0;struct dmi_header{ u8 type; u8 length; u16 handle;};#undef DMI_DEBUG#ifdef DMI_DEBUG#define dmi_printk(x) printk x#else#define dmi_printk(x)#endifstatic char * __init dmi_string(struct dmi_header *dm, u8 s){ u8 *bp=(u8 *)dm; bp+=dm->length; if(!s) return ""; s--; while(s>0 && *bp) { bp+=strlen(bp); bp++; s--; } return bp;}/* * We have to be cautious here. We have seen BIOSes with DMI pointers * pointing to completely the wrong place for example */ static int __init dmi_table(u32 base, int len, int num, void (*decode)(struct dmi_header *)){ u8 *buf; struct dmi_header *dm; u8 *data; int i=0; buf = bt_ioremap(base, len); if(buf==NULL) return -1; data = buf; /* * Stop when we see all the items the table claimed to have * OR we run off the end of the table (also happens) */ while(i<num && data-buf+sizeof(struct dmi_header)<=len) { dm=(struct dmi_header *)data; /* * We want to know the total length (formated area and strings) * before decoding to make sure we won't run off the table in * dmi_decode or dmi_string */ data+=dm->length; while(data-buf<len-1 && (data[0] || data[1])) data++; if(data-buf<len-1) decode(dm); data+=2; i++; } bt_iounmap(buf, len); return 0;}inline static int __init dmi_checksum(u8 *buf){ u8 sum=0; int a; for(a=0; a<15; a++) sum+=buf[a]; return (sum==0);}static int __init dmi_iterate(void (*decode)(struct dmi_header *)){ u8 buf[15]; u32 fp=0xF0000; while (fp < 0xFFFFF) { isa_memcpy_fromio(buf, fp, 15); if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf)) { u16 num=buf[13]<<8|buf[12]; u16 len=buf[7]<<8|buf[6]; u32 base=buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8]; /* * DMI version 0.0 means that the real version is taken from * the SMBIOS version, which we don't know at this point. */ if(buf[14]!=0) printk(KERN_INFO "DMI %d.%d present.\n", buf[14]>>4, buf[14]&0x0F); else printk(KERN_INFO "DMI present.\n"); dmi_printk((KERN_INFO "%d structures occupying %d bytes.\n", num, len)); dmi_printk((KERN_INFO "DMI table at 0x%08X.\n", base)); if(dmi_table(base,len, num, decode)==0) return 0; } fp+=16; } return -1;}static char *dmi_ident[DMI_STRING_MAX];/* * Save a DMI string */ static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string){ char *d = (char*)dm; char *p = dmi_string(dm, d[string]); if(p==NULL || *p == 0) return; if (dmi_ident[slot]) return; dmi_ident[slot] = alloc_bootmem(strlen(p)+1); if(dmi_ident[slot]) strcpy(dmi_ident[slot], p); else printk(KERN_ERR "dmi_save_ident: out of memory.\n");}/* * Ugly compatibility crap. */#define dmi_blacklist dmi_system_id#define NO_MATCH { DMI_NONE, NULL}#define MATCH DMI_MATCH/* * Some machines, usually laptops, can't handle an enabled local APIC. * The symptoms include hangs or reboots when suspending or resuming, * attaching or detaching the power cord, or entering BIOS setup screens * through magic key sequences. */static int __init local_apic_kills_bios(struct dmi_blacklist *d){#ifdef CONFIG_X86_LOCAL_APIC extern int enable_local_apic; if (enable_local_apic == 0) { enable_local_apic = -1; printk(KERN_WARNING "%s with broken BIOS detected. " "Refusing to enable the local APIC.\n", d->ident); }#endif return 0;}/* * Toshiba keyboard likes to repeat keys when they are not repeated. */static __init int broken_toshiba_keyboard(struct dmi_blacklist *d){ printk(KERN_WARNING "Toshiba with broken keyboard detected. If your keyboard sometimes generates 3 keypresses instead of one, see http://davyd.ucc.asn.au/projects/toshiba/README\n"); return 0;}#ifdef CONFIG_ACPI_SLEEPstatic __init int reset_videomode_after_s3(struct dmi_blacklist *d){ /* See acpi_wakeup.S */ extern long acpi_video_flags; acpi_video_flags |= 2; return 0;}#endif#ifdef CONFIG_ACPI_BOOTextern int acpi_force;static __init __attribute__((unused)) int dmi_disable_acpi(struct dmi_blacklist *d) { if (!acpi_force) { printk(KERN_NOTICE "%s detected: acpi off\n",d->ident); disable_acpi(); } else { printk(KERN_NOTICE "Warning: DMI blacklist says broken, but acpi forced\n"); } return 0;} /* * Limit ACPI to CPU enumeration for HT */static __init __attribute__((unused)) int force_acpi_ht(struct dmi_blacklist *d) { if (!acpi_force) { printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", d->ident); disable_acpi(); acpi_ht = 1; } else { printk(KERN_NOTICE "Warning: acpi=force overrules DMI blacklist: acpi=ht\n"); } return 0;} /* * early nForce2 reference BIOS shipped with a * bogus ACPI IRQ0 -> pin2 interrupt override -- ignore it */static __init int ignore_timer_override(struct dmi_blacklist *d){ extern int acpi_skip_timer_override; printk(KERN_NOTICE "%s detected: BIOS IRQ0 pin2 override" " will be ignored\n", d->ident); acpi_skip_timer_override = 1; return 0;}#endif#ifdef CONFIG_ACPI_PCIstatic __init int disable_acpi_irq(struct dmi_blacklist *d) { if (!acpi_force) { printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n", d->ident); acpi_noirq_set(); } return 0;}static __init int disable_acpi_pci(struct dmi_blacklist *d) { if (!acpi_force) { printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n", d->ident); acpi_disable_pci(); } return 0;} #endif/* * Process the DMI blacklists */ /* * This will be expanded over time to force things like the APM * interrupt mask settings according to the laptop */ static __initdata struct dmi_blacklist dmi_blacklist[]={ /* Machines which have problems handling enabled local APICs */ { local_apic_kills_bios, "Dell Inspiron", { MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), MATCH(DMI_PRODUCT_NAME, "Inspiron"), NO_MATCH, NO_MATCH } }, { local_apic_kills_bios, "Dell Latitude", { MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), MATCH(DMI_PRODUCT_NAME, "Latitude"), NO_MATCH, NO_MATCH } }, { local_apic_kills_bios, "IBM Thinkpad T20", { MATCH(DMI_BOARD_VENDOR, "IBM"), MATCH(DMI_BOARD_NAME, "264741U"), NO_MATCH, NO_MATCH } }, { local_apic_kills_bios, "ASUS L3C", { MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), MATCH(DMI_BOARD_NAME, "P4_L3C"), NO_MATCH, NO_MATCH } }, { broken_toshiba_keyboard, "Toshiba Satellite 4030cdt", { /* Keyboard generates spurious repeats */ MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"), NO_MATCH, NO_MATCH, NO_MATCH } },#ifdef CONFIG_ACPI_SLEEP { reset_videomode_after_s3, "Toshiba Satellite 4030cdt", { /* Reset video mode after returning from ACPI S3 sleep */ MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?