1ca987d46SWarner Losh /*- 2ca987d46SWarner Losh * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 3ca987d46SWarner Losh * All rights reserved. 4ca987d46SWarner Losh * 5ca987d46SWarner Losh * Redistribution and use in source and binary forms, with or without 6ca987d46SWarner Losh * modification, are permitted provided that the following conditions 7ca987d46SWarner Losh * are met: 8ca987d46SWarner Losh * 1. Redistributions of source code must retain the above copyright 9ca987d46SWarner Losh * notice, this list of conditions and the following disclaimer. 10ca987d46SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 11ca987d46SWarner Losh * notice, this list of conditions and the following disclaimer in the 12ca987d46SWarner Losh * documentation and/or other materials provided with the distribution. 13ca987d46SWarner Losh * 14ca987d46SWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15ca987d46SWarner Losh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16ca987d46SWarner Losh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17ca987d46SWarner Losh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18ca987d46SWarner Losh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19ca987d46SWarner Losh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20ca987d46SWarner Losh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21ca987d46SWarner Losh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22ca987d46SWarner Losh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23ca987d46SWarner Losh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24ca987d46SWarner Losh * SUCH DAMAGE. 25ca987d46SWarner Losh * 26ca987d46SWarner Losh * $FreeBSD$ 27ca987d46SWarner Losh */ 28ca987d46SWarner Losh 29ca987d46SWarner Losh 30ca987d46SWarner Losh /* 31ca987d46SWarner Losh * i386 fully-qualified device descriptor. 32ca987d46SWarner Losh */ 33b3a2aad1SWarner Losh struct i386_devdesc { 349f6fd839SIan Lepore struct devdesc dd; /* Must be first. */ 35ca987d46SWarner Losh union 36ca987d46SWarner Losh { 37ca987d46SWarner Losh struct 38ca987d46SWarner Losh { 39ca987d46SWarner Losh int slice; 40ca987d46SWarner Losh int partition; 41ca987d46SWarner Losh off_t offset; 42ca987d46SWarner Losh } biosdisk; 43ca987d46SWarner Losh struct 44ca987d46SWarner Losh { 45ca987d46SWarner Losh uint64_t pool_guid; 46ca987d46SWarner Losh uint64_t root_guid; 47ca987d46SWarner Losh } zfs; 48ca987d46SWarner Losh } d_kind; 49ca987d46SWarner Losh }; 50ca987d46SWarner Losh 51ca987d46SWarner Losh /* 52ca987d46SWarner Losh * relocater trampoline support. 53ca987d46SWarner Losh */ 54ca987d46SWarner Losh struct relocate_data { 55ca987d46SWarner Losh uint32_t src; 56ca987d46SWarner Losh uint32_t dest; 57ca987d46SWarner Losh uint32_t size; 58ca987d46SWarner Losh }; 59ca987d46SWarner Losh 60ca987d46SWarner Losh extern void relocater(void); 61ca987d46SWarner Losh 62ca987d46SWarner Losh /* 63ca987d46SWarner Losh * The relocater_data[] is fixed size array allocated in relocater_tramp.S 64ca987d46SWarner Losh */ 65ca987d46SWarner Losh extern struct relocate_data relocater_data[]; 66ca987d46SWarner Losh extern uint32_t relocater_size; 67ca987d46SWarner Losh 68ca987d46SWarner Losh extern uint16_t relocator_ip; 69ca987d46SWarner Losh extern uint16_t relocator_cs; 70ca987d46SWarner Losh extern uint16_t relocator_ds; 71ca987d46SWarner Losh extern uint16_t relocator_es; 72ca987d46SWarner Losh extern uint16_t relocator_fs; 73ca987d46SWarner Losh extern uint16_t relocator_gs; 74ca987d46SWarner Losh extern uint16_t relocator_ss; 75ca987d46SWarner Losh extern uint16_t relocator_sp; 76ca987d46SWarner Losh extern uint32_t relocator_esi; 77ca987d46SWarner Losh extern uint32_t relocator_eax; 78ca987d46SWarner Losh extern uint32_t relocator_ebx; 79ca987d46SWarner Losh extern uint32_t relocator_edx; 80ca987d46SWarner Losh extern uint32_t relocator_ebp; 81ca987d46SWarner Losh extern uint16_t relocator_a20_enabled; 82ca987d46SWarner Losh 83ca987d46SWarner Losh int i386_getdev(void **vdev, const char *devspec, const char **path); 84ca987d46SWarner Losh char *i386_fmtdev(void *vdev); 85ca987d46SWarner Losh int i386_setcurrdev(struct env_var *ev, int flags, const void *value); 86ca987d46SWarner Losh 87ca987d46SWarner Losh extern struct devdesc currdev; /* our current device */ 88ca987d46SWarner Losh 89ca987d46SWarner Losh #define MAXDEV 31 /* maximum number of distinct devices */ 90ca987d46SWarner Losh #define MAXBDDEV MAXDEV 91ca987d46SWarner Losh 92ca987d46SWarner Losh /* exported devices XXX rename? */ 93ca987d46SWarner Losh extern struct devsw bioscd; 94*cdff1036SToomas Soome extern struct devsw biosfd; 95*cdff1036SToomas Soome extern struct devsw bioshd; 96ca987d46SWarner Losh extern struct devsw pxedisk; 97ca987d46SWarner Losh extern struct fs_ops pxe_fsops; 98ca987d46SWarner Losh 99ca987d46SWarner Losh int bc_add(int biosdev); /* Register CD booted from. */ 100ca987d46SWarner Losh uint32_t bd_getbigeom(int bunit); /* return geometry in bootinfo format */ 101ca987d46SWarner Losh int bd_bios2unit(int biosdev); /* xlate BIOS device -> biosdisk unit */ 102*cdff1036SToomas Soome int bd_unit2bios(struct i386_devdesc *); /* xlate biosdisk -> BIOS device */ 103ca987d46SWarner Losh int bd_getdev(struct i386_devdesc *dev); /* return dev_t for (dev) */ 104ca987d46SWarner Losh 105ca987d46SWarner Losh ssize_t i386_copyin(const void *src, vm_offset_t dest, const size_t len); 106ca987d46SWarner Losh ssize_t i386_copyout(const vm_offset_t src, void *dest, const size_t len); 107ca987d46SWarner Losh ssize_t i386_readin(const int fd, vm_offset_t dest, const size_t len); 108ca987d46SWarner Losh 109ca987d46SWarner Losh struct preloaded_file; 110ca987d46SWarner Losh void bios_addsmapdata(struct preloaded_file *); 111ca987d46SWarner Losh void bios_getsmap(void); 112ca987d46SWarner Losh 113ca987d46SWarner Losh void bios_getmem(void); 114ca987d46SWarner Losh extern uint32_t bios_basemem; /* base memory in bytes */ 115ca987d46SWarner Losh extern uint32_t bios_extmem; /* extended memory in bytes */ 116ca987d46SWarner Losh extern vm_offset_t memtop; /* last address of physical memory + 1 */ 117ca987d46SWarner Losh extern vm_offset_t memtop_copyin; /* memtop less heap size for the cases */ 118ca987d46SWarner Losh /* when heap is at the top of */ 119ca987d46SWarner Losh /* extended memory; for other cases */ 120ca987d46SWarner Losh /* just the same as memtop */ 121ca987d46SWarner Losh extern uint32_t high_heap_size; /* extended memory region available */ 122ca987d46SWarner Losh extern vm_offset_t high_heap_base; /* for use as the heap */ 123ca987d46SWarner Losh 124388199e5SWarner Losh /* 125388199e5SWarner Losh * Values for width parameter to biospci_{read,write}_config 126388199e5SWarner Losh */ 127388199e5SWarner Losh #define BIOSPCI_8BITS 0 128388199e5SWarner Losh #define BIOSPCI_16BITS 1 129388199e5SWarner Losh #define BIOSPCI_32BITS 2 130388199e5SWarner Losh 131ca987d46SWarner Losh void biospci_detect(void); 132ca987d46SWarner Losh int biospci_find_devclass(uint32_t class, int index, uint32_t *locator); 133ca987d46SWarner Losh int biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val); 134ca987d46SWarner Losh uint32_t biospci_locator(int8_t bus, uint8_t device, uint8_t function); 135ca987d46SWarner Losh int biospci_write_config(uint32_t locator, int offset, int width, uint32_t val); 136ca987d46SWarner Losh 137ca987d46SWarner Losh void biosacpi_detect(void); 138ca987d46SWarner Losh 139ca987d46SWarner Losh int i386_autoload(void); 140ca987d46SWarner Losh 141ca987d46SWarner Losh int bi_getboothowto(char *kargs); 142ca987d46SWarner Losh void bi_setboothowto(int howto); 143ca987d46SWarner Losh vm_offset_t bi_copyenv(vm_offset_t addr); 144ca987d46SWarner Losh int bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, 145ca987d46SWarner Losh vm_offset_t *modulep, vm_offset_t *kernend); 146ca987d46SWarner Losh int bi_load64(char *args, vm_offset_t addr, vm_offset_t *modulep, 147ca987d46SWarner Losh vm_offset_t *kernend, int add_smap); 148ca987d46SWarner Losh 149ca987d46SWarner Losh void pxe_enable(void *pxeinfo); 150