/*
* Memory and machine-specific definitions. Used in C and assembler.
*/
#define KiB 1024u /* Kibi 0x0000000000000400 */
#define MiB 1048576u /* Mebi 0x0000000000100000 */
#define GiB 1073741824u /* Gibi 000000000040000000 */
#define MIN(a, b) ((a) < (b)? (a): (b))
#define MAX(a, b) ((a) > (b)? (a): (b))
/*
* Not sure where these macros should go.
* This probably isn't right but will do for now.
* The macro names are problematic too.
*/
/*
* In B(o), 'o' is the bit offset in the register.
* For multi-bit fields use F(v, o, w) where 'v' is the value
* of the bit-field of width 'w' with LSb at bit offset 'o'.
*/
#define B(o) (1<<(o))
#define F(v, o, w) (((v) & ((1<<(w))-1))<<(o))
#define FCLR(d, o, w) ((d) & ~(((1<<(w))-1)<<(o)))
#define FEXT(d, o, w) (((d)>>(o)) & ((1<<(w))-1))
#define FINS(d, o, w, v) (FCLR((d), (o), (w))|F((v), (o), (w)))
#define FSET(d, o, w) ((d)|(((1<<(w))-1)<<(o)))
#define MAXMACH 1 /* max # cpus system can run */
#define MACHSIZE BY2PG
#define KSTACK (16*KiB) /* was 8K */
#define STACKALIGN(sp) ((sp) & ~3) /* bug: assure with alloc */
/*
* Address spaces.
* KTZERO is used by kprof and dumpstack (if any).
*
* KZERO (0xc0000000) is mapped to physical 0x80000000 (start of dram).
* u-boot claims to occupy the first 3 MB of dram, but we're willing to
* step on it once we're loaded. Expect plan9.ini in the first 64K past 3MB.
*
* L2 PTEs are stored in 1K before Mach (11K to 12K above KZERO).
* cpu0's Mach struct is at L1 - MACHSIZE(4K) to L1 (12K to 16K above KZERO).
* L1 PTEs are stored from L1 to L1+32K (16K to 48K above KZERO).
* KTZERO may be anywhere after that (but probably shouldn't collide with
* u-boot).
* This should leave over 8K from KZERO to L2 PTEs.
*/
#define KSEG0 0xC0000000 /* kernel segment */
/* mask to check segment; good for 512MB dram */
#define KSEGM 0xE0000000
#define KZERO KSEG0 /* kernel address space */
#define L1 (KZERO+16*KiB) /* tt ptes: 16KiB aligned */
#define CONFADDR (KZERO+0x300000) /* unparsed plan9.ini */
/* KTZERO must match loadaddr in mkfile */
#define KTZERO (KZERO+0x310000) /* kernel text start */
#define UZERO 0 /* user segment */
#define UTZERO (UZERO+BY2PG) /* user text start */
/* moved USTKTOP down to 512MB to keep MMIO space out of user space. */
#define USTKTOP 0x20000000 /* user segment end +1 */
#define USTKSIZE (8*1024*1024) /* user stack size */
/* address at which to copy and execute rebootcode */
#define REBOOTADDR KADDR(0x100)
/*
* Legacy...
*/
#define BLOCKALIGN 32 /* only used in allocb.c */
/*
* Sizes
*/
#define BI2BY 8 /* bits per byte */
#define BY2SE 4
#define BY2WD 4
#define BY2V 8 /* only used in xalloc.c */
/*
* These bits are completely artificial.
* With a little work these move to port.
*/
#define PTEVALID (1<<0)
#define PTERONLY 0
#define PTEWRITE (1<<1)
#define PTECACHED 0
#define PTEUNCACHED (1<<2)
/*
* Physical machine information from here on.
*/
/* gpmc-controlled address space 0—1G */
#define PHYSNAND 1 /* cs0 is onenand flash */
#define PHYSETHER 0x2c000000
#define PHYSIO 0x48000000 /* L4 ctl */
#define PHYSSCM 0x48002000 /* system control module */
/* core control pad cfg 0x48002030—0x480021e4, */
/* core control d2d pad cfg 0x480021e4—0x48002264 */
#define PHYSSCMPCONF 0x48002270 /* general device config */
#define PHYSOMAPSTS 0x4800244c /* standalone short: has l2 size */
/* core control pad cfg (2) 0x480025d8—0x480025fc */
#define PHYSSWBOOTCFG 0x48002910 /* sw booting config */
/* wakeup control pad cfg 0x48002a00—0x48002a54 */