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