Rev 1683 | Details | Compare with Previous | 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 | /* Access the info stucture */ |
||
23 | |||
1621 | fabio | 24 | #include <arch/i386/stdlib.h> |
2 | pj | 25 | #include <ll/i386/hw-func.h> |
26 | #include <ll/i386/mb-info.h> |
||
27 | #include <ll/i386/x-bios.h> |
||
28 | |||
40 | pj | 29 | FILE(X-Info); |
2 | pj | 30 | |
31 | /* |
||
32 | The x_bios is stored in the low memory area and contains all the |
||
33 | stuff necessary to perform a BIOS call from PM; it can be accessed |
||
34 | using a linear pointer, which is returned by the following call! |
||
35 | */ |
||
36 | |||
40 | pj | 37 | X_CALLBIOS * x_bios_address(void) |
2 | pj | 38 | { |
40 | pj | 39 | X_CALLBIOS *a = (X_CALLBIOS *)GDT_read(X_CALLBIOS_SEL,NULL,NULL,NULL); |
2 | pj | 40 | return (a); |
41 | } |
||
42 | |||
43 | /* Stuff information retrieving function */ |
||
44 | |||
45 | WORD X_version(void) |
||
46 | { |
||
47 | X_CALLBIOS *x_bios = x_bios_address(); |
||
83 | pj | 48 | return(x_bios->_ver); |
2 | pj | 49 | } |
50 | |||
40 | pj | 51 | void X_meminfo(LIN_ADDR *b1,DWORD *s1,LIN_ADDR *b2,DWORD *s2) |
2 | pj | 52 | { |
53 | struct multiboot_info *mbi = mbi_address(); |
||
40 | pj | 54 | int x = 0; |
55 | |||
56 | if (mbi->flags & MB_INFO_BOOT_LOADER_NAME) { |
||
57 | char *name; |
||
58 | |||
59 | name = (char *) mbi->boot_loader_name; |
||
60 | if (*name == 'X') { |
||
61 | x = 1; |
||
62 | } |
||
63 | } |
||
64 | if (x) { |
||
65 | if (b1 != NULL) *b1 = (LIN_ADDR)mbi->mem_upbase; |
||
66 | if (s1 != NULL) *s1 = mbi->mem_upper * 1024; |
||
67 | if (b2 != NULL) *b2 = (LIN_ADDR)mbi->mem_lowbase; |
||
68 | if (s2 != NULL) *s2 = mbi->mem_lower * 1024; |
||
2 | pj | 69 | } else { |
40 | pj | 70 | if (b1 != NULL) *b1 = (LIN_ADDR)0x100000; |
71 | if (s1 != NULL) *s1 = mbi->mem_upper * 1024; |
||
72 | if (b2 != NULL) *b2 = (LIN_ADDR)0x4000; |
||
73 | if (s2 != NULL) *s2 = mbi->mem_lower * 1024; |
||
2 | pj | 74 | } |
75 | /* |
||
76 | #ifdef __OLD_MB__ |
||
77 | if (b1 != NULL) *b1 = 0x100000; |
||
78 | if (s1 != NULL) *s1 = mbi->mem_upper; |
||
79 | if (b2 != NULL) *b2 = 0x4000; |
||
80 | if (s2 != NULL) *s2 = mbi->mem_lower; |
||
81 | #else |
||
82 | if (b1 != NULL) *b1 = mbi->mem_upbase; |
||
83 | if (s1 != NULL) *s1 = mbi->mem_upper; |
||
84 | if (b2 != NULL) *b2 = mbi->mem_lowbase; |
||
85 | if (s2 != NULL) *s2 = mbi->mem_lower; |
||
86 | #endif |
||
87 | */ |
||
88 | } |
||
89 | |||
90 | #ifdef CHECK |
||
91 | #include <cons.h> |
||
92 | /* Alert if a wrong addressing is intercepted */ |
||
93 | /* Used only for debug purposes */ |
||
94 | |||
40 | pj | 95 | void check_addr(void *addr,char *caller) |
2 | pj | 96 | { |
97 | extern DWORD _stktop; |
||
40 | pj | 98 | if ((DWORD)(addr) < _stktop) { |
99 | cprintf("CRISIS! Addr : %lx(%lx) Caller was %s\n",(DWORD)(addr),_stktop,caller); |
||
2 | pj | 100 | } |
101 | } |
||
102 | #endif |