ref: c0d4498ab8a4e564156f49e5b6633a6335b91fc4
parent: 9f54c2831717bc656df6e5a2fde2bf7be8e29fef
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Apr 25 13:41:34 EDT 2021
kernel: clean up Mach structure Remove unused fields and factor common fields into a new PMach struct in port/portdat.h. The fields machno, splpc and proc are not moved to PMach as they are part of the known offsets from assembly (l.s).
--- a/sys/src/9/bcm/dat.h
+++ b/sys/src/9/bcm/dat.h
@@ -150,42 +150,17 @@
{
int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */
+ Proc* proc; /* current process on this processor */
- Proc* proc; /* current process */
-
MMMU;
- int flushmmu; /* flush current proc mmu state */
+ /* end of offsets known to asm */
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void* alarm; /* alarms bound to this clock */
+ PMach;
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
int cputype;
ulong delayloop;
-
- /* stats */
- int tlbfault;
- int tlbpurge;
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
- uvlong fastclock; /* last sampled value */
- uvlong inidle; /* time spent in idlehands() */
- ulong spuriousintr;
- int lastintr;
- int ilockdepth;
- Perf perf; /* performance counters */
-
-
int cpumhz;
uvlong cpuhz; /* speed of cpu */
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
/* vfp2 or vfp3 fpu */
int havefp;
@@ -206,7 +181,7 @@
u32int smon[5]; /* probably not needed */
u32int ssys[5];
- int stack[1];
+ uintptr stack[1];
};
/*
--- a/sys/src/9/bcm64/dat.h
+++ b/sys/src/9/bcm64/dat.h
@@ -142,41 +142,17 @@
{
int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */
+ Proc* proc; /* current process on this processor */
+ /* end of offsets known to asm */
- Proc* proc; /* current process */
-
MMMU;
- int flushmmu; /* flush current proc mmu state */
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void* alarm; /* alarms bound to this clock */
+ PMach;
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
int cputype;
ulong delayloop;
-
- /* stats */
- int tlbfault;
- int tlbpurge;
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
- uvlong fastclock; /* last sampled value */
- uvlong inidle; /* time spent in idlehands() */
- ulong spuriousintr;
- int lastintr;
- int ilockdepth;
- Perf perf; /* performance counters */
-
int cpumhz;
uvlong cpuhz; /* speed of cpu */
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
int stack[1];
};
--- a/sys/src/9/cycv/dat.h
+++ b/sys/src/9/cycv/dat.h
@@ -116,47 +116,23 @@
struct Mach
{
- /* known to assembly */
int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process */
ulong excregs[3];
ulong cycleshi;
- /* end of known to assembly */
+ /* end of known offsets to assembly */
- int flushmmu; /* flush current proc mmu state */
+ MMMU;
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void* alarm; /* alarms bound to this clock */
- int inclockintr;
+ PMach;
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
- ulong delayloop;
-
- /* stats */
- int tlbfault;
- int tlbpurge;
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
int lastintr;
- int ilockdepth;
- Perf perf; /* performance counters */
-
int cpumhz;
uvlong cpuhz; /* speed of cpu */
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
-
- MMMU;
- int stack[1];
+ uintptr stack[1];
};
#define NISAOPT 8
--- a/sys/src/9/kw/dat.h
+++ b/sys/src/9/kw/dat.h
@@ -130,43 +130,19 @@
{
int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */
-
Proc* proc; /* current process */
-
MMMU;
- int flushmmu; /* flush current proc mmu state */
+ /* end of offsets known to asm */
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void* alarm; /* alarms bound to this clock */
+ PMach;
+
+ vlong fastclock; /* last sampled value */
int inclockintr;
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
int cputype;
int socrev; /* system-on-chip revision */
ulong delayloop;
-
- /* stats */
- int tlbfault;
- int tlbpurge;
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
- vlong fastclock; /* last sampled value */
- uvlong inidle; /* time spent in idlehands() */
- ulong spuriousintr;
- int lastintr;
- int ilockdepth;
- Perf perf; /* performance counters */
-
-// int cpumhz;
uvlong cpuhz; /* speed of cpu */
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
/* save areas for exceptions */
u32int sfiq[5];
@@ -178,7 +154,7 @@
#define abtstack sabt
#define undstack sund
- int stack[1];
+ uintptr stack[1];
};
/*
--- a/sys/src/9/mtx/dat.h
+++ b/sys/src/9/mtx/dat.h
@@ -123,54 +123,28 @@
{
/* OFFSETS OF THE FOLLOWING KNOWN BY l.s */
int machno; /* physical id of processor */
- ulong splpc; /* pc that called splhi() */
+ uintptr splpc; /* pc that called splhi() */
Proc *proc; /* current process on this processor */
/* ordering from here on irrelevant */
+ PMach;
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void *alarm; /* alarms bound to this clock */
- int inclockintr;
+ uintptr ptabbase; /* start of page table in kernel virtual space */
+ int slotgen; /* next pte (byte offset) when pteg is full */
+ int mmupid; /* next mmu pid to use */
+ int sweepcolor;
+ int trigcolor;
+ Rendez sweepr;
+
int cputype;
ulong loopconst;
-
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
vlong cpuhz;
ulong bushz;
ulong dechz;
ulong tbhz;
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
- ulong pcclast;
- uvlong fastclock;
- Perf perf; /* performance counters */
-
- int tlbfault; /* only used by devproc; no access to tlb */
- int tlbpurge; /* ... */
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
- int flushmmu; /* make current proc flush it's mmu state */
- int ilockdepth;
-
- ulong ptabbase; /* start of page table in kernel virtual space */
- int slotgen; /* next pte (byte offset) when pteg is full */
- int mmupid; /* next mmu pid to use */
- int sweepcolor;
- int trigcolor;
- Rendez sweepr;
-
- ulong spuriousintr;
- int lastintr;
-
/* MUST BE LAST */
- int stack[1];
+ uintptr stack[1];
};
struct
--- a/sys/src/9/omap/dat.h
+++ b/sys/src/9/omap/dat.h
@@ -154,43 +154,19 @@
{
int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */
-
Proc* proc; /* current process */
-
MMMU;
- int flushmmu; /* flush current proc mmu state */
+ /* end of offsets known to asm */
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void* alarm; /* alarms bound to this clock */
+ PMach;
+
+ uvlong fastclock; /* last sampled value */
int inclockintr;
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
int cputype;
ulong delayloop;
-
- /* stats */
- int tlbfault;
- int tlbpurge;
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
- uvlong fastclock; /* last sampled value */
- uvlong inidle; /* time spent in idlehands() */
- ulong spuriousintr;
- int lastintr;
- int ilockdepth;
- Perf perf; /* performance counters */
-
-
int cpumhz;
uvlong cpuhz; /* speed of cpu */
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
/* save areas for exceptions, hold R0-R4 */
u32int sfiq[5];
@@ -200,7 +176,7 @@
u32int smon[5]; /* probably not needed */
u32int ssys[5];
- int stack[1];
+ uintptr stack[1];
};
/*
--- a/sys/src/9/pc/dat.h
+++ b/sys/src/9/pc/dat.h
@@ -190,50 +190,25 @@
ulong iomap; /* I/O map base address + T-bit */
} Tss;
+
struct Mach
{
- int machno; /* physical id of processor (KNOWN TO ASSEMBLY) */
- ulong splpc; /* pc of last caller to splhi */
-
- ulong* pdb; /* page directory base for this processor (va) */
- Tss* tss; /* tss for this processor */
- Segdesc *gdt; /* gdt for this processor */
-
+ int machno; /* physical id of processor */
+ uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process on this processor */
Proc* externup; /* extern register Proc *up */
- Page* pdbpool;
- int pdbcnt;
+ PMach;
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void* alarm; /* alarms bound to this clock */
- int inclockintr;
-
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
- int tlbfault;
- int tlbpurge;
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
- int flushmmu; /* make current proc flush it's mmu state */
- int ilockdepth;
- Perf perf; /* performance counters */
-
+ uvlong tscticks;
ulong spuriousintr;
int lastintr;
int loopconst;
int aalcycles;
-
int cpumhz;
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
uvlong cpuhz;
+
int cpuidax;
int cpuidcx;
int cpuiddx;
@@ -242,19 +217,26 @@
uchar cpuidfamily;
uchar cpuidmodel;
uchar cpuidstepping;
- int havetsc;
- int havepge;
- int havewatchpt8;
- int havenx;
- uvlong tscticks;
- int pdballoc;
- int pdbfree;
+
+ char havetsc;
+ char havepge;
+ char havewatchpt8;
+ char havenx;
+
+ ulong* pdb; /* page directory base for this processor (va) */
+ Tss* tss; /* tss for this processor */
+ Segdesc*gdt; /* gdt for this processor */
u32int dr7; /* shadow copy of dr7 */
u32int xcr0;
void* vmx;
- int stack[1];
+ Page* pdbpool;
+ int pdbcnt;
+ int pdballoc;
+ int pdbfree;
+
+ uintptr stack[1];
};
/*
--- a/sys/src/9/pc64/dat.h
+++ b/sys/src/9/pc64/dat.h
@@ -184,48 +184,21 @@
struct Mach
{
- int machno; /* physical id of processor (KNOWN TO ASSEMBLY) */
- uintptr splpc; /* pc of last caller to splhi (KNOWN TO ASSEMBLY) */
+ int machno; /* physical id of processor */
+ uintptr splpc; /* pc of last caller to splhi */
+ Proc* proc; /* current process on this processor */
- Proc* proc; /* current process on this processor (KNOWN TO ASSEMBLY) */
+ PMach;
- u64int* pml4; /* pml4 base for this processor (va) */
- Tss* tss; /* tss for this processor */
- Segdesc *gdt; /* gdt for this processor */
-
- u64int mmumap[4]; /* bitmap of pml4 entries for zapping */
- MMU* mmufree; /* freelist for MMU structures */
- ulong mmucount; /* number of MMU structures in freelist */
-
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void* alarm; /* alarms bound to this clock */
- int inclockintr;
-
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
- int tlbfault;
- int tlbpurge;
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
- int flushmmu; /* make current proc flush it's mmu state */
- int ilockdepth;
- Perf perf; /* performance counters */
-
+ uvlong tscticks;
ulong spuriousintr;
int lastintr;
int loopconst;
int aalcycles;
-
int cpumhz;
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
uvlong cpuhz;
+
int cpuidax;
int cpuidcx;
int cpuiddx;
@@ -234,16 +207,23 @@
uchar cpuidfamily;
uchar cpuidmodel;
uchar cpuidstepping;
- int havetsc;
- int havepge;
- int havewatchpt8;
- int havenx;
- uvlong tscticks;
+ char havetsc;
+ char havepge;
+ char havewatchpt8;
+ char havenx;
+
+ u64int* pml4; /* pml4 base for this processor (va) */
+ Tss* tss; /* tss for this processor */
+ Segdesc*gdt; /* gdt for this processor */
+
u64int dr7; /* shadow copy of dr7 */
u64int xcr0;
-
void* vmx;
+
+ MMU* mmufree; /* freelist for MMU structures */
+ ulong mmucount; /* number of MMU structures in freelist */
+ u64int mmumap[4]; /* bitmap of pml4 entries for zapping */
uintptr stack[1];
};
--- a/sys/src/9/port/portdat.h
+++ b/sys/src/9/port/portdat.h
@@ -31,6 +31,7 @@
typedef struct Physseg Physseg;
typedef struct Proc Proc;
typedef struct Pte Pte;
+typedef struct PMach PMach;
typedef struct QLock QLock;
typedef struct Queue Queue;
typedef struct Ref Ref;
@@ -967,6 +968,29 @@
uintptr addr, len;
};
+struct PMach
+{
+ Proc* readied; /* for runproc */
+ Label sched; /* scheduler wakeup */
+ ulong ticks; /* of the clock since boot time */
+ ulong schedticks; /* next forced context switch */
+
+ int pfault;
+ int cs;
+ int syscall;
+ int load;
+ int intr;
+ int ilockdepth;
+
+ int flushmmu; /* make current proc flush it's mmu state */
+
+ int tlbfault;
+ int tlbpurge;
+
+ Perf perf; /* performance counters */
+
+ uvlong cyclefreq; /* Frequency of user readable cycle counter */
+};
/* queue state bits, Qmsg, Qcoalesce, and Qkick can be set in qopen */
enum
--- a/sys/src/9/ppc/dat.h
+++ b/sys/src/9/ppc/dat.h
@@ -137,25 +137,23 @@
/*0x14*/ ulong dmiss; /* number of data misses */
/* ordering from here on irrelevant */
+ PMach;
Imap* imap;
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void *alarm; /* alarms bound to this clock */
- int inclockintr;
+ uintptr ptabbase; /* start of page table in kernel virtual space */
+ int slotgen; /* next pte (byte offset) when pteg is full */
+ int mmupid; /* next mmu pid to use */
+ int sweepcolor;
+ int trigcolor;
+ Rendez sweepr;
+
int cputype;
ulong loopconst;
- Perf perf; /* performance counters */
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
ulong clkin; /* basic clock frequency */
ulong vco_out;
vlong cpuhz;
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
ulong bushz;
ulong dechz;
ulong tbhz;
@@ -162,30 +160,8 @@
ulong cpmhz; /* communications processor module frequency */
ulong brghz; /* baud rate generator frequency */
- ulong pcclast;
- uvlong fastclock;
-
- int tlbpurge; /* # of tlb purges */
- int pfault; /* # of page faults */
- int cs;
- int syscall;
- int load;
- int intr;
- int flushmmu; /* make current proc flush it's mmu state */
- int ilockdepth;
-
- ulong ptabbase; /* start of page table in kernel virtual space */
- int slotgen; /* next pte (byte offset) when pteg is full */
- int mmupid; /* next mmu pid to use */
- int sweepcolor;
- int trigcolor;
- Rendez sweepr;
-
- ulong spuriousintr;
- int lastintr;
-
/* MUST BE LAST */
- int stack[1];
+ uintptr stack[1];
};
struct
--- a/sys/src/9/sgi/dat.h
+++ b/sys/src/9/sgi/dat.h
@@ -144,48 +144,34 @@
int machno; /* physical id of processor */
Softtlb*stb;
Proc* proc; /* process on this processor */
- ulong splpc; /* pc that called splhi() */
+ uintptr splpc; /* pc that called splhi() */
ulong tlbfault;
/* the following is safe to move */
- ulong tlbpurge;
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- void* alarm; /* alarms bound to this clock */
+ PMach;
+
int lastpid; /* last pid allocated on this machine */
Proc* pidproc[NTLBPID]; /* proc that owns tlbpid on this mach */
+
KMap* kactive; /* active on this machine */
int knext;
uchar ktlbx[NTLB]; /* tlb index used for kmap */
uchar ktlbnext;
- int speed; /* cpu speed */
- ulong delayloop; /* for the delay() routine */
- ulong fairness; /* for runproc */
- int flushmmu;
- int inclockintr;
- int ilockdepth;
- Perf perf; /* performance counters */
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
/* for per-processor timers */
- ulong lastcount;
uvlong fastticks;
+ ulong lastcount;
+
ulong hz;
+ int speed; /* cpu speed */
+ ulong delayloop; /* for the delay() routine */
ulong maxperiod;
ulong minperiod;
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
int hashcoll; /* soft-tlb hash collisions */
int paststartup; /* for putktlb */
- int stack[1];
+ uintptr stack[1];
};
struct KMap
--- a/sys/src/9/teg2/dat.h
+++ b/sys/src/9/teg2/dat.h
@@ -163,51 +163,27 @@
struct Mach
{
- /* offsets known to asm */
int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */
+ Proc* proc; /* current process on this processor */
- Proc* proc; /* current process */
-
MMMU;
/* end of offsets known to asm */
- int flushmmu; /* flush current proc mmu state */
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void* alarm; /* alarms bound to this clock */
- int inclockintr;
+ PMach;
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
- int cputype;
- ulong delayloop;
-
- /* stats */
- int tlbfault;
- int tlbpurge;
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
uvlong fastclock; /* last sampled value */
- uvlong inidle; /* time spent in idlehands() */
- ulong spuriousintr;
- int lastintr;
- int ilockdepth;
- Perf perf; /* performance counters */
+ int inclockintr;
+ int inidlehands;
int probing; /* probeaddr() state */
int trapped;
Lock probelock;
- int inidlehands;
+ int cputype;
+ ulong delayloop;
int cpumhz;
uvlong cpuhz; /* speed of cpu */
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
/* vfp3 fpu */
int havefp;
@@ -228,7 +204,7 @@
u32int smon[5]; /* probably not needed */
u32int ssys[5];
- int stack[1];
+ uintptr stack[1];
};
/*
--- a/sys/src/9/zynq/dat.h
+++ b/sys/src/9/zynq/dat.h
@@ -115,7 +115,6 @@
struct Mach
{
- /* known to assembly */
int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process */
@@ -123,39 +122,16 @@
ulong cycleshi;
/* end of known to assembly */
- int flushmmu; /* flush current proc mmu state */
+ MMMU;
- ulong ticks; /* of the clock since boot time */
- Label sched; /* scheduler wakeup */
- Lock alarmlock; /* access to alarm list */
- void* alarm; /* alarms bound to this clock */
- int inclockintr;
+ PMach;
- Proc* readied; /* for runproc */
- ulong schedticks; /* next forced context switch */
-
- ulong delayloop;
-
- /* stats */
- int tlbfault;
- int tlbpurge;
- int pfault;
- int cs;
- int syscall;
- int load;
- int intr;
int lastintr;
- int ilockdepth;
- Perf perf; /* performance counters */
-
int cpumhz;
uvlong cpuhz; /* speed of cpu */
- uvlong cyclefreq; /* Frequency of user readable cycle counter */
-
- MMMU;
- int stack[1];
+ uintptr stack[1];
};
#define NISAOPT 8