]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/omap4/mem.h
kernel: add portable uncached memory allocator (ucalloc) (from sources)
[plan9front.git] / sys / src / 9 / omap4 / mem.h
1 #define KiB             1024u                   /* Kibi 0x0000000000000400 */
2 #define MiB             1048576u                /* Mebi 0x0000000000100000 */
3 #define GiB             1073741824u             /* Gibi 000000000040000000 */
4
5 #define HOWMANY(x, y)   (((x)+((y)-1))/(y))
6 #define ROUNDUP(x, y)   (HOWMANY((x), (y))*(y)) /* ceiling */
7 #define ROUNDDN(x, y)   (((x)/(y))*(y))         /* floor */
8 #define MIN(a, b)       ((a) < (b)? (a): (b))
9 #define MAX(a, b)       ((a) > (b)? (a): (b))
10 #define PGROUND(s)      ROUNDUP(s, BY2PG)
11 #define ROUND(s, sz)    (((s)+(sz-1))&~(sz-1))
12 #define PPN(x)          ((x)&~(BY2PG-1))
13 #define F(v, o, w)      (((v) & ((1<<(w))-1))<<(o))
14
15 #define FMASK(o, w)     (((1<<(w))-1)<<(o))
16
17 #define KZERO           0xF0000000
18 #define KTZERO          0xF2000000
19 #define VECTORS         0xFFFF0000
20 #define MACHADDR        0xFFFF1000
21
22 #define UZERO           0
23 #define UTZERO          BY2PG
24 #define USTKTOP         0xE0000000
25
26 /* we map MMIO somewhere here */
27 #define IZERO           0xE0000000
28 #define NIOPAGES        ROUNDDN((KZERO - IZERO) / BY2PG, 256)
29
30 #define KSTKSIZ         (16*KiB)
31 #define KSTACK          KSTKSIZ
32 #define TSTKSIZ         256
33 #define USTKSIZE                (8*MiB)
34 #define TSTKTOP         (USTKTOP - USTKSIZE)
35 #define HZ              100
36
37 #define MAXSYSARG       7
38 #define MAXMACH         2
39
40 #define BI2BY           8
41 #define BY2WD           4
42 #define BY2V            8
43 #define BY2PG           4096
44 #define PGSHIFT         12
45 #define PTEMAPMEM       1048576
46 #define PTEPERTAB       (PTEMAPMEM/BY2PG)
47 #define SEGMAPSIZE      1984
48 #define SSEGMAPSIZE     16
49 #define BLOCKALIGN      32
50
51 #define PTEVALID        (1<<0)
52 #define PTERONLY        0
53 #define PTEWRITE        (1<<1)
54 #define PTEUNCACHED     (1<<2)
55 #define PTEKERNEL       (1<<3)
56
57 #define PHYSDRAM        0x80000000
58 #define DRAMSIZ         (1024 * MiB)
59
60 #define L1PT            PHYSDRAM
61 #define L1SIZ           (16 * KiB)
62 #define IOPT            (L1PT + L1SIZ)
63 #define L2SIZ           (1 * KiB)
64 #define PRIVL2          (IOPT + L2SIZ * (NIOPAGES / 256))
65 #define PHYSVECTORS     ROUNDUP(PRIVL2 + L2SIZ, BY2PG)
66 #define FIRSTMACH       (PHYSVECTORS + BY2PG)