annotate kernel/src/memory.c3 @ 395:3b0c495e3008

Speed improvements
author Windel Bouwman
date Fri, 23 May 2014 14:28:03 +0200
parents 6ae782a085e0
children
rev   line source
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
1 module memory;
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 283
diff changeset
2
377
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 367
diff changeset
3 import arch;
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
4 import io;
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
5
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 296
diff changeset
6 var int ptr;
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
7
393
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
8 // Let the heap grow upwards..
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
9
367
577ed7fb3fe4 Try to make thumb work again
Windel Bouwman
parents: 359
diff changeset
10 function void init()
577ed7fb3fe4 Try to make thumb work again
Windel Bouwman
parents: 359
diff changeset
11 {
393
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
12 ptr = 0x80000;
367
577ed7fb3fe4 Try to make thumb work again
Windel Bouwman
parents: 359
diff changeset
13 }
577ed7fb3fe4 Try to make thumb work again
Windel Bouwman
parents: 359
diff changeset
14
393
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
15 function u8* alloc(int size)
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
16 {
393
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
17 var int ptr2;
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
18 ptr2 = ptr;
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
19
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
20 io.print2("alloc size ", size);
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
21 io.print2("alloc address ", ptr);
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
22
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
23 // Increment new free point:
296
9417caea2eb3 Directorized some backend files
Windel Bouwman
parents: 293
diff changeset
24 ptr = ptr + size;
393
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
25 return cast<u8*>(ptr2);
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
26 }
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
27
393
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
28 function void memcpy(u8* dst, u8* src, int size)
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
29 {
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
30 //
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
31 var int i;
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
32 for (i = 0; i < size; i = i + 1)
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
33 {
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
34 *(dst + i) = *(src + i);
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
35 }
6ae782a085e0 Added init program
Windel Bouwman
parents: 389
diff changeset
36 }
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
37