283
|
1 module memory;
|
293
|
2
|
377
|
3 import arch;
|
381
|
4 import io;
|
283
|
5
|
301
|
6 var int ptr;
|
283
|
7
|
393
|
8 // Let the heap grow upwards..
|
|
9
|
367
|
10 function void init()
|
|
11 {
|
408
|
12 ptr = 0x60080000;
|
367
|
13 }
|
|
14
|
402
|
15 function byte* alloc(int size)
|
283
|
16 {
|
393
|
17 var int ptr2;
|
|
18 ptr2 = ptr;
|
|
19
|
|
20 io.print2("alloc size ", size);
|
|
21 io.print2("alloc address ", ptr);
|
|
22
|
|
23 // Increment new free point:
|
296
|
24 ptr = ptr + size;
|
402
|
25 return ptr2;
|
283
|
26 }
|
|
27
|
408
|
28 function byte* allocate_physical()
|
|
29 {
|
|
30 return 0;
|
|
31 }
|
|
32
|
|
33 function byte* allocate_virtual(byte* address)
|
|
34 {
|
|
35 var byte* address2;
|
|
36 address2 = allocate_physical();
|
|
37 return address2;
|
|
38 }
|
|
39
|
402
|
40 function void memcpy(byte* dst, byte* src, int size)
|
393
|
41 {
|
|
42 var int i;
|
408
|
43 io.print2("memcpy to ", cast<int>(dst));
|
|
44 io.print2("memcpy from ", cast<int>(src));
|
|
45 for (i = 0; i < size; i += 1)
|
393
|
46 {
|
|
47 *(dst + i) = *(src + i);
|
|
48 }
|
|
49 }
|
283
|
50
|