1 /* $NetBSD: libi386.h,v 1.56 2025/10/09 16:10:03 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 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_COM 9 72 #define CONSDEV_UCOM 10 73 #define CONSDEV_AUTO (-1) 74 int iskey(int); 75 char awaitkey(int, int); 76 void wait_sec(int); 77 78 /* multiboot */ 79 struct multiboot_package; 80 struct multiboot_package_priv; 81 82 struct multiboot_package { 83 int mbp_version; 84 struct multiboot_header *mbp_header; 85 const char *mbp_file; 86 char *mbp_args; 87 u_long mbp_basemem; 88 u_long mbp_extmem; 89 u_long mbp_loadaddr; 90 u_long *mbp_marks; 91 struct multiboot_package_priv*mbp_priv; 92 struct multiboot_package*(*mbp_probe)(const char *); 93 int (*mbp_exec)(struct multiboot_package *); 94 void (*mbp_cleanup)(struct multiboot_package *); 95 }; 96 97 struct multiboot_package *probe_multiboot1(const char *); 98 struct multiboot_package *probe_multiboot2(const char *); 99 100 /* this is in "user code"! */ 101 int parsebootfile(const char *, char **, char **, int *, int *, const char **); 102 103 /* parseutils.c */ 104 char *gettrailer(char *); 105 int parseopts(const char *, int *); 106 int parseboot(char *, char **, int *); 107 108 /* menuutils.c */ 109 struct bootblk_command { 110 const char *c_name; 111 void (*c_fn)(char *); 112 }; 113 void bootmenu(void); 114 void docommand(char *); 115 116 /* in "user code": */ 117 void command_help(char *); 118 extern const struct bootblk_command commands[]; 119 120 /* asm bios/dos calls */ 121 __compactcall int biosdisk_extread(int, void *); 122 int biosdisk_read(int, int, int, int, int, void *); 123 __compactcall int biosdisk_reset(int); 124 125 __compactcall int biosgetrtc(u_long *); 126 int biosgetsystime(void); 127 int comgetc(int); 128 void cominit(int); 129 __compactcall int computc(int, int); 130 int comstatus(int); 131 int congetc(void); 132 int conisshift(void); 133 int coniskey(void); 134 __compactcall void conputc(int); 135 void conclr(void); 136 137 int getextmem2(int *); 138 __compactcall int getextmemps2(void *); 139 int getmementry(int *, int *); 140 141 __compactcall int biosdisk_int13ext(int); 142 __compactcall int biosdisk_getinfo(int); 143 struct biosdisk_extinfo; 144 __compactcall int biosdisk_getextinfo(int, struct biosdisk_extinfo *); 145 int get_harddrives(void); 146 void biosdisk_probe(void); 147 148 void module_add(char *); 149 void splash_add(char *); 150 void rnd_add(char *); 151 void fs_add(char *); 152 void userconf_add(char *); 153 void module_add_split(const char *, uint8_t); 154 155 /* Note: implementations differ in boot2, dosboot & efiboot */ 156 void command_dev(char *); 157 158 struct btinfo_framebuffer; 159 void framebuffer_configure(struct btinfo_framebuffer *); 160 161 void ksyms_addr_set(void *, void *, void *); 162 163 #endif /* __I386_STAND_LIBI386_H__ */ 164