Browse Source

riscv: don't compile everything in.

For now, we just want a minimal kernel that can print "hello".

Also, stop generating rdb calls. rdb is dead.

Add a little BUILDME so people can see how riscv is built.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 4 years ago
parent
commit
396dc74dad

+ 1 - 0
sys/src/9/riscv/BUILDME

@@ -0,0 +1 @@
+ARCH=riscv STRIP=/home/rminnich/projects/riscv/riscv-tools/bin/riscv64-unknown-elf-strip CC=/home/rminnich/projects/riscv/riscv-tools/bin/riscv64-unknown-elf-gcc LD=/home/rminnich/projects/riscv/riscv-tools/bin/riscv64-unknown-elf-ld ../../../../util/build riscvcpu.json

+ 3 - 3
sys/src/9/riscv/core.json

@@ -47,19 +47,19 @@
 			"archriscv.c",
 			"asm.c",
 		        "coreboot.c",
-			"ctype.c",
 			"devarch.c",
-			"main.c",
 			"map.c",
 			"memory.c",
 			"mmu.c",
 			"mp.c",
 			"physalloc.c",
+			"systab.c",
 			"tcore.c",
 			"trap.c"
 		],
 		"SourceFiles": [
-			"systab.c"
+			"ctype.c",
+			"main.c"
 		]
 	}
 }

+ 25 - 0
sys/src/9/riscv/ctype.c

@@ -0,0 +1,25 @@
+#include <u.h>
+#include <libc.h>
+#include <ctype.h>
+
+uint8_t	_ctype[256] =
+{
+/*	 0	 1	 2	 3	 4	 5	 6	 7  */
+
+/*  0*/	_C,	_C,	_C,	_C,	_C,	_C,	_C,	_C,
+/* 10*/	_C,	_S|_C,	_S|_C,	_S|_C,	_S|_C,	_S|_C,	_C,	_C,
+/* 20*/	_C,	_C,	_C,	_C,	_C,	_C,	_C,	_C,
+/* 30*/	_C,	_C,	_C,	_C,	_C,	_C,	_C,	_C,
+/* 40*/	_S|_B,	_P,	_P,	_P,	_P,	_P,	_P,	_P,
+/* 50*/	_P,	_P,	_P,	_P,	_P,	_P,	_P,	_P,
+/* 60*/	_N|_X,	_N|_X,	_N|_X,	_N|_X,	_N|_X,	_N|_X,	_N|_X,	_N|_X,
+/* 70*/	_N|_X,	_N|_X,	_P,	_P,	_P,	_P,	_P,	_P,
+/*100*/	_P,	_U|_X,	_U|_X,	_U|_X,	_U|_X,	_U|_X,	_U|_X,	_U,
+/*110*/	_U,	_U,	_U,	_U,	_U,	_U,	_U,	_U,
+/*120*/	_U,	_U,	_U,	_U,	_U,	_U,	_U,	_U,
+/*130*/	_U,	_U,	_U,	_P,	_P,	_P,	_P,	_P,
+/*140*/	_P,	_L|_X,	_L|_X,	_L|_X,	_L|_X,	_L|_X,	_L|_X,	_L,
+/*150*/	_L,	_L,	_L,	_L,	_L,	_L,	_L,	_L,
+/*160*/	_L,	_L,	_L,	_L,	_L,	_L,	_L,	_L,
+/*170*/	_L,	_L,	_L,	_P,	_P,	_P,	_P,	_C,
+};

+ 100 - 0
sys/src/9/riscv/io.h

@@ -0,0 +1,100 @@
+/*
+ * This file is part of the UCB release of Plan 9. It is subject to the license
+ * terms in the LICENSE file found in the top-level directory of this
+ * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
+ * part of the UCB release of Plan 9, including this file, may be copied,
+ * modified, propagated, or distributed except according to the terms contained
+ * in the LICENSE file.
+ */
+
+enum {
+	VectorNMI	= 2,		/* non-maskable interrupt */
+	VectorBPT	= 3,		/* breakpoint */
+	VectorUD	= 6,		/* invalid opcode exception */
+	VectorCNA	= 7,		/* coprocessor not available */
+	Vector2F	= 8,		/* double fault */
+	VectorCSO	= 9,		/* coprocessor segment overrun */
+	VectorPF	= 14,		/* page fault */
+	Vector15	= 15,		/* reserved */
+	VectorCERR	= 16,		/* coprocessor error */
+
+	VectorPIC	= 32,		/* external i8259 interrupts */
+	IrqCLOCK	= 0,
+	IrqKBD		= 1,
+	IrqUART1	= 3,
+	IrqUART0	= 4,
+	IrqPCMCIA	= 5,
+	IrqFLOPPY	= 6,
+	IrqLPT		= 7,
+	IrqIRQ7		= 7,
+	IrqAUX		= 12,		/* PS/2 port */
+	IrqIRQ13	= 13,		/* coprocessor on 386 */
+	IrqATA0		= 14,
+	IrqATA1		= 15,
+	MaxIrqPIC	= 15,
+
+	VectorLAPIC	= VectorPIC+16,	/* local APIC interrupts */
+	IrqLINT0	= VectorLAPIC+0,
+	IrqLINT1	= VectorLAPIC+1,
+	IrqTIMER	= VectorLAPIC+2,
+	IrqERROR	= VectorLAPIC+3,
+	IrqPCINT	= VectorLAPIC+4,
+	IrqSPURIOUS	= VectorLAPIC+15,
+	MaxIrqLAPIC	= VectorLAPIC+15,
+
+	VectorSYSCALL	= 64,
+
+	VectorAPIC	= 65,		/* external APIC interrupts */
+	MaxVectorAPIC	= 255,
+};
+
+typedef struct Vkey {
+	int	tbdf;			/* pci: ioapic or msi sources */
+	int	irq;			/* 8259-emulating sources */
+} Vkey;
+
+typedef struct Vctl {
+	Vctl*	next;			/* handlers on this vector */
+
+	int	isintr;			/* interrupt or fault/trap */
+
+	Vkey Vkey;			/* source-specific key; tbdf for pci */
+	void	(*f)(Ureg*, void*);	/* handler to call */
+	void*	a;			/* argument to call it with */
+	char	name[KNAMELEN];		/* of driver */
+	char	*type;
+
+	int	(*isr)(int);		/* get isr bit for this irq */
+	int	(*eoi)(int);		/* eoi */
+	int	(*mask)(Vkey*, int);	/* interrupt enable returns masked vector */
+	int	vno;
+} Vctl;
+
+typedef struct ACVctl {
+	char*	(*f)(Ureg*,void*);
+	void*	a;
+	int	vno;
+	char	name[KNAMELEN];		/* of driver */
+} ACVctl;
+
+enum {
+	BusCBUS		= 0,		/* Corollary CBUS */
+	BusCBUSII,			/* Corollary CBUS II */
+	BusEISA,			/* Extended ISA */
+	BusFUTURE,			/* IEEE Futurebus */
+	BusINTERN,			/* Internal bus */
+	BusISA,				/* Industry Standard Architecture */
+	BusMBI,				/* Multibus I */
+	BusMBII,			/* Multibus II */
+	BusMCA,				/* Micro Channel Architecture */
+	BusMPI,				/* MPI */
+	BusMPSA,			/* MPSA */
+	BusNUBUS,			/* Apple Macintosh NuBus */
+	BusPCI,				/* Peripheral Component Interconnect */
+	BusPCMCIA,			/* PC Memory Card International Association */
+	BusTC,				/* DEC TurboChannel */
+	BusVL,				/* VESA Local bus */
+	BusVME,				/* VMEbus */
+	BusXPRESS,			/* Express System Bus */
+};
+

+ 1 - 1
sys/src/9/riscv/kernel.ld

@@ -7,7 +7,7 @@
 
 OUTPUT_ARCH("riscv")
 /*OUTPUT_FORMAT("elf64-littleriscv", "elf64-x86-64", "elf64-x86-64") */
-ENTRY(_start)
+ENTRY(main)
 /* start the kernel at 0x110000. 
  * That way we can use lower ram for critical structures
  */

+ 23 - 0
sys/src/9/riscv/main.c

@@ -0,0 +1,23 @@
+/*
+ * This file is part of the UCB release of Plan 9. It is subject to the license
+ * terms in the LICENSE file found in the top-level directory of this
+ * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
+ * part of the UCB release of Plan 9, including this file, may be copied,
+ * modified, propagated, or distributed except according to the terms contained
+ * in the LICENSE file.
+ */
+
+#include "u.h"
+#include "../port/lib.h"
+#include "mem.h"
+#include "dat.h"
+#include "fns.h"
+
+#include "init.h"
+#include "io.h"
+
+void
+main(uint32_t mbmagic, uint32_t mbaddress)
+{
+	while (1);
+}

+ 7 - 5
sys/src/9/riscv/riscvcpu.json

@@ -4,7 +4,9 @@
 			"CONF=riscvcpu"
 		],
 		"Include": [
-			"core.json",
+			"core.json"
+		],
+		"IncludeSomeday": [
 			"../ip/ip.json",
 			"../port/port.json"
 		],
@@ -14,7 +16,7 @@
 					"int cpuserver = 1;",
 					"uint32_t kerndate = 1;"
 				],
-				"Dev": [
+				"NoDev": [
 					"arch",
 					"cap",
 					"cons",
@@ -37,7 +39,7 @@
 					"ws",
 					"zp"
 				],
-				"Ip": [
+				"NoIp": [
 					"tcp",
 					"udp",
 					"ipifc",
@@ -45,11 +47,11 @@
 					"icmp6",
 					"gre"
 				],
-				"Uart": [
+				"NoUart": [
 					"pci"
 				]
 			},
-			"Ramfiles": {
+			"NoRamfiles": {
 				"bind": "/$ARCH/bin/bind",
 				"boot": "/sys/src/9/boot/bootcpu.elf.out",
 				"cat": "/$ARCH/bin/cat",

+ 0 - 8
util/src/harvey/cmd/build/codegen.go

@@ -19,14 +19,6 @@ const kernconfTmpl = `
 #include "../port/error.h"
 #include "io.h"
 
-void
-rdb(void)
-{
-	splhi();
-	iprint("rdb...not installed\n");
-	for(;;);
-}
-
 {{ range .Rootcodes }}
 {{ . }}
 {{ end }}