1/*	$NetBSD: libi386.h,v 1.47 2019/10/18 01:24:51 manu Exp $	*/
2
3/*
4 * Copyright (c) 1996
5 *	Matthias Drochner.  All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
29#ifndef	__I386_STAND_LIBI386_H__
30#define	__I386_STAND_LIBI386_H__
31
32typedef unsigned long physaddr_t;
33
34/* this is in startup code */
35void vpbcopy(const void *, void *, size_t);
36void pvbcopy(const void *, void *, size_t);
37void pbzero(void *, size_t);
38physaddr_t vtophys(void *);
39
40ssize_t pread(int, void *, size_t);
41void startprog(physaddr_t, uint32_t, uint32_t *, physaddr_t);
42void multiboot(physaddr_t, physaddr_t, physaddr_t, uint32_t);
43
44int exec_netbsd(const char *, physaddr_t, int, int, void (*)(void));
45int exec_multiboot(const char *, char *);
46
47void delay(int);
48int getbasemem(void);
49int getextmemx(void);
50int getextmem1(void);
51int biosvideomode(void);
52#ifdef CONSERVATIVE_MEMDETECT
53#define getextmem() getextmem1()
54#else
55#define getextmem() getextmemx()
56#endif
57void printmemlist(void);
58void reboot(void);
59void gateA20(void);
60
61void clear_pc_screen(void);
62void initio(int);
63#define CONSDEV_PC 0
64#define CONSDEV_COM0 1
65#define CONSDEV_COM1 2
66#define CONSDEV_COM2 3
67#define CONSDEV_COM3 4
68#define CONSDEV_COM0KBD 5
69#define CONSDEV_COM1KBD 6
70#define CONSDEV_COM2KBD 7
71#define CONSDEV_COM3KBD 8
72#define CONSDEV_AUTO (-1)
73int iskey(int);
74char awaitkey(int, int);
75void wait_sec(int);
76
77/* multiboot */
78struct multiboot_package;
79struct multiboot_package_priv;
80
81struct multiboot_package {
82	int			 mbp_version;
83	struct multiboot_header	*mbp_header;
84	const char		*mbp_file;
85	char			*mbp_args;
86	u_long			 mbp_basemem;
87	u_long			 mbp_extmem;
88	u_long			 mbp_loadaddr;
89	u_long			*mbp_marks;
90	struct multiboot_package_priv*mbp_priv;
91	struct multiboot_package*(*mbp_probe)(const char *);
92	int			(*mbp_exec)(struct multiboot_package *);
93	void			(*mbp_cleanup)(struct multiboot_package *);
94};
95
96struct multiboot_package *probe_multiboot1(const char *);
97struct multiboot_package *probe_multiboot2(const char *);
98
99/* this is in "user code"! */
100int parsebootfile(const char *, char **, char **, int *, int *, const char **);
101
102#ifdef XMS
103physaddr_t ppbcopy(physaddr_t, physaddr_t, int);
104int checkxms(void);
105physaddr_t xmsalloc(int);
106#endif
107
108/* parseutils.c */
109char *gettrailer(char *);
110int parseopts(const char *, int *);
111int parseboot(char *, char **, int *);
112
113/* menuutils.c */
114struct bootblk_command {
115	const char *c_name;
116	void (*c_fn)(char *);
117};
118void bootmenu(void);
119void docommand(char *);
120
121/* in "user code": */
122void command_help(char *);
123extern const struct bootblk_command commands[];
124
125/* asm bios/dos calls */
126__compactcall int biosdisk_extread(int, void *);
127int biosdisk_read(int, int, int, int, int, void *);
128__compactcall int biosdisk_reset(int);
129
130__compactcall int biosgetrtc(u_long *);
131int biosgetsystime(void);
132int comgetc(int);
133void cominit(int);
134__compactcall int computc(int, int);
135int comstatus(int);
136int congetc(void);
137int conisshift(void);
138int coniskey(void);
139__compactcall void conputc(int);
140void conclr(void);
141
142int getextmem2(int *);
143__compactcall int getextmemps2(void *);
144int getmementry(int *, int *);
145
146__compactcall int biosdisk_int13ext(int);
147__compactcall int biosdisk_getinfo(int);
148struct biosdisk_extinfo;
149__compactcall int biosdisk_getextinfo(int, struct biosdisk_extinfo *);
150int get_harddrives(void);
151void biosdisk_probe(void);
152
153int pcibios_cfgread(unsigned int, int, int *);
154int pcibios_cfgwrite(unsigned int, int, int);
155int pcibios_finddev(int, int, int, unsigned int *);
156int pcibios_present(int *);
157
158void dosclose(int);
159int dosopen(char *);
160int dosread(int, char *, int);
161int dosseek(int, int, int);
162extern int doserrno;	/* in dos_file.S */
163
164void module_add(char *);
165void splash_add(char *);
166void rnd_add(char *);
167void fs_add(char *);
168void userconf_add(char *);
169void module_add_split(const char *, uint8_t);
170
171struct btinfo_framebuffer;
172void framebuffer_configure(struct btinfo_framebuffer *);
173
174void ksyms_addr_set(void *, void *, void *);
175
176#endif	/* __I386_STAND_LIBI386_H__ */
177