changeset 491:0bb9a9b527cd

cp: stubs for config file parsing At the moment, there isn't much to it. It accesses the IPL DASD and then reads each record from SYSTEM CONFIG on that volume. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Thu, 21 Apr 2011 15:52:52 -0400
parents 0242c06156d8
children bf04161a8f5c
files cp/include/config.h cp/nucleus/Makefile cp/nucleus/config.c cp/nucleus/init.c
diffstat 4 files changed, 65 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cp/include/config.h	Thu Apr 21 14:35:54 2011 -0400
+++ b/cp/include/config.h	Thu Apr 21 15:52:52 2011 -0400
@@ -18,4 +18,10 @@
 
 #define OPER_CONSOLE_CCUU	0x0009
 
+#define CONFIG_LRECL			80
+#define CONFIG_FILE_NAME		"SYSTEM  "
+#define CONFIG_FILE_TYPE		"CONFIG  "
+
+extern int load_config();
+
 #endif
--- a/cp/nucleus/Makefile	Thu Apr 21 14:35:54 2011 -0400
+++ b/cp/nucleus/Makefile	Thu Apr 21 15:52:52 2011 -0400
@@ -1,2 +1,2 @@
 objs-nucleus := init.o io.o printf.o int.o ext.o svc.o pgm.o spinlock.o \
-	mutex.o sched.o
+	mutex.o sched.o config.o
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cp/nucleus/config.c	Thu Apr 21 15:52:52 2011 -0400
@@ -0,0 +1,52 @@
+#include <device.h>
+#include <bdev.h>
+#include <edf.h>
+#include <ebcdic.h>
+
+static int parse_config_stmnt(char *stmnt)
+{
+	if (stmnt[0] == '*')
+		return 0; /* comment */
+
+	return 0;
+}
+
+int load_config(u32 iplsch)
+{
+	struct device *dev;
+	struct fs *fs;
+	struct file *file;
+	char buf[CONFIG_LRECL];
+	int ret;
+	int i;
+
+	/* find the real device */
+	dev = find_device_by_sch(iplsch);
+	if (IS_ERR(dev))
+		return PTR_ERR(dev);
+
+	/* mount the fs */
+	fs = edf_mount(dev);
+	if (IS_ERR(fs))
+		return PTR_ERR(fs);
+
+	/* look up the config file */
+	file = edf_lookup(fs, CONFIG_FILE_NAME, CONFIG_FILE_TYPE);
+	if (IS_ERR(file))
+		return PTR_ERR(file);
+
+	/* parse each record in the config file */
+	for(i=0; i<file->FST.FSTAIC; i++) {
+		ret = edf_read_rec(file, buf, i);
+		if (ret)
+			return ret;
+
+		ebcdic2ascii((u8 *) buf, CONFIG_LRECL);
+
+		ret = parse_config_stmnt(buf);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
--- a/cp/nucleus/init.c	Thu Apr 21 14:35:54 2011 -0400
+++ b/cp/nucleus/init.c	Thu Apr 21 15:52:52 2011 -0400
@@ -186,6 +186,12 @@
 	init_sched();
 
 	/*
+	 * Load the config file
+	 */
+	if (load_config(__iplsch))
+		BUG();
+
+	/*
 	 * IPL is more or less done
 	 */
 	get_parsed_tod(&ipltime);