blob: 7a23b518fcabd95c91e7b578e6182a47b3716e61 [file] [log] [blame]
Kevin O'Connorfa9c66a2013-09-14 19:10:40 -04001// Misc function and variable declarations.
Kevin O'Connor786502d2008-02-27 10:41:41 -05002#ifndef __UTIL_H
3#define __UTIL_H
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05004
Kevin O'Connor9521e262008-07-04 13:04:29 -04005#include "types.h" // u32
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05006
Kevin O'Connorb367e0a2013-09-15 00:43:51 -04007// apm.c
8void apm_shutdown(void);
Kevin O'Connor2d2fa312013-09-14 21:55:26 -04009struct bregs;
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040010void handle_1553(struct bregs *regs);
Kevin O'Connorbdce35f2008-02-26 21:33:14 -050011
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040012// bmp.c
13struct bmp_decdata *bmp_alloc(void);
14int bmp_decode(struct bmp_decdata *bmp, unsigned char *data, int data_size);
15void bmp_get_size(struct bmp_decdata *bmp, int *width, int *height);
16int bmp_show(struct bmp_decdata *bmp, unsigned char *pic, int width
17 , int height, int depth, int bytes_per_line_dest);
Kevin O'Connorf54c1502008-06-14 15:56:16 -040018
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040019// boot.c
20void boot_init(void);
21void boot_add_bev(u16 seg, u16 bev, u16 desc, int prio);
22void boot_add_bcv(u16 seg, u16 ip, u16 desc, int prio);
23struct drive_s;
24void boot_add_floppy(struct drive_s *drive_g, const char *desc, int prio);
25void boot_add_hd(struct drive_s *drive_g, const char *desc, int prio);
26void boot_add_cd(struct drive_s *drive_g, const char *desc, int prio);
27void boot_add_cbfs(void *data, const char *desc, int prio);
28void interactive_bootmenu(void);
29void bcv_prepboot(void);
30struct pci_device;
31int bootprio_find_pci_device(struct pci_device *pci);
32int bootprio_find_scsi_device(struct pci_device *pci, int target, int lun);
33int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave);
34int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid);
35int bootprio_find_pci_rom(struct pci_device *pci, int instance);
36int bootprio_find_named_rom(const char *name, int instance);
37struct usbdevice_s;
38int bootprio_find_usb(struct usbdevice_s *usbdev, int lun);
Stefan Berger320df852015-11-30 11:14:19 -050039int get_keystroke(int msec);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040040
41// bootsplash.c
42void enable_vga_console(void);
43void enable_bootsplash(void);
44void disable_bootsplash(void);
Kevin O'Connor913cc2e2008-04-13 17:31:45 -040045
Kevin O'Connor135f3f62013-09-14 23:57:26 -040046// cdrom.c
Kevin O'Connor02f76762014-05-10 01:20:46 -040047extern struct eltorito_s CDEmu;
Kevin O'Connor135f3f62013-09-14 23:57:26 -040048extern struct drive_s *cdemu_drive_gf;
49struct disk_op_s;
Kevin O'Connor17856452015-07-07 14:56:20 -040050int cdemu_process_op(struct disk_op_s *op);
Kevin O'Connor135f3f62013-09-14 23:57:26 -040051void cdrom_prepboot(void);
Kevin O'Connor135f3f62013-09-14 23:57:26 -040052int cdrom_boot(struct drive_s *drive_g);
53
Kevin O'Connorbdce35f2008-02-26 21:33:14 -050054// clock.c
Kevin O'Connorc6e8c072013-07-20 10:51:58 -040055void clock_setup(void);
56void handle_1583(struct bregs *regs);
Kevin O'Connorbd5f6c72015-08-10 16:14:48 -040057void clock_poll_irq(void);
Kevin O'Connor9fcd1992013-09-15 01:50:00 -040058u32 irqtimer_calc_ticks(u32 count);
59u32 irqtimer_calc(u32 msecs);
60int irqtimer_check(u32 end);
Kevin O'Connorc6e8c072013-07-20 10:51:58 -040061void handle_1586(struct bregs *regs);
Kevin O'Connorc6e8c072013-07-20 10:51:58 -040062
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040063// fw/acpi.c
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040064void acpi_setup(void);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040065
66// fw/biostable.c
Kevin O'Connor3bd2dc62014-04-07 16:35:18 -040067void copy_pir(void *pos);
68void copy_mptable(void *pos);
Kevin O'Connor19646a42014-04-07 15:55:23 -040069extern struct pir_header *PirAddr;
Kevin O'Connor3bd2dc62014-04-07 16:35:18 -040070void copy_acpi_rsdp(void *pos);
Kevin O'Connor836b4d82014-04-07 15:42:04 -040071extern struct rsdp_descriptor *RsdpAddr;
72extern u32 acpi_pm1a_cnt;
Gerd Hoffmanna217de92014-05-13 14:01:22 +020073extern u16 acpi_pm_base;
Kevin O'Connor836b4d82014-04-07 15:42:04 -040074void *find_acpi_rsdp(void);
Kevin O'Connor9ec57de2016-01-10 10:53:24 -050075void *find_acpi_table(u32 signature);
Kevin O'Connor836b4d82014-04-07 15:42:04 -040076u32 find_resume_vector(void);
77void acpi_reboot(void);
78void find_acpi_features(void);
Kevin O'Connord18c9f02014-04-07 15:48:12 -040079extern struct smbios_entry_point *SMBiosAddr;
Stefan Berger5aa2a752015-03-23 14:22:17 -040080struct smbios_entry_point *get_smbios_entry_point();
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040081void copy_smbios(void *pos);
Kevin O'Connord18c9f02014-04-07 15:48:12 -040082void display_uuid(void);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040083void copy_table(void *pos);
Gabriel L. Somlod85c22e2014-04-23 15:04:49 -040084void smbios_setup(void);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040085
86// fw/coreboot.c
87extern const char *CBvendor, *CBpart;
88struct cbfs_file;
Kevin O'Connor4cd522e2013-11-29 12:14:34 -050089void coreboot_debug_putc(char c);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040090void cbfs_run_payload(struct cbfs_file *file);
91void coreboot_platform_setup(void);
92void cbfs_payload_setup(void);
93void coreboot_preinit(void);
94void coreboot_cbfs_init(void);
Kevin O'Connor5ab18be2014-02-11 15:33:42 -050095struct cb_header;
96void *find_cb_subtable(struct cb_header *cbh, u32 tag);
97struct cb_header *find_cb_table(void);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -040098
99// fw/csm.c
100int csm_bootprio_fdc(struct pci_device *pci, int port, int fdid);
101int csm_bootprio_ata(struct pci_device *pci, int chanid, int slave);
102int csm_bootprio_pci(struct pci_device *pci);
103
104// fw/mptable.c
105void mptable_setup(void);
106
107// fw/mtrr.c
108void mtrr_setup(void);
109
Vladimir Serbinenko1b911d72015-05-18 19:07:16 +0200110// fw/multiboot.c
111void multiboot_init(void);
112
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400113// fw/pciinit.c
Kevin O'Connor62ff9d52016-02-03 00:47:27 -0500114extern u64 pcimem_start, pcimem_end;
115extern u64 pcimem64_start, pcimem64_end;
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400116extern const u8 pci_irqs[4];
117void pci_setup(void);
Marcel Apfelbaum40d020f2014-01-15 14:20:06 +0200118void pci_resume(void);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400119
120// fw/pirtable.c
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400121void pirtable_setup(void);
122
123// fw/shadow.c
124void make_bios_writable(void);
125void make_bios_readonly(void);
Kevin O'Connorc68aff52017-03-03 10:48:45 -0500126void qemu_reboot(void);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400127
128// fw/smbios.c
Gabriel L. Somlod85c22e2014-04-23 15:04:49 -0400129void smbios_legacy_setup(void);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400130
131// fw/smm.c
132void smm_device_setup(void);
133void smm_setup(void);
134
135// fw/smp.c
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400136extern u32 MaxCountCPUs;
137void wrmsr_smp(u32 index, u64 val);
138void smp_setup(void);
Paolo Bonzini54e3a882016-07-07 16:00:40 +0200139void smp_resume(void);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400140int apic_id_is_present(u8 apic_id);
141
Kevin O'Connor7b9f2972013-09-18 21:04:03 -0400142// hw/dma.c
143int dma_floppy(u32 addr, int count, int isWrite);
144void dma_setup(void);
145
Kevin O'Connor135f3f62013-09-14 23:57:26 -0400146// hw/floppy.c
147extern struct floppy_ext_dbt_s diskette_param_table2;
148void floppy_setup(void);
149struct drive_s *init_floppy(int floppyid, int ftype);
150int find_floppy_type(u32 size);
Kevin O'Connor17856452015-07-07 14:56:20 -0400151int floppy_process_op(struct disk_op_s *op);
Kevin O'Connor135f3f62013-09-14 23:57:26 -0400152void floppy_tick(void);
153
154// hw/ramdisk.c
155void ramdisk_setup(void);
Kevin O'Connor17856452015-07-07 14:56:20 -0400156int ramdisk_process_op(struct disk_op_s *op);
Kevin O'Connor135f3f62013-09-14 23:57:26 -0400157
Kevin O'Connor72691a52014-12-16 09:55:16 -0500158// hw/sdcard.c
Kevin O'Connor17856452015-07-07 14:56:20 -0400159int sdcard_process_op(struct disk_op_s *op);
Kevin O'Connor72691a52014-12-16 09:55:16 -0500160void sdcard_setup(void);
161
Kevin O'Connor5d369d82013-09-02 20:48:46 -0400162// hw/timer.c
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500163void timer_setup(void);
Kevin O'Connor018bdd72013-07-20 18:22:57 -0400164void pmtimer_setup(u16 ioport);
165u32 timer_calc(u32 msecs);
166u32 timer_calc_usec(u32 usecs);
167int timer_check(u32 end);
Kevin O'Connorbc2aecd2008-11-28 16:40:06 -0500168void ndelay(u32 count);
169void udelay(u32 count);
170void mdelay(u32 count);
Kevin O'Connor10ad7992009-10-24 11:06:08 -0400171void nsleep(u32 count);
172void usleep(u32 count);
173void msleep(u32 count);
Kevin O'Connor018bdd72013-07-20 18:22:57 -0400174u32 ticks_to_ms(u32 ticks);
175u32 ticks_from_ms(u32 ms);
Kevin O'Connor9fcd1992013-09-15 01:50:00 -0400176void pit_setup(void);
Kevin O'Connorbdce35f2008-02-26 21:33:14 -0500177
Kevin O'Connor07cf73b2013-09-15 00:31:17 -0400178// jpeg.c
179struct jpeg_decdata *jpeg_alloc(void);
180int jpeg_decode(struct jpeg_decdata *jpeg, unsigned char *buf);
181void jpeg_get_size(struct jpeg_decdata *jpeg, int *width, int *height);
182int jpeg_show(struct jpeg_decdata *jpeg, unsigned char *pic, int width
183 , int height, int depth, int bytes_per_line_dest);
184
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400185// kbd.c
186void kbd_init(void);
187void handle_15c2(struct bregs *regs);
188void process_key(u8 key);
Gerd Hoffmann90fa5112017-09-18 10:47:20 +0200189u8 enqueue_key(u16 keycode);
190u16 ascii_to_keycode(u8 ascii);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400191
192// misc.c
Kevin O'Connoreb599242015-11-19 15:29:39 -0500193extern int HaveRunPost;
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400194extern struct bios_config_table_s BIOS_CONFIG_TABLE __aligned(1);
Kevin O'Connorca34ce52014-05-24 10:40:35 -0400195extern struct floppy_dbt_s diskette_param_table __aligned(1);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400196extern u8 BiosChecksum;
Kevin O'Connor6c68e7a2014-04-19 12:22:22 -0400197int in_post(void);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400198void mathcp_setup(void);
199
200// mouse.c
201void mouse_init(void);
202void process_mouse(u8 data);
203
Kevin O'Connor8fb3a5e2013-09-14 22:27:14 -0400204// optionroms.c
205struct rom_header;
206void callrom(struct rom_header *rom, u16 bdf);
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400207void call_bcv(u16 seg, u16 ip);
208int is_pci_vga(struct pci_device *pci);
209void optionrom_setup(void);
210void vgarom_setup(void);
211void s3_resume_vga(void);
212extern int ScreenAndDebug;
Kevin O'Connor8fb3a5e2013-09-14 22:27:14 -0400213
Kevin O'Connora0dc2962008-03-16 14:29:32 -0400214// pcibios.c
215void handle_1ab1(struct bregs *regs);
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500216void bios32_init(void);
Kevin O'Connora0dc2962008-03-16 14:29:32 -0400217
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400218// pmm.c
219void pmm_init(void);
220void pmm_prepboot(void);
221
222// pnpbios.c
223u16 get_pnp_offset(void);
224void pnp_init(void);
225
Kevin O'Connor07cf73b2013-09-15 00:31:17 -0400226// post.c
227void interface_init(void);
228void device_hardware_setup(void);
229void prepareboot(void);
230void startBoot(void);
231void reloc_preinit(void *f, void *arg);
Kevin O'Connora48f6022016-01-12 14:22:33 -0500232void code_mutable_preinit(void);
Kevin O'Connor07cf73b2013-09-15 00:31:17 -0400233
Gerd Hoffmannd6728f32017-09-18 10:47:23 +0200234// sercon.c
235void sercon_setup(void);
236void sercon_check_event(void);
237
Kevin O'Connorb367e0a2013-09-15 00:43:51 -0400238// serial.c
239void serial_setup(void);
240void lpt_setup(void);
Ian Campbell1442c312011-06-01 11:00:28 +0100241
Kevin O'Connor8cdf0c52016-08-05 13:44:12 -0400242// version.c
243extern const char VERSION[], BUILDINFO[];
244
Kevin O'Connorcbffa8e2008-08-17 11:11:07 -0400245// vgahooks.c
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500246void handle_155f(struct bregs *regs);
Jonathan A. Kollasche9a3e122013-10-20 12:48:56 -0500247void handle_157f(struct bregs *regs);
Kevin O'Connorc1de91b2011-07-02 13:50:21 -0400248void vgahook_setup(struct pci_device *pci);
Kevin O'Connorcbffa8e2008-08-17 11:11:07 -0400249
Kevin O'Connor786502d2008-02-27 10:41:41 -0500250#endif // util.h