xref: /netbsd-src/sys/arch/i386/stand/lib/libi386.h (revision b324aceaab262551713cd9b1ad2c767cd96c86e9)
1 /*	$NetBSD: libi386.h,v 1.54 2024/09/18 00:44:03 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 /* parseutils.c */
102 char *gettrailer(char *);
103 int parseopts(const char *, int *);
104 int parseboot(char *, char **, int *);
105 
106 /* menuutils.c */
107 struct bootblk_command {
108 	const char *c_name;
109 	void (*c_fn)(char *);
110 };
111 void bootmenu(void);
112 void docommand(char *);
113 
114 /* in "user code": */
115 void command_help(char *);
116 extern const struct bootblk_command commands[];
117 
118 /* asm bios/dos calls */
119 __compactcall int biosdisk_extread(int, void *);
120 int biosdisk_read(int, int, int, int, int, void *);
121 __compactcall int biosdisk_reset(int);
122 
123 __compactcall int biosgetrtc(u_long *);
124 int biosgetsystime(void);
125 int comgetc(int);
126 void cominit(int);
127 __compactcall int computc(int, int);
128 int comstatus(int);
129 int congetc(void);
130 int conisshift(void);
131 int coniskey(void);
132 __compactcall void conputc(int);
133 void conclr(void);
134 
135 int getextmem2(int *);
136 __compactcall int getextmemps2(void *);
137 int getmementry(int *, int *);
138 
139 __compactcall int biosdisk_int13ext(int);
140 __compactcall int biosdisk_getinfo(int);
141 struct biosdisk_extinfo;
142 __compactcall int biosdisk_getextinfo(int, struct biosdisk_extinfo *);
143 int get_harddrives(void);
144 void biosdisk_probe(void);
145 
146 void module_add(char *);
147 void splash_add(char *);
148 void rnd_add(char *);
149 void fs_add(char *);
150 void userconf_add(char *);
151 void module_add_split(const char *, uint8_t);
152 
153 struct btinfo_framebuffer;
154 void framebuffer_configure(struct btinfo_framebuffer *);
155 
156 void ksyms_addr_set(void *, void *, void *);
157 
158 #endif	/* __I386_STAND_LIBI386_H__ */
159