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