xref: /illumos-gate/usr/src/boot/i386/libi386/libi386.h (revision ceb3ef19)
13273f292SToomas Soome /*
2199767f8SToomas Soome  * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3199767f8SToomas Soome  * All rights reserved.
4199767f8SToomas Soome  *
5199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
6199767f8SToomas Soome  * modification, are permitted provided that the following conditions
7199767f8SToomas Soome  * are met:
8199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
9199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
10199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
11199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
12199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
13199767f8SToomas Soome  *
14199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15199767f8SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16199767f8SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17199767f8SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18199767f8SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19199767f8SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20199767f8SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21199767f8SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22199767f8SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23199767f8SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24199767f8SToomas Soome  * SUCH DAMAGE.
25199767f8SToomas Soome  */
26199767f8SToomas Soome 
27f9feecc1SToomas Soome #ifndef	_LIBI386_H
28f9feecc1SToomas Soome #define	_LIBI386_H
29199767f8SToomas Soome 
30199767f8SToomas Soome /*
31199767f8SToomas Soome  * i386 fully-qualified device descriptor.
32199767f8SToomas Soome  */
330a06a804SToomas Soome struct i386_devdesc {
34e3c18722SToomas Soome     struct devdesc	dd;	/* Must be first. */
3576b35943SToomas Soome     union {
3676b35943SToomas Soome 	struct {
37199767f8SToomas Soome 	    int		slice;
38199767f8SToomas Soome 	    int		partition;
39199767f8SToomas Soome 	    off_t	offset;
40199767f8SToomas Soome 	} biosdisk;
4176b35943SToomas Soome 	struct {
42199767f8SToomas Soome 	    uint64_t	pool_guid;
43199767f8SToomas Soome 	    uint64_t	root_guid;
44199767f8SToomas Soome 	} zfs;
45199767f8SToomas Soome     } d_kind;
46199767f8SToomas Soome };
47199767f8SToomas Soome 
48199767f8SToomas Soome /*
49199767f8SToomas Soome  * relocater trampoline support.
50199767f8SToomas Soome  */
51199767f8SToomas Soome struct relocate_data {
52199767f8SToomas Soome 	uint32_t	src;
53199767f8SToomas Soome 	uint32_t	dest;
54199767f8SToomas Soome 	uint32_t	size;
55199767f8SToomas Soome };
56199767f8SToomas Soome 
57199767f8SToomas Soome extern void relocater(void);
58199767f8SToomas Soome 
597b2aa502SToomas Soome /*
607b2aa502SToomas Soome  * The relocater_data[] is fixed size array allocated in relocater_tramp.S
617b2aa502SToomas Soome  */
627b2aa502SToomas Soome extern struct relocate_data relocater_data[];
63199767f8SToomas Soome extern uint32_t relocater_size;
64199767f8SToomas Soome 
65199767f8SToomas Soome extern uint16_t relocator_ip;
66199767f8SToomas Soome extern uint16_t relocator_cs;
67199767f8SToomas Soome extern uint16_t relocator_ds;
68199767f8SToomas Soome extern uint16_t relocator_es;
69199767f8SToomas Soome extern uint16_t relocator_fs;
70199767f8SToomas Soome extern uint16_t relocator_gs;
71199767f8SToomas Soome extern uint16_t relocator_ss;
72199767f8SToomas Soome extern uint16_t relocator_sp;
73199767f8SToomas Soome extern uint32_t relocator_esi;
74199767f8SToomas Soome extern uint32_t relocator_eax;
75199767f8SToomas Soome extern uint32_t relocator_ebx;
76199767f8SToomas Soome extern uint32_t relocator_edx;
77199767f8SToomas Soome extern uint32_t relocator_ebp;
78199767f8SToomas Soome extern uint16_t relocator_a20_enabled;
79199767f8SToomas Soome 
80199767f8SToomas Soome int	i386_getdev(void **vdev, const char *devspec, const char **path);
81199767f8SToomas Soome char	*i386_fmtdev(void *vdev);
82199767f8SToomas Soome int	i386_setcurrdev(struct env_var *ev, int flags, const void *value);
83199767f8SToomas Soome 
84199767f8SToomas Soome extern struct devdesc	currdev;	/* our current device */
85199767f8SToomas Soome 
86199767f8SToomas Soome #define MAXDEV		31		/* maximum number of distinct devices */
87199767f8SToomas Soome #define MAXBDDEV	MAXDEV
88199767f8SToomas Soome 
89199767f8SToomas Soome /* exported devices XXX rename? */
90199767f8SToomas Soome extern struct devsw bioscd;
91863275a4SToomas Soome extern struct devsw biosfd;
92863275a4SToomas Soome extern struct devsw bioshd;
93199767f8SToomas Soome extern struct devsw pxedisk;
94199767f8SToomas Soome extern struct fs_ops pxe_fsops;
95199767f8SToomas Soome 
96199767f8SToomas Soome int	bc_add(int biosdev);		/* Register CD booted from. */
97199767f8SToomas Soome uint32_t bd_getbigeom(int bunit);	/* return geometry in bootinfo format */
98199767f8SToomas Soome int	bd_bios2unit(int biosdev);	/* xlate BIOS device -> biosdisk unit */
99863275a4SToomas Soome int	bd_unit2bios(struct i386_devdesc *); /* xlate biosdisk -> BIOS device */
100199767f8SToomas Soome int	bd_getdev(struct i386_devdesc *dev);	/* return dev_t for (dev) */
101199767f8SToomas Soome 
102199767f8SToomas Soome ssize_t	i386_copyin(const void *src, vm_offset_t dest, const size_t len);
103199767f8SToomas Soome ssize_t	i386_copyout(const vm_offset_t src, void *dest, const size_t len);
104199767f8SToomas Soome ssize_t	i386_readin(const int fd, vm_offset_t dest, const size_t len);
105199767f8SToomas Soome 
106199767f8SToomas Soome struct preloaded_file;
107199767f8SToomas Soome void	bios_addsmapdata(struct preloaded_file *);
108199767f8SToomas Soome void	bios_getsmap(void);
109199767f8SToomas Soome 
110199767f8SToomas Soome void	bios_getmem(void);
111199767f8SToomas Soome extern uint32_t		bios_basemem;	/* base memory in bytes */
112199767f8SToomas Soome extern uint32_t		bios_extmem;	/* extended memory in bytes */
113199767f8SToomas Soome extern vm_offset_t	memtop;		/* last address of physical memory + 1 */
114199767f8SToomas Soome extern vm_offset_t	memtop_copyin;	/* memtop less heap size for the cases */
115199767f8SToomas Soome 					/*  when heap is at the top of         */
116199767f8SToomas Soome 					/*  extended memory; for other cases   */
117199767f8SToomas Soome 					/*  just the same as memtop            */
118199767f8SToomas Soome extern uint32_t		high_heap_size;	/* extended memory region available */
119199767f8SToomas Soome extern vm_offset_t	high_heap_base;	/* for use as the heap */
120199767f8SToomas Soome 
1213273f292SToomas Soome /* 16KB buffer space for real mode data transfers. */
1223273f292SToomas Soome #define	BIO_BUFFER_SIZE 0x4000
1233273f292SToomas Soome void *bio_alloc(size_t size);
1243273f292SToomas Soome void bio_free(void *ptr, size_t size);
1253273f292SToomas Soome 
126199767f8SToomas Soome void	biospci_detect(void);
127199767f8SToomas Soome int biospci_find_devclass(uint32_t class, int index, uint32_t *locator);
128199767f8SToomas Soome int biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val);
129199767f8SToomas Soome uint32_t biospci_locator(int8_t bus, uint8_t device, uint8_t function);
130eee59048SToomas Soome int biospci_write_config(uint32_t locator, int offset, int width, uint32_t val);
131199767f8SToomas Soome 
132199767f8SToomas Soome void	biosacpi_detect(void);
133*ceb3ef19SToomas Soome int	comc_getspeed(int);
134199767f8SToomas Soome 
135199767f8SToomas Soome int	i386_autoload(void);
1368600fd4dSToomas Soome vm_offset_t i386_loadaddr(u_int type, void *data, vm_offset_t addr);
137199767f8SToomas Soome 
138199767f8SToomas Soome int	bi_getboothowto(char *kargs);
139199767f8SToomas Soome void	bi_setboothowto(int howto);
140199767f8SToomas Soome vm_offset_t	bi_copyenv(vm_offset_t addr);
141199767f8SToomas Soome int	bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip,
142199767f8SToomas Soome 	    vm_offset_t *modulep, vm_offset_t *kernend);
143199767f8SToomas Soome int	bi_load64(char *args, vm_offset_t addr, vm_offset_t *modulep,
144199767f8SToomas Soome 	    vm_offset_t *kernend, int add_smap);
145199767f8SToomas Soome int	bi_checkcpu(void);
146d9256fffSToomas Soome void	bi_isadir(void);
147199767f8SToomas Soome 
148f9feecc1SToomas Soome int	mb_kernel_cmdline(struct preloaded_file *, struct devdesc *, char **);
149f9feecc1SToomas Soome void	multiboot_tramp(uint32_t, vm_offset_t, vm_offset_t);
150199767f8SToomas Soome void	pxe_enable(void *pxeinfo);
151f9feecc1SToomas Soome 
152f9feecc1SToomas Soome #endif /* _LIBI386_H */
153