changeset 115:4473e746fe5a

Restructured the include directory somewhat
author Jonathan Pevarnek <pevarnj@gmail.com>
date Sat, 11 Jun 2011 16:40:48 -0400
parents 4187043a3e3a
children 967a56b96d13
files .hgignore arch/svc.c include/elf.h include/os/elf.h include/os/psw.h include/os/scall.h include/os/svc.h include/prog/svcCalls.h include/prog/svc_prog.h include/psw.h include/svc.h include/svcCalls.h include/svc_prog.h src/os/scall.c src/os/shell.c src/os/std.c src/prog/echo.c src/prog/hello.c src/prog/ls.c
diffstat 19 files changed, 277 insertions(+), 276 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Jun 11 15:35:44 2011 -0400
+++ b/.hgignore	Sat Jun 11 16:40:48 2011 -0400
@@ -2,12 +2,13 @@
 \.a$
 \.rto$
 ^ipl/ipl_ccws\.S$
+^shell$
+^hello$
+^ls$
+^echo$
 ^sarpn$
 ^dynamic$
 ^testFS$
-^shell$
-^hello$
-^ls$
 ^loader\.bin$
 ^cscope\.out$
 \.swp$
--- a/arch/svc.c	Sat Jun 11 15:35:44 2011 -0400
+++ b/arch/svc.c	Sat Jun 11 16:40:48 2011 -0400
@@ -1,4 +1,4 @@
-#include <psw.h>
+#include <os/psw.h>
 #include <die.h>
 
 #include "svcint.h"
--- a/include/elf.h	Sat Jun 11 15:35:44 2011 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-#ifndef __ELF_H
-#define __ELF_H
-
-#define EI_MAG0		0
-#define EI_MAG1		1
-#define EI_MAG2		2
-#define EI_MAG3		3
-#define EI_CLASS	4
-#define EI_DATA		5
-#define EI_VERSION	6
-#define EI_OSABI	7
-#define EI_ABIVERSION	8
-#define EI_PAD		9
-#define EI_NIDENT	16
-
-#define ELFMAG0		0x7f
-#define ELFMAG1		'E'
-#define ELFMAG2		'L'
-#define ELFMAG3		'F'
-
-#define ELFCLASS64	2
-
-#define ELFDATA2MSB	2
-
-#define EV_CURRENT	1
-
-#define ELFOSABI_NONE	0
-
-#define ET_EXEC		2
-
-#define EM_S390		22
-
-#define PT_NULL		0
-#define PT_LOAD		1
-#define PT_DYNAMIC	2
-#define PT_INTERP	3
-#define PT_NOTE		4
-#define PT_SHLIB	5
-#define PT_PHDR		6
-#define PT_TLS		7
-
-#define PF_X		0x1
-#define PF_W		0x2
-#define PF_R		0x4
-
-typedef u64 Elf64_Addr;
-typedef u64 Elf64_Off;
-typedef u16 Elf64_Half;
-typedef u32 Elf64_Word;
-typedef s32 Elf64_Sword;
-typedef u64 Elf64_Xword;
-typedef s64 Elf64_Sxword;
-
-/*
- * ELF file header
- */
-typedef struct {
-	unsigned char   e_ident[EI_NIDENT];	/* ELF identification */
-	Elf64_Half      e_type;			/* Object file type */
-	Elf64_Half      e_machine;		/* Machine type */
-	Elf64_Word      e_version;		/* Object file version */
-	Elf64_Addr      e_entry;		/* Entry point address */
-	Elf64_Off       e_phoff;		/* Program header offset */
-	Elf64_Off       e_shoff;		/* Section header offset */
-	Elf64_Word      e_flags;		/* Processor-specific flags */
-	Elf64_Half      e_ehsize;		/* ELF header size */
-	Elf64_Half      e_phentsize;		/* Size of program header entry */
-	Elf64_Half      e_phnum;		/* Number of program header entries */
-	Elf64_Half      e_shentsize;		/* Size of section header entries */
-	Elf64_Half      e_shnum;		/* Number of section header entries */
-	Elf64_Half      e_shstrndx;		/* Section name string table index */
-} Elf64_Ehdr;
-
-/*
- * ELF program header
- */
-typedef struct {
-	Elf64_Word	p_type;			/* Segment type */
-	Elf64_Word	p_flags;		/* Segment file offset */
-	Elf64_Off	p_offset;		/* Segment virt. addr */
-	Elf64_Addr	p_vaddr;		/* <undefined> */
-	Elf64_Addr	p_paddr;		/* Segment size in file */
-	Elf64_Xword	p_filesz;		/* Segment size in mem */
-	Elf64_Xword	p_memsz;		/* Segment flags */
-	Elf64_Xword	p_align;		/* Segment alignment */
-} Elf64_Phdr;
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/os/elf.h	Sat Jun 11 16:40:48 2011 -0400
@@ -0,0 +1,88 @@
+#ifndef __ELF_H
+#define __ELF_H
+
+#define EI_MAG0		0
+#define EI_MAG1		1
+#define EI_MAG2		2
+#define EI_MAG3		3
+#define EI_CLASS	4
+#define EI_DATA		5
+#define EI_VERSION	6
+#define EI_OSABI	7
+#define EI_ABIVERSION	8
+#define EI_PAD		9
+#define EI_NIDENT	16
+
+#define ELFMAG0		0x7f
+#define ELFMAG1		'E'
+#define ELFMAG2		'L'
+#define ELFMAG3		'F'
+
+#define ELFCLASS64	2
+
+#define ELFDATA2MSB	2
+
+#define EV_CURRENT	1
+
+#define ELFOSABI_NONE	0
+
+#define ET_EXEC		2
+
+#define EM_S390		22
+
+#define PT_NULL		0
+#define PT_LOAD		1
+#define PT_DYNAMIC	2
+#define PT_INTERP	3
+#define PT_NOTE		4
+#define PT_SHLIB	5
+#define PT_PHDR		6
+#define PT_TLS		7
+
+#define PF_X		0x1
+#define PF_W		0x2
+#define PF_R		0x4
+
+typedef u64 Elf64_Addr;
+typedef u64 Elf64_Off;
+typedef u16 Elf64_Half;
+typedef u32 Elf64_Word;
+typedef s32 Elf64_Sword;
+typedef u64 Elf64_Xword;
+typedef s64 Elf64_Sxword;
+
+/*
+ * ELF file header
+ */
+typedef struct {
+	unsigned char   e_ident[EI_NIDENT];	/* ELF identification */
+	Elf64_Half      e_type;			/* Object file type */
+	Elf64_Half      e_machine;		/* Machine type */
+	Elf64_Word      e_version;		/* Object file version */
+	Elf64_Addr      e_entry;		/* Entry point address */
+	Elf64_Off       e_phoff;		/* Program header offset */
+	Elf64_Off       e_shoff;		/* Section header offset */
+	Elf64_Word      e_flags;		/* Processor-specific flags */
+	Elf64_Half      e_ehsize;		/* ELF header size */
+	Elf64_Half      e_phentsize;		/* Size of program header entry */
+	Elf64_Half      e_phnum;		/* Number of program header entries */
+	Elf64_Half      e_shentsize;		/* Size of section header entries */
+	Elf64_Half      e_shnum;		/* Number of section header entries */
+	Elf64_Half      e_shstrndx;		/* Section name string table index */
+} Elf64_Ehdr;
+
+/*
+ * ELF program header
+ */
+typedef struct {
+	Elf64_Word	p_type;			/* Segment type */
+	Elf64_Word	p_flags;		/* Segment file offset */
+	Elf64_Off	p_offset;		/* Segment virt. addr */
+	Elf64_Addr	p_vaddr;		/* <undefined> */
+	Elf64_Addr	p_paddr;		/* Segment size in file */
+	Elf64_Xword	p_filesz;		/* Segment size in mem */
+	Elf64_Xword	p_memsz;		/* Segment flags */
+	Elf64_Xword	p_align;		/* Segment alignment */
+} Elf64_Phdr;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/os/psw.h	Sat Jun 11 16:40:48 2011 -0400
@@ -0,0 +1,33 @@
+#ifndef __PSW_H
+#define __PSW_H
+
+struct psw {
+	u8 _zero0:1,
+	   r:1,			/* PER Mask (R)			*/
+	   _zero1:3,
+	   t:1,			/* DAT Mode (T)			*/
+	   io:1,		/* I/O Mask (IO)		*/
+	   ex:1;		/* External Mask (EX)		*/
+
+	u8 key:4,		/* Key				*/
+	   _zero2:1,
+	   m:1,			/* Machine-Check Mask (M)	*/
+	   w:1,			/* Wait State (W)		*/
+	   p:1;			/* Problem State (P)		*/
+
+	u8 as:2,		/* Address-Space Control (AS)	*/
+	   cc:2,		/* Condition Code (CC)		*/
+	   prog_mask:4;		/* Program Mask			*/
+
+	u8 _zero3:7,
+	   ea:1;		/* Extended Addressing (EA)	*/
+
+	u32 ba:1,		/* Basic Addressing (BA)	*/
+	    _zero4:31;
+
+	u64 ptr;
+};
+
+typedef struct psw Psw;
+
+#endif
--- a/include/os/scall.h	Sat Jun 11 15:35:44 2011 -0400
+++ b/include/os/scall.h	Sat Jun 11 16:40:48 2011 -0400
@@ -1,7 +1,7 @@
 #ifndef __SCALL_H
 #define __SCALL_H
 
-#include <psw.h>
+#include <os/psw.h>
 
 Psw shellPsw; //XXX No idea if this is correct XXX
 u64 shellRegisters[16];
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/os/svc.h	Sat Jun 11 16:40:48 2011 -0400
@@ -0,0 +1,12 @@
+#ifndef __SVC_H
+#define __SVC_H
+
+#include <os/psw.h>
+
+extern void setcontext(struct psw *psw, u64 *regs);
+extern void savecontext(struct psw *psw, u64 *regs);
+extern void swapcontext(struct psw *oldpsw, u64 *oldregs,
+			struct psw *newpsw, u64 *newregs);
+extern void set_svc_handler(u64(*f)(u64, u64, u64, u64, u64), void *stack);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/prog/svcCalls.h	Sat Jun 11 16:40:48 2011 -0400
@@ -0,0 +1,29 @@
+#ifndef __SVCCALLS_H
+#define __SVCCALLS_H
+
+#include <prog/svc_prog.h>
+#include <os/svcNums.h>
+#include <error.h>
+
+static inline void exit()
+{
+	invoke_svc0(SVC_EXIT);
+}
+
+static inline int printLine(char *buf, int len)
+{
+	return invoke_svc2(SVC_PRINT, buf, len);
+}
+
+static inline int readLine(char *buf, int len)
+{
+	return invoke_svc2(SVC_READ, buf, len);
+}
+
+static inline ErrCode finfo(u32 n, void* de)
+{
+	return invoke_svc2(SVC_FINFO, n, de);
+}
+
+
+#endif //__SVCCALLS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/prog/svc_prog.h	Sat Jun 11 16:40:48 2011 -0400
@@ -0,0 +1,100 @@
+#ifndef __SVC_PROG_H
+#define __SVC_PROG_H
+
+/* invokes the specified SVC with 0 to 4 args */
+
+#define invoke_svc0(n) ({ \
+				u64 _ret; \
+				asm volatile( \
+					"svc	%1\n" \
+					"lgr	%0,%%r2\n" \
+				: /* output */ \
+				  "=r" (_ret) \
+				: /* input */ \
+				  "i" (n) \
+				: /* clobber */ \
+				  "cc", "r2", "r3" \
+				); \
+				_ret; \
+			})
+
+#define invoke_svc1(n, a1) ({ \
+				u64 _ret; \
+				asm volatile( \
+					"lgr	%%r2,%2\n" \
+					"svc	%1\n" \
+					"lgr	%0,%%r2\n" \
+				: /* output */ \
+				  "=r" (_ret) \
+				: /* input */ \
+				  "i" (n), \
+				  "d" (a1) \
+				: /* clobber */ \
+				  "cc", "r2", "r3" \
+				); \
+				_ret; \
+			})
+
+#define invoke_svc2(n, a1, a2) ({ \
+				u64 _ret; \
+				asm volatile( \
+					"lgr	%%r2,%2\n" \
+					"lgr	%%r3,%3\n" \
+					"svc	%1\n" \
+					"lgr	%0,%%r2\n" \
+				: /* output */ \
+				  "=r" (_ret) \
+				: /* input */ \
+				  "i" (n), \
+				  "d" (a1), \
+				  "d" (a2) \
+				: /* clobber */ \
+				  "cc", "r2", "r3" \
+				); \
+				_ret; \
+			})
+
+#define invoke_svc3(n, a1, a2, a3) ({ \
+				u64 _ret; \
+				asm volatile( \
+					"lgr	%%r2,%2\n" \
+					"lgr	%%r3,%3\n" \
+					"lgr	%%r4,%4\n" \
+					"svc	%1\n" \
+					"lgr	%0,%%r2\n" \
+				: /* output */ \
+				  "=r" (_ret) \
+				: /* input */ \
+				  "i" (n), \
+				  "d" (a1), \
+				  "d" (a2), \
+				  "d" (a3) \
+				: /* clobber */ \
+				  "cc", "r2", "r3", "r4" \
+				); \
+				_ret; \
+			})
+
+#define invoke_svc4(n, a1, a2, a3, a4) ({ \
+				u64 _ret; \
+				asm volatile( \
+					"lgr	%%r2,%2\n" \
+					"lgr	%%r3,%3\n" \
+					"lgr	%%r4,%4\n" \
+					"lgr	%%r5,%5\n" \
+					"svc	%1\n" \
+					"lgr	%0,%%r2\n" \
+				: /* output */ \
+				  "=r" (_ret) \
+				: /* input */ \
+				  "i" (n), \
+				  "d" (a1), \
+				  "d" (a2), \
+				  "d" (a3) \
+				: /* clobber */ \
+				  "cc", "r2", "r3", "r4", "r5" \
+				); \
+				_ret; \
+			})
+
+#endif
--- a/include/psw.h	Sat Jun 11 15:35:44 2011 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#ifndef __PSW_H
-#define __PSW_H
-
-struct psw {
-	u8 _zero0:1,
-	   r:1,			/* PER Mask (R)			*/
-	   _zero1:3,
-	   t:1,			/* DAT Mode (T)			*/
-	   io:1,		/* I/O Mask (IO)		*/
-	   ex:1;		/* External Mask (EX)		*/
-
-	u8 key:4,		/* Key				*/
-	   _zero2:1,
-	   m:1,			/* Machine-Check Mask (M)	*/
-	   w:1,			/* Wait State (W)		*/
-	   p:1;			/* Problem State (P)		*/
-
-	u8 as:2,		/* Address-Space Control (AS)	*/
-	   cc:2,		/* Condition Code (CC)		*/
-	   prog_mask:4;		/* Program Mask			*/
-
-	u8 _zero3:7,
-	   ea:1;		/* Extended Addressing (EA)	*/
-
-	u32 ba:1,		/* Basic Addressing (BA)	*/
-	    _zero4:31;
-
-	u64 ptr;
-};
-
-typedef struct psw Psw;
-
-#endif
--- a/include/svc.h	Sat Jun 11 15:35:44 2011 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-#ifndef __SVC_H
-#define __SVC_H
-
-#include <psw.h>
-
-extern void setcontext(struct psw *psw, u64 *regs);
-extern void savecontext(struct psw *psw, u64 *regs);
-extern void swapcontext(struct psw *oldpsw, u64 *oldregs,
-			struct psw *newpsw, u64 *newregs);
-extern void set_svc_handler(u64(*f)(u64, u64, u64, u64, u64), void *stack);
-
-#endif
--- a/include/svcCalls.h	Sat Jun 11 15:35:44 2011 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#ifndef __SVCCALLS_H
-#define __SVCCALLS_H
-
-#include <svc_prog.h>
-#include <os/svcNums.h>
-#include <error.h>
-
-static inline void exit()
-{
-	invoke_svc0(SVC_EXIT);
-}
-
-static inline int printLine(char *buf, int len)
-{
-	return invoke_svc2(SVC_PRINT, buf, len);
-}
-
-static inline int readLine(char *buf, int len)
-{
-	return invoke_svc2(SVC_READ, buf, len);
-}
-
-static inline ErrCode finfo(u32 n, void* de)
-{
-	return invoke_svc2(SVC_FINFO, n, de);
-}
-
-
-#endif //__SVCCALLS_H
--- a/include/svc_prog.h	Sat Jun 11 15:35:44 2011 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-#ifndef __SVC_PROG_H
-#define __SVC_PROG_H
-
-/* invokes the specified SVC with 0 to 4 args */
-
-#define invoke_svc0(n) ({ \
-				u64 _ret; \
-				asm volatile( \
-					"svc	%1\n" \
-					"lgr	%0,%%r2\n" \
-				: /* output */ \
-				  "=r" (_ret) \
-				: /* input */ \
-				  "i" (n) \
-				: /* clobber */ \
-				  "cc", "r2", "r3" \
-				); \
-				_ret; \
-			})
-
-#define invoke_svc1(n, a1) ({ \
-				u64 _ret; \
-				asm volatile( \
-					"lgr	%%r2,%2\n" \
-					"svc	%1\n" \
-					"lgr	%0,%%r2\n" \
-				: /* output */ \
-				  "=r" (_ret) \
-				: /* input */ \
-				  "i" (n), \
-				  "d" (a1) \
-				: /* clobber */ \
-				  "cc", "r2", "r3" \
-				); \
-				_ret; \
-			})
-
-#define invoke_svc2(n, a1, a2) ({ \
-				u64 _ret; \
-				asm volatile( \
-					"lgr	%%r2,%2\n" \
-					"lgr	%%r3,%3\n" \
-					"svc	%1\n" \
-					"lgr	%0,%%r2\n" \
-				: /* output */ \
-				  "=r" (_ret) \
-				: /* input */ \
-				  "i" (n), \
-				  "d" (a1), \
-				  "d" (a2) \
-				: /* clobber */ \
-				  "cc", "r2", "r3" \
-				); \
-				_ret; \
-			})
-
-#define invoke_svc3(n, a1, a2, a3) ({ \
-				u64 _ret; \
-				asm volatile( \
-					"lgr	%%r2,%2\n" \
-					"lgr	%%r3,%3\n" \
-					"lgr	%%r4,%4\n" \
-					"svc	%1\n" \
-					"lgr	%0,%%r2\n" \
-				: /* output */ \
-				  "=r" (_ret) \
-				: /* input */ \
-				  "i" (n), \
-				  "d" (a1), \
-				  "d" (a2), \
-				  "d" (a3) \
-				: /* clobber */ \
-				  "cc", "r2", "r3", "r4" \
-				); \
-				_ret; \
-			})
-
-#define invoke_svc4(n, a1, a2, a3, a4) ({ \
-				u64 _ret; \
-				asm volatile( \
-					"lgr	%%r2,%2\n" \
-					"lgr	%%r3,%3\n" \
-					"lgr	%%r4,%4\n" \
-					"lgr	%%r5,%5\n" \
-					"svc	%1\n" \
-					"lgr	%0,%%r2\n" \
-				: /* output */ \
-				  "=r" (_ret) \
-				: /* input */ \
-				  "i" (n), \
-				  "d" (a1), \
-				  "d" (a2), \
-				  "d" (a3) \
-				: /* clobber */ \
-				  "cc", "r2", "r3", "r4", "r5" \
-				); \
-				_ret; \
-			})
-
-#endif
--- a/src/os/scall.c	Sat Jun 11 15:35:44 2011 -0400
+++ b/src/os/scall.c	Sat Jun 11 16:40:48 2011 -0400
@@ -1,7 +1,7 @@
 #include <os/scall.h>
 #include <os/svcNums.h>
 #include <os/fs.h>
-#include <svc.h>
+#include <os/svc.h>
 /*
 #include <stdio.h>
 #include <string.h>
--- a/src/os/shell.c	Sat Jun 11 15:35:44 2011 -0400
+++ b/src/os/shell.c	Sat Jun 11 16:40:48 2011 -0400
@@ -3,10 +3,10 @@
 #include <stdio.h>
 #include <error.h>
 #include <os/fs.h>
-#include <die.h>
-#include <elf.h>
-#include <psw.h>
-#include <svc.h>
+//#include <die.h>
+#include <os/elf.h>
+#include <os/psw.h>
+#include <os/svc.h>
 #include <os/scall.h>
 
 #define PROGRAM_STACK_START 0x400000 - 160 //this is correct, ignore the documentation
--- a/src/os/std.c	Sat Jun 11 15:35:44 2011 -0400
+++ b/src/os/std.c	Sat Jun 11 16:40:48 2011 -0400
@@ -1,7 +1,7 @@
 #include <std.h>
 #include <string.h>
 #ifndef OSLEVEL
-#include <svcCalls.h>
+#include <prog/svcCalls.h>
 #endif
 
 void init_all(u64 __memsize)
--- a/src/prog/echo.c	Sat Jun 11 15:35:44 2011 -0400
+++ b/src/prog/echo.c	Sat Jun 11 16:40:48 2011 -0400
@@ -1,4 +1,4 @@
-#include <svcCalls.h>
+#include <prog/svcCalls.h>
 #include <std.h>
 
 void start() //TODO: accept a command line argument of what to print
--- a/src/prog/hello.c	Sat Jun 11 15:35:44 2011 -0400
+++ b/src/prog/hello.c	Sat Jun 11 16:40:48 2011 -0400
@@ -1,4 +1,4 @@
-#include <svcCalls.h>
+#include <prog/svcCalls.h>
 #include <std.h>
 
 void start()
--- a/src/prog/ls.c	Sat Jun 11 15:35:44 2011 -0400
+++ b/src/prog/ls.c	Sat Jun 11 16:40:48 2011 -0400
@@ -1,5 +1,5 @@
 #include <os/fsStructs.h>
-#include <svcCalls.h>
+#include <prog/svcCalls.h>
 
 void start()
 {