Rev 3 | 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 | /* Routines to create address spaces and bind physical memory to them */ |
||
23 | |||
24 | #include <ll/sys/ll/ll-data.h> |
||
25 | #include <ll/sys/ll/aspace.h> |
||
26 | |||
40 | pj | 27 | FILE(Address-Space); |
2 | pj | 28 | |
29 | struct as AS_table[ASMax]; |
||
30 | |||
31 | void as_init(void) |
||
32 | { |
||
40 | pj | 33 | int i; |
2 | pj | 34 | |
40 | pj | 35 | for (i = 0; i < ASMax; i++) { |
36 | AS_table[i].status = AS_FREE; |
||
37 | } |
||
2 | pj | 38 | } |
39 | |||
40 | AS as_create(void) |
||
41 | { |
||
40 | pj | 42 | int i; |
2 | pj | 43 | |
40 | pj | 44 | i = 0; |
45 | while((i < ASMax) && (AS_table[i].status & AS_BUSY)) { |
||
46 | i++; |
||
47 | } |
||
48 | |||
49 | if (i == ASMax) { |
||
50 | return 0; |
||
51 | } |
||
52 | |||
53 | AS_table[i].status = AS_BUSY; /* Empty address space... */ |
||
54 | AS_table[i].base = 0; |
||
55 | AS_table[i].limit= 0; |
||
2 | pj | 56 | |
40 | pj | 57 | GDT_place(ASindex2sel(i), AS_table[i].base, AS_table[i].limit, |
58 | DATA_ACCESS, GRAN_32B); |
||
59 | GDT_place(ASindex2sel(i) + 8, AS_table[i].base, AS_table[i].limit, |
||
60 | CODE_ACCESS, GRAN_32B); |
||
2 | pj | 61 | /* We also need a code segment... */ |
62 | |||
40 | pj | 63 | return ASindex2sel(i); |
2 | pj | 64 | } |
65 | |||
66 | int as_bind(AS as, DWORD ph_addr, DWORD l_addr, DWORD size) |
||
67 | { |
||
40 | pj | 68 | int i = ASsel2index(as); |
2 | pj | 69 | |
40 | pj | 70 | /* We have not paging... So l_addr must be 0 */ |
71 | if (l_addr != 0) |
||
72 | return -1; |
||
2 | pj | 73 | |
40 | pj | 74 | AS_table[i].base = ph_addr; |
75 | AS_table[i].limit= size; |
||
2 | pj | 76 | |
40 | pj | 77 | GDT_place(as, AS_table[i].base, AS_table[i].limit, |
78 | DATA_ACCESS, GRAN_32B); |
||
79 | GDT_place(as + 8, AS_table[i].base, AS_table[i].limit, |
||
80 | CODE_ACCESS, GRAN_32B); |
||
2 | pj | 81 | /* We also need a code segment... */ |
82 | |||
40 | pj | 83 | return 1; |
2 | pj | 84 | } |