aboutsummaryrefslogtreecommitdiff
path: root/include/bios.h
blob: df60c5a77269098842ad8f492bd5466106c95ace (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef BIOS_H_
#define BIOS_H_

#include <inttypes.h>
#include <stddef.h>
#include <stdbool.h>

/*
 * When interfacing with assembler code we need to be sure how
 * arguments are passed in real mode.
 */
#define bioscall __attribute__((regparm(3)))

#ifndef __ASSEMBLER__

struct biosregs {
	uint32_t			eax;
	uint32_t			ebx;
	uint32_t			ecx;
	uint32_t			edx;
	uint32_t			esp;
	uint32_t			ebp;
	uint32_t			esi;
	uint32_t			edi;
	uint32_t			ds;
	uint32_t			es;
	uint32_t			fs;
	uint32_t			eip;
	uint32_t			eflags;
};

extern bioscall void int10_handler(struct biosregs *regs);
extern bioscall void int15_handler(struct biosregs *regs);
extern bioscall void e820_query_map(struct biosregs *regs);

extern void bios_intfake(void);
extern void bios_irq(void);
extern void bios_int10(void);
extern void bios_int15(void);

extern void setup_pci(void);
extern void setup_hw(void);
extern bool setup_mmconfig(void);
extern void extract_acpi(void);
extern void boot_from_fwcfg(void);
extern bool boot_from_cbfs(void *base, size_t sz);

extern uint16_t e820_seg;
extern uint32_t lowmem;

extern uint8_t stext;
extern uint8_t edata;
extern uint8_t sinit;
extern uint8_t einit;

#define ARRAY_SIZE(x)	(sizeof(x) / sizeof(x[0]))

static inline void __attribute__((noreturn)) panic(void)
{
	asm volatile("cli; hlt");
	for(;;);
}

#endif

#endif /* BIOS_H_ */