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 | /* 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 | |||
27 | FILE(Address - Space); |
||
28 | |||
29 | struct as AS_table[ASMax]; |
||
30 | |||
31 | void as_init(void) |
||
32 | { |
||
33 | int i; |
||
34 | |||
35 | for (i = 0; i < ASMax; i++) { |
||
36 | AS_table[i].status = AS_FREE; |
||
37 | } |
||
38 | } |
||
39 | |||
40 | AS as_create(void) |
||
41 | { |
||
42 | int i; |
||
43 | |||
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; |
||
56 | |||
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); |
||
61 | /* We also need a code segment... */ |
||
62 | |||
63 | return ASindex2sel(i); |
||
64 | } |
||
65 | |||
66 | int as_bind(AS as, DWORD ph_addr, DWORD l_addr, DWORD size) |
||
67 | { |
||
68 | int i = ASsel2index(as); |
||
69 | |||
70 | /* We have not paging... So l_addr must be 0 */ |
||
71 | if (l_addr != 0) |
||
72 | return -1; |
||
73 | |||
74 | AS_table[i].base = ph_addr; |
||
75 | AS_table[i].limit = size; |
||
76 | |||
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); |
||
81 | /* We also need a code segment... */ |
||
82 | |||
83 | return 1; |
||
84 | } |