~kris/9p

9hist

ae831baddcf7de09f116a4907a5e06f6b338e197 — David du Colombier 27 years ago 1656551
Plan 9 from Bell Labs 1999-05-14
9 files changed, 121 insertions(+), 82 deletions(-)

M alphapc/fns.h
M alphapc/kbd.c
M alphapc/l.s
M alphapc/main.c
M alphapc/ns16552.h
M pc/devlml.c
M pc/devlml.h
M pc/trap.c
M port/devns16552.c
M alphapc/fns.h => alphapc/fns.h +1 -3
@@ 55,10 55,8 @@ ulong 	meminit(void);
void		mmuinit(void);
#define	mmunewpage(x)
void		mntdump(void);
void		ns16552special(int, int, Queue**, Queue**, int (*)(Queue*, int));
void		ns16552setup(ulong, ulong, char*);
void		ns16552install(void);
void		ns16552intr(int);
void		ns16552special(int, int, Queue**, Queue**, int (*)(Queue*, int));
ulong	pcibarsize(Pcidev*, int);
int	pcicfgr8(Pcidev*, int);
int	pcicfgr16(Pcidev*, int);

M alphapc/kbd.c => alphapc/kbd.c +15 -5
@@ 62,6 62,10 @@ uchar kbtab[] =
[0x48]	'8',	'9',	'-',	'4',	'5',	'6',	'+',	'1',
[0x50]	'2',	'3',	'0',	'.',	No,	No,	No,	KF|11,
[0x58]	KF|12,	No,	No,	No,	No,	No,	No,	No,
[0x60]	No,	No,	No,	No,	No,	No,	No,	No,
[0x68]	No,	No,	No,	No,	No,	No,	No,	No,
[0x70]	No,	No,	No,	No,	No,	No,	No,	No,
[0x78]	No,	View,	No,	KF|14,	No,	No,	No,	No,
};

uchar kbtabshift[] =


@@ 78,6 82,10 @@ uchar kbtabshift[] =
[0x48]	'8',	'9',	'-',	'4',	'5',	'6',	'+',	'1',
[0x50]	'2',	'3',	'0',	'.',	No,	No,	No,	KF|11,
[0x58]	KF|12,	No,	No,	No,	No,	No,	No,	No,
[0x60]	No,	No,	No,	No,	No,	No,	No,	No,
[0x68]	No,	No,	No,	No,	No,	No,	No,	No,
[0x70]	No,	No,	No,	No,	No,	No,	No,	No,
[0x78]	No,	KF|14,	No,	KF|14,	No,	No,	No,	No,
};

uchar kbtabesc1[] =


@@ 94,6 102,10 @@ uchar kbtabesc1[] =
[0x48]	Up,	Pgup,	No,	Left,	No,	Right,	No,	End,
[0x50]	Down,	Pgdown,	Ins,	Del,	No,	No,	No,	No,
[0x58]	No,	No,	No,	No,	No,	No,	No,	No,
[0x60]	No,	No,	No,	No,	No,	No,	No,	No,
[0x68]	No,	No,	No,	No,	No,	No,	No,	No,
[0x70]	No,	No,	No,	No,	No,	No,	No,	No,
[0x78]	No,	KF|14,	No,	No,	No,	No,	No,	No,
};

enum


@@ 379,7 391,7 @@ i8042auxenable(void (*putc)(int, int))
void
kbdinit(void)
{
	int c, x;
	int c;

	kbdq = qopen(4*1024, 0, 0, 0);
	if(kbdq == nil)


@@ 390,10 402,8 @@ kbdinit(void)

	/* wait for a quiescent controller */
	while((c = inb(Status)) & (Outbusy | Inready))
		if(c & Inready) {
			x = inb(Data);
			USED(x);
		}
		if(c & Inready)
			inb(Data);

	/* get current controller command byte */
	outb(Cmd, 0x20);

M alphapc/l.s => alphapc/l.s +63 -33
@@ 2,12 2,12 @@

#define SP		R30

#define	HI_IPL	6	/* use 7 to disable mchecks */
#define	HI_IPL	6			/* use 7 to disable mchecks */

TEXT	_main(SB), $-8
	MOVQ	$setSB(SB), R29
	MOVQ	R29, R16
	CALL_PAL	$PALwrkgp
	CALL_PAL $PALwrkgp
	MOVQ	$mach0(SB), R(MACH)
	MOVQ	$(BY2PG-8)(R(MACH)), R30
	MOVQ	R31, R(USER)


@@ 18,31 18,63 @@ clrbss:
	MOVQ	R31, (R1)
	ADDQ	$8, R1
	CMPUGT	R1, R2, R3
	BEQ		R3, clrbss
	BEQ	R3, clrbss

	MOVL	R0, bootconf(SB)		/* passed in from boot loader */
	MOVL	R0, bootconf(SB)	/* passed in from boot loader */

	TRAPB
_fpinit:
	MOVQ	R0, R16
	CALL_PAL $PALwrfen
	MOVQ	$1, R1
	SLLQ		$59, R1		/* normal rounding mode */
	SLLQ	$59, R1			/* normal rounding mode */
	MOVQ	R1, (R30)
	MOVT	(R30), F1
	EXCB
	MOVT	F1, FPCR
	TRAPB
	EXCB

	MOVT	$0.5, F28
	ADDT	F28, F28, F29
	ADDT	F29, F29, F30

	SUBT	F28, F28, F0
	MOVT	F0, F1
	MOVT	F0, F2
	MOVT	F0, F3
	MOVT	F0, F4
	MOVT	F0, F5
	MOVT	F0, F6
	MOVT	F0, F7
	MOVT	F0, F8
	MOVT	F0, F9
	MOVT	F0, F10
	MOVT	F0, F11
	MOVT	F0, F12
	MOVT	F0, F13
	MOVT	F0, F14
	MOVT	F0, F15
	MOVT	F0, F16
	MOVT	F0, F17
	MOVT	F0, F18
	MOVT	F0, F19
	MOVT	F0, F20
	MOVT	F0, F21
	MOVT	F0, F22
	MOVT	F0, F23
	MOVT	F0, F24
	MOVT	F0, F25
	MOVT	F0, F26
	MOVT	F0, F27

	JSR	main(SB)
	MOVQ	$_divq(SB), R31		/* touch _divq etc.; doesn't need to execute */
	MOVQ	$_divl(SB), R31			/* touch _divl etc.; doesn't need to execute */
	MOVQ	$_divl(SB), R31		/* touch _divl etc.; doesn't need to execute */
	RET

TEXT	setpcb(SB), $-8
	MOVQ	R30, (R0)
	AND		$0x7FFFFFFF, R0, R16		/* make address physical */
	CALL_PAL	$PALswpctx
	AND	$0x7FFFFFFF, R0, R16	/* make address physical */
	CALL_PAL $PALswpctx
	RET

GLOBL	mach0(SB), $(MAXMACH*BY2PG)


@@ 53,7 85,7 @@ TEXT	firmware(SB), $-8

TEXT	splhi(SB), $0

	MOVL	R26, 4(R(MACH))	/* save PC in m->splpc */
	MOVL	R26, 4(R(MACH))		/* save PC in m->splpc */
	MOVQ	$HI_IPL, R16
	CALL_PAL $PALswpipl
	RET


@@ 64,9 96,9 @@ TEXT	spllo(SB), $0
	RET

TEXT	splx(SB), $0
	MOVL	R26, 4(R(MACH))	/* save PC in m->splpc */
	MOVL	R26, 4(R(MACH))		/* save PC in m->splpc */

TEXT splxpc(SB), $0				/* for iunlock */
TEXT splxpc(SB), $0			/* for iunlock */
	MOVQ	R0, R16
	CALL_PAL $PALswpipl
	RET


@@ 76,8 108,8 @@ TEXT	spldone(SB), $0

TEXT	islo(SB), $0
	CALL_PAL $PALrdps
	AND		$IPL, R0
	XOR		$IPL, R0
	AND	$IPL, R0
	XOR	$IPL, R0
	RET

TEXT	mb(SB), $-8


@@ 96,7 128,7 @@ TEXT	tlbflush(SB), $-8

TEXT	swpctx(SB), $-8
	MOVQ	R0, R16
	AND		$0x7FFFFFFF, R16		/* make address physical */
	AND	$0x7FFFFFFF, R16	/* make address physical */
	CALL_PAL $PALswpctx
	RET



@@ 108,24 140,22 @@ TEXT	wrent(SB), $-8

TEXT	wrvptptr(SB), $-8
	MOVQ	R0, R16
	CALL_PAL	$PALwrvptptr
	CALL_PAL $PALwrvptptr
	RET

TEXT	cserve(SB), $-8
	MOVQ	R0, R16
	MOVL	4(FP), R17
	CALL_PAL	$PALcserve
	CALL_PAL $PALcserve
	RET

TEXT	setlabel(SB), $-8

	MOVL	R30, 0(R0)
	MOVL	R26, 4(R0)
	MOVQ	$0, R0
	RET

TEXT	gotolabel(SB), $-8

	MOVL	0(R0), R30
	MOVL	4(R0), R26
	MOVQ	$1, R0


@@ 238,14 268,14 @@ trapcommon:
	CALL_PAL $PALswpipl

	CALL_PAL	$PALrdusp
	MOVQ	R0, (4*BY2WD+30*BY2V)(R30)		/* save USP */
	MOVQ	R0, (4*BY2WD+30*BY2V)(R30)	/* save USP */

	MOVQ	$mach0(SB), R(MACH)
	MOVQ	$(4*BY2WD)(R30), R0
	JSR		trap(SB)
trapret:
	MOVQ	(4*BY2WD+30*BY2V)(R30), R16	/* USP */
	CALL_PAL	$PALwrusp			/* ... */
	CALL_PAL $PALwrusp			/* ... */
	MOVQ	(4*BY2WD+4*BY2V)(R30), R0
	MOVQ	(4*BY2WD+5*BY2V)(R30), R1
	MOVQ	(4*BY2WD+6*BY2V)(R30), R2


@@ 286,14 316,14 @@ TEXT	syscall0(SB), $-8
	MOVQ	$HI_IPL, R16
	CALL_PAL $PALswpipl
	MOVQ	$mach0(SB), R(MACH)
	CALL_PAL	$PALrdusp
	MOVQ	R0, (4*BY2WD+30*BY2V)(R30)		/* save USP */
	CALL_PAL $PALrdusp
	MOVQ	R0, (4*BY2WD+30*BY2V)(R30)	/* save USP */
	MOVQ	R26, (4*BY2WD+27*BY2V)(R30)	/* save last return address */
	MOVQ	$(4*BY2WD)(R30), R0			/* pass address of Ureg */
	JSR		syscall(SB)
	MOVQ	$(4*BY2WD)(R30), R0		/* pass address of Ureg */
	JSR	syscall(SB)
systrapret:
	MOVQ	(4*BY2WD+30*BY2V)(R30), R16	/* USP */
	CALL_PAL	$PALwrusp					/* consider doing this in execregs... */
	CALL_PAL $PALwrusp		/* consider doing this in execregs... */
	MOVQ	(4*BY2WD+27*BY2V)(R30), R26	/* restore last return address */
	ADDQ	$(4*BY2WD+31*BY2V), R30
	CALL_PAL	$PALretsys


@@ 305,15 335,15 @@ systrapret:

TEXT	touser(SB), $-8
	MOVQ	R0, R16
	CALL_PAL	$PALwrusp					/* set USP to value passed */
	SUBQ	$(6*BY2V), R30					/* create frame for retsys */
	MOVQ	$(UTZERO+32), R26				/* header appears in text */
	MOVQ	R26, (1*BY2V)(R30)				/* PC -- only reg that matters */
	CALL_PAL $PALwrusp			/* set USP to value passed */
	SUBQ	$(6*BY2V), R30			/* create frame for retsys */
	MOVQ	$(UTZERO+32), R26		/* header appears in text */
	MOVQ	R26, (1*BY2V)(R30)		/* PC -- only reg that matters */
	CALL_PAL	$PALretsys

TEXT	rfnote(SB), $0
	SUBL		$(2*BY2WD), R0, SP
	JMP		trapret
	SUBL	$(2*BY2WD), R0, SP
	JMP	trapret

TEXT	savefpregs(SB), $-8
	MOVT	F0, 0x00(R0)

M alphapc/main.c => alphapc/main.c +3 -5
@@ 27,6 27,7 @@ main(void)
	confinit();
	archinit();
	savefpregs(&initfp);
	fpenab(0);
	mmuinit();
	xinit();
	printinit();


@@ 273,19 274,16 @@ char *confname[] =
{
	"ether0",
	"scsi0",
	"scsi1",
	"scsi2",
	"audio0",

	"ether1",
};

char *confval[] =
{
	"type=2114x",
	"type=ata",
	"type=ata",
	"type=ata",
	"type=sb16",
	"type=2114x",
};

int	nconf = nelem(confname);

M alphapc/ns16552.h => alphapc/ns16552.h +5 -2
@@ 3,6 3,9 @@

#define uartpower(x, y)

void ns16552setup(ulong, ulong, char*, int);
void ns16552intr(int);

/*
 *  handle an interrupt to a single uart
 */


@@ 21,9 24,9 @@ ns16552install(void)
		return;
	already = 1;

	ns16552setup(Uart0, UartFREQ, "eia0");
	ns16552setup(Uart0, UartFREQ, "eia0", Ns550);
	intrenable(VectorUART0, ns16552intrx, (void*)0, BUSUNKNOWN);
	ns16552setup(Uart1, UartFREQ, "eia1");
	ns16552setup(Uart1, UartFREQ, "eia1", Ns550);
	intrenable(VectorUART1, ns16552intrx, (void*)0, BUSUNKNOWN);
}


M pc/devlml.c => pc/devlml.c +3 -1
@@ 642,9 642,10 @@ print("reading %lux at %lux (%lux)\n", v, pciBaseAddr + off, off);
}

static long
lmlwrite(Chan *c, void *va, long n, vlong off) {
lmlwrite(Chan *c, void *va, long n, vlong voff) {
	int i;
	uchar *buf = va;
	long off = voff;

	switch(c->qid.path & ~CHDIR){



@@ 686,6 687,7 @@ lmlwrite(Chan *c, void *va, long n, vlong off) {
			writew(*(short *)buf, pciBaseAddr + off);
			break;
		case 4:
print("writing %lux to %lux (%lux)\n", *(long *)buf, pciBaseAddr + off, off);
			writel(*(long *)buf, pciBaseAddr + off);
			break;
		default:

M pc/devlml.h => pc/devlml.h +31 -31
@@ 38,47 38,47 @@
// The following are the datastructures needed by the device.
#define ZR36057_I2C_BUS		0x044
// which bit of ZR36057_I2C_BUS is which
#define ZR36057_I2C_SCL                 1
#define ZR36057_I2C_SDA                 2
#define ZR36057_INTR_JPEGREP            0x08000000
#define ZR36057_INTR_STAT               0x03c
#define ZR36057_I2C_SCL		1
#define ZR36057_I2C_SDA		2
#define ZR36057_INTR_JPEGREP	0x08000000
#define ZR36057_INTR_STAT	0x03c

// A Device records the properties of the various card types supported.
typedef struct {
	int		number;			// The H33_CARDTYPE_ assigned
	char	*card_name;		// A string name
	int		zr060addr;		// Which guest bus address for the ZR36060
	int	number;		// The H33_CARDTYPE_ assigned
	char	*card_name;	// A string name
	int	zr060addr;	// Which guest bus address for the ZR36060
} Device;

// An entry in the fragment table
typedef struct {
	ulong	address;		// bus address of page
	int		length;			// length of page
	ulong	address;	// bus address of page
	int	length;		// length of page
} RingPage;

// The structure that we will use to tell the '57 about the buffers
// The sizeof(RingData) should not exceed page size
typedef struct {
	void			*buffer[4];
	ulong			i_stat_com[4];
	RingPage		ring_pages[4][PAGES];
	void		*buffer[4];
	ulong		i_stat_com[4];
	RingPage	ring_pages[4][PAGES];
} RingData;

typedef struct {
	int		expect;			// the buffer the int routine expects next
	int		which;			// which ring buffer the read or write uses
	int		filled;			// the current number of filled buffers
	int		pages;			// the number of complete pages
	int		remainder;		// the number of bytes in incomplete page
	int	expect;		// the buffer the int routine expects next
	int	which;		// which ring buffer the read or write uses
	int	filled;		// the current number of filled buffers
	int	pages;		// the number of complete pages
	int	remainder;	// the number of bytes in incomplete page
} RingPtr;

// The remainder of the #defs are constants which should not need changing.

// The PCI vendor and device ids of the zoran chipset on the dc30
// these really belong in pci.h
#define PCI_VENDOR_ZORAN				0x11de
#define PCI_DEVICE_ZORAN_36057			0x6057
#define PCI_DEVICE_ZORAN_36067			PCI_DEVICE_ZORAN_36057
#define PCI_VENDOR_ZORAN		0x11de
#define PCI_DEVICE_ZORAN_36057		0x6057
#define PCI_DEVICE_ZORAN_36067		PCI_DEVICE_ZORAN_36057

#define BT819Addr 0x8a
#define BT856Addr 0x88


@@ 89,19 89,19 @@ typedef struct {
#define FRAGM_FINAL_B 1
#define STAT_BIT 1

#define writel(v, a)	(*(ulong *)(a) = (v))
#define writel(v, a)	(*(ulong  *)(a) = (v))
#define writew(v, a)	(*(ushort *)(a) = (v))
#define writeb(v, a)	(*(uchar *)(a) = (v))
#define readl(a)		(*(ulong *)(a))
#define readw(a)		(*(ushort *)(a))
#define readb(a)		(*(uchar *)(a))

typedef struct FrameHeader			FrameHeader;
typedef struct MjpgDrv				MjpgDrv;
typedef struct Fragment				Fragment;
#define writeb(v, a)	(*(uchar  *)(a) = (v))
#define readl(a)	(*(ulong  *)(a))
#define readw(a)	(*(ushort *)(a))
#define readb(a)	(*(uchar  *)(a))

typedef struct FrameHeader		FrameHeader;
typedef struct MjpgDrv			MjpgDrv;
typedef struct Fragment			Fragment;
typedef struct FragmentTable		FragmentTable;
typedef struct CodeData				CodeData;
typedef struct ML33Board			LML33Board;
typedef struct CodeData			CodeData;
typedef struct ML33Board		LML33Board;

#define FRAGSIZE (MB/NBUF)


M pc/trap.c => pc/trap.c +0 -1
@@ 376,7 376,6 @@ fault386(Ureg* ureg, void*)
	n = fault(addr, read);
	if(n < 0){
		if(!user){
print("fault pc %luX addr %luX\n", ureg->pc, addr);
			dumpregs(ureg);
			panic("fault: 0x%lux\n", addr);
		}

M port/devns16552.c => port/devns16552.c +0 -1
@@ 313,7 313,6 @@ ns16552mflow(Uart *p, int n)

	ilock(&p->tlock);
	if(n){
print("mflow type %d\n", p->type);
		if(p->type == Ns650){
			outb(p->port + Format, 0xbf);
			outb(p->port + Efr, Eena|Arts|Acts);