fs.h: A slighly more useful default PATH
[syslinux.git] / core / init.c
blob19db1e27205bb6efdbdaa25c5358c14079831b1a
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 */
11 static inline void check_escapes(void)
13 com32sys_t ireg, oreg;
15 ireg.eax.b[1] = 0x02; /* Check keyboard flags */
16 __intcall(0x16, &ireg, &oreg);
18 KbdFlags = oreg.eax.b[0];
20 /* Ctrl->skip 386 check */
21 if (oreg.eax.b[0] & 0x04) {
23 * Now check that there is sufficient low (DOS) memory
25 * NOTE: Linux doesn't use all of real_mode_seg, but we use
26 * the same segment for COMBOOT images, which can use all 64K.
28 uint16_t mem;
30 __intcall(0x12, &ireg, &oreg);
32 mem = ((uint32_t)__lowmem_heap) + min_lowmem_heap + 1023;
33 mem = mem >> 10;
35 if (mem < oreg.eax.w[0]) {
36 char buf[256];
38 snprintf(buf, sizeof(buf),
39 "It appears you computer has less than "
40 "%dK of low (DOS)\nRAM. Syslinux "
41 "needs at least this amount to boot. "
42 "If you get\nthis message in error, "
43 "hold down the Ctrl key while\nbooting, "
44 "and I will take your word for it.\n",
45 mem);
46 writestr(buf);
47 kaboom();
52 extern uint32_t BIOS_timer_next;
53 extern uint32_t timer_irq;
54 static inline void bios_timer_init(void)
56 unsigned long next;
57 uint32_t *hook = (uint32_t *)BIOS_timer_hook;
59 next = *hook;
60 BIOS_timer_next = next;
61 *hook = (uint32_t)&timer_irq;
64 extern void printf_init(void);
65 void init(com32sys_t *regs __unused)
67 int i;
69 /* Initialize timer */
70 bios_timer_init();
72 for (i = 0; i < 256; i++)
73 KbdMap[i] = i;
75 adjust_screen();
76 printf_init();
78 /* Init the memory subsystem */
79 mem_init();
81 /* CPU-dependent initialization and related checks. */
82 check_escapes();