]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/cpu/apic.c
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / cpu / apic.c
1
2 #include <stdio.h>
3 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <assert.h>
7 #include <string.h>
8 #include <setjmp.h>
9 #include <fcntl.h>
10 #include <dos.h>
11
12 #include <hw/cpu/cpu.h>
13 #include <hw/dos/dos.h>
14 #include <hw/flatreal/flatreal.h>
15 #include <hw/dos/doswin.h>
16
17 #include <hw/cpu/apiclib.h>
18
19 int main(int argc,char **argv) {
20         if (!probe_apic()) {
21                 printf("APIC not detected. Reason: %s\n",apic_error_str);
22                 return 1;
23         }
24
25         printf("APIC base address:        0x%08lx\n",(unsigned long)apic_base);
26         printf("APIC global enable:       %u\n",(unsigned int)(apic_flags&APIC_FLAG_GLOBAL_ENABLE?1:0));
27         printf("Read from bootstrap CPU:  %u\n",(unsigned int)(apic_flags&APIC_FLAG_PROBE_ON_BOOT_CPU?1:1));
28
29 #if TARGET_MSDOS == 32
30         dos_ltp_probe();
31         /* TODO: If LTP probe indicates we shouldn't assume physical<->linear addresses (i.e paging) then bail out */
32 #else
33         probe_dos();
34         detect_windows();
35         if (!flatrealmode_setup(FLATREALMODE_4GB)) {
36                 printf("Cannot enter flat real mode\n");
37                 return 1;
38         }
39 #endif
40
41         {
42                 unsigned int i;
43
44                 /* NTS: For safe access on Intel processors always read on 16-byte aligned boundary, 32-bit at all times.
45                  * Intel warns the undefined bytes 4-15 between the regs are undefined and may cause undefined behavior. */
46                 printf("APIC dump:\n");
47                 for (i=0x0;i < 0x400;i += 16) {
48                         if ((i&0x7F) == 0)
49                                 printf("0x%03x:",i);
50
51                         printf("%08lx ",(unsigned long)apic_readd(i));
52                         if ((i&0x7F) == 0x70)
53                                 printf("\n");
54                 }
55         }
56
57         return 0;
58 }
59