libi386.h revision 329183
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: stable/11/stand/i386/libi386/libi386.h 329183 2018-02-12 20:51:28Z kevans $ 27 */ 28 29 30/* 31 * i386 fully-qualified device descriptor. 32 * Note, this must match the 'struct devdesc' declaration 33 * in bootstrap.h and also with struct zfs_devdesc for zfs 34 * support. 35 */ 36struct i386_devdesc 37{ 38 struct devsw *d_dev; 39 int d_type; 40 int d_unit; 41 union 42 { 43 struct 44 { 45 void *data; 46 int slice; 47 int partition; 48 off_t offset; 49 } biosdisk; 50 struct 51 { 52 void *data; 53 } bioscd; 54 struct 55 { 56 void *data; 57 uint64_t pool_guid; 58 uint64_t root_guid; 59 } zfs; 60 } d_kind; 61}; 62 63/* 64 * relocater trampoline support. 65 */ 66struct relocate_data { 67 uint32_t src; 68 uint32_t dest; 69 uint32_t size; 70}; 71 72extern void relocater(void); 73 74/* 75 * The relocater_data[] is fixed size array allocated in relocater_tramp.S 76 */ 77extern struct relocate_data relocater_data[]; 78extern uint32_t relocater_size; 79 80extern uint16_t relocator_ip; 81extern uint16_t relocator_cs; 82extern uint16_t relocator_ds; 83extern uint16_t relocator_es; 84extern uint16_t relocator_fs; 85extern uint16_t relocator_gs; 86extern uint16_t relocator_ss; 87extern uint16_t relocator_sp; 88extern uint32_t relocator_esi; 89extern uint32_t relocator_eax; 90extern uint32_t relocator_ebx; 91extern uint32_t relocator_edx; 92extern uint32_t relocator_ebp; 93extern uint16_t relocator_a20_enabled; 94 95int i386_getdev(void **vdev, const char *devspec, const char **path); 96char *i386_fmtdev(void *vdev); 97int i386_setcurrdev(struct env_var *ev, int flags, const void *value); 98 99extern struct devdesc currdev; /* our current device */ 100 101#define MAXDEV 31 /* maximum number of distinct devices */ 102#define MAXBDDEV MAXDEV 103 104/* exported devices XXX rename? */ 105extern struct devsw bioscd; 106extern struct devsw biosdisk; 107extern struct devsw pxedisk; 108extern struct fs_ops pxe_fsops; 109 110int bc_add(int biosdev); /* Register CD booted from. */ 111int bc_getdev(struct i386_devdesc *dev); /* return dev_t for (dev) */ 112int bc_bios2unit(int biosdev); /* xlate BIOS device -> bioscd unit */ 113int bc_unit2bios(int unit); /* xlate bioscd unit -> BIOS device */ 114uint32_t bd_getbigeom(int bunit); /* return geometry in bootinfo format */ 115int bd_bios2unit(int biosdev); /* xlate BIOS device -> biosdisk unit */ 116int bd_unit2bios(int unit); /* xlate biosdisk unit -> BIOS device */ 117int bd_getdev(struct i386_devdesc *dev); /* return dev_t for (dev) */ 118 119ssize_t i386_copyin(const void *src, vm_offset_t dest, const size_t len); 120ssize_t i386_copyout(const vm_offset_t src, void *dest, const size_t len); 121ssize_t i386_readin(const int fd, vm_offset_t dest, const size_t len); 122 123struct preloaded_file; 124void bios_addsmapdata(struct preloaded_file *); 125void bios_getsmap(void); 126 127void bios_getmem(void); 128extern uint32_t bios_basemem; /* base memory in bytes */ 129extern uint32_t bios_extmem; /* extended memory in bytes */ 130extern vm_offset_t memtop; /* last address of physical memory + 1 */ 131extern vm_offset_t memtop_copyin; /* memtop less heap size for the cases */ 132 /* when heap is at the top of */ 133 /* extended memory; for other cases */ 134 /* just the same as memtop */ 135extern uint32_t high_heap_size; /* extended memory region available */ 136extern vm_offset_t high_heap_base; /* for use as the heap */ 137 138/* 139 * Values for width parameter to biospci_{read,write}_config 140 */ 141#define BIOSPCI_8BITS 0 142#define BIOSPCI_16BITS 1 143#define BIOSPCI_32BITS 2 144 145void biospci_detect(void); 146int biospci_find_devclass(uint32_t class, int index, uint32_t *locator); 147int biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val); 148uint32_t biospci_locator(int8_t bus, uint8_t device, uint8_t function); 149int biospci_write_config(uint32_t locator, int offset, int width, uint32_t val); 150 151void biosacpi_detect(void); 152 153int i386_autoload(void); 154 155int bi_getboothowto(char *kargs); 156void bi_setboothowto(int howto); 157vm_offset_t bi_copyenv(vm_offset_t addr); 158int bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, 159 vm_offset_t *modulep, vm_offset_t *kernend); 160int bi_load64(char *args, vm_offset_t addr, vm_offset_t *modulep, 161 vm_offset_t *kernend, int add_smap); 162 163void pxe_enable(void *pxeinfo); 164