diff options
Diffstat (limited to 'usr/src/boot/sys/i386')
21 files changed, 1785 insertions, 0 deletions
diff --git a/usr/src/boot/sys/i386/include/_align.h b/usr/src/boot/sys/i386/include/_align.h new file mode 100644 index 0000000000..28c4669ad2 --- /dev/null +++ b/usr/src/boot/sys/i386/include/_align.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/_align.h> diff --git a/usr/src/boot/sys/i386/include/_inttypes.h b/usr/src/boot/sys/i386/include/_inttypes.h new file mode 100644 index 0000000000..40107cd74a --- /dev/null +++ b/usr/src/boot/sys/i386/include/_inttypes.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/_inttypes.h> diff --git a/usr/src/boot/sys/i386/include/_limits.h b/usr/src/boot/sys/i386/include/_limits.h new file mode 100644 index 0000000000..3c7365bb4e --- /dev/null +++ b/usr/src/boot/sys/i386/include/_limits.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/_limits.h> diff --git a/usr/src/boot/sys/i386/include/_stdint.h b/usr/src/boot/sys/i386/include/_stdint.h new file mode 100644 index 0000000000..db1affc077 --- /dev/null +++ b/usr/src/boot/sys/i386/include/_stdint.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/_stdint.h> diff --git a/usr/src/boot/sys/i386/include/_types.h b/usr/src/boot/sys/i386/include/_types.h new file mode 100644 index 0000000000..26803672ff --- /dev/null +++ b/usr/src/boot/sys/i386/include/_types.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/_types.h> diff --git a/usr/src/boot/sys/i386/include/asm.h b/usr/src/boot/sys/i386/include/asm.h new file mode 100644 index 0000000000..b2d4a6b289 --- /dev/null +++ b/usr/src/boot/sys/i386/include/asm.h @@ -0,0 +1,120 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 + * $FreeBSD$ + */ + +#ifndef _MACHINE_ASM_H_ +#define _MACHINE_ASM_H_ + +#include <sys/cdefs.h> + +#ifdef PIC +#define PIC_PROLOGUE \ + pushl %ebx; \ + call 1f; \ +1: \ + popl %ebx; \ + addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx +#define PIC_EPILOGUE \ + popl %ebx +#define PIC_PLT(x) x@PLT +#define PIC_GOT(x) x@GOT(%ebx) +#define PIC_GOTOFF(x) x@GOTOFF(%ebx) +#else +#define PIC_PROLOGUE +#define PIC_EPILOGUE +#define PIC_PLT(x) x +#define PIC_GOTOFF(x) x +#endif + +/* + * CNAME and HIDENAME manage the relationship between symbol names in C + * and the equivalent assembly language names. CNAME is given a name as + * it would be used in a C program. It expands to the equivalent assembly + * language name. HIDENAME is given an assembly-language name, and expands + * to a possibly-modified form that will be invisible to C programs. + */ +#define CNAME(csym) csym +#define HIDENAME(asmsym) .asmsym + +/* XXX should use .p2align 4,0x90 for -m486. */ +#define _START_ENTRY .text; .p2align 2,0x90 + +#define _ENTRY(x) _START_ENTRY; \ + .globl CNAME(x); .type CNAME(x),@function; CNAME(x): +#define END(x) .size x, . - x + +#ifdef PROF +#define ALTENTRY(x) _ENTRY(x); \ + pushl %ebp; movl %esp,%ebp; \ + call PIC_PLT(HIDENAME(mcount)); \ + popl %ebp; \ + jmp 9f +#define ENTRY(x) _ENTRY(x); \ + pushl %ebp; movl %esp,%ebp; \ + call PIC_PLT(HIDENAME(mcount)); \ + popl %ebp; \ + 9: +#else +#define ALTENTRY(x) _ENTRY(x) +#define ENTRY(x) _ENTRY(x) +#endif + +/* + * WEAK_REFERENCE(): create a weak reference alias from sym. + * The macro is not a general asm macro that takes arbitrary names, + * but one that takes only C names. It does the non-null name + * translation inside the macro. + */ + +#define WEAK_REFERENCE(sym, alias) \ + .weak CNAME(alias); \ + .equ CNAME(alias),CNAME(sym) + +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#define RCSID(x) .text; .asciz x + +#undef __FBSDID +#if !defined(lint) && !defined(STRIP_FBSDID) +#define __FBSDID(s) .ident s +#else +#define __FBSDID(s) /* nothing */ +#endif /* not lint and not STRIP_FBSDID */ + +#endif /* !_MACHINE_ASM_H_ */ diff --git a/usr/src/boot/sys/i386/include/bootinfo.h b/usr/src/boot/sys/i386/include/bootinfo.h new file mode 100644 index 0000000000..ef595d5f52 --- /dev/null +++ b/usr/src/boot/sys/i386/include/bootinfo.h @@ -0,0 +1,119 @@ +/*- + * Copyright (C) 1994 by Rodney W. Grimes, Milwaukie, Oregon 97222 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer as + * the first lines of this file unmodified. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Rodney W. Grimes. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RODNEY W. GRIMES ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL RODNEY W. GRIMES BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_BOOTINFO_H_ +#define _MACHINE_BOOTINFO_H_ + +/* Only change the version number if you break compatibility. */ +#define BOOTINFO_VERSION 1 + +#define N_BIOS_GEOM 8 + +/* + * A zero bootinfo field often means that there is no info available. + * Flags are used to indicate the validity of fields where zero is a + * normal value. + */ +struct bootinfo { + u_int32_t bi_version; + u_int32_t bi_kernelname; /* represents a char * */ + u_int32_t bi_nfs_diskless; /* struct nfs_diskless * */ + /* End of fields that are always present. */ +#define bi_endcommon bi_n_bios_used + u_int32_t bi_n_bios_used; + u_int32_t bi_bios_geom[N_BIOS_GEOM]; + u_int32_t bi_size; + u_int8_t bi_memsizes_valid; + u_int8_t bi_bios_dev; /* bootdev BIOS unit number */ + u_int8_t bi_pad[2]; + u_int32_t bi_basemem; + u_int32_t bi_extmem; + u_int32_t bi_symtab; /* struct symtab * */ + u_int32_t bi_esymtab; /* struct symtab * */ + /* Items below only from advanced bootloader */ + u_int32_t bi_kernend; /* end of kernel space */ + u_int32_t bi_envp; /* environment */ + u_int32_t bi_modulep; /* preloaded modules */ + uint32_t bi_memdesc_version; /* EFI memory desc version */ + uint64_t bi_memdesc_size; /* sizeof EFI memory desc */ + uint64_t bi_memmap; /* pa of EFI memory map */ + uint64_t bi_memmap_size; /* size of EFI memory map */ + uint64_t bi_hcdp; /* DIG64 HCDP table */ + uint64_t bi_fpswa; /* FPSWA interface */ + uint64_t bi_systab; /* pa of EFI system table */ +}; + +#ifdef _KERNEL +extern struct bootinfo bootinfo; +#endif + +/* + * Constants for converting boot-style device number to type, + * adaptor (uba, mba, etc), unit number and partition number. + * Type (== major device number) is in the low byte + * for backward compatibility. Except for that of the "magic + * number", each mask applies to the shifted value. + * Format: + * (4) (8) (4) (8) (8) + * -------------------------------- + * |MA | SLICE | UN| PART | TYPE | + * -------------------------------- + */ +#define B_SLICESHIFT 20 +#define B_SLICEMASK 0xff +#define B_SLICE(val) (((val)>>B_SLICESHIFT) & B_SLICEMASK) +#define B_UNITSHIFT 16 +#define B_UNITMASK 0xf +#define B_UNIT(val) (((val) >> B_UNITSHIFT) & B_UNITMASK) +#define B_PARTITIONSHIFT 8 +#define B_PARTITIONMASK 0xff +#define B_PARTITION(val) (((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK) +#define B_TYPESHIFT 0 +#define B_TYPEMASK 0xff +#define B_TYPE(val) (((val) >> B_TYPESHIFT) & B_TYPEMASK) + +#define B_MAGICMASK 0xf0000000 +#define B_DEVMAGIC 0xa0000000 + +#define MAKEBOOTDEV(type, slice, unit, partition) \ + (((type) << B_TYPESHIFT) | ((slice) << B_SLICESHIFT) | \ + ((unit) << B_UNITSHIFT) | ((partition) << B_PARTITIONSHIFT) | \ + B_DEVMAGIC) + +#define BASE_SLICE 2 +#define COMPATIBILITY_SLICE 0 +#define MAX_SLICES 32 +#define WHOLE_DISK_SLICE 1 + +#endif /* !_MACHINE_BOOTINFO_H_ */ diff --git a/usr/src/boot/sys/i386/include/cpufunc.h b/usr/src/boot/sys/i386/include/cpufunc.h new file mode 100644 index 0000000000..f43319476d --- /dev/null +++ b/usr/src/boot/sys/i386/include/cpufunc.h @@ -0,0 +1,796 @@ +/*- + * Copyright (c) 1993 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Functions to provide access to special i386 instructions. + * This in included in sys/systm.h, and that file should be + * used in preference to this. + */ + +#ifndef _MACHINE_CPUFUNC_H_ +#define _MACHINE_CPUFUNC_H_ + +#ifndef _SYS_CDEFS_H_ +#error this file needs sys/cdefs.h as a prerequisite +#endif + +struct region_descriptor; + +#define readb(va) (*(volatile uint8_t *) (va)) +#define readw(va) (*(volatile uint16_t *) (va)) +#define readl(va) (*(volatile uint32_t *) (va)) + +#define writeb(va, d) (*(volatile uint8_t *) (va) = (d)) +#define writew(va, d) (*(volatile uint16_t *) (va) = (d)) +#define writel(va, d) (*(volatile uint32_t *) (va) = (d)) + +#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE) + +static __inline void +breakpoint(void) +{ + __asm __volatile("int $3"); +} + +static __inline u_int +bsfl(u_int mask) +{ + u_int result; + + __asm("bsfl %1,%0" : "=r" (result) : "rm" (mask) : "cc"); + return (result); +} + +static __inline u_int +bsrl(u_int mask) +{ + u_int result; + + __asm("bsrl %1,%0" : "=r" (result) : "rm" (mask) : "cc"); + return (result); +} + +static __inline void +clflush(u_long addr) +{ + + __asm __volatile("clflush %0" : : "m" (*(char *)addr)); +} + +static __inline void +clflushopt(u_long addr) +{ + + __asm __volatile(".byte 0x66;clflush %0" : : "m" (*(char *)addr)); +} + +static __inline void +clts(void) +{ + + __asm __volatile("clts"); +} + +static __inline void +disable_intr(void) +{ + + __asm __volatile("cli" : : : "memory"); +} + +static __inline void +do_cpuid(u_int ax, u_int *p) +{ + __asm __volatile("cpuid" + : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) + : "0" (ax)); +} + +static __inline void +cpuid_count(u_int ax, u_int cx, u_int *p) +{ + __asm __volatile("cpuid" + : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) + : "0" (ax), "c" (cx)); +} + +static __inline void +enable_intr(void) +{ + + __asm __volatile("sti"); +} + +static __inline void +cpu_monitor(const void *addr, u_long extensions, u_int hints) +{ + + __asm __volatile("monitor" + : : "a" (addr), "c" (extensions), "d" (hints)); +} + +static __inline void +cpu_mwait(u_long extensions, u_int hints) +{ + + __asm __volatile("mwait" : : "a" (hints), "c" (extensions)); +} + +static __inline void +lfence(void) +{ + + __asm __volatile("lfence" : : : "memory"); +} + +static __inline void +mfence(void) +{ + + __asm __volatile("mfence" : : : "memory"); +} + +#ifdef _KERNEL + +#define HAVE_INLINE_FFS + +static __inline int +ffs(int mask) +{ + /* + * Note that gcc-2's builtin ffs would be used if we didn't declare + * this inline or turn off the builtin. The builtin is faster but + * broken in gcc-2.4.5 and slower but working in gcc-2.5 and later + * versions. + */ + return (mask == 0 ? mask : (int)bsfl((u_int)mask) + 1); +} + +#define HAVE_INLINE_FFSL + +static __inline int +ffsl(long mask) +{ + return (ffs((int)mask)); +} + +#define HAVE_INLINE_FLS + +static __inline int +fls(int mask) +{ + return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1); +} + +#define HAVE_INLINE_FLSL + +static __inline int +flsl(long mask) +{ + return (fls((int)mask)); +} + +#endif /* _KERNEL */ + +static __inline void +halt(void) +{ + __asm __volatile("hlt"); +} + +static __inline u_char +inb(u_int port) +{ + u_char data; + + __asm __volatile("inb %w1, %0" : "=a" (data) : "Nd" (port)); + return (data); +} + +static __inline u_int +inl(u_int port) +{ + u_int data; + + __asm __volatile("inl %w1, %0" : "=a" (data) : "Nd" (port)); + return (data); +} + +static __inline void +insb(u_int port, void *addr, size_t count) +{ + __asm __volatile("cld; rep; insb" + : "+D" (addr), "+c" (count) + : "d" (port) + : "memory"); +} + +static __inline void +insw(u_int port, void *addr, size_t count) +{ + __asm __volatile("cld; rep; insw" + : "+D" (addr), "+c" (count) + : "d" (port) + : "memory"); +} + +static __inline void +insl(u_int port, void *addr, size_t count) +{ + __asm __volatile("cld; rep; insl" + : "+D" (addr), "+c" (count) + : "d" (port) + : "memory"); +} + +static __inline void +invd(void) +{ + __asm __volatile("invd"); +} + +static __inline u_short +inw(u_int port) +{ + u_short data; + + __asm __volatile("inw %w1, %0" : "=a" (data) : "Nd" (port)); + return (data); +} + +static __inline void +outb(u_int port, u_char data) +{ + __asm __volatile("outb %0, %w1" : : "a" (data), "Nd" (port)); +} + +static __inline void +outl(u_int port, u_int data) +{ + __asm __volatile("outl %0, %w1" : : "a" (data), "Nd" (port)); +} + +static __inline void +outsb(u_int port, const void *addr, size_t count) +{ + __asm __volatile("cld; rep; outsb" + : "+S" (addr), "+c" (count) + : "d" (port)); +} + +static __inline void +outsw(u_int port, const void *addr, size_t count) +{ + __asm __volatile("cld; rep; outsw" + : "+S" (addr), "+c" (count) + : "d" (port)); +} + +static __inline void +outsl(u_int port, const void *addr, size_t count) +{ + __asm __volatile("cld; rep; outsl" + : "+S" (addr), "+c" (count) + : "d" (port)); +} + +static __inline void +outw(u_int port, u_short data) +{ + __asm __volatile("outw %0, %w1" : : "a" (data), "Nd" (port)); +} + +static __inline void +ia32_pause(void) +{ + __asm __volatile("pause"); +} + +static __inline u_int +read_eflags(void) +{ + u_int ef; + + __asm __volatile("pushfl; popl %0" : "=r" (ef)); + return (ef); +} + +static __inline uint64_t +rdmsr(u_int msr) +{ + uint64_t rv; + + __asm __volatile("rdmsr" : "=A" (rv) : "c" (msr)); + return (rv); +} + +static __inline uint32_t +rdmsr32(u_int msr) +{ + uint32_t low; + + __asm __volatile("rdmsr" : "=a" (low) : "c" (msr) : "edx"); + return (low); +} + +static __inline uint64_t +rdpmc(u_int pmc) +{ + uint64_t rv; + + __asm __volatile("rdpmc" : "=A" (rv) : "c" (pmc)); + return (rv); +} + +static __inline uint64_t +rdtsc(void) +{ + uint64_t rv; + + __asm __volatile("rdtsc" : "=A" (rv)); + return (rv); +} + +static __inline uint32_t +rdtsc32(void) +{ + uint32_t rv; + + __asm __volatile("rdtsc" : "=a" (rv) : : "edx"); + return (rv); +} + +static __inline void +wbinvd(void) +{ + __asm __volatile("wbinvd"); +} + +static __inline void +write_eflags(u_int ef) +{ + __asm __volatile("pushl %0; popfl" : : "r" (ef)); +} + +static __inline void +wrmsr(u_int msr, uint64_t newval) +{ + __asm __volatile("wrmsr" : : "A" (newval), "c" (msr)); +} + +static __inline void +load_cr0(u_int data) +{ + + __asm __volatile("movl %0,%%cr0" : : "r" (data)); +} + +static __inline u_int +rcr0(void) +{ + u_int data; + + __asm __volatile("movl %%cr0,%0" : "=r" (data)); + return (data); +} + +static __inline u_int +rcr2(void) +{ + u_int data; + + __asm __volatile("movl %%cr2,%0" : "=r" (data)); + return (data); +} + +static __inline void +load_cr3(u_int data) +{ + + __asm __volatile("movl %0,%%cr3" : : "r" (data) : "memory"); +} + +static __inline u_int +rcr3(void) +{ + u_int data; + + __asm __volatile("movl %%cr3,%0" : "=r" (data)); + return (data); +} + +static __inline void +load_cr4(u_int data) +{ + __asm __volatile("movl %0,%%cr4" : : "r" (data)); +} + +static __inline u_int +rcr4(void) +{ + u_int data; + + __asm __volatile("movl %%cr4,%0" : "=r" (data)); + return (data); +} + +static __inline uint64_t +rxcr(u_int reg) +{ + u_int low, high; + + __asm __volatile("xgetbv" : "=a" (low), "=d" (high) : "c" (reg)); + return (low | ((uint64_t)high << 32)); +} + +static __inline void +load_xcr(u_int reg, uint64_t val) +{ + u_int low, high; + + low = val; + high = val >> 32; + __asm __volatile("xsetbv" : : "c" (reg), "a" (low), "d" (high)); +} + +/* + * Global TLB flush (except for thise for pages marked PG_G) + */ +static __inline void +invltlb(void) +{ + + load_cr3(rcr3()); +} + +/* + * TLB flush for an individual page (even if it has PG_G). + * Only works on 486+ CPUs (i386 does not have PG_G). + */ +static __inline void +invlpg(u_int addr) +{ + + __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); +} + +static __inline u_short +rfs(void) +{ + u_short sel; + __asm __volatile("movw %%fs,%0" : "=rm" (sel)); + return (sel); +} + +static __inline uint64_t +rgdt(void) +{ + uint64_t gdtr; + __asm __volatile("sgdt %0" : "=m" (gdtr)); + return (gdtr); +} + +static __inline u_short +rgs(void) +{ + u_short sel; + __asm __volatile("movw %%gs,%0" : "=rm" (sel)); + return (sel); +} + +static __inline uint64_t +ridt(void) +{ + uint64_t idtr; + __asm __volatile("sidt %0" : "=m" (idtr)); + return (idtr); +} + +static __inline u_short +rldt(void) +{ + u_short ldtr; + __asm __volatile("sldt %0" : "=g" (ldtr)); + return (ldtr); +} + +static __inline u_short +rss(void) +{ + u_short sel; + __asm __volatile("movw %%ss,%0" : "=rm" (sel)); + return (sel); +} + +static __inline u_short +rtr(void) +{ + u_short tr; + __asm __volatile("str %0" : "=g" (tr)); + return (tr); +} + +static __inline void +load_fs(u_short sel) +{ + __asm __volatile("movw %0,%%fs" : : "rm" (sel)); +} + +static __inline void +load_gs(u_short sel) +{ + __asm __volatile("movw %0,%%gs" : : "rm" (sel)); +} + +static __inline void +lidt(struct region_descriptor *addr) +{ + __asm __volatile("lidt (%0)" : : "r" (addr)); +} + +static __inline void +lldt(u_short sel) +{ + __asm __volatile("lldt %0" : : "r" (sel)); +} + +static __inline void +ltr(u_short sel) +{ + __asm __volatile("ltr %0" : : "r" (sel)); +} + +static __inline u_int +rdr0(void) +{ + u_int data; + __asm __volatile("movl %%dr0,%0" : "=r" (data)); + return (data); +} + +static __inline void +load_dr0(u_int dr0) +{ + __asm __volatile("movl %0,%%dr0" : : "r" (dr0)); +} + +static __inline u_int +rdr1(void) +{ + u_int data; + __asm __volatile("movl %%dr1,%0" : "=r" (data)); + return (data); +} + +static __inline void +load_dr1(u_int dr1) +{ + __asm __volatile("movl %0,%%dr1" : : "r" (dr1)); +} + +static __inline u_int +rdr2(void) +{ + u_int data; + __asm __volatile("movl %%dr2,%0" : "=r" (data)); + return (data); +} + +static __inline void +load_dr2(u_int dr2) +{ + __asm __volatile("movl %0,%%dr2" : : "r" (dr2)); +} + +static __inline u_int +rdr3(void) +{ + u_int data; + __asm __volatile("movl %%dr3,%0" : "=r" (data)); + return (data); +} + +static __inline void +load_dr3(u_int dr3) +{ + __asm __volatile("movl %0,%%dr3" : : "r" (dr3)); +} + +static __inline u_int +rdr4(void) +{ + u_int data; + __asm __volatile("movl %%dr4,%0" : "=r" (data)); + return (data); +} + +static __inline void +load_dr4(u_int dr4) +{ + __asm __volatile("movl %0,%%dr4" : : "r" (dr4)); +} + +static __inline u_int +rdr5(void) +{ + u_int data; + __asm __volatile("movl %%dr5,%0" : "=r" (data)); + return (data); +} + +static __inline void +load_dr5(u_int dr5) +{ + __asm __volatile("movl %0,%%dr5" : : "r" (dr5)); +} + +static __inline u_int +rdr6(void) +{ + u_int data; + __asm __volatile("movl %%dr6,%0" : "=r" (data)); + return (data); +} + +static __inline void +load_dr6(u_int dr6) +{ + __asm __volatile("movl %0,%%dr6" : : "r" (dr6)); +} + +static __inline u_int +rdr7(void) +{ + u_int data; + __asm __volatile("movl %%dr7,%0" : "=r" (data)); + return (data); +} + +static __inline void +load_dr7(u_int dr7) +{ + __asm __volatile("movl %0,%%dr7" : : "r" (dr7)); +} + +static __inline u_char +read_cyrix_reg(u_char reg) +{ + outb(0x22, reg); + return inb(0x23); +} + +static __inline void +write_cyrix_reg(u_char reg, u_char data) +{ + outb(0x22, reg); + outb(0x23, data); +} + +static __inline register_t +intr_disable(void) +{ + register_t eflags; + + eflags = read_eflags(); + disable_intr(); + return (eflags); +} + +static __inline void +intr_restore(register_t eflags) +{ + write_eflags(eflags); +} + +#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */ + +int breakpoint(void); +u_int bsfl(u_int mask); +u_int bsrl(u_int mask); +void clflush(u_long addr); +void clts(void); +void cpuid_count(u_int ax, u_int cx, u_int *p); +void disable_intr(void); +void do_cpuid(u_int ax, u_int *p); +void enable_intr(void); +void halt(void); +void ia32_pause(void); +u_char inb(u_int port); +u_int inl(u_int port); +void insb(u_int port, void *addr, size_t count); +void insl(u_int port, void *addr, size_t count); +void insw(u_int port, void *addr, size_t count); +register_t intr_disable(void); +void intr_restore(register_t ef); +void invd(void); +void invlpg(u_int addr); +void invltlb(void); +u_short inw(u_int port); +void lidt(struct region_descriptor *addr); +void lldt(u_short sel); +void load_cr0(u_int cr0); +void load_cr3(u_int cr3); +void load_cr4(u_int cr4); +void load_dr0(u_int dr0); +void load_dr1(u_int dr1); +void load_dr2(u_int dr2); +void load_dr3(u_int dr3); +void load_dr4(u_int dr4); +void load_dr5(u_int dr5); +void load_dr6(u_int dr6); +void load_dr7(u_int dr7); +void load_fs(u_short sel); +void load_gs(u_short sel); +void ltr(u_short sel); +void outb(u_int port, u_char data); +void outl(u_int port, u_int data); +void outsb(u_int port, const void *addr, size_t count); +void outsl(u_int port, const void *addr, size_t count); +void outsw(u_int port, const void *addr, size_t count); +void outw(u_int port, u_short data); +u_int rcr0(void); +u_int rcr2(void); +u_int rcr3(void); +u_int rcr4(void); +uint64_t rdmsr(u_int msr); +uint64_t rdpmc(u_int pmc); +u_int rdr0(void); +u_int rdr1(void); +u_int rdr2(void); +u_int rdr3(void); +u_int rdr4(void); +u_int rdr5(void); +u_int rdr6(void); +u_int rdr7(void); +uint64_t rdtsc(void); +u_char read_cyrix_reg(u_char reg); +u_int read_eflags(void); +u_int rfs(void); +uint64_t rgdt(void); +u_int rgs(void); +uint64_t ridt(void); +u_short rldt(void); +u_short rtr(void); +void wbinvd(void); +void write_cyrix_reg(u_char reg, u_char data); +void write_eflags(u_int ef); +void wrmsr(u_int msr, uint64_t newval); + +#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */ + +void reset_dbregs(void); + +#ifdef _KERNEL +int rdmsr_safe(u_int msr, uint64_t *val); +int wrmsr_safe(u_int msr, uint64_t newval); +#endif + +#endif /* !_MACHINE_CPUFUNC_H_ */ diff --git a/usr/src/boot/sys/i386/include/elf.h b/usr/src/boot/sys/i386/include/elf.h new file mode 100644 index 0000000000..f9323775dc --- /dev/null +++ b/usr/src/boot/sys/i386/include/elf.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/elf.h> diff --git a/usr/src/boot/sys/i386/include/endian.h b/usr/src/boot/sys/i386/include/endian.h new file mode 100644 index 0000000000..2ad27a9069 --- /dev/null +++ b/usr/src/boot/sys/i386/include/endian.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/endian.h> diff --git a/usr/src/boot/sys/i386/include/exec.h b/usr/src/boot/sys/i386/include/exec.h new file mode 100644 index 0000000000..8d07887be2 --- /dev/null +++ b/usr/src/boot/sys/i386/include/exec.h @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)exec.h 8.1 (Berkeley) 6/11/93 + * $FreeBSD$ + */ + +#ifndef _MACHINE_EXEC_H_ +#define _MACHINE_EXEC_H_ + +#define __LDPGSZ 4096 + +#endif /* !_MACHINE_EXEC_H_ */ diff --git a/usr/src/boot/sys/i386/include/metadata.h b/usr/src/boot/sys/i386/include/metadata.h new file mode 100644 index 0000000000..98d0272fd4 --- /dev/null +++ b/usr/src/boot/sys/i386/include/metadata.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/metadata.h> diff --git a/usr/src/boot/sys/i386/include/param.h b/usr/src/boot/sys/i386/include/param.h new file mode 100644 index 0000000000..f7968f8308 --- /dev/null +++ b/usr/src/boot/sys/i386/include/param.h @@ -0,0 +1,168 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)param.h 5.8 (Berkeley) 6/28/91 + * $FreeBSD$ + */ + + +#ifndef _I386_INCLUDE_PARAM_H_ +#define _I386_INCLUDE_PARAM_H_ + +#include <machine/_align.h> + +/* + * Machine dependent constants for Intel 386. + */ + + +#define __HAVE_ACPI +#define __HAVE_PIR +#define __PCI_REROUTE_INTERRUPT + +#ifndef MACHINE +#define MACHINE "i386" +#endif +#ifndef MACHINE_ARCH +#define MACHINE_ARCH "i386" +#endif +#define MID_MACHINE MID_I386 + +#if defined(SMP) || defined(KLD_MODULE) +#ifndef MAXCPU +#define MAXCPU 32 +#endif +#else +#define MAXCPU 1 +#endif /* SMP || KLD_MODULE */ + +#ifndef MAXMEMDOM +#define MAXMEMDOM 1 +#endif + +#define ALIGNBYTES _ALIGNBYTES +#define ALIGN(p) _ALIGN(p) +/* + * ALIGNED_POINTER is a boolean macro that checks whether an address + * is valid to fetch data elements of type t from on this architecture. + * This does not reflect the optimal alignment, just the possibility + * (within reasonable limits). + */ +#define ALIGNED_POINTER(p, t) 1 + +/* + * CACHE_LINE_SIZE is the compile-time maximum cache line size for an + * architecture. It should be used with appropriate caution. + */ +#define CACHE_LINE_SHIFT 7 +#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) + +#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ +#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ +#define PAGE_MASK (PAGE_SIZE-1) +#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) + +#if defined(PAE) || defined(PAE_TABLES) +#define NPGPTD 4 +#define PDRSHIFT 21 /* LOG2(NBPDR) */ +#define NPGPTD_SHIFT 9 +#else +#define NPGPTD 1 +#define PDRSHIFT 22 /* LOG2(NBPDR) */ +#define NPGPTD_SHIFT 10 +#endif + +#define NBPTD (NPGPTD<<PAGE_SHIFT) +#define NPDEPTD (NBPTD/(sizeof (pd_entry_t))) +#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) +#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ +#define PDRMASK (NBPDR-1) + +#define MAXPAGESIZES 2 /* maximum number of supported page sizes */ + +#define IOPAGES 2 /* pages of i/o permission bitmap */ + +#ifndef KSTACK_PAGES +#define KSTACK_PAGES 2 /* Includes pcb! */ +#endif +#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */ +#if KSTACK_PAGES < 4 +#define TD0_KSTACK_PAGES 4 +#else +#define TD0_KSTACK_PAGES KSTACK_PAGES +#endif + +/* + * Ceiling on amount of swblock kva space, can be changed via + * the kern.maxswzone /boot/loader.conf variable. + * + * 276 is sizeof(struct swblock), but we do not always have a definition + * in scope for struct swblock, so we have to hardcode it. Each struct + * swblock holds metadata for 32 pages, so in theory, this is enough for + * 16 GB of swap. In practice, however, the usable amount is considerably + * lower due to fragmentation. + */ +#ifndef VM_SWZONE_SIZE_MAX +#define VM_SWZONE_SIZE_MAX (276 * 128 * 1024) +#endif + +/* + * Ceiling on size of buffer cache (really only effects write queueing, + * the VM page cache is not effected), can be changed via + * the kern.maxbcache /boot/loader.conf variable. + * + * The value is equal to the size of the auto-tuned buffer map for + * the machine with 4GB of RAM, see vfs_bio.c:kern_vfs_bio_buffer_alloc(). + */ +#ifndef VM_BCACHE_SIZE_MAX +#define VM_BCACHE_SIZE_MAX (7224 * 16 * 1024) +#endif + +/* + * Mach derived conversion macros + */ +#define trunc_page(x) ((x) & ~PAGE_MASK) +#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) +#define trunc_4mpage(x) ((x) & ~PDRMASK) +#define round_4mpage(x) ((((x)) + PDRMASK) & ~PDRMASK) + +#define atop(x) ((x) >> PAGE_SHIFT) +#define ptoa(x) ((x) << PAGE_SHIFT) + +#define i386_btop(x) ((x) >> PAGE_SHIFT) +#define i386_ptob(x) ((x) << PAGE_SHIFT) + +#define pgtok(x) ((x) * (PAGE_SIZE / 1024)) + +#define INKERNEL(va) (((vm_offset_t)(va)) >= VM_MAXUSER_ADDRESS && \ + ((vm_offset_t)(va)) < VM_MAX_KERNEL_ADDRESS) + +#endif /* !_I386_INCLUDE_PARAM_H_ */ diff --git a/usr/src/boot/sys/i386/include/pc/bios.h b/usr/src/boot/sys/i386/include/pc/bios.h new file mode 100644 index 0000000000..d1d8caff4a --- /dev/null +++ b/usr/src/boot/sys/i386/include/pc/bios.h @@ -0,0 +1,350 @@ +/*- + * Copyright (c) 1997 Michael Smith + * Copyright (c) 1998 Jonathan Lemon + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_PC_BIOS_H_ +#define _MACHINE_PC_BIOS_H_ + +/* + * Signature structure for the BIOS32 Service Directory header + */ +struct bios32_SDheader +{ + u_int8_t sig[4]; + u_int32_t entry; + u_int8_t revision; + u_int8_t len; + u_int8_t cksum; + u_int8_t pad[5]; +}; + +/* + * PnP BIOS presence structure + */ +struct PnPBIOS_table +{ + u_int8_t sig[4]; /* "$PnP */ + u_int8_t version; /* should be 0x10 */ + u_int8_t len; /* total structure length */ + u_int16_t control; /* BIOS feature flags */ + u_int8_t cksum; /* checksum */ + u_int32_t evflagaddr; /* address of event notificaton flag */ + u_int16_t rmentryoffset; /* real-mode entry offset */ + u_int16_t rmentryseg; /* segment */ + u_int16_t pmentryoffset; /* protected-mode entry offset */ + u_int32_t pmentrybase; /* segment base */ + u_int32_t oemdevid; /* motherboard EISA ID */ + u_int16_t rmbiosseg; /* real-mode BIOS segment */ + u_int32_t pmdataseg; /* protected-mode data segment */ +} __packed; + +/* + * PnP BIOS return codes + */ +#define PNP_SUCCESS 0x00 +#define PNP_NOT_SET_STATICALLY 0x7f +#define PNP_UNKNOWN_FUNCTION 0x81 +#define PNP_FUNCTION_NOT_SUPPORTED 0x82 +#define PNP_INVALID_HANDLE 0x83 +#define PNP_BAD_PARAMETER 0x84 +#define PNP_SET_FAILED 0x85 +#define PNP_EVENTS_NOT_PENDING 0x86 +#define PNP_SYSTEM_NOT_DOCKED 0x87 +#define PNP_NO_ISA_PNP_CARDS 0x88 +#define PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES 0x89 +#define PNP_CONFIG_CHANGE_FAILED_NO_BATTERY 0x8a +#define PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT 0x8b +#define PNP_BUFFER_TOO_SMALL 0x8c +#define PNP_USE_ESCD_SUPPORT 0x8d +#define PNP_MESSAGE_NOT_SUPPORTED 0x8e +#define PNP_HARDWARE_ERROR 0x8f + +/* + * DMI return codes + */ +#define DMI_SUCCESS 0x00 +#define DMI_UNKNOWN_FUNCTION 0x81 +#define DMI_FUNCTION_NOT_SUPPORTED 0x82 +#define DMI_INVALID_HANDLE 0x83 +#define DMI_BAD_PARAMETER 0x84 +#define DMI_INVALID_SUBFUNCTION 0x85 +#define DMI_NO_CHANGE 0x86 +#define DMI_ADD_STRUCTURE_FAILED 0x87 +#define DMI_READ_ONLY 0x8d +#define DMI_LOCK_NOT_SUPPORTED 0x90 +#define DMI_CURRENTLY_LOCKED 0x91 +#define DMI_INVALID_LOCK 0x92 + +/* + * format specifiers and defines for bios16() + * s = short (16 bits) + * i = int (32 bits) + * p = pointer (converted to seg:offset) + * C,D,U = selector (corresponding to code/data/utility segment) + */ +#define PNP_COUNT_DEVNODES "sppD", 0x00 +#define PNP_GET_DEVNODE "sppsD", 0x01 +#define PNP_SET_DEVNODE "sspsD", 0x02 +#define PNP_GET_EVENT "spD", 0x03 +#define PNP_SEND_MSG "ssD", 0x04 +#define PNP_GET_DOCK_INFO "spD", 0x05 + +#define PNP_SEL_PRIBOOT "ssiiisspD", 0x07 +#define PNP_GET_PRIBOOT "sspppppD", 0x08 +#define PNP_SET_RESINFO "spD", 0x09 +#define PNP_GET_RESINFO "spD", 0x0A +#define PNP_GET_APM_ID "sppD", 0x0B + +#define PNP_GET_ISA_INFO "spD", 0x40 +#define PNP_GET_ECSD_INFO "spppD", 0x41 +#define PNP_READ_ESCD "spUD", 0x42 +#define PNP_WRITE_ESCD "spUD", 0x43 + +#define PNP_GET_DMI_INFO "spppppD", 0x50 +#define PNP_GET_DMI_STRUCTURE "sppUD", 0x51 +#define PNP_SET_DMI_STRUCTURE "sppsUD" 0x52 +#define PNP_GET_DMI_CHANGE "spUD" 0x53 +#define PNP_DMI_CONTROL "sspsUD" 0x54 +#define PNP_GET_GPNV_INFO "sppppD" 0x55 +#define PNP_READ_GPNV_DATA "ssppUD" 0x56 +#define PNP_WRITE_GPNV_DATA "sspsUD" 0x57 + +#define PNP_BOOT_CHECK "sp", 0x60 +#define PNP_COUNT_IPL "sppp", 0x61 +#define PNP_GET_BOOTPRI "spp", 0x62 +#define PNP_SET_BOOTPRI "sp", 0x63 +#define PNP_GET_LASTBOOT "sp", 0x64 +#define PNP_GET_BOOTFIRST "sp", 0x65 +#define PNP_SET_BOOTFIRST "sp", 0x66 + +/* + * PCI BIOS functions + */ +#define PCIBIOS_BIOS_PRESENT 0xb101 +#define PCIBIOS_READ_CONFIG_BYTE 0xb108 +#define PCIBIOS_READ_CONFIG_WORD 0xb109 +#define PCIBIOS_READ_CONFIG_DWORD 0xb10a +#define PCIBIOS_WRITE_CONFIG_BYTE 0xb10b +#define PCIBIOS_WRITE_CONFIG_WORD 0xb10c +#define PCIBIOS_WRITE_CONFIG_DWORD 0xb10d +#define PCIBIOS_GET_IRQ_ROUTING 0xb10e +#define PCIBIOS_ROUTE_INTERRUPT 0xb10f + +/* + * PCI interrupt routing table. + * + * $PIR in the BIOS segment contains a PIR_table + * int 1a:b106 returns PIR_table in buffer at es:(e)di + * int 1a:b18e returns PIR_table in buffer at es:(e)di + * int 1a:b406 returns es:di pointing to the BIOS PIR_table + */ +struct PIR_header +{ + int8_t ph_signature[4]; + u_int16_t ph_version; + u_int16_t ph_length; + u_int8_t ph_router_bus; + u_int8_t ph_router_dev_fn; + u_int16_t ph_pci_irqs; + u_int16_t ph_router_vendor; + u_int16_t ph_router_device; + u_int32_t ph_miniport; + u_int8_t ph_res[11]; + u_int8_t ph_checksum; +} __packed; + +struct PIR_intpin +{ + u_int8_t link; + u_int16_t irqs; +} __packed; + +struct PIR_entry +{ + u_int8_t pe_bus; + u_int8_t pe_res1:3; + u_int8_t pe_device:5; + struct PIR_intpin pe_intpin[4]; + u_int8_t pe_slot; + u_int8_t pe_res3; +} __packed; + +struct PIR_table +{ + struct PIR_header pt_header; + struct PIR_entry pt_entry[0]; +} __packed; + +/* + * Int 15:E820 'SMAP' structure + */ +#define SMAP_SIG 0x534D4150 /* 'SMAP' */ + +#define SMAP_TYPE_MEMORY 1 +#define SMAP_TYPE_RESERVED 2 +#define SMAP_TYPE_ACPI_RECLAIM 3 +#define SMAP_TYPE_ACPI_NVS 4 +#define SMAP_TYPE_ACPI_ERROR 5 + +#define SMAP_XATTR_ENABLED 0x00000001 +#define SMAP_XATTR_NON_VOLATILE 0x00000002 +#define SMAP_XATTR_MASK (SMAP_XATTR_ENABLED | SMAP_XATTR_NON_VOLATILE) + +struct bios_smap { + u_int64_t base; + u_int64_t length; + u_int32_t type; +} __packed; + +/* Structure extended to include extended attribute field in ACPI 3.0. */ +struct bios_smap_xattr { + u_int64_t base; + u_int64_t length; + u_int32_t type; + u_int32_t xattr; +} __packed; + +/* + * System Management BIOS + */ +#define SMBIOS_START 0xf0000 +#define SMBIOS_STEP 0x10 +#define SMBIOS_OFF 0 +#define SMBIOS_LEN 4 +#define SMBIOS_SIG "_SM_" + +struct smbios_eps { + uint8_t anchor_string[4]; /* '_SM_' */ + uint8_t checksum; + uint8_t length; + uint8_t major_version; + uint8_t minor_version; + uint16_t maximum_structure_size; + uint8_t entry_point_revision; + uint8_t formatted_area[5]; + uint8_t intermediate_anchor_string[5]; /* '_DMI_' */ + uint8_t intermediate_checksum; + uint16_t structure_table_length; + uint32_t structure_table_address; + uint16_t number_structures; + uint8_t BCD_revision; +}; + +struct smbios_structure_header { + uint8_t type; + uint8_t length; + uint16_t handle; +}; + +#ifdef _KERNEL +#define BIOS_PADDRTOVADDR(x) ((x) + KERNBASE) +#define BIOS_VADDRTOPADDR(x) ((x) - KERNBASE) + +struct bios_oem_signature { + char * anchor; /* search anchor string in BIOS memory */ + size_t offset; /* offset from anchor (may be negative) */ + size_t totlen; /* total length of BIOS string to copy */ +} __packed; + +struct bios_oem_range { + u_int from; /* shouldn't be below 0xe0000 */ + u_int to; /* shouldn't be above 0xfffff */ +} __packed; + +struct bios_oem { + struct bios_oem_range range; + struct bios_oem_signature signature[]; +} __packed; + +struct segment_info { + u_int base; + u_int limit; +}; + +#define BIOSCODE_FLAG 0x01 +#define BIOSDATA_FLAG 0x02 +#define BIOSUTIL_FLAG 0x04 +#define BIOSARGS_FLAG 0x08 + +struct bios_segments { + struct segment_info code32; /* 32-bit code (mandatory) */ + struct segment_info code16; /* 16-bit code */ + struct segment_info data; /* 16-bit data */ + struct segment_info util; /* 16-bit utility */ + struct segment_info args; /* 16-bit args */ +}; + +struct bios_regs { + u_int eax; + u_int ebx; + u_int ecx; + u_int edx; + u_int esi; + u_int edi; +}; + +struct bios_args { + u_int entry; /* entry point of routine */ + struct bios_regs r; + struct bios_segments seg; +}; + +/* + * BIOS32 Service Directory entry. Caller supplies name, bios32_SDlookup + * fills in the rest of the details. + */ +struct bios32_SDentry +{ + union + { + u_int8_t name[4]; /* service identifier */ + u_int32_t id; /* as a 32-bit value */ + } ident; + u_int32_t base; /* base of service */ + u_int32_t len; /* service length */ + u_int32_t entry; /* entrypoint offset from base */ + vm_offset_t ventry; /* entrypoint in kernel virtual segment */ +}; + +/* + * Exported lookup results + */ +extern struct bios32_SDentry PCIbios; + +int bios_oem_strings(struct bios_oem *oem, u_char *buffer, size_t maxlen); +uint32_t bios_sigsearch(uint32_t start, u_char *sig, int siglen, int paralen, + int sigofs); +int bios16(struct bios_args *, char *, ...); +int bios16_call(struct bios_regs *, char *); +int bios32(struct bios_regs *, u_int, u_short); +int bios32_SDlookup(struct bios32_SDentry *ent); +void set_bios_selectors(struct bios_segments *, int); + +#endif + +#endif /* _MACHINE_PC_BIOS_H_ */ diff --git a/usr/src/boot/sys/i386/include/psl.h b/usr/src/boot/sys/i386/include/psl.h new file mode 100644 index 0000000000..4d945a1ebb --- /dev/null +++ b/usr/src/boot/sys/i386/include/psl.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/psl.h> diff --git a/usr/src/boot/sys/i386/include/reloc.h b/usr/src/boot/sys/i386/include/reloc.h new file mode 100644 index 0000000000..1883193233 --- /dev/null +++ b/usr/src/boot/sys/i386/include/reloc.h @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)reloc.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +#ifndef _I386_MACHINE_RELOC_H_ +#define _I386_MACHINE_RELOC_H_ + +/* Relocation format. */ +struct relocation_info { + int r_address; /* offset in text or data segment */ + unsigned int r_symbolnum : 24, /* ordinal number of add symbol */ + r_pcrel : 1, /* 1 if value should be pc-relative */ + r_length : 2, /* log base 2 of value's width */ + r_extern : 1, /* 1 if need to add symbol to value */ + r_baserel : 1, /* linkage table relative */ + r_jmptable : 1, /* relocate to jump table */ + r_relative : 1, /* load address relative */ + r_copy : 1; /* run time copy */ +}; + +#endif diff --git a/usr/src/boot/sys/i386/include/setjmp.h b/usr/src/boot/sys/i386/include/setjmp.h new file mode 100644 index 0000000000..c4101a77fd --- /dev/null +++ b/usr/src/boot/sys/i386/include/setjmp.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/setjmp.h> diff --git a/usr/src/boot/sys/i386/include/signal.h b/usr/src/boot/sys/i386/include/signal.h new file mode 100644 index 0000000000..26c1ee6363 --- /dev/null +++ b/usr/src/boot/sys/i386/include/signal.h @@ -0,0 +1,67 @@ +/*- + * Copyright (c) 1986, 1989, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)signal.h 8.1 (Berkeley) 6/11/93 + * $FreeBSD$ + */ + +#ifndef _MACHINE_SIGNAL_H_ +#define _MACHINE_SIGNAL_H_ + +#include <x86/signal.h> + +#if defined(_KERNEL) && defined(COMPAT_43) +/* + * Only the kernel should need these old type definitions. + */ +struct osigcontext { + int sc_onstack; /* sigstack state to restore */ + osigset_t sc_mask; /* signal mask to restore */ + int sc_esp; /* machine state follows: */ + int sc_ebp; + int sc_isp; + int sc_eip; + int sc_efl; + int sc_es; + int sc_ds; + int sc_cs; + int sc_ss; + int sc_edi; + int sc_esi; + int sc_ebx; + int sc_edx; + int sc_ecx; + int sc_eax; + int sc_gs; + int sc_fs; + int sc_trapno; + int sc_err; +}; +#endif + +#endif /* !_MACHINE_SIGNAL_H_ */ diff --git a/usr/src/boot/sys/i386/include/specialreg.h b/usr/src/boot/sys/i386/include/specialreg.h new file mode 100644 index 0000000000..aace4bfd62 --- /dev/null +++ b/usr/src/boot/sys/i386/include/specialreg.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/specialreg.h> diff --git a/usr/src/boot/sys/i386/include/stdarg.h b/usr/src/boot/sys/i386/include/stdarg.h new file mode 100644 index 0000000000..1f80090356 --- /dev/null +++ b/usr/src/boot/sys/i386/include/stdarg.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/stdarg.h> diff --git a/usr/src/boot/sys/i386/include/trap.h b/usr/src/boot/sys/i386/include/trap.h new file mode 100644 index 0000000000..4d950771dc --- /dev/null +++ b/usr/src/boot/sys/i386/include/trap.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include <x86/trap.h> |
