From: unobe@cpan.org
To: 9front@9front.org
Subject: Re: [9front] [PATCH] mk for only supported archs
Date: Sat, 21 Aug 2021 01:27:45 -0700 [thread overview]
Message-ID: <B6E9999BF5948CFFFAE5121CFC68C21A@smtp.pobox.com> (raw)
In-Reply-To: <B55797B5C540F32686A55FB7BA2F2121@smtp.pobox.com>
The mtx and ppc (ucu config) kernel now build. I've also added a
Readme for the ppc kernel. I gleaned the Readme and some code from
the Plan 9 kernel found on github; I assume it was updated after
9front had forked. I made some minor edits to Readme, but otherwise I
left the code received as-is (namely, ppc/^(trap.c l.s devce.c) ). I did
not see any manual page for devce. As for (emulated) hardware, QEMU
emulates the G3 but not the G2.
'mk kernels' now completes without failure.
Quoth unobe@cpan.org:
> I'm testing that all the "supported" archs build. This is the rc
> script I use:
>
> #!/bin/rc
> echo Updating system
> sysupdate || exit 'sysupdate failed'
> . /sys/lib/rootstub
> cd /sys/src
> objtypes_default=`{cat mkfile.proto| grep 'CPUS=' | sed -e 's/CPUS=//'}
> if (~ $objtypes '')
> objtypes=($cputype `{{for (f in $cputype $objtypes_default) echo $f} | sort | uniq -u})
> for (objtype in $objtypes)
> for (mk in nuke all install clean)
> mk $mk || exit 'mk '^$mk^' failed for '^$objtype
>
> cd /sys/man
> mk || exit '/sys/man failed'
>
> cd /sys/doc
> mk || exit '/sys/doc failed'
>
> cd /sys/src
> mk kernels || exit 'mk kernels failed'
>
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/9/mtx/dat.h
+++ /sys/src/9/mtx/dat.h
@@ -71,6 +71,8 @@
FPinit,
FPactive,
FPinactive,
+
+ FPillegal= 0x100,
};
struct Confmem
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/9/mtx/devarch.c
+++ /sys/src/9/mtx/devarch.c
@@ -130,7 +130,6 @@
uchar *cp;
ushort *sp;
ulong *lp;
- IOMap *m;
Rdwrfn *fn;
switch((ulong)c->qid.path){
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/9/mtx/fns.h
+++ /sys/src/9/mtx/fns.h
@@ -47,7 +47,6 @@
void ioinit(void);
int iprint(char*, ...);
int isaconfig(char*, int, ISAConf*);
-#define kexit(a)
#define kmapinval()
void links(void);
void mmuinit(void);
@@ -88,6 +87,10 @@
void tlbflushall(void);
#define userureg(ur) (((ur)->status & MSR_PR) != 0)
void watchreset(void);
+
+/* devarch */
+Dirtab* addarchfile(char*, int, long(*)(Chan*, void*, long, vlong),
+ long(*)(Chan*, void*, long, vlong));
#define waserror() (up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
#define KADDR(a) ((void*)((ulong)(a)|KZERO))
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/9/mtx/mem.h
+++ /sys/src/9/mtx/mem.h
@@ -2,6 +2,9 @@
* Memory and machine-specific definitions. Used in C and assembler.
*/
+#define MIN(a, b) ((a) < (b)? (a): (b))
+#define MAX(a, b) ((a) > (b)? (a): (b))
+
/*
* Sizes
*/
@@ -31,7 +34,8 @@
/*
* Time
*/
-#define HZ 100 /* clock frequency */
+#define HZ (100) /* clock frequency */
+#define MS2HZ (1000/HZ) /* millisec per clock tick */
#define TK2SEC(t) ((t)/HZ) /* ticks to seconds */
/*
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/9/mtx/mkfile
+++ /sys/src/9/mtx/mkfile
@@ -58,8 +58,8 @@
/$objtype/lib/libmemdraw.a\
/$objtype/lib/libdraw.a\
/$objtype/lib/libip.a\
- /$objtype/lib/libc.a\
/$objtype/lib/libsec.a\
+ /$objtype/lib/libc.a\
ETHER=`{echo devether.c ether*.c | sed 's/\.c/.'$O'/g'}
VGA=`{echo devvga.c screen.c vga*.c | sed 's/\.c/.'$O'/g'}
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/9/mtx/mtx
+++ /sys/src/9/mtx/mtx
@@ -9,6 +9,7 @@
proc
mnt
srv
+ shr
dup
ssl
cap
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/9/mtx/pcimtx.c
+++ /sys/src/9/mtx/pcimtx.c
@@ -115,7 +115,7 @@
int
pcicfgrw8(int tbdf, int rno, int data, int read)
{
- int o, x;
+ int o;
switch(pcicfgmode){
case 1:
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/9/mtx/raven.c
+++ /sys/src/9/mtx/raven.c
@@ -3,6 +3,7 @@
*/
#include "u.h"
#include "../port/lib.h"
+#include "../port/pci.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/9/mtx/trap.c
+++ /sys/src/9/mtx/trap.c
@@ -1,5 +1,6 @@
#include "u.h"
#include "../port/lib.h"
+#include "../port/pci.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
@@ -632,7 +633,7 @@
up->s = *((Sargs*)(sp+BY2WD));
up->psstate = sysctab[scallnr];
- ret = systab[scallnr](up->s.args);
+ ret = systab[scallnr]((char *)up->s.args);
poperror();
}else{
/* failure: save the error buffer for errstr */
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/boot/zynq/mkfile
+++ /sys/src/boot/zynq/mkfile
@@ -7,6 +7,9 @@
all:V: $TARG
+install:V:
+ echo install not supported >[1=2]
+
clean:V:
rm -rf $TARG *.$O
@{objtype=$cputype mk -f mkfile.port clean}
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/cmd/mkfile
+++ /sys/src/cmd/mkfile
@@ -8,8 +8,9 @@
YFLAGS=-d
NOTSYS=sml|dup|.+\..+
+NOTPOWER=|dtracy
PCONLY=|vmx
-NOMK=$NOTSYS`{~ $objtype (386 amd64) || echo $PCONLY}
+NOMK=$NOTSYS$NOTPOWER`{~ $objtype (386 amd64) || echo $PCONLY}
cpuobjtype=`{sed -n 's/^O=//p' /$cputype/mkfile}
DIRS=`{echo */mkfile | sed 's,/mkfile *,\n,g' | grep -v '^('$NOMK')$'}
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree//sys/src/mkfile.proto
+++ /sys/src/mkfile.proto
@@ -2,8 +2,8 @@
# common mkfile parameters shared by all architectures
#
-OS=05678qv
-CPUS=spim arm arm64 amd64 386 power mips
+OS=5678qv
+CPUS=arm arm64 amd64 386 power mips
CFLAGS=-FTVw
LEX=lex
YACC=yacc
--- /tmp/diff100001999533
+++ sys/src/9/ppc/Readme
@@ -1,0 +1,26 @@
+This directory contains source code for two PowerPC ports,
+
+The kernel made with
+ mk 'CONF=blast'
+is an 8260 kernel. The 8260 (PowerQUICC II, e.g. Apple G2) is an
+embedded PowerPC with on-chip DMA, Uart, Ethernet, ATM controllers and
+a few other things.
+
+The 8260-specific code is in m8260.c (no surprises there) and in the
+device drivers for SMC uart (uartsmc.c) and FCC ethernet (etherfcc.c).
+
+The kernel made with
+ mk 'CONF=ucu'
+is a PowerPC 750/755 (e.g., Apple G3) kernel using the saturn chip for
+Ether and Uart.
+
+We run both kernels on Lucent proprietary boards, but the kernels are
+pretty generic. On a different board, the ports may be hooked up differently,
+the clocks may be running at different speeds, the memory banks may be
+configured differently and this will require tweaking the Ethernet setup,
+Uart setup, Memory bank setup and several other things as well.
+
+There is 8260 and Ucu specific code in l.s too (lucu.s and lblast.s).
+These differences primarily concern the state of the system at bootup.
+In the case of the ucu, virtual memory is already on when the kernel
+starts.
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree/sys/src/9/ppc/clock.c
+++ sys/src/9/ppc/clock.c
@@ -82,6 +82,11 @@
}
ulong
+µs(void)
+{
+ return fastticks2us(m->ticks);
+}
+ulong
perfticks(void)
{
return (ulong)fastticks(nil);
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree/sys/src/9/ppc/dat.h
+++ sys/src/9/ppc/dat.h
@@ -15,7 +15,7 @@
typedef struct Sys Sys;
typedef struct Ureg Ureg;
typedef struct Vctl Vctl;
-typedef long Tval;
+typedef uvlong Tval;
#pragma incomplete Ureg
#pragma incomplete Imap
@@ -37,8 +37,9 @@
ulong sr;
ulong pc;
Proc *p;
- ulong pid;
+ Mach *m;
ushort isilock;
+ long lockcycles;
};
struct Label
--- /tmp/diff100001999542
+++ sys/src/9/ppc/devce.c
@@ -1,0 +1,191 @@
+//
+// channel element driver
+//
+#include "u.h"
+#include "../port/lib.h"
+#include "mem.h"
+#include "dat.h"
+#include "fns.h"
+#include "io.h"
+#include "../port/error.h"
+#include "msaturn.h"
+
+enum{
+ Ucuunknown = 0,
+ Ucu64,
+
+ Ndsp = 16,
+
+ Cedead = 0,
+ Cereset,
+ Celoaded,
+ Cerunning,
+
+ Qdir = 0,
+ Qctl,
+ Qce,
+
+ Cpldbase = Saturn + 0x6000000,
+ Cplducuversion_ucu = 0x1c,
+ Cebase = Saturn + 0x3000000,
+ Cesize = 0x100000,
+};
+
+typedef struct Cpld Cpld;
+struct Cpld{
+ uchar led;
+ uchar fpga1;
+ uchar slotid;
+ uchar version;
+ uchar watchdog;
+ uchar spi;
+ uchar asicreset;
+ uchar dspreset;
+ uchar generalreset;
+ uchar ucuversion;
+ uchar fpga2;
+};
+
+typedef struct Circbuf Circbuf;
+struct Circbuf{
+ uchar *nextin;
+ uchar *nextout;
+ uchar *start;
+ uchar *end;
+};
+
+typedef struct Dsp Dsp;
+struct Dsp{
+ Ref;
+ int state;
+ Circbuf *cb;
+};
+
+typedef struct Ce Ce;
+struct Ce{
+ int ucutype;
+ Ce *ces[Ndsp];
+};
+
+static Cpld*cpld = (Cpld*)Cpldbase;
+static Ce ce;
+
+static void
+ceinit(void)
+{
+ if(cpld->ucuversion & Cplducuversion_ucu)
+ ce.ucutype = Ucu64;
+ else{
+ print("ceinit: unsuppoerted UCU\n");
+ return;
+ }
+
+}
+
+static Chan*
+ceattach(char*spec)
+{
+ return devattach('C', spec);
+}
+
+#define DEV(q) ((int)(((q).path >> 8) & 0xff))
+#define TYPE(q) ((int)((q).path & 0xff))
+#define QID(d, t) ((((d) & 0xff) << 8) | (t))
+
+static int
+cegen(Chan*c, char*, Dirtab*, int, int i, Dir*dp)
+{
+ Qid qid;
+
+ switch(TYPE(c->qid)){
+ case Qdir:
+ if(i == DEVDOTDOT){
+ mkqid(&qid, QID(0, Qdir), 0, QTDIR);
+ devdir(c, qid, "#C", 0, eve, 0555, dp);
+ return 1;
+ }
+
+ if(i == 0){
+ mkqid(&qid, QID(-1, Qctl), 0, QTFILE);
+ devdir(c, qid, "cectl", 0, eve, 0644, dp);
+ return 1;
+ }
+
+ if (--i >= Ndsp)
+ return -1;
+
+ mkqid(&qid, QID(Qce, i), 0, QTFILE);
+ snprint(up->genbuf, sizeof(up->genbuf), "ce%d", i);
+ devdir(c, qid, up->genbuf, 0, eve, 0644, dp);
+ return 1;
+
+ default:
+ return -1;
+ }
+}
+
+static Walkqid *
+cewalk(Chan*c, Chan*nc, char**name, int nname)
+{
+ return devwalk(c, nc, name, nname, 0, 0, cegen);
+}
+
+static int
+cestat(Chan*c, uchar*db, int n)
+{
+ return devstat(c, db, n, 0, 0, cegen);
+}
+
+static Chan*
+ceopen(Chan*c, int omode)
+{
+ c->mode = openmode(omode);
+ c->flag |= COPEN;
+ c->offset = 0;
+ return c;
+}
+
+static void
+ceclose(Chan*)
+{}
+
+static long
+ceread(Chan*c, void*a, long n, vlong)
+{
+ switch(TYPE(c->qid)){
+ case Qdir:
+ return devdirread(c, a, n, 0, 0, cegen);
+
+ default:
+ error("unsupported operation");
+ }
+ return 0;
+}
+
+static long
+cewrite(Chan*, void*, long, vlong)
+{
+ return 0;
+}
+
+Dev cedevtab = {
+ 'C',
+ "channel element",
+
+ devreset,
+ ceinit,
+ devshutdown,
+ ceattach,
+ cewalk,
+ cestat,
+ ceopen,
+ devcreate,
+ ceclose,
+ ceread,
+ devbread,
+ cewrite,
+ devbwrite,
+ devremove,
+ devwstat,
+ devpower,
+};
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree/sys/src/9/ppc/fns.h
+++ sys/src/9/ppc/fns.h
@@ -1,7 +1,9 @@
#include "../port/portfns.h"
+ulong cankaddr(ulong);
void clockinit(void);
void clockintr(Ureg*);
+int cmpswap(long*, long, long);
void cpuidprint(void);
void cycles(uvlong*);
void dbgputc(int c);
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree/sys/src/9/ppc/l.s
+++ sys/src/9/ppc/l.s
@@ -346,7 +346,6 @@
RETURN
TEXT tas(SB), $0
-TEXT _tas(SB), $0
MOVW R3, R4
MOVW $0xdead, R5
tas1:
@@ -360,6 +359,42 @@
EIEIO
tas0:
SYNC
+ RETURN
+
+TEXT _xinc(SB), $0 /* void _xinc(long *); */
+ MOVW R3, R4
+xincloop:
+ DCBF (R4) /* fix for 603x bug */
+ LWAR (R4), R3
+ ADD $1, R3
+ STWCCC R3, (R4)
+ BNE xincloop
+ RETURN
+
+TEXT _xdec(SB), $0 /* long _xdec(long *); */
+ MOVW R3, R4
+xdecloop:
+ DCBF (R4) /* fix for 603x bug */
+ LWAR (R4), R3
+ ADD $-1, R3
+ STWCCC R3, (R4)
+ BNE xdecloop
+ RETURN
+
+TEXT cmpswap(SB),$0 /* int cmpswap(long*, long, long) */
+ MOVW R3, R4 /* addr */
+ MOVW old+4(FP), R5
+ MOVW new+8(FP), R6
+ DCBF (R4) /* fix for 603x bug? */
+ LWAR (R4), R3
+ CMP R3, R5
+ BNE fail
+ STWCCC R6, (R4)
+ BNE fail
+ MOVW $1, R3
+ RETURN
+fail:
+ MOVW $0, R3
RETURN
TEXT tlbflushall(SB), $0
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree/sys/src/9/ppc/mem.h
+++ sys/src/9/ppc/mem.h
@@ -8,6 +8,9 @@
#include "blast.h"
#endif
+#define MIN(a, b) ((a) < (b)? (a): (b))
+#define MAX(a, b) ((a) > (b)? (a): (b))
+
/*
* Sizes
*/
@@ -37,7 +40,8 @@
/*
* Time
*/
-#define HZ 1000 /* clock frequency */
+#define HZ (1000) /* clock frequency */
+#define MS2HZ (HZ) /* millisec per clock tick */
#define TK2SEC(t) ((t)/HZ) /* ticks to seconds */
/*
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree/sys/src/9/ppc/mkfile
+++ sys/src/9/ppc/mkfile
@@ -37,6 +37,7 @@
tod.$O\
xalloc.$O\
random.$O\
+ userinit.$O\
OBJ=\
l.$O\
@@ -60,8 +61,9 @@
/$objtype/lib/libmemlayer.a\
/$objtype/lib/libmemdraw.a\
/$objtype/lib/libdraw.a\
- /$objtype/lib/libc.a\
/$objtype/lib/libsec.a\
+ /$objtype/lib/libip.a\
+ /$objtype/lib/libc.a\
ETHER=`{echo devether.c ether*.c | sed 's/\.c/.'$O'/g'}
VGA=`{echo devvga.c screen.c vga*.c | sed 's/\.c/.'$O'/g'}
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree/sys/src/9/ppc/saturntimer.c
+++ sys/src/9/ppc/saturntimer.c
@@ -72,7 +72,7 @@
}
void
-timerset(uvlong next)
+timerset(Tval next)
{
ulong offset;
uvlong now;
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree/sys/src/9/ppc/trap.c
+++ sys/src/9/ppc/trap.c
@@ -11,6 +11,14 @@
static Lock vctllock;
Vctl *vctl[256];
+int nintr[10];
+int nintro;
+int dblintr[64];
+ulong thisto[32];
+ulong thistoo;
+vlong vnot[64];
+ulong vnon[64];
+
void
intrenable(int irq, void (*f)(Ureg*, void*), void* a, char *name)
{
@@ -368,6 +376,62 @@
vp[n] = 0x4e800021; /* BL (LR) */
}else
vp[n] = (18<<26)|(pa&0x3FFFFFC)|3; /* bla */
+}
+
+void
+intr(Ureg *ureg)
+{
+ int vno, pvno, i;
+ Vctl *ctl, *v;
+ void (*pt)(Proc*, int, vlong);
+ uvlong tt, x;
+
+ cycles(&tt);
+ pt = proctrace;
+ pvno = -1;
+ for(i = 0; i < 64; i++){
+ vno = intvec();
+ if(vno == 0)
+ break;
+ cycles(&x);
+ vnot[vno] -= x;
+ if(vno == pvno)
+ dblintr[vno]++;
+ pvno = vno;
+ if(pt && up && up->trace)
+ pt(up, (vno << 16) | SInts, 0);
+
+ if(vno > nelem(vctl) || (ctl = vctl[vno]) == 0) {
+ iprint("spurious intr %d\n", vno);
+ return;
+ }
+
+ for(v = ctl; v != nil; v = v->next)
+ if(v->f)
+ v->f(ureg, v->a);
+
+ intend(vno); /* reenable the interrupt */
+
+ if(pt && up && up->trace)
+ pt(up, (vno << 16) | SInte, 0);
+ cycles(&x);
+ vnot[vno] += x;
+ vnon[vno]++;
+ }
+ if(i < nelem(nintr))
+ nintr[i]++;
+ else
+ nintro++;
+ cycles(&x);
+ tt = x - tt;
+ i = tt / 3600; /* 100 microseconds units */
+ if(i < nelem(thisto))
+ thisto[i]++;
+ else
+ thistoo++;
+
+ if(up)
+ preempted();
}
char*
--- //.git/fs/object/8c796bf8b9c10a0845717c47af908e47dfe14482/tree/sys/src/9/ppc/ucu
+++ sys/src/9/ppc/ucu
@@ -1,11 +1,13 @@
dev
root
cons
+ swap
env
pipe
proc
mnt
srv
+ shr
dup
ssl
cap
next prev parent reply other threads:[~2021-08-21 9:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 14:00 unobe
2021-08-17 15:53 ` Amavect
2021-08-17 20:15 ` unobe
2021-08-21 8:27 ` unobe [this message]
2021-08-22 14:15 ` cinap_lenrek
2021-08-22 14:33 ` cinap_lenrek
2021-08-22 15:13 ` Amavect
2021-08-18 3:00 ` ori
2021-08-18 22:47 ` unobe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B6E9999BF5948CFFFAE5121CFC68C21A@smtp.pobox.com \
--to=unobe@cpan.org \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).