Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* Project: OSLib |
2 | * Description: The OS Construction Kit |
||
3 | * Date: 1.6.2000 |
||
4 | * Idea by: Luca Abeni & Gerardo Lamastra |
||
5 | * |
||
6 | * OSLib is an SO project aimed at developing a common, easy-to-use |
||
7 | * low-level infrastructure for developing OS kernels and Embedded |
||
8 | * Applications; it partially derives from the HARTIK project but it |
||
9 | * currently is independently developed. |
||
10 | * |
||
11 | * OSLib is distributed under GPL License, and some of its code has |
||
12 | * been derived from the Linux kernel source; also some important |
||
13 | * ideas come from studying the DJGPP go32 extender. |
||
14 | * |
||
15 | * We acknowledge the Linux Community, Free Software Foundation, |
||
16 | * D.J. Delorie and all the other developers who believe in the |
||
17 | * freedom of software and ideas. |
||
18 | * |
||
19 | * For legalese, check out the included GPL license. |
||
20 | */ |
||
21 | |||
22 | /* VM86 demo: tries to call BIOS services in vm86 mode... */ |
||
23 | |||
24 | #include <ll/i386/hw-func.h> |
||
25 | #include <ll/i386/tss-ctx.h> |
||
26 | #include <ll/i386/x-bios.h> |
||
27 | #include <ll/i386/cons.h> |
||
28 | #include <ll/i386/error.h> |
||
29 | #include <ll/stdlib.h> |
||
30 | |||
31 | #define T 1000 |
||
32 | #define WAIT() for (w = 0; w < 0xFFFFFFFF; w++) |
||
33 | |||
34 | static unsigned long int w; |
||
35 | |||
36 | #define __VM86__ |
||
37 | |||
38 | #ifdef __VM86__ |
||
39 | void vm86BIOSDemo(void) |
||
40 | { |
||
41 | X_REGS16 ir,or; |
||
42 | X_SREGS16 sr; |
||
43 | /* Print ASCII character */ |
||
44 | ir.h.ah = 9; |
||
45 | /* AL = character to display */ |
||
46 | ir.h.al = '+'; |
||
47 | /* BH = page number, BL = attribute */ |
||
48 | ir.x.bx = 3; |
||
49 | /* Count number */ |
||
50 | ir.x.cx = 3; |
||
51 | vm86_callBIOS(0x10,&ir,&or,&sr); |
||
52 | } |
||
53 | #else |
||
54 | |||
55 | void XBIOSDemo(void) |
||
56 | { |
||
57 | X_REGS16 ir,or; |
||
58 | X_SREGS16 sr; |
||
59 | /* Set video mode */ |
||
60 | ir.h.ah = 9; |
||
61 | ir.h.al = '+'; |
||
62 | ir.x.bx = 3; |
||
63 | ir.x.cx = 3; |
||
64 | X_callBIOS(0x10,&ir,&or,&sr); |
||
65 | } |
||
66 | #endif |
||
67 | |||
68 | void BIOSDemo(void) |
||
69 | { |
||
70 | X_REGS16 ir,or; |
||
71 | X_SREGS16 sr; |
||
72 | register int i; |
||
73 | /* Set video mode */ |
||
74 | ir.h.ah = 0; |
||
75 | ir.h.al = 0x12; |
||
76 | vm86_callBIOS(0x10,&ir,&or,&sr); |
||
77 | #if 1 |
||
78 | /* Put some pixels */ |
||
79 | for (i = 0; i < 200; i++) { |
||
80 | ir.h.ah = 0x0C; |
||
81 | ir.h.al = i % 16; |
||
82 | ir.x.bx = 0; |
||
83 | ir.x.dx = i+40; |
||
84 | ir.x.cx = i+100; |
||
85 | vm86_callBIOS(0x10,&ir,&or,&sr); |
||
86 | } |
||
87 | #endif |
||
88 | WAIT(); |
||
89 | /* Set video mode */ |
||
90 | ir.h.ah = 0; |
||
91 | ir.h.al = 0x03; |
||
92 | vm86_callBIOS(0x10,&ir,&or,&sr); |
||
93 | } |
||
94 | |||
95 | int main (int argc, char *argv[]) |
||
96 | { |
||
97 | DWORD sp1, sp2; |
||
98 | WORD c; |
||
99 | int i; |
||
100 | struct multiboot_info *mbi; |
||
101 | |||
102 | sp1 = get_SP(); |
||
103 | mbi = l1_init(); |
||
104 | |||
105 | if (mbi == NULL) { |
||
106 | message("Error in LowLevel initialization code...\n"); |
||
107 | l1_exit(-1); |
||
108 | } |
||
109 | |||
110 | message("Starting..."); |
||
111 | c = ll_context_save(); |
||
112 | message("CX=%x\n",c); |
||
113 | for (i = 0; i < 0x4F000; i++); |
||
114 | #ifdef __VM86__ |
||
115 | vm86_init(); |
||
116 | BIOSDemo(); |
||
117 | #else |
||
118 | XBIOSDemo(); |
||
119 | #endif |
||
120 | sp2 = get_SP(); |
||
121 | message("End reached!\n"); |
||
122 | message("Actual stack : %lx - ", sp2); |
||
123 | message("Begin stack : %lx\n", sp1); |
||
124 | message("Check if same : %s\n",sp1 == sp2 ? "Ok :-)" : "No :-("); |
||
125 | |||
126 | l1_end(); |
||
127 | return 1; |
||
128 | } |