138465Smsmith/*- 238465Smsmith * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 338465Smsmith * All rights reserved. 438465Smsmith * 538465Smsmith * Redistribution and use in source and binary forms, with or without 638465Smsmith * modification, are permitted provided that the following conditions 738465Smsmith * are met: 838465Smsmith * 1. Redistributions of source code must retain the above copyright 938465Smsmith * notice, this list of conditions and the following disclaimer. 1038465Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1138465Smsmith * notice, this list of conditions and the following disclaimer in the 1238465Smsmith * documentation and/or other materials provided with the distribution. 1338465Smsmith * 1438465Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1538465Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1638465Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1738465Smsmith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1838465Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1938465Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2038465Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2138465Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2238465Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2338465Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2438465Smsmith * SUCH DAMAGE. 2538465Smsmith * 2650477Speter * $FreeBSD$ 2738465Smsmith */ 2838465Smsmith 2938465Smsmith 3038465Smsmith/* 3138465Smsmith * i386 fully-qualified device descriptor. 3238465Smsmith * Note, this must match the 'struct devdesc' declaration 33235329Savg * in bootstrap.h and also with struct zfs_devdesc for zfs 34235329Savg * support. 3538465Smsmith */ 3638465Smsmithstruct i386_devdesc 3738465Smsmith{ 3838465Smsmith struct devsw *d_dev; 3938465Smsmith int d_type; 40163897Smarcel int d_unit; 4138465Smsmith union 4238465Smsmith { 4338465Smsmith struct 4438465Smsmith { 45163897Smarcel void *data; 4638465Smsmith int slice; 4738465Smsmith int partition; 48239066Sae off_t offset; 4938465Smsmith } biosdisk; 5086091Sjhb struct 5186091Sjhb { 5286091Sjhb void *data; 5386091Sjhb } bioscd; 54235329Savg struct 55235329Savg { 56235329Savg void *data; 57235329Savg uint64_t pool_guid; 58235329Savg uint64_t root_guid; 59235329Savg } zfs; 6038465Smsmith } d_kind; 6138465Smsmith}; 6238465Smsmith 6364187Sjhbint i386_getdev(void **vdev, const char *devspec, const char **path); 6464187Sjhbchar *i386_fmtdev(void *vdev); 65146697Sjhbint i386_setcurrdev(struct env_var *ev, int flags, const void *value); 6638465Smsmith 6738465Smsmithextern struct devdesc currdev; /* our current device */ 6838465Smsmith 69235155Savg#define MAXDEV 31 /* maximum number of distinct devices */ 70235155Savg#define MAXBDDEV MAXDEV 7138465Smsmith 7238465Smsmith/* exported devices XXX rename? */ 7386091Sjhbextern struct devsw bioscd; 7438465Smsmithextern struct devsw biosdisk; 7558713Sjhbextern struct devsw pxedisk; 7658713Sjhbextern struct fs_ops pxe_fsops; 7738465Smsmith 7886091Sjhbint bc_add(int biosdev); /* Register CD booted from. */ 79130603Sphkint bc_getdev(struct i386_devdesc *dev); /* return dev_t for (dev) */ 8086091Sjhbint bc_bios2unit(int biosdev); /* xlate BIOS device -> bioscd unit */ 8186091Sjhbint bc_unit2bios(int unit); /* xlate bioscd unit -> BIOS device */ 82200216Sjhbuint32_t bd_getbigeom(int bunit); /* return geometry in bootinfo format */ 83200216Sjhbint bd_bios2unit(int biosdev); /* xlate BIOS device -> biosdisk unit */ 84200216Sjhbint bd_unit2bios(int unit); /* xlate biosdisk unit -> BIOS device */ 85130603Sphkint bd_getdev(struct i386_devdesc *dev); /* return dev_t for (dev) */ 8638465Smsmith 8764187Sjhbssize_t i386_copyin(const void *src, vm_offset_t dest, const size_t len); 8864187Sjhbssize_t i386_copyout(const vm_offset_t src, void *dest, const size_t len); 8964187Sjhbssize_t i386_readin(const int fd, vm_offset_t dest, const size_t len); 9038712Smsmith 91114379Speterstruct preloaded_file; 92114379Spetervoid bios_addsmapdata(struct preloaded_file *); 93114379Spetervoid bios_getsmap(void); 94114379Speter 9564187Sjhbvoid bios_getmem(void); 96200216Sjhbextern uint32_t bios_basemem; /* base memory in bytes */ 97200216Sjhbextern uint32_t bios_extmem; /* extended memory in bytes */ 98153589Ssobomaxextern vm_offset_t memtop; /* last address of physical memory + 1 */ 99153589Ssobomaxextern vm_offset_t memtop_copyin; /* memtop less heap size for the cases */ 100200216Sjhb /* when heap is at the top of */ 101200216Sjhb /* extended memory; for other cases */ 102200216Sjhb /* just the same as memtop */ 103200219Sjhbextern uint32_t high_heap_size; /* extended memory region available */ 104200219Sjhbextern vm_offset_t high_heap_base; /* for use as the heap */ 10538465Smsmith 106162814Sruint biospci_find_devclass(uint32_t class, int index, uint32_t *locator); 107162814Sruint biospci_write_config(uint32_t locator, int offset, int width, uint32_t val); 108136779Ssimokawaint biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val); 109229435Skibuint32_t biospci_locator(int8_t bus, uint8_t device, uint8_t function); 110136779Ssimokawa 111156519Sjkimvoid biosacpi_detect(void); 11282531Smsmith 113156519Sjkimvoid smbios_detect(void); 114148006Sjkim 11564187Sjhbint i386_autoload(void); 11638465Smsmith 11764187Sjhbint bi_getboothowto(char *kargs); 118150470Sruvoid bi_setboothowto(int howto); 11964187Sjhbvm_offset_t bi_copyenv(vm_offset_t addr); 120114379Speterint bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, 121114379Speter vm_offset_t *modulep, vm_offset_t *kernend); 122114379Speterint bi_load64(char *args, vm_offset_t *modulep, vm_offset_t *kernend); 12339441Smsmith 12464187Sjhbvoid pxe_enable(void *pxeinfo); 125