blob: 79a2e7f2b29125e3e49a4174e33097a707f8ed1a [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'Connorf076a3e2008-02-25 22:25:15 -05007// kbd.c
Kevin O'Connord83c87b2013-01-21 01:14:12 -05008void kbd_init(void);
Kevin O'Connor2d2fa312013-09-14 21:55:26 -04009struct bregs;
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050010void handle_15c2(struct bregs *regs);
Kevin O'Connor114592f2009-09-28 21:32:08 -040011void process_key(u8 key);
Kevin O'Connorbdce35f2008-02-26 21:33:14 -050012
Kevin O'Connorf54c1502008-06-14 15:56:16 -040013// mouse.c
Kevin O'Connord83c87b2013-01-21 01:14:12 -050014void mouse_init(void);
Kevin O'Connor57877482009-12-09 21:00:41 -050015void process_mouse(u8 data);
Kevin O'Connorf54c1502008-06-14 15:56:16 -040016
Kevin O'Connor913cc2e2008-04-13 17:31:45 -040017// serial.c
Kevin O'Connor1ca05b02010-01-03 17:43:37 -050018void serial_setup(void);
19void lpt_setup(void);
Kevin O'Connor913cc2e2008-04-13 17:31:45 -040020
Kevin O'Connor135f3f62013-09-14 23:57:26 -040021// cdrom.c
22extern u8 CDRom_locks[];
23extern struct cdemu_s CDEmu;
24extern struct drive_s *cdemu_drive_gf;
25struct disk_op_s;
26int process_cdemu_op(struct disk_op_s *op);
27void cdrom_prepboot(void);
28void cdemu_134b(struct bregs *regs);
29int cdrom_boot(struct drive_s *drive_g);
30
Kevin O'Connorbdce35f2008-02-26 21:33:14 -050031// clock.c
Kevin O'Connorc6e8c072013-07-20 10:51:58 -040032void clock_setup(void);
33void handle_1583(struct bregs *regs);
34void handle_1586(struct bregs *regs);
35void useRTC(void);
36void releaseRTC(void);
37
Kevin O'Connor135f3f62013-09-14 23:57:26 -040038// hw/floppy.c
39extern struct floppy_ext_dbt_s diskette_param_table2;
40void floppy_setup(void);
41struct drive_s *init_floppy(int floppyid, int ftype);
42int find_floppy_type(u32 size);
43int process_floppy_op(struct disk_op_s *op);
44void floppy_tick(void);
45
46// hw/ramdisk.c
47void ramdisk_setup(void);
48int process_ramdisk_op(struct disk_op_s *op);
49
Kevin O'Connor5d369d82013-09-02 20:48:46 -040050// hw/timer.c
Kevin O'Connor1ca05b02010-01-03 17:43:37 -050051void timer_setup(void);
Kevin O'Connor018bdd72013-07-20 18:22:57 -040052void pmtimer_setup(u16 ioport);
53u32 timer_calc(u32 msecs);
54u32 timer_calc_usec(u32 usecs);
55int timer_check(u32 end);
Kevin O'Connorbc2aecd2008-11-28 16:40:06 -050056void ndelay(u32 count);
57void udelay(u32 count);
58void mdelay(u32 count);
Kevin O'Connor10ad7992009-10-24 11:06:08 -040059void nsleep(u32 count);
60void usleep(u32 count);
61void msleep(u32 count);
Kevin O'Connor018bdd72013-07-20 18:22:57 -040062u32 ticks_to_ms(u32 ticks);
63u32 ticks_from_ms(u32 ms);
Kevin O'Connor95ee3822013-07-20 18:07:50 -040064u32 irqtimer_calc_ticks(u32 count);
65u32 irqtimer_calc(u32 msecs);
66int irqtimer_check(u32 end);
Kevin O'Connorbdce35f2008-02-26 21:33:14 -050067
Kevin O'Connor95b2f782008-03-05 19:52:06 -050068// apm.c
Kevin O'Connor244caf82010-09-15 21:48:16 -040069void apm_shutdown(void);
Kevin O'Connorc0031482010-01-01 13:03:17 -050070void handle_1553(struct bregs *regs);
Kevin O'Connor95b2f782008-03-05 19:52:06 -050071
Kevin O'Connor07cf73b2013-09-15 00:31:17 -040072// bmp.c
73struct bmp_decdata *bmp_alloc(void);
74int bmp_decode(struct bmp_decdata *bmp, unsigned char *data, int data_size);
75void bmp_get_size(struct bmp_decdata *bmp, int *width, int *height);
76int bmp_show(struct bmp_decdata *bmp, unsigned char *pic, int width
77 , int height, int depth, int bytes_per_line_dest);
78
79// boot.c
80void boot_init(void);
81void boot_add_bev(u16 seg, u16 bev, u16 desc, int prio);
82void boot_add_bcv(u16 seg, u16 ip, u16 desc, int prio);
83void boot_add_floppy(struct drive_s *drive_g, const char *desc, int prio);
84void boot_add_hd(struct drive_s *drive_g, const char *desc, int prio);
85void boot_add_cd(struct drive_s *drive_g, const char *desc, int prio);
86void boot_add_cbfs(void *data, const char *desc, int prio);
87void interactive_bootmenu(void);
88void bcv_prepboot(void);
89struct pci_device;
90int bootprio_find_pci_device(struct pci_device *pci);
91int bootprio_find_scsi_device(struct pci_device *pci, int target, int lun);
92int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave);
93int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid);
94int bootprio_find_pci_rom(struct pci_device *pci, int instance);
95int bootprio_find_named_rom(const char *name, int instance);
96struct usbdevice_s;
97int bootprio_find_usb(struct usbdevice_s *usbdev, int lun);
98
99// jpeg.c
100struct jpeg_decdata *jpeg_alloc(void);
101int jpeg_decode(struct jpeg_decdata *jpeg, unsigned char *buf);
102void jpeg_get_size(struct jpeg_decdata *jpeg, int *width, int *height);
103int jpeg_show(struct jpeg_decdata *jpeg, unsigned char *pic, int width
104 , int height, int depth, int bytes_per_line_dest);
105
Kevin O'Connor8fb3a5e2013-09-14 22:27:14 -0400106// optionroms.c
107struct rom_header;
108void callrom(struct rom_header *rom, u16 bdf);
109
Kevin O'Connora0dc2962008-03-16 14:29:32 -0400110// pcibios.c
111void handle_1ab1(struct bregs *regs);
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500112void bios32_init(void);
Kevin O'Connora0dc2962008-03-16 14:29:32 -0400113
Kevin O'Connor07cf73b2013-09-15 00:31:17 -0400114// post.c
115void interface_init(void);
116void device_hardware_setup(void);
117void prepareboot(void);
118void startBoot(void);
119void reloc_preinit(void *f, void *arg);
120
Kevin O'Connor5a7545c2013-09-14 22:54:44 -0400121// fw/acpi.c
122extern struct rsdp_descriptor *RsdpAddr;
123extern u32 acpi_pm1a_cnt;
124void acpi_setup(void);
125u32 find_resume_vector(void);
126void find_acpi_features(void);
127struct acpi_20_generic_address;
128void acpi_set_reset_reg(struct acpi_20_generic_address *reg, u8 val);
129void acpi_reboot(void);
130
Kevin O'Connorf6d700d2013-09-14 22:38:00 -0400131// fw/csm.c
Kevin O'Connorf6d700d2013-09-14 22:38:00 -0400132int csm_bootprio_fdc(struct pci_device *pci, int port, int fdid);
133int csm_bootprio_ata(struct pci_device *pci, int chanid, int slave);
134int csm_bootprio_pci(struct pci_device *pci);
135
Kevin O'Connor3d0dfe12013-09-14 22:48:04 -0400136// fw/mptable.c
137void mptable_setup(void);
138
Kevin O'Connorccee6e82013-09-02 21:25:21 -0400139// fw/shadow.c
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500140void make_bios_writable(void);
141void make_bios_readonly(void);
Kevin O'Connor244caf82010-09-15 21:48:16 -0400142void qemu_prep_reset(void);
Kevin O'Connorda4a6482008-06-08 13:48:06 -0400143
Kevin O'Connorb37a5282013-09-14 22:45:05 -0400144// fw/smbios.c
145extern struct smbios_entry_point *SMBiosAddr;
146void smbios_setup(void);
147void display_uuid(void);
148
Kevin O'Connorccee6e82013-09-02 21:25:21 -0400149// fw/pciinit.c
Kevin O'Connor0d6b8d52010-07-10 13:12:37 -0400150extern const u8 pci_irqs[4];
Kevin O'Connor40f5b5a2009-09-13 10:46:57 -0400151void pci_setup(void);
Kevin O'Connora4d35762008-03-08 15:43:03 -0500152
Kevin O'Connorc5e06fb2013-09-14 22:22:28 -0400153// fw/pirtable.c
154extern struct pir_header *PirAddr;
155void pirtable_setup(void);
156
Kevin O'Connorccee6e82013-09-02 21:25:21 -0400157// fw/smm.c
Kevin O'Connorcdbac7f2013-03-08 19:33:39 -0500158void smm_device_setup(void);
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500159void smm_setup(void);
Kevin O'Connorf7ba6d72008-07-04 05:05:54 -0400160
Kevin O'Connorccee6e82013-09-02 21:25:21 -0400161// fw/smp.c
Kevin O'Connor603bfc32009-06-22 20:04:56 -0400162extern u32 CountCPUs;
Kevin O'Connor84705852009-10-08 22:13:15 -0400163extern u32 MaxCountCPUs;
Kevin O'Connore97ca7b2009-06-21 09:10:28 -0400164void wrmsr_smp(u32 index, u64 val);
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500165void smp_setup(void);
Eduardo Habkost008c1fc2012-07-25 15:45:30 -0300166int apic_id_is_present(u8 apic_id);
Kevin O'Connor84ad59a2008-07-04 05:47:26 -0400167
Kevin O'Connorccee6e82013-09-02 21:25:21 -0400168// fw/coreboot.c
Kevin O'Connorc1de91b2011-07-02 13:50:21 -0400169extern const char *CBvendor, *CBpart;
Kevin O'Connor1edc89d2009-04-30 21:50:35 -0400170struct cbfs_file;
Gerd Hoffmannebf03f72013-06-24 11:24:57 +0200171void debug_cbmem(char c);
Kevin O'Connor1f836252009-08-16 20:17:35 -0400172void cbfs_run_payload(struct cbfs_file *file);
Kevin O'Connora2a86e22013-02-13 19:35:12 -0500173void coreboot_platform_setup(void);
Kevin O'Connor89a1efd2011-01-08 12:24:39 -0500174void cbfs_payload_setup(void);
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500175void coreboot_preinit(void);
176void coreboot_cbfs_init(void);
Kevin O'Connorc7812932008-06-08 23:08:12 -0400177
Kevin O'Connorccee6e82013-09-02 21:25:21 -0400178// fw/biostable.c
David Woodhouse38b24db2013-01-25 19:33:58 -0600179void copy_smbios(void *pos);
Kevin O'Connor4d053eb2012-06-09 13:08:02 -0400180void copy_table(void *pos);
Ian Campbell1442c312011-06-01 11:00:28 +0100181
Kevin O'Connorcbffa8e2008-08-17 11:11:07 -0400182// vgahooks.c
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500183void handle_155f(struct bregs *regs);
Kevin O'Connorc1de91b2011-07-02 13:50:21 -0400184void vgahook_setup(struct pci_device *pci);
Kevin O'Connorcbffa8e2008-08-17 11:11:07 -0400185
Kevin O'Connor714325c2008-11-01 20:32:27 -0400186// optionroms.c
Kevin O'Connor0a924122009-02-08 19:43:47 -0500187void call_bcv(u16 seg, u16 ip);
Alex Williamson7adfd712013-03-20 10:58:47 -0600188int is_pci_vga(struct pci_device *pci);
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500189void optionrom_setup(void);
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500190void vgarom_setup(void);
191void s3_resume_vga(void);
Kevin O'Connor422263d2011-07-05 20:56:07 -0400192extern int ScreenAndDebug;
Kevin O'Connor714325c2008-11-01 20:32:27 -0400193
Kevin O'Connorafbed1b2010-06-28 07:34:53 -0400194// bootsplash.c
195void enable_vga_console(void);
Kevin O'Connor9a01a9c2010-08-25 21:07:48 -0400196void enable_bootsplash(void);
Kevin O'Connorafbed1b2010-06-28 07:34:53 -0400197void disable_bootsplash(void);
198
Kevin O'Connor18e38b22008-12-10 20:40:13 -0500199// resume.c
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400200extern int HaveRunPost;
Kevin O'Connor9e4d41c2013-01-21 12:14:29 -0500201void dma_setup(void);
Kevin O'Connor18e38b22008-12-10 20:40:13 -0500202
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500203// pnpbios.c
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500204u16 get_pnp_offset(void);
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500205void pnp_init(void);
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500206
Kevin O'Connore54ee382009-07-26 19:33:13 -0400207// pmm.c
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500208void pmm_init(void);
209void pmm_prepboot(void);
Kevin O'Connore54ee382009-07-26 19:33:13 -0400210
Kevin O'Connorccee6e82013-09-02 21:25:21 -0400211// fw/mtrr.c
Kevin O'Connor7061eb62009-01-04 21:48:22 -0500212void mtrr_setup(void);
213
Kevin O'Connor18e38b22008-12-10 20:40:13 -0500214// romlayout.S
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500215void reset_vector(void) __noreturn;
Kevin O'Connor18e38b22008-12-10 20:40:13 -0500216
Kevin O'Connor30853762009-01-17 18:49:20 -0500217// misc.c
Kevin O'Connor392d2aa2013-09-15 00:14:28 -0400218extern struct bios_config_table_s BIOS_CONFIG_TABLE __aligned(1);
Kevin O'Connor30853762009-01-17 18:49:20 -0500219extern u8 BiosChecksum;
Kevin O'Connor392d2aa2013-09-15 00:14:28 -0400220void mathcp_setup(void);
Kevin O'Connor30853762009-01-17 18:49:20 -0500221
Kevin O'Connorc95d2ce2009-07-29 20:41:39 -0400222// version (auto generated file out/version.c)
223extern const char VERSION[];
224
Kevin O'Connor786502d2008-02-27 10:41:41 -0500225#endif // util.h