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).
This commit is contained in:
cinap_lenrek 2021-04-25 17:41:34 +02:00
parent 9f54c28317
commit c0d4498ab8
13 changed files with 128 additions and 375 deletions

View file

@ -150,42 +150,17 @@ struct Mach
{ {
int machno; /* physical id of processor */ int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */ uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process on this processor */
Proc* proc; /* current process */
MMMU; MMMU;
int flushmmu; /* flush current proc mmu state */ /* end of offsets known to asm */
ulong ticks; /* of the clock since boot time */ PMach;
Label sched; /* scheduler wakeup */
Lock alarmlock; /* access to alarm list */
void* alarm; /* alarms bound to this clock */
Proc* readied; /* for runproc */
ulong schedticks; /* next forced context switch */
int cputype; int cputype;
ulong delayloop; 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; int cpumhz;
uvlong cpuhz; /* speed of cpu */ uvlong cpuhz; /* speed of cpu */
uvlong cyclefreq; /* Frequency of user readable cycle counter */
/* vfp2 or vfp3 fpu */ /* vfp2 or vfp3 fpu */
int havefp; int havefp;
@ -206,7 +181,7 @@ struct Mach
u32int smon[5]; /* probably not needed */ u32int smon[5]; /* probably not needed */
u32int ssys[5]; u32int ssys[5];
int stack[1]; uintptr stack[1];
}; };
/* /*

View file

@ -142,41 +142,17 @@ struct Mach
{ {
int machno; /* physical id of processor */ int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */ uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process on this processor */
Proc* proc; /* current process */ /* end of offsets known to asm */
MMMU; MMMU;
int flushmmu; /* flush current proc mmu state */
ulong ticks; /* of the clock since boot time */ PMach;
Label sched; /* scheduler wakeup */
Lock alarmlock; /* access to alarm list */
void* alarm; /* alarms bound to this clock */
Proc* readied; /* for runproc */
ulong schedticks; /* next forced context switch */
int cputype; int cputype;
ulong delayloop; 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; int cpumhz;
uvlong cpuhz; /* speed of cpu */ uvlong cpuhz; /* speed of cpu */
uvlong cyclefreq; /* Frequency of user readable cycle counter */
int stack[1]; int stack[1];
}; };

View file

@ -116,47 +116,23 @@ struct MMMU
struct Mach struct Mach
{ {
/* known to assembly */
int machno; /* physical id of processor */ int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */ uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process */ Proc* proc; /* current process */
ulong excregs[3]; ulong excregs[3];
ulong cycleshi; ulong cycleshi;
/* end of known to assembly */ /* end of known offsets to assembly */
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;
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; MMMU;
int stack[1]; PMach;
int lastintr;
int cpumhz;
uvlong cpuhz; /* speed of cpu */
uintptr stack[1];
}; };
#define NISAOPT 8 #define NISAOPT 8

View file

@ -130,43 +130,19 @@ struct Mach
{ {
int machno; /* physical id of processor */ int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */ uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process */ Proc* proc; /* current process */
MMMU; MMMU;
int flushmmu; /* flush current proc mmu state */ /* end of offsets known to asm */
ulong ticks; /* of the clock since boot time */ PMach;
Label sched; /* scheduler wakeup */
Lock alarmlock; /* access to alarm list */ vlong fastclock; /* last sampled value */
void* alarm; /* alarms bound to this clock */
int inclockintr; int inclockintr;
Proc* readied; /* for runproc */
ulong schedticks; /* next forced context switch */
int cputype; int cputype;
int socrev; /* system-on-chip revision */ int socrev; /* system-on-chip revision */
ulong delayloop; 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 cpuhz; /* speed of cpu */
uvlong cyclefreq; /* Frequency of user readable cycle counter */
/* save areas for exceptions */ /* save areas for exceptions */
u32int sfiq[5]; u32int sfiq[5];
@ -178,7 +154,7 @@ struct Mach
#define abtstack sabt #define abtstack sabt
#define undstack sund #define undstack sund
int stack[1]; uintptr stack[1];
}; };
/* /*

View file

@ -123,54 +123,28 @@ struct Mach
{ {
/* OFFSETS OF THE FOLLOWING KNOWN BY l.s */ /* OFFSETS OF THE FOLLOWING KNOWN BY l.s */
int machno; /* physical id of processor */ 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 */ Proc *proc; /* current process on this processor */
/* ordering from here on irrelevant */ /* ordering from here on irrelevant */
PMach;
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;
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;
int cputype; int cputype;
ulong loopconst; ulong loopconst;
Proc* readied; /* for runproc */
ulong schedticks; /* next forced context switch */
vlong cpuhz; vlong cpuhz;
ulong bushz; ulong bushz;
ulong dechz; ulong dechz;
ulong tbhz; 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 */ /* MUST BE LAST */
int stack[1]; uintptr stack[1];
}; };
struct struct

View file

@ -154,43 +154,19 @@ struct Mach
{ {
int machno; /* physical id of processor */ int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */ uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process */ Proc* proc; /* current process */
MMMU; MMMU;
int flushmmu; /* flush current proc mmu state */ /* end of offsets known to asm */
ulong ticks; /* of the clock since boot time */ PMach;
Label sched; /* scheduler wakeup */
Lock alarmlock; /* access to alarm list */ uvlong fastclock; /* last sampled value */
void* alarm; /* alarms bound to this clock */
int inclockintr; int inclockintr;
Proc* readied; /* for runproc */
ulong schedticks; /* next forced context switch */
int cputype; int cputype;
ulong delayloop; 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; int cpumhz;
uvlong cpuhz; /* speed of cpu */ uvlong cpuhz; /* speed of cpu */
uvlong cyclefreq; /* Frequency of user readable cycle counter */
/* save areas for exceptions, hold R0-R4 */ /* save areas for exceptions, hold R0-R4 */
u32int sfiq[5]; u32int sfiq[5];
@ -200,7 +176,7 @@ struct Mach
u32int smon[5]; /* probably not needed */ u32int smon[5]; /* probably not needed */
u32int ssys[5]; u32int ssys[5];
int stack[1]; uintptr stack[1];
}; };
/* /*

View file

@ -190,50 +190,25 @@ typedef struct {
ulong iomap; /* I/O map base address + T-bit */ ulong iomap; /* I/O map base address + T-bit */
} Tss; } Tss;
struct Mach struct Mach
{ {
int machno; /* physical id of processor (KNOWN TO ASSEMBLY) */ int machno; /* physical id of processor */
ulong splpc; /* pc of last caller to splhi */ uintptr 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 */
Proc* proc; /* current process on this processor */ Proc* proc; /* current process on this processor */
Proc* externup; /* extern register Proc *up */ Proc* externup; /* extern register Proc *up */
Page* pdbpool; PMach;
int pdbcnt;
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; ulong spuriousintr;
int lastintr; int lastintr;
int loopconst; int loopconst;
int aalcycles; int aalcycles;
int cpumhz; int cpumhz;
uvlong cyclefreq; /* Frequency of user readable cycle counter */
uvlong cpuhz; uvlong cpuhz;
int cpuidax; int cpuidax;
int cpuidcx; int cpuidcx;
int cpuiddx; int cpuiddx;
@ -242,19 +217,26 @@ struct Mach
uchar cpuidfamily; uchar cpuidfamily;
uchar cpuidmodel; uchar cpuidmodel;
uchar cpuidstepping; uchar cpuidstepping;
int havetsc;
int havepge; char havetsc;
int havewatchpt8; char havepge;
int havenx; char havewatchpt8;
uvlong tscticks; char havenx;
int pdballoc;
int pdbfree; 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 dr7; /* shadow copy of dr7 */
u32int xcr0; u32int xcr0;
void* vmx; void* vmx;
int stack[1]; Page* pdbpool;
int pdbcnt;
int pdballoc;
int pdbfree;
uintptr stack[1];
}; };
/* /*

View file

@ -184,48 +184,21 @@ typedef struct {
struct Mach struct Mach
{ {
int machno; /* physical id of processor (KNOWN TO ASSEMBLY) */ int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi (KNOWN TO ASSEMBLY) */ 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; ulong spuriousintr;
int lastintr; int lastintr;
int loopconst; int loopconst;
int aalcycles; int aalcycles;
int cpumhz; int cpumhz;
uvlong cyclefreq; /* Frequency of user readable cycle counter */
uvlong cpuhz; uvlong cpuhz;
int cpuidax; int cpuidax;
int cpuidcx; int cpuidcx;
int cpuiddx; int cpuiddx;
@ -234,17 +207,24 @@ struct Mach
uchar cpuidfamily; uchar cpuidfamily;
uchar cpuidmodel; uchar cpuidmodel;
uchar cpuidstepping; uchar cpuidstepping;
int havetsc;
int havepge; char havetsc;
int havewatchpt8; char havepge;
int havenx; char havewatchpt8;
uvlong tscticks; 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 dr7; /* shadow copy of dr7 */
u64int xcr0; u64int xcr0;
void* vmx; 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]; uintptr stack[1];
}; };

View file

@ -31,6 +31,7 @@ typedef struct Pgrp Pgrp;
typedef struct Physseg Physseg; typedef struct Physseg Physseg;
typedef struct Proc Proc; typedef struct Proc Proc;
typedef struct Pte Pte; typedef struct Pte Pte;
typedef struct PMach PMach;
typedef struct QLock QLock; typedef struct QLock QLock;
typedef struct Queue Queue; typedef struct Queue Queue;
typedef struct Ref Ref; typedef struct Ref Ref;
@ -967,6 +968,29 @@ struct Watchpt
uintptr addr, len; 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 */ /* queue state bits, Qmsg, Qcoalesce, and Qkick can be set in qopen */
enum enum

View file

@ -137,55 +137,31 @@ struct Mach
/*0x14*/ ulong dmiss; /* number of data misses */ /*0x14*/ ulong dmiss; /* number of data misses */
/* ordering from here on irrelevant */ /* ordering from here on irrelevant */
PMach;
Imap* imap; Imap* imap;
ulong ticks; /* of the clock since boot time */ uintptr ptabbase; /* start of page table in kernel virtual space */
Label sched; /* scheduler wakeup */
Lock alarmlock; /* access to alarm list */
void *alarm; /* alarms bound to this clock */
int inclockintr;
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;
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 slotgen; /* next pte (byte offset) when pteg is full */
int mmupid; /* next mmu pid to use */ int mmupid; /* next mmu pid to use */
int sweepcolor; int sweepcolor;
int trigcolor; int trigcolor;
Rendez sweepr; Rendez sweepr;
ulong spuriousintr; int cputype;
int lastintr; ulong loopconst;
ulong clkin; /* basic clock frequency */
ulong vco_out;
vlong cpuhz;
ulong bushz;
ulong dechz;
ulong tbhz;
ulong cpmhz; /* communications processor module frequency */
ulong brghz; /* baud rate generator frequency */
/* MUST BE LAST */ /* MUST BE LAST */
int stack[1]; uintptr stack[1];
}; };
struct struct

View file

@ -144,48 +144,34 @@ struct Mach
int machno; /* physical id of processor */ int machno; /* physical id of processor */
Softtlb*stb; Softtlb*stb;
Proc* proc; /* process on this processor */ Proc* proc; /* process on this processor */
ulong splpc; /* pc that called splhi() */ uintptr splpc; /* pc that called splhi() */
ulong tlbfault; ulong tlbfault;
/* the following is safe to move */ /* the following is safe to move */
ulong tlbpurge; PMach;
ulong ticks; /* of the clock since boot time */
Label sched; /* scheduler wakeup */
void* alarm; /* alarms bound to this clock */
int lastpid; /* last pid allocated on this machine */ int lastpid; /* last pid allocated on this machine */
Proc* pidproc[NTLBPID]; /* proc that owns tlbpid on this mach */ Proc* pidproc[NTLBPID]; /* proc that owns tlbpid on this mach */
KMap* kactive; /* active on this machine */ KMap* kactive; /* active on this machine */
int knext; int knext;
uchar ktlbx[NTLB]; /* tlb index used for kmap */ uchar ktlbx[NTLB]; /* tlb index used for kmap */
uchar ktlbnext; 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 */ /* for per-processor timers */
ulong lastcount;
uvlong fastticks; uvlong fastticks;
ulong lastcount;
ulong hz; ulong hz;
int speed; /* cpu speed */
ulong delayloop; /* for the delay() routine */
ulong maxperiod; ulong maxperiod;
ulong minperiod; 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 hashcoll; /* soft-tlb hash collisions */
int paststartup; /* for putktlb */ int paststartup; /* for putktlb */
int stack[1]; uintptr stack[1];
}; };
struct KMap struct KMap

View file

@ -163,51 +163,27 @@ struct PMMU
struct Mach struct Mach
{ {
/* offsets known to asm */
int machno; /* physical id of processor */ int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */ uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process on this processor */
Proc* proc; /* current process */
MMMU; MMMU;
/* end of offsets known to asm */ /* end of offsets known to asm */
int flushmmu; /* flush current proc mmu state */
ulong ticks; /* of the clock since boot time */ PMach;
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 cputype;
ulong delayloop;
/* stats */
int tlbfault;
int tlbpurge;
int pfault;
int cs;
int syscall;
int load;
int intr;
uvlong fastclock; /* last sampled value */ uvlong fastclock; /* last sampled value */
uvlong inidle; /* time spent in idlehands() */ int inclockintr;
ulong spuriousintr; int inidlehands;
int lastintr;
int ilockdepth;
Perf perf; /* performance counters */
int probing; /* probeaddr() state */ int probing; /* probeaddr() state */
int trapped; int trapped;
Lock probelock; Lock probelock;
int inidlehands;
int cputype;
ulong delayloop;
int cpumhz; int cpumhz;
uvlong cpuhz; /* speed of cpu */ uvlong cpuhz; /* speed of cpu */
uvlong cyclefreq; /* Frequency of user readable cycle counter */
/* vfp3 fpu */ /* vfp3 fpu */
int havefp; int havefp;
@ -228,7 +204,7 @@ struct Mach
u32int smon[5]; /* probably not needed */ u32int smon[5]; /* probably not needed */
u32int ssys[5]; u32int ssys[5];
int stack[1]; uintptr stack[1];
}; };
/* /*

View file

@ -115,7 +115,6 @@ struct MMMU
struct Mach struct Mach
{ {
/* known to assembly */
int machno; /* physical id of processor */ int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */ uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process */ Proc* proc; /* current process */
@ -123,39 +122,16 @@ struct Mach
ulong cycleshi; ulong cycleshi;
/* end of known to assembly */ /* end of known to assembly */
int flushmmu; /* flush current proc mmu state */ MMMU;
ulong ticks; /* of the clock since boot time */ PMach;
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 */
ulong delayloop;
/* stats */
int tlbfault;
int tlbpurge;
int pfault;
int cs;
int syscall;
int load;
int intr;
int lastintr; int lastintr;
int ilockdepth;
Perf perf; /* performance counters */
int cpumhz; int cpumhz;
uvlong cpuhz; /* speed of cpu */ uvlong cpuhz; /* speed of cpu */
uvlong cyclefreq; /* Frequency of user readable cycle counter */
MMMU; uintptr stack[1];
int stack[1];
}; };
#define NISAOPT 8 #define NISAOPT 8