Subversion Repositories shark

Rev

Rev 2 | 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
 
24
#include <ll/i386/stdlib.h>
25
#include <ll/i386/hw-func.h>
26
#include <ll/i386/mb-info.h>
27
#include <ll/i386/x-bios.h>
28
 
29
FILE(X - Info);
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
 
37
X_CALLBIOS *x_bios_address(void)
38
{
39
    X_CALLBIOS *a =
40
        (X_CALLBIOS *) GDT_read(X_CALLBIOS_SEL, NULL, NULL, NULL);
41
    return (a);
42
}
43
 
44
/* Stuff information retrieving function */
45
 
46
WORD X_version(void)
47
{
48
    X_CALLBIOS *x_bios = x_bios_address();
49
    return (x_bios->ver);
50
}
51
 
52
void X_meminfo(LIN_ADDR * b1, DWORD * s1, LIN_ADDR * b2, DWORD * s2)
53
{
54
    struct multiboot_info *mbi = mbi_address();
55
    if (mbi->flags & MB_INFO_USEGDT) {
56
        if (b1 != NULL)
57
            *b1 = (LIN_ADDR) mbi->mem_upbase;
58
        if (s1 != NULL)
59
            *s1 = mbi->mem_upper * 1024;
60
        if (b2 != NULL)
61
            *b2 = (LIN_ADDR) mbi->mem_lowbase;
62
        if (s2 != NULL)
63
            *s2 = mbi->mem_lower * 1024;
64
    } else {
65
        if (b1 != NULL)
66
            *b1 = (LIN_ADDR) 0x100000;
67
        if (s1 != NULL)
68
            *s1 = mbi->mem_upper * 1024;
69
        if (b2 != NULL)
70
            *b2 = (LIN_ADDR) 0x4000;
71
        if (s2 != NULL)
72
            *s2 = mbi->mem_lower * 1024;
73
    }
74
/*
75
#ifdef __OLD_MB__
76
    if (b1 != NULL) *b1 = 0x100000;
77
    if (s1 != NULL) *s1 = mbi->mem_upper;
78
    if (b2 != NULL) *b2 = 0x4000;
79
    if (s2 != NULL) *s2 = mbi->mem_lower;
80
#else    
81
    if (b1 != NULL) *b1 = mbi->mem_upbase;
82
    if (s1 != NULL) *s1 = mbi->mem_upper;
83
    if (b2 != NULL) *b2 = mbi->mem_lowbase;
84
    if (s2 != NULL) *s2 = mbi->mem_lower;
85
#endif
86
*/
87
}
88
 
89
#ifdef CHECK
90
#include <cons.h>
91
/* Alert if a wrong addressing is intercepted   */
92
/* Used only for debug purposes                 */
93
 
94
void check_addr(void *addr, char *caller)
95
{
96
    extern DWORD _stktop;
97
    if ((DWORD) (addr) < _stktop) {
98
        cprintf("CRISIS! Addr : %lx(%lx) Caller was %s\n", (DWORD) (addr),
99
                _stktop, caller);
100
    }
101
}
102
#endif