txt/Makefile: make directories
[syslinux.git] / core / init.c
bloba1412252ddf65eb4d1ee9d842621438d8a0ee809
1 #include <core.h>
2 #include <com32.h>
3 #include <sys/io.h>
4 #include <fs.h>
5 #include <bios.h>
7 static uint32_t min_lowmem_heap = 65536;
8 extern char __lowmem_heap[];
9 uint8_t KbdFlags; /* Check for keyboard escapes */
10 __export uint8_t KbdMap[256]; /* Keyboard map */
12 __export uint16_t PXERetry;
14 static inline void check_escapes(void)
16 com32sys_t ireg, oreg;
18 ireg.eax.b[1] = 0x02; /* Check keyboard flags */
19 __intcall(0x16, &ireg, &oreg);
21 KbdFlags = oreg.eax.b[0];
23 /* Ctrl->skip 386 check */
24 if (oreg.eax.b[0] & 0x04) {
26 * Now check that there is sufficient low (DOS) memory
28 * NOTE: Linux doesn't use all of real_mode_seg, but we use
29 * the same segment for COMBOOT images, which can use all 64K.
31 uint16_t mem;
33 __intcall(0x12, &ireg, &oreg);
35 mem = ((uint32_t)__lowmem_heap) + min_lowmem_heap + 1023;
36 mem = mem >> 10;
38 if (mem < oreg.eax.w[0]) {
39 char buf[256];
41 snprintf(buf, sizeof(buf),
42 "It appears your computer has only "
43 "%dK of low (\"DOS\") RAM.\n"
44 "This version of Syslinux needs "
45 "%dK to boot. "
46 "If you get this\nmessage in error, "
47 "hold down the Ctrl key while booting, "
48 "and I\nwill take your word for it.\n",
49 oreg.eax.w[0], mem);
50 writestr(buf);
51 kaboom();
56 extern uint32_t BIOS_timer_next;
57 extern uint32_t timer_irq;
58 static inline void bios_timer_init(void)
60 unsigned long next;
61 uint32_t *hook = (uint32_t *)BIOS_timer_hook;
63 next = *hook;
64 BIOS_timer_next = next;
65 *hook = (uint32_t)&timer_irq;
68 void init(com32sys_t *regs __unused)
70 int i;
72 /* Initialize timer */
73 bios_timer_init();
75 for (i = 0; i < 256; i++)
76 KbdMap[i] = i;
78 adjust_screen();
80 /* Init the memory subsystem */
81 mem_init();
83 /* CPU-dependent initialization and related checks. */
84 check_escapes();