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).
front
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 */
uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process */
Proc* proc; /* current process on this processor */
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 */
Proc* readied; /* for runproc */
ulong schedticks; /* next forced context switch */
PMach;
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 @@ struct Mach
u32int smon[5]; /* probably not needed */
u32int ssys[5];
int stack[1];
uintptr stack[1];
};
/*

View File

@ -142,41 +142,17 @@ struct Mach
{
int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process */
Proc* proc; /* current process on this processor */
/* end of offsets known to asm */
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 */
Proc* readied; /* for runproc */
ulong schedticks; /* next forced context switch */
PMach;
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];
};

View File

@ -116,47 +116,23 @@ struct MMMU
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

View File

@ -130,43 +130,19 @@ struct Mach
{
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 @@ struct Mach
#define abtstack sabt
#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 */
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;
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;
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

View File

@ -154,43 +154,19 @@ struct Mach
{
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 @@ struct Mach
u32int smon[5]; /* probably not needed */
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 */
} 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;
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 */
PMach;
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 @@ struct Mach
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];
};
/*

View File

@ -184,48 +184,21 @@ typedef struct {
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) */
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 */
PMach;
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,17 +207,24 @@ struct Mach
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];
};

View File

@ -31,6 +31,7 @@ typedef struct Pgrp Pgrp;
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 @@ struct Watchpt
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

View File

@ -137,55 +137,31 @@ struct Mach
/*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;
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 */
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 spuriousintr;
int lastintr;
int cputype;
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 */
int stack[1];
uintptr stack[1];
};
struct

View File

@ -144,48 +144,34 @@ struct Mach
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

View File

@ -163,51 +163,27 @@ struct PMMU
struct Mach
{
/* offsets known to asm */
int machno; /* physical id of processor */
uintptr splpc; /* pc of last caller to splhi */
Proc* proc; /* current process */
Proc* proc; /* current process on this processor */
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 @@ struct Mach
u32int smon[5]; /* probably not needed */
u32int ssys[5];
int stack[1];
uintptr stack[1];
};
/*

View File

@ -115,7 +115,6 @@ struct MMMU
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 @@ struct Mach
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