xref: /netbsd-src/sys/arch/i386/stand/lib/libi386.h (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /*	$NetBSD: libi386.h,v 1.42 2017/03/12 05:33:48 nonaka 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);
43 
44 int exec_netbsd(const char *, physaddr_t, int, int, void (*)(void));
45 int exec_multiboot(const char *, char *);
46 int count_netbsd(const char *, u_long *);
47 
48 void delay(int);
49 int getbasemem(void);
50 int getextmemx(void);
51 int getextmem1(void);
52 int biosvideomode(void);
53 #ifdef CONSERVATIVE_MEMDETECT
54 #define getextmem() getextmem1()
55 #else
56 #define getextmem() getextmemx()
57 #endif
58 void printmemlist(void);
59 void reboot(void);
60 void gateA20(void);
61 
62 void clear_pc_screen(void);
63 void initio(int);
64 #define CONSDEV_PC 0
65 #define CONSDEV_COM0 1
66 #define CONSDEV_COM1 2
67 #define CONSDEV_COM2 3
68 #define CONSDEV_COM3 4
69 #define CONSDEV_COM0KBD 5
70 #define CONSDEV_COM1KBD 6
71 #define CONSDEV_COM2KBD 7
72 #define CONSDEV_COM3KBD 8
73 #define CONSDEV_AUTO (-1)
74 int iskey(int);
75 char awaitkey(int, int);
76 void wait_sec(int);
77 
78 /* this is in "user code"! */
79 int parsebootfile(const char *, char **, char **, int *, int *, const char **);
80 
81 #ifdef XMS
82 physaddr_t ppbcopy(physaddr_t, physaddr_t, int);
83 int checkxms(void);
84 physaddr_t xmsalloc(int);
85 #endif
86 
87 /* parseutils.c */
88 char *gettrailer(char *);
89 int parseopts(const char *, int *);
90 int parseboot(char *, char **, int *);
91 
92 /* menuutils.c */
93 struct bootblk_command {
94 	const char *c_name;
95 	void (*c_fn)(char *);
96 };
97 void bootmenu(void);
98 void docommand(char *);
99 
100 /* in "user code": */
101 void command_help(char *);
102 extern const struct bootblk_command commands[];
103 
104 /* asm bios/dos calls */
105 __compactcall int biosdisk_extread(int, void *);
106 int biosdisk_read(int, int, int, int, int, void *);
107 __compactcall int biosdisk_reset(int);
108 
109 __compactcall int biosgetrtc(u_long *);
110 int biosgetsystime(void);
111 int comgetc(int);
112 void cominit(int);
113 __compactcall int computc(int, int);
114 int comstatus(int);
115 int congetc(void);
116 int conisshift(void);
117 int coniskey(void);
118 __compactcall void conputc(int);
119 void conclr(void);
120 
121 int getextmem2(int *);
122 __compactcall int getextmemps2(void *);
123 int getmementry(int *, int *);
124 
125 __compactcall int biosdisk_int13ext(int);
126 __compactcall int biosdisk_getinfo(int);
127 struct biosdisk_extinfo;
128 __compactcall int biosdisk_getextinfo(int, struct biosdisk_extinfo *);
129 int get_harddrives(void);
130 void biosdisk_probe(void);
131 
132 int pcibios_cfgread(unsigned int, int, int *);
133 int pcibios_cfgwrite(unsigned int, int, int);
134 int pcibios_finddev(int, int, int, unsigned int *);
135 int pcibios_present(int *);
136 
137 void dosclose(int);
138 int dosopen(char *);
139 int dosread(int, char *, int);
140 int dosseek(int, int, int);
141 extern int doserrno;	/* in dos_file.S */
142 
143 void module_add(char *);
144 void splash_add(char *);
145 void rnd_add(char *);
146 void fs_add(char *);
147 void userconf_add(char *);
148 
149 struct btinfo_framebuffer;
150 void framebuffer_configure(struct btinfo_framebuffer *);
151 
152 #endif	/* __I386_STAND_LIBI386_H__ */
153