2 * Copyright (c) 2009 Alex Keda <admin@lissyara.su>
3 * Copyright (c) 2009-2010 Jung-uk Kim <jkim@FreeBSD.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
31 #include "opt_x86bios.h"
33 #include <sys/param.h>
35 #include <sys/kernel.h>
37 #include <sys/malloc.h>
38 #include <sys/module.h>
39 #include <sys/mutex.h>
40 #include <sys/sysctl.h>
42 #include <contrib/x86emu/x86emu.h>
43 #include <contrib/x86emu/x86emu_regs.h>
44 #include <compat/x86bios/x86bios.h>
46 #include <dev/pci/pcireg.h>
47 #include <dev/pci/pcivar.h>
53 #define X86BIOS_NATIVE_ARCH
56 #define X86BIOS_NATIVE_VM86
59 #define X86BIOS_MEM_SIZE 0x00100000 /* 1M */
61 #define X86BIOS_TRACE(h, n, r) do { \
63 " (ax=0x%04x bx=0x%04x cx=0x%04x dx=0x%04x es=0x%04x di=0x%04x)\n",\
64 (n), (r)->R_AX, (r)->R_BX, (r)->R_CX, (r)->R_DX, \
65 (r)->R_ES, (r)->R_DI); \
68 static struct mtx x86bios_lock;
70 static SYSCTL_NODE(_debug, OID_AUTO, x86bios, CTLFLAG_RD, NULL,
72 static int x86bios_trace_call;
73 SYSCTL_INT(_debug_x86bios, OID_AUTO, call, CTLFLAG_RWTUN, &x86bios_trace_call, 0,
74 "Trace far function calls");
75 static int x86bios_trace_int;
76 SYSCTL_INT(_debug_x86bios, OID_AUTO, int, CTLFLAG_RWTUN, &x86bios_trace_int, 0,
77 "Trace software interrupt handlers");
79 #ifdef X86BIOS_NATIVE_VM86
81 #include <machine/vm86.h>
82 #include <machine/vmparam.h>
83 #include <machine/pc/bios.h>
85 struct vm86context x86bios_vmc;
88 x86bios_emu2vmf(struct x86emu_regs *regs, struct vm86frame *vmf)
91 vmf->vmf_ds = regs->R_DS;
92 vmf->vmf_es = regs->R_ES;
93 vmf->vmf_ax = regs->R_AX;
94 vmf->vmf_bx = regs->R_BX;
95 vmf->vmf_cx = regs->R_CX;
96 vmf->vmf_dx = regs->R_DX;
97 vmf->vmf_bp = regs->R_BP;
98 vmf->vmf_si = regs->R_SI;
99 vmf->vmf_di = regs->R_DI;
103 x86bios_vmf2emu(struct vm86frame *vmf, struct x86emu_regs *regs)
106 regs->R_DS = vmf->vmf_ds;
107 regs->R_ES = vmf->vmf_es;
108 regs->R_FLG = vmf->vmf_flags;
109 regs->R_AX = vmf->vmf_ax;
110 regs->R_BX = vmf->vmf_bx;
111 regs->R_CX = vmf->vmf_cx;
112 regs->R_DX = vmf->vmf_dx;
113 regs->R_BP = vmf->vmf_bp;
114 regs->R_SI = vmf->vmf_si;
115 regs->R_DI = vmf->vmf_di;
119 x86bios_alloc(uint32_t *offset, size_t size, int flags)
124 if (offset == NULL || size == 0)
126 vaddr = contigmalloc(size, M_DEVBUF, flags, 0, X86BIOS_MEM_SIZE,
129 *offset = vtophys(vaddr);
130 mtx_lock(&x86bios_lock);
131 for (i = 0; i < atop(round_page(size)); i++)
132 vm86_addpage(&x86bios_vmc, atop(*offset) + i,
133 (vm_offset_t)vaddr + ptoa(i));
134 mtx_unlock(&x86bios_lock);
141 x86bios_free(void *addr, size_t size)
146 if (addr == NULL || size == 0)
148 paddr = vtophys(addr);
149 if (paddr >= X86BIOS_MEM_SIZE || (paddr & PAGE_MASK) != 0)
151 mtx_lock(&x86bios_lock);
152 for (i = 0; i < x86bios_vmc.npages; i++)
153 if (x86bios_vmc.pmap[i].kva == (vm_offset_t)addr)
155 if (i >= x86bios_vmc.npages) {
156 mtx_unlock(&x86bios_lock);
159 nfree = atop(round_page(size));
160 bzero(x86bios_vmc.pmap + i, sizeof(*x86bios_vmc.pmap) * nfree);
161 if (i + nfree == x86bios_vmc.npages) {
162 x86bios_vmc.npages -= nfree;
163 while (--i >= 0 && x86bios_vmc.pmap[i].kva == 0)
164 x86bios_vmc.npages--;
166 mtx_unlock(&x86bios_lock);
167 contigfree(addr, size, M_DEVBUF);
171 x86bios_init_regs(struct x86regs *regs)
174 bzero(regs, sizeof(*regs));
178 x86bios_call(struct x86regs *regs, uint16_t seg, uint16_t off)
180 struct vm86frame vmf;
182 if (x86bios_trace_call)
183 X86BIOS_TRACE(Calling 0x%06x, (seg << 4) + off, regs);
185 bzero(&vmf, sizeof(vmf));
186 x86bios_emu2vmf((struct x86emu_regs *)regs, &vmf);
189 mtx_lock(&x86bios_lock);
190 vm86_datacall(-1, &vmf, &x86bios_vmc);
191 mtx_unlock(&x86bios_lock);
192 x86bios_vmf2emu(&vmf, (struct x86emu_regs *)regs);
194 if (x86bios_trace_call)
195 X86BIOS_TRACE(Exiting 0x%06x, (seg << 4) + off, regs);
199 x86bios_get_intr(int intno)
202 return (readl(BIOS_PADDRTOVADDR(intno * 4)));
206 x86bios_set_intr(int intno, uint32_t saddr)
209 writel(BIOS_PADDRTOVADDR(intno * 4), saddr);
213 x86bios_intr(struct x86regs *regs, int intno)
215 struct vm86frame vmf;
217 if (x86bios_trace_int)
218 X86BIOS_TRACE(Calling INT 0x%02x, intno, regs);
220 bzero(&vmf, sizeof(vmf));
221 x86bios_emu2vmf((struct x86emu_regs *)regs, &vmf);
222 mtx_lock(&x86bios_lock);
223 vm86_datacall(intno, &vmf, &x86bios_vmc);
224 mtx_unlock(&x86bios_lock);
225 x86bios_vmf2emu(&vmf, (struct x86emu_regs *)regs);
227 if (x86bios_trace_int)
228 X86BIOS_TRACE(Exiting INT 0x%02x, intno, regs);
232 x86bios_offset(uint32_t offset)
236 addr = vm86_getaddr(&x86bios_vmc, X86BIOS_PHYSTOSEG(offset),
237 X86BIOS_PHYSTOOFF(offset));
239 addr = BIOS_PADDRTOVADDR(offset);
241 return ((void *)addr);
248 mtx_init(&x86bios_lock, "x86bios lock", NULL, MTX_DEF);
249 bzero(&x86bios_vmc, sizeof(x86bios_vmc));
258 mtx_destroy(&x86bios_lock);
265 #include <machine/iodev.h>
267 #define X86BIOS_PAGE_SIZE 0x00001000 /* 4K */
269 #define X86BIOS_IVT_SIZE 0x00000500 /* 1K + 256 (BDA) */
271 #define X86BIOS_IVT_BASE 0x00000000
272 #define X86BIOS_RAM_BASE 0x00001000
273 #define X86BIOS_ROM_BASE 0x000a0000
275 #define X86BIOS_ROM_SIZE (X86BIOS_MEM_SIZE - x86bios_rom_phys)
276 #define X86BIOS_SEG_SIZE X86BIOS_PAGE_SIZE
278 #define X86BIOS_PAGES (X86BIOS_MEM_SIZE / X86BIOS_PAGE_SIZE)
280 #define X86BIOS_R_SS _pad2
281 #define X86BIOS_R_SP _pad3.I16_reg.x_reg
283 static struct x86emu x86bios_emu;
285 static void *x86bios_ivt;
286 static void *x86bios_rom;
287 static void *x86bios_seg;
289 static vm_offset_t *x86bios_map;
291 static vm_paddr_t x86bios_rom_phys;
292 static vm_paddr_t x86bios_seg_phys;
294 static int x86bios_fault;
295 static uint32_t x86bios_fault_addr;
296 static uint16_t x86bios_fault_cs;
297 static uint16_t x86bios_fault_ip;
300 x86bios_set_fault(struct x86emu *emu, uint32_t addr)
304 x86bios_fault_addr = addr;
305 x86bios_fault_cs = emu->x86.R_CS;
306 x86bios_fault_ip = emu->x86.R_IP;
307 x86emu_halt_sys(emu);
311 x86bios_get_pages(uint32_t offset, size_t size)
315 if (offset + size > X86BIOS_MEM_SIZE + X86BIOS_IVT_SIZE)
318 if (offset >= X86BIOS_MEM_SIZE)
319 offset -= X86BIOS_MEM_SIZE;
320 addr = x86bios_map[offset / X86BIOS_PAGE_SIZE];
322 addr += offset % X86BIOS_PAGE_SIZE;
324 return ((void *)addr);
328 x86bios_set_pages(vm_offset_t va, vm_paddr_t pa, size_t size)
332 for (i = pa / X86BIOS_PAGE_SIZE, j = 0;
333 j < howmany(size, X86BIOS_PAGE_SIZE); i++, j++)
334 x86bios_map[i] = va + j * X86BIOS_PAGE_SIZE;
338 x86bios_emu_rdb(struct x86emu *emu, uint32_t addr)
342 va = x86bios_get_pages(addr, sizeof(*va));
344 x86bios_set_fault(emu, addr);
350 x86bios_emu_rdw(struct x86emu *emu, uint32_t addr)
354 va = x86bios_get_pages(addr, sizeof(*va));
356 x86bios_set_fault(emu, addr);
358 #ifndef __NO_STRICT_ALIGNMENT
360 return (le16dec(va));
363 return (le16toh(*va));
367 x86bios_emu_rdl(struct x86emu *emu, uint32_t addr)
371 va = x86bios_get_pages(addr, sizeof(*va));
373 x86bios_set_fault(emu, addr);
375 #ifndef __NO_STRICT_ALIGNMENT
377 return (le32dec(va));
380 return (le32toh(*va));
384 x86bios_emu_wrb(struct x86emu *emu, uint32_t addr, uint8_t val)
388 va = x86bios_get_pages(addr, sizeof(*va));
390 x86bios_set_fault(emu, addr);
396 x86bios_emu_wrw(struct x86emu *emu, uint32_t addr, uint16_t val)
400 va = x86bios_get_pages(addr, sizeof(*va));
402 x86bios_set_fault(emu, addr);
404 #ifndef __NO_STRICT_ALIGNMENT
413 x86bios_emu_wrl(struct x86emu *emu, uint32_t addr, uint32_t val)
417 va = x86bios_get_pages(addr, sizeof(*va));
419 x86bios_set_fault(emu, addr);
421 #ifndef __NO_STRICT_ALIGNMENT
430 x86bios_emu_inb(struct x86emu *emu, uint16_t port)
433 #ifndef X86BIOS_NATIVE_ARCH
434 if (port == 0xb2) /* APM scratch register */
436 if (port >= 0x80 && port < 0x88) /* POST status register */
440 return (iodev_read_1(port));
444 x86bios_emu_inw(struct x86emu *emu, uint16_t port)
448 #ifndef X86BIOS_NATIVE_ARCH
449 if (port >= 0x80 && port < 0x88) /* POST status register */
452 if ((port & 1) != 0) {
453 val = iodev_read_1(port);
454 val |= iodev_read_1(port + 1) << 8;
457 val = iodev_read_2(port);
463 x86bios_emu_inl(struct x86emu *emu, uint16_t port)
467 #ifndef X86BIOS_NATIVE_ARCH
468 if (port >= 0x80 && port < 0x88) /* POST status register */
471 if ((port & 1) != 0) {
472 val = iodev_read_1(port);
473 val |= iodev_read_2(port + 1) << 8;
474 val |= iodev_read_1(port + 3) << 24;
475 } else if ((port & 2) != 0) {
476 val = iodev_read_2(port);
477 val |= iodev_read_2(port + 2) << 16;
480 val = iodev_read_4(port);
486 x86bios_emu_outb(struct x86emu *emu, uint16_t port, uint8_t val)
489 #ifndef X86BIOS_NATIVE_ARCH
490 if (port == 0xb2) /* APM scratch register */
492 if (port >= 0x80 && port < 0x88) /* POST status register */
496 iodev_write_1(port, val);
500 x86bios_emu_outw(struct x86emu *emu, uint16_t port, uint16_t val)
503 #ifndef X86BIOS_NATIVE_ARCH
504 if (port >= 0x80 && port < 0x88) /* POST status register */
507 if ((port & 1) != 0) {
508 iodev_write_1(port, val);
509 iodev_write_1(port + 1, val >> 8);
512 iodev_write_2(port, val);
516 x86bios_emu_outl(struct x86emu *emu, uint16_t port, uint32_t val)
519 #ifndef X86BIOS_NATIVE_ARCH
520 if (port >= 0x80 && port < 0x88) /* POST status register */
523 if ((port & 1) != 0) {
524 iodev_write_1(port, val);
525 iodev_write_2(port + 1, val >> 8);
526 iodev_write_1(port + 3, val >> 24);
527 } else if ((port & 2) != 0) {
528 iodev_write_2(port, val);
529 iodev_write_2(port + 2, val >> 16);
532 iodev_write_4(port, val);
536 x86bios_alloc(uint32_t *offset, size_t size, int flags)
540 if (offset == NULL || size == 0)
542 vaddr = contigmalloc(size, M_DEVBUF, flags, X86BIOS_RAM_BASE,
543 x86bios_rom_phys, X86BIOS_PAGE_SIZE, 0);
545 *offset = vtophys(vaddr);
546 mtx_lock(&x86bios_lock);
547 x86bios_set_pages((vm_offset_t)vaddr, *offset, size);
548 mtx_unlock(&x86bios_lock);
555 x86bios_free(void *addr, size_t size)
559 if (addr == NULL || size == 0)
561 paddr = vtophys(addr);
562 if (paddr < X86BIOS_RAM_BASE || paddr >= x86bios_rom_phys ||
563 paddr % X86BIOS_PAGE_SIZE != 0)
565 mtx_lock(&x86bios_lock);
566 bzero(x86bios_map + paddr / X86BIOS_PAGE_SIZE,
567 sizeof(*x86bios_map) * howmany(size, X86BIOS_PAGE_SIZE));
568 mtx_unlock(&x86bios_lock);
569 contigfree(addr, size, M_DEVBUF);
573 x86bios_init_regs(struct x86regs *regs)
576 bzero(regs, sizeof(*regs));
577 regs->X86BIOS_R_SS = X86BIOS_PHYSTOSEG(x86bios_seg_phys);
578 regs->X86BIOS_R_SP = X86BIOS_PAGE_SIZE - 2;
582 x86bios_call(struct x86regs *regs, uint16_t seg, uint16_t off)
585 if (x86bios_trace_call)
586 X86BIOS_TRACE(Calling 0x%06x, (seg << 4) + off, regs);
588 mtx_lock(&x86bios_lock);
589 memcpy((struct x86regs *)&x86bios_emu.x86, regs, sizeof(*regs));
592 x86emu_exec_call(&x86bios_emu, seg, off);
594 memcpy(regs, &x86bios_emu.x86, sizeof(*regs));
595 mtx_unlock(&x86bios_lock);
597 if (x86bios_trace_call) {
598 X86BIOS_TRACE(Exiting 0x%06x, (seg << 4) + off, regs);
600 printf("Page fault at 0x%06x from 0x%04x:0x%04x.\n",
601 x86bios_fault_addr, x86bios_fault_cs,
607 x86bios_get_intr(int intno)
610 return (le32toh(*((uint32_t *)x86bios_ivt + intno)));
614 x86bios_set_intr(int intno, uint32_t saddr)
617 *((uint32_t *)x86bios_ivt + intno) = htole32(saddr);
621 x86bios_intr(struct x86regs *regs, int intno)
624 if (intno < 0 || intno > 255)
627 if (x86bios_trace_int)
628 X86BIOS_TRACE(Calling INT 0x%02x, intno, regs);
630 mtx_lock(&x86bios_lock);
631 memcpy((struct x86regs *)&x86bios_emu.x86, regs, sizeof(*regs));
634 x86emu_exec_intr(&x86bios_emu, intno);
636 memcpy(regs, &x86bios_emu.x86, sizeof(*regs));
637 mtx_unlock(&x86bios_lock);
639 if (x86bios_trace_int) {
640 X86BIOS_TRACE(Exiting INT 0x%02x, intno, regs);
642 printf("Page fault at 0x%06x from 0x%04x:0x%04x.\n",
643 x86bios_fault_addr, x86bios_fault_cs,
649 x86bios_offset(uint32_t offset)
652 return (x86bios_get_pages(offset, 1));
656 x86bios_unmap_mem(void)
659 if (x86bios_map != NULL) {
660 free(x86bios_map, M_DEVBUF);
663 if (x86bios_ivt != NULL) {
664 #ifdef X86BIOS_NATIVE_ARCH
665 pmap_unmapbios((vm_offset_t)x86bios_ivt, X86BIOS_IVT_SIZE);
667 free(x86bios_ivt, M_DEVBUF);
671 if (x86bios_rom != NULL)
672 pmap_unmapdev((vm_offset_t)x86bios_rom, X86BIOS_ROM_SIZE);
673 if (x86bios_seg != NULL) {
674 contigfree(x86bios_seg, X86BIOS_SEG_SIZE, M_DEVBUF);
680 x86bios_map_mem(void)
683 x86bios_map = malloc(sizeof(*x86bios_map) * X86BIOS_PAGES, M_DEVBUF,
685 if (x86bios_map == NULL)
688 #ifdef X86BIOS_NATIVE_ARCH
689 x86bios_ivt = pmap_mapbios(X86BIOS_IVT_BASE, X86BIOS_IVT_SIZE);
691 /* Probe EBDA via BDA. */
692 x86bios_rom_phys = *(uint16_t *)((caddr_t)x86bios_ivt + 0x40e);
693 x86bios_rom_phys = x86bios_rom_phys << 4;
694 if (x86bios_rom_phys != 0 && x86bios_rom_phys < X86BIOS_ROM_BASE &&
695 X86BIOS_ROM_BASE - x86bios_rom_phys <= 128 * 1024)
697 rounddown(x86bios_rom_phys, X86BIOS_PAGE_SIZE);
700 x86bios_ivt = malloc(X86BIOS_IVT_SIZE, M_DEVBUF, M_NOWAIT | M_ZERO);
701 if (x86bios_ivt == NULL)
705 x86bios_rom_phys = X86BIOS_ROM_BASE;
706 x86bios_rom = pmap_mapdev(x86bios_rom_phys, X86BIOS_ROM_SIZE);
707 if (x86bios_rom == NULL)
709 #ifdef X86BIOS_NATIVE_ARCH
710 /* Change attribute for EBDA. */
711 if (x86bios_rom_phys < X86BIOS_ROM_BASE &&
712 pmap_change_attr((vm_offset_t)x86bios_rom,
713 X86BIOS_ROM_BASE - x86bios_rom_phys, PAT_WRITE_BACK) != 0)
717 x86bios_seg = contigmalloc(X86BIOS_SEG_SIZE, M_DEVBUF, M_NOWAIT,
718 X86BIOS_RAM_BASE, x86bios_rom_phys, X86BIOS_PAGE_SIZE, 0);
719 if (x86bios_seg == NULL)
721 x86bios_seg_phys = vtophys(x86bios_seg);
723 x86bios_set_pages((vm_offset_t)x86bios_ivt, X86BIOS_IVT_BASE,
725 x86bios_set_pages((vm_offset_t)x86bios_rom, x86bios_rom_phys,
727 x86bios_set_pages((vm_offset_t)x86bios_seg, x86bios_seg_phys,
731 printf("x86bios: IVT 0x%06jx-0x%06jx at %p\n",
732 (vm_paddr_t)X86BIOS_IVT_BASE,
733 (vm_paddr_t)X86BIOS_IVT_SIZE + X86BIOS_IVT_BASE - 1,
735 printf("x86bios: SSEG 0x%06jx-0x%06jx at %p\n",
737 (vm_paddr_t)X86BIOS_SEG_SIZE + x86bios_seg_phys - 1,
739 if (x86bios_rom_phys < X86BIOS_ROM_BASE)
740 printf("x86bios: EBDA 0x%06jx-0x%06jx at %p\n",
741 x86bios_rom_phys, (vm_paddr_t)X86BIOS_ROM_BASE - 1,
743 printf("x86bios: ROM 0x%06jx-0x%06jx at %p\n",
744 (vm_paddr_t)X86BIOS_ROM_BASE,
745 (vm_paddr_t)X86BIOS_MEM_SIZE - X86BIOS_SEG_SIZE - 1,
746 (caddr_t)x86bios_rom + X86BIOS_ROM_BASE - x86bios_rom_phys);
761 mtx_init(&x86bios_lock, "x86bios lock", NULL, MTX_DEF);
763 if (x86bios_map_mem() != 0)
766 bzero(&x86bios_emu, sizeof(x86bios_emu));
768 x86bios_emu.emu_rdb = x86bios_emu_rdb;
769 x86bios_emu.emu_rdw = x86bios_emu_rdw;
770 x86bios_emu.emu_rdl = x86bios_emu_rdl;
771 x86bios_emu.emu_wrb = x86bios_emu_wrb;
772 x86bios_emu.emu_wrw = x86bios_emu_wrw;
773 x86bios_emu.emu_wrl = x86bios_emu_wrl;
775 x86bios_emu.emu_inb = x86bios_emu_inb;
776 x86bios_emu.emu_inw = x86bios_emu_inw;
777 x86bios_emu.emu_inl = x86bios_emu_inl;
778 x86bios_emu.emu_outb = x86bios_emu_outb;
779 x86bios_emu.emu_outw = x86bios_emu_outw;
780 x86bios_emu.emu_outl = x86bios_emu_outl;
790 mtx_destroy(&x86bios_lock);
798 x86bios_get_orm(uint32_t offset)
802 /* Does the shadow ROM contain BIOS POST code for x86? */
803 p = x86bios_offset(offset);
804 if (p == NULL || p[0] != 0x55 || p[1] != 0xaa ||
805 (p[3] != 0xe9 && p[3] != 0xeb))
812 x86bios_match_device(uint32_t offset, device_t dev)
815 uint16_t device, vendor;
816 uint8_t class, progif, subclass;
818 /* Does the shadow ROM contain BIOS POST code for x86? */
819 p = x86bios_get_orm(offset);
823 /* Does it contain PCI data structure? */
824 p += le16toh(*(uint16_t *)(p + 0x18));
825 if (bcmp(p, "PCIR", 4) != 0 ||
826 le16toh(*(uint16_t *)(p + 0x0a)) < 0x18 || *(p + 0x14) != 0)
829 /* Does it match the vendor, device, and classcode? */
830 vendor = le16toh(*(uint16_t *)(p + 0x04));
831 device = le16toh(*(uint16_t *)(p + 0x06));
832 progif = *(p + 0x0d);
833 subclass = *(p + 0x0e);
835 if (vendor != pci_get_vendor(dev) || device != pci_get_device(dev) ||
836 class != pci_get_class(dev) || subclass != pci_get_subclass(dev) ||
837 progif != pci_get_progif(dev))
844 x86bios_modevent(module_t mod __unused, int type, void *data __unused)
849 return (x86bios_init());
851 return (x86bios_uninit());
857 static moduledata_t x86bios_mod = {
863 DECLARE_MODULE(x86bios, x86bios_mod, SI_SUB_CPU, SI_ORDER_ANY);
864 MODULE_VERSION(x86bios, 1);