xref: /netbsd-src/sys/arch/i386/stand/lib/libi386.h (revision ccd9df534e375a4366c5b55f23782053c7a98d82)
1 /*	$NetBSD: libi386.h,v 1.53 2024/06/29 13:46:40 rin 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 
32 typedef unsigned long physaddr_t;
33 
34 /* this is in startup code */
35 void vpbcopy(const void *, void *, size_t);
36 void pvbcopy(const void *, void *, size_t);
37 void pbzero(void *, size_t);
38 physaddr_t vtophys(void *);
39 
40 ssize_t pread(int, void *, size_t);
41 void startprog(physaddr_t, uint32_t, uint32_t *, physaddr_t);
42 void multiboot(physaddr_t, physaddr_t, physaddr_t, uint32_t);
43 
44 int exec_netbsd(const char *, physaddr_t, int, int, void (*)(void));
45 int exec_multiboot(const char *, char *);
46 
47 void delay(int);
48 int getbasemem(void);
49 int getextmemx(void);
50 int getextmem1(void);
51 int biosvideomode(void);
52 #ifdef CONSERVATIVE_MEMDETECT
53 #define getextmem() getextmem1()
54 #else
55 #define getextmem() getextmemx()
56 #endif
57 void reboot(void);
58 void gateA20(void);
59 
60 void clear_pc_screen(void);
61 void initio(int);
62 #define CONSDEV_PC 0
63 #define CONSDEV_COM0 1
64 #define CONSDEV_COM1 2
65 #define CONSDEV_COM2 3
66 #define CONSDEV_COM3 4
67 #define CONSDEV_COM0KBD 5
68 #define CONSDEV_COM1KBD 6
69 #define CONSDEV_COM2KBD 7
70 #define CONSDEV_COM3KBD 8
71 #define CONSDEV_AUTO (-1)
72 int iskey(int);
73 char awaitkey(int, int);
74 void wait_sec(int);
75 
76 /* multiboot */
77 struct multiboot_package;
78 struct multiboot_package_priv;
79 
80 struct multiboot_package {
81 	int			 mbp_version;
82 	struct multiboot_header	*mbp_header;
83 	const char		*mbp_file;
84 	char			*mbp_args;
85 	u_long			 mbp_basemem;
86 	u_long			 mbp_extmem;
87 	u_long			 mbp_loadaddr;
88 	u_long			*mbp_marks;
89 	struct multiboot_package_priv*mbp_priv;
90 	struct multiboot_package*(*mbp_probe)(const char *);
91 	int			(*mbp_exec)(struct multiboot_package *);
92 	void			(*mbp_cleanup)(struct multiboot_package *);
93 };
94 
95 struct multiboot_package *probe_multiboot1(const char *);
96 struct multiboot_package *probe_multiboot2(const char *);
97 
98 /* this is in "user code"! */
99 int parsebootfile(const char *, char **, char **, int *, int *, const char **);
100 
101 #ifdef XMS
102 physaddr_t ppbcopy(physaddr_t, physaddr_t, int);
103 int checkxms(void);
104 physaddr_t xmsalloc(int);
105 #endif
106 
107 /* parseutils.c */
108 char *gettrailer(char *);
109 int parseopts(const char *, int *);
110 int parseboot(char *, char **, int *);
111 
112 /* menuutils.c */
113 struct bootblk_command {
114 	const char *c_name;
115 	void (*c_fn)(char *);
116 };
117 void bootmenu(void);
118 void docommand(char *);
119 
120 /* in "user code": */
121 void command_help(char *);
122 extern const struct bootblk_command commands[];
123 
124 /* asm bios/dos calls */
125 __compactcall int biosdisk_extread(int, void *);
126 int biosdisk_read(int, int, int, int, int, void *);
127 __compactcall int biosdisk_reset(int);
128 
129 __compactcall int biosgetrtc(u_long *);
130 int biosgetsystime(void);
131 int comgetc(int);
132 void cominit(int);
133 __compactcall int computc(int, int);
134 int comstatus(int);
135 int congetc(void);
136 int conisshift(void);
137 int coniskey(void);
138 __compactcall void conputc(int);
139 void conclr(void);
140 
141 int getextmem2(int *);
142 __compactcall int getextmemps2(void *);
143 int getmementry(int *, int *);
144 
145 __compactcall int biosdisk_int13ext(int);
146 __compactcall int biosdisk_getinfo(int);
147 struct biosdisk_extinfo;
148 __compactcall int biosdisk_getextinfo(int, struct biosdisk_extinfo *);
149 int get_harddrives(void);
150 void biosdisk_probe(void);
151 
152 void module_add(char *);
153 void splash_add(char *);
154 void rnd_add(char *);
155 void fs_add(char *);
156 void userconf_add(char *);
157 void module_add_split(const char *, uint8_t);
158 
159 struct btinfo_framebuffer;
160 void framebuffer_configure(struct btinfo_framebuffer *);
161 
162 void ksyms_addr_set(void *, void *, void *);
163 
164 #endif	/* __I386_STAND_LIBI386_H__ */
165