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