mem.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Memory and machine-specific definitions. Used in C and assembler.
  3. */
  4. #define KiB 1024u /* Kibi 0x0000000000000400 */
  5. #define MiB 1048576u /* Mebi 0x0000000000100000 */
  6. #define GiB 1073741824u /* Gibi 000000000040000000 */
  7. /*
  8. * Sizes
  9. */
  10. #define BY2PG (4*KiB) /* bytes per page */
  11. #define PGSHIFT 12 /* log(BY2PG) */
  12. #define MAXMACH 1 /* max # cpus system can run */
  13. #define MACHSIZE BY2PG
  14. #define KSTKSIZE (8*KiB)
  15. #define STACKALIGN(sp) ((sp) & ~3) /* bug: assure with alloc */
  16. /*
  17. * Address spaces.
  18. * KTZERO is used by kprof and dumpstack (if any).
  19. *
  20. * KZERO is mapped to physical 0 (start of ram).
  21. *
  22. * vectors are at 0, plan9.ini is at KZERO+256 and is limited to 16K by
  23. * devenv.
  24. */
  25. #define KSEG0 0x80000000 /* kernel segment */
  26. /* mask to check segment; good for 512MB dram */
  27. #define KSEGM 0xE0000000
  28. #define KZERO KSEG0 /* kernel address space */
  29. #define CONFADDR (KZERO+0x100) /* unparsed plan9.ini */
  30. #define MACHADDR (KZERO+0x2000) /* Mach structure */
  31. #define L2 (KZERO+0x3000) /* L2 ptes for vectors etc */
  32. #define VCBUFFER (KZERO+0x3400) /* videocore mailbox buffer */
  33. #define FIQSTKTOP (KZERO+0x4000) /* FIQ stack */
  34. #define L1 (KZERO+0x4000) /* tt ptes: 16KiB aligned */
  35. #define KTZERO (KZERO+0x8000) /* kernel text start */
  36. #define VIRTIO 0x7E000000 /* i/o registers */
  37. #define FRAMEBUFFER 0xA0000000 /* video framebuffer */
  38. #define UZERO 0 /* user segment */
  39. #define UTZERO (UZERO+BY2PG) /* user text start */
  40. #define UTROUND(t) ROUNDUP((t), BY2PG)
  41. #define USTKTOP 0x20000000 /* user segment end +1 */
  42. #define USTKSIZE (8*1024*1024) /* user stack size */
  43. #define TSTKTOP (USTKTOP-USTKSIZE) /* sysexec temporary stack */
  44. #define TSTKSIZ 256
  45. /* address at which to copy and execute rebootcode */
  46. #define REBOOTADDR (KZERO+0x3400)
  47. /*
  48. * Legacy...
  49. */
  50. #define BLOCKALIGN 32 /* only used in allocb.c */
  51. #define KSTACK KSTKSIZE
  52. /*
  53. * Sizes
  54. */
  55. #define BI2BY 8 /* bits per byte */
  56. #define BY2SE 4
  57. #define BY2WD 4
  58. #define BY2V 8 /* only used in xalloc.c */
  59. #define CACHELINESZ 32
  60. #define PTEMAPMEM (1024*1024)
  61. #define PTEPERTAB (PTEMAPMEM/BY2PG)
  62. #define SEGMAPSIZE 1984
  63. #define SSEGMAPSIZE 16
  64. #define PPN(x) ((x)&~(BY2PG-1))
  65. /*
  66. * With a little work these move to port.
  67. */
  68. #define PTEVALID (1<<0)
  69. #define PTERONLY 0
  70. #define PTEWRITE (1<<1)
  71. #define PTEUNCACHED (1<<2)
  72. #define PTEKERNEL (1<<3)
  73. /*
  74. * Physical machine information from here on.
  75. * PHYS addresses as seen from the arm cpu.
  76. * BUS addresses as seen from the videocore gpu.
  77. */
  78. #define PHYSDRAM 0
  79. #define BUSDRAM 0x40000000
  80. #define DRAMSIZE (512*MiB)
  81. #define PHYSIO 0x20000000
  82. #define BUSIO 0x7E000000
  83. #define IOSIZE (16*MiB)