Rev 185 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
132 | giacomo | 1 | /* |
2 | Linux Real Mode Interface - A library of DPMI-like functions for Linux. |
||
3 | |||
4 | Copyright (C) 1998 by Josh Vanderhoof |
||
5 | |||
6 | You are free to distribute and modify this file, as long as you |
||
7 | do not remove this copyright notice and clearly label modified |
||
8 | versions as being modified. |
||
9 | |||
10 | This software has NO WARRANTY. Use it at your own risk. |
||
11 | */ |
||
12 | |||
13 | #include <stdio.h> |
||
14 | #include <string.h> |
||
15 | #include <sys/types.h> |
||
16 | #include <unistd.h> |
||
17 | #include <fcntl.h> |
||
18 | #include <stdlib.h> |
||
19 | |||
20 | #include <ll/i386/hw-data.h> |
||
21 | #include <ll/i386/x-dosmem.h> |
||
22 | |||
23 | #include "lrmi.h" |
||
24 | #include "libvga.h" |
||
25 | |||
26 | #include <kernel/log.h> |
||
27 | |||
28 | int |
||
29 | LRMI_init(void) |
||
30 | { |
||
31 | DOS_mem_init(); |
||
32 | return 0; |
||
33 | } |
||
34 | |||
35 | void * |
||
36 | LRMI_alloc_real(int size) |
||
37 | { |
||
38 | return DOS_alloc(size); |
||
39 | } |
||
40 | |||
41 | void |
||
42 | LRMI_free_real(void *m, int s) |
||
43 | { |
||
44 | DOS_free(m,s); |
||
45 | } |
||
46 | |||
47 | |||
48 | int LRMI_int(int i, struct LRMI_regs *r) |
||
49 | { |
||
50 | |||
51 | unsigned char p1,p2; |
||
52 | |||
53 | X_REGS16 inregs, outregs; |
||
54 | X_SREGS16 sregs; |
||
55 | |||
56 | inregs.x.ax = r->eax; |
||
57 | inregs.x.bx = r->ebx; |
||
58 | inregs.x.cx = r->ecx; |
||
59 | inregs.x.dx = r->edx; |
||
60 | sregs.es = r->es; |
||
61 | sregs.ds = r->ds; |
||
62 | inregs.x.di = r->edi; |
||
63 | |||
64 | #ifndef VM86 |
||
65 | p1 = inp(0x21); |
||
66 | p2 = inp(0xA1); |
||
67 | outp(0x21,0xFF); |
||
68 | outp(0xA1,0xFF); |
||
69 | X_callBIOS(i, &inregs, &outregs, &sregs); |
||
70 | outp(0x21,p1); |
||
71 | outp(0xA1,p2); |
||
72 | #else |
||
73 | vm86_callBIOS(i, &inregs, &outregs, &sregs); |
||
74 | #endif |
||
75 | |||
76 | r->eax = outregs.x.ax; |
||
77 | r->ebx = outregs.x.bx; |
||
78 | r->ecx = outregs.x.cx; |
||
79 | r->edx = outregs.x.dx; |
||
80 | r->esi = outregs.x.si; |
||
81 | r->edi = outregs.x.di; |
||
82 | |||
83 | return 1; |
||
84 | |||
85 | } |
||
86 |