Subversion Repositories shark

Rev

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
/* The OSLib (flat space) <-> Phisical address conversion       */
23
 
24
#include <ll/i386/hw-func.h>
25
#include <ll/i386/mem.h>
26
 
27
FILE(X - Conv);
28
 
29
/* Conversion between PM address space & phisical address space */
30
/* If we do not support paging we need to relocate the .ELF executable  */
31
/* using the segment register; however we also need to access all the   */
32
/* phisical memory; for example if we allocate some memory (phisical)   */
33
/* and we use a pointer to access that memory, the pointer will use     */
34
/* the current DS to address the specified offset; but the phisical     */
35
/* offset cannot be used because the base of DS is not zero as required */
36
/* to access phisical memory; the DS base is stored by X into the       */
37
/* exec_base field of _X_info! This is the key to traslate ELF address  */
38
/* into phisical address & viceversa                                    */
39
 
40
/*
41
DWORD appl2linear(void *p)
42
{
43
    unsigned long result;
44
    result = (DWORD)(p) + _X_info->exec_base;
45
    return(result);
46
}
47
 
48
void *linear2appl(DWORD a)
49
{
50
    void *p;
51
    if (a < _X_info->exec_base) p = NULL;
52
    else p = (void *)(a-_X_info->exec_base);
53
    return(p);
54
}
55
*/
56
 
57
LIN_ADDR addr2linear(unsigned short seg, unsigned long offset)
58
{
59
    LIN_ADDR flatbase;
60
    flatbase = (LIN_ADDR) GDT_read(seg, NULL, NULL, NULL);
61
    return (flatbase + offset);
62
}