# HG changeset patch # User Josef 'Jeff' Sipek # Date 1303415572 14400 # Node ID 0bb9a9b527cd40a144cdd37e4201f9bc995b6b2c # Parent 0242c06156d8fb5f310a71fa5cf3f58291845c8d 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 diff -r 0242c06156d8 -r 0bb9a9b527cd cp/include/config.h --- 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 diff -r 0242c06156d8 -r 0bb9a9b527cd cp/nucleus/Makefile --- 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 diff -r 0242c06156d8 -r 0bb9a9b527cd cp/nucleus/config.c --- /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 +#include +#include +#include + +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; iFST.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; +} diff -r 0242c06156d8 -r 0bb9a9b527cd cp/nucleus/init.c --- 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);