From 0bd9b90cbf31dc9d02e380ecdda3ac439bb82409 Mon Sep 17 00:00:00 2001 From: Josef 'Jeff' Sipek Date: Mon, 29 Jul 2019 17:36:19 -0400 Subject: [PATCH] Convert non-tools build system to plain old makefiles (bmake-flavor) CMake works great when not cross compiling, and that's why we continue using it for tools building. When it comes to cross-compling, it is much simpler to just use a hand-crafted makefile that does all the heavy lifting. This build-a-stand-alone-binary makefile still has some rough edges, but it seems to work well enough. bmake seems to be the simplest variant of make to accomplish all this without too much pain. Signed-off-by: Josef 'Jeff' Sipek --- .hgignore | 15 +-- CMakeLists.txt | 57 ---------- Makefile | 70 ++++++++++++ build.mk | 124 +++++++++++++++++++++ build/.hgignore | 5 + cp/.hgignore | 6 - cp/CMakeLists.txt | 56 ---------- cp/Makefile | 81 ++++++++++++++ cp/drivers/objs.cmake | 2 - cp/fs/objs.cmake | 1 - cp/guest/objs.cmake | 2 - cp/include/interrupt.h | 6 +- cp/include/nucleus.h | 6 +- cp/{scripts/linker-hvf.script => linker.script} | 0 cp/mm/objs.cmake | 1 - cp/nucleus/.hgignore | 14 +-- cp/nucleus/{config.y => config_grammar.y} | 0 cp/nucleus/{config.l => config_lexer.l} | 4 +- cp/nucleus/direct.c | 4 +- cp/nucleus/{direct.y => direct_grammar.y} | 0 cp/nucleus/{direct.l => direct_lexer.l} | 4 +- cp/nucleus/objs.cmake | 4 - cp/shell/objs.cmake | 1 - include/types.h | 6 +- installer/.hgignore | 9 -- installer/CMakeLists.txt | 29 ----- installer/Makefile | 26 +++++ installer/installer/.hgignore | 3 + installer/installer/Makefile | 36 ++++++ installer/{ => installer}/cpio.c | 4 +- installer/{ => installer}/edf.c | 0 installer/{ => installer}/linker.script | 6 +- installer/{ => installer}/loader.h | 0 installer/{ => installer}/loader_asm.s | 4 +- installer/{ => installer}/loader_c.c | 0 installer/{ => installer}/malloc.c | 0 installer/{ => installer}/setmode.s | 0 installer/rdr-ipl-rec/.hgignore | 4 + installer/rdr-ipl-rec/Makefile | 34 ++++++ .../linker.script} | 0 lib/CMakeLists.txt | 5 - lib/Makefile | 33 ++++++ loader/CMakeLists.txt | 19 ---- loader/Makefile | 25 +++++ loader/{ => eckd-ipl-rec}/.hgignore | 3 - loader/eckd-ipl-rec/Makefile | 29 +++++ loader/{ => eckd-ipl-rec}/eckd.s | 0 .../linker.script} | 0 loader/layout.txt | 6 +- loader/{ => loader}/.hgignore | 3 - loader/loader/Makefile | 31 ++++++ loader/{ => loader}/linker.script | 5 +- loader/{ => loader}/loader.h | 0 loader/{ => loader}/loader_asm.s | 2 - loader/{ => loader}/loader_c.c | 12 +- loader/{ => loader}/setmode.s | 0 nss/8ball/.hgignore | 2 - nss/8ball/CMakeLists.txt | 4 - nss/8ball/Makefile | 27 +++++ nss/8ball/{linker-8ball.script => linker.script} | 0 nss/CMakeLists.txt | 3 - nss/Makefile | 26 +++++ nss/ipldev/CMakeLists.txt | 4 - nss/ipldev/Makefile | 27 +++++ nss/login/CMakeLists.txt | 5 - nss/login/Makefile | 34 ++++++ nss/login/io.c | 4 +- nss/login/linker.script | 4 +- nss/login/main.c | 6 +- nss/login/mch.c | 4 +- nss/login/prg.c | 4 +- 71 files changed, 680 insertions(+), 271 deletions(-) delete mode 100644 CMakeLists.txt create mode 100644 Makefile create mode 100644 build.mk delete mode 100644 cp/CMakeLists.txt create mode 100644 cp/Makefile delete mode 100644 cp/drivers/objs.cmake delete mode 100644 cp/fs/objs.cmake delete mode 100644 cp/guest/objs.cmake rename cp/{scripts/linker-hvf.script => linker.script} (100%) delete mode 100644 cp/mm/objs.cmake rename cp/nucleus/{config.y => config_grammar.y} (100%) rename cp/nucleus/{config.l => config_lexer.l} (96%) rename cp/nucleus/{direct.y => direct_grammar.y} (100%) rename cp/nucleus/{direct.l => direct_lexer.l} (97%) delete mode 100644 cp/nucleus/objs.cmake delete mode 100644 cp/shell/objs.cmake delete mode 100644 installer/CMakeLists.txt create mode 100644 installer/Makefile create mode 100644 installer/installer/.hgignore create mode 100644 installer/installer/Makefile rename installer/{ => installer}/cpio.c (97%) rename installer/{ => installer}/edf.c (100%) rename installer/{ => installer}/linker.script (75%) rename installer/{ => installer}/loader.h (100%) rename installer/{ => installer}/loader_asm.s (98%) rename installer/{ => installer}/loader_c.c (100%) rename installer/{ => installer}/malloc.c (100%) rename installer/{ => installer}/setmode.s (100%) create mode 100644 installer/rdr-ipl-rec/.hgignore create mode 100644 installer/rdr-ipl-rec/Makefile rename installer/{linker-rdr.script => rdr-ipl-rec/linker.script} (100%) delete mode 100644 lib/CMakeLists.txt create mode 100644 lib/Makefile delete mode 100644 loader/CMakeLists.txt create mode 100644 loader/Makefile copy loader/{ => eckd-ipl-rec}/.hgignore (57%) create mode 100644 loader/eckd-ipl-rec/Makefile rename loader/{ => eckd-ipl-rec}/eckd.s (100%) rename loader/{linker-eckd.script => eckd-ipl-rec/linker.script} (100%) rename loader/{ => loader}/.hgignore (63%) create mode 100644 loader/loader/Makefile rename loader/{ => loader}/linker.script (75%) rename loader/{ => loader}/loader.h (100%) rename loader/{ => loader}/loader_asm.s (99%) rename loader/{ => loader}/loader_c.c (97%) rename loader/{ => loader}/setmode.s (100%) delete mode 100644 nss/8ball/CMakeLists.txt create mode 100644 nss/8ball/Makefile rename nss/8ball/{linker-8ball.script => linker.script} (100%) delete mode 100644 nss/CMakeLists.txt create mode 100644 nss/Makefile delete mode 100644 nss/ipldev/CMakeLists.txt create mode 100644 nss/ipldev/Makefile delete mode 100644 nss/login/CMakeLists.txt create mode 100644 nss/login/Makefile diff --git a/.hgignore b/.hgignore index fa32a0f..b3dbacb 100644 --- a/.hgignore +++ b/.hgignore @@ -4,14 +4,11 @@ syntax: glob *.orig *.rej -installer.bin - -CMakeCache.txt -CMakeFiles -Makefile -cmake_install.cmake +*.o +*.raw -build-prefix +installer.bin +installer.cpio subinclude:build/.hgignore subinclude:build/byacc/.hgignore @@ -26,8 +23,12 @@ subinclude:cp/nucleus/.hgignore subinclude:cp/shell/.hgignore subinclude:doc/manual/.hgignore subinclude:installer/.hgignore +subinclude:installer/installer/.hgignore +subinclude:installer/rdr-ipl-rec/.hgignore subinclude:lib/.hgignore subinclude:loader/.hgignore +subinclude:loader/eckd-ipl-rec/.hgignore +subinclude:loader/loader/.hgignore subinclude:nss/8ball/.hgignore subinclude:nss/debuggers/.hgignore subinclude:nss/debuggers/src/.hgignore diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 2989c2d..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -# we need to compile the build tools -include(ExternalProject) -ExternalProject_add(build - DOWNLOAD_COMMAND "" - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build - CONFIGURE_COMMAND cmake - INSTALL_COMMAND "" - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/build -) - -include(CMakeForceCompiler) - -set(CMAKE_SYSTEM_NAME Linux) -enable_language(ASM-ATT) - -set(CMAKE_LINKER "s390x-linux-ld") -set(CMAKE_OBJCOPY "s390x-linux-objcopy") -set(CMAKE_ASM "s390x-linux-as") -CMAKE_FORCE_C_COMPILER(s390x-linux-gcc GNU) -set(CMAKE_ASM-ATT_COMPILE_OBJECT - "${CMAKE_ASM} ${ASM_SYS_FLAGS} -o ") - -set(CMAKE_C_FLAGS "-g -fno-strict-aliasing -fno-builtin -nostdlib -nostdinc -Wall -m64 -I ${PROJECT_SOURCE_DIR}/include/ -include ${PROJECT_SOURCE_DIR}/include/types.h -O2 -mbackchain") - -set(HVF_VERSION "0.16-rc3") - -add_subdirectory(lib) -add_subdirectory(cp) -add_subdirectory(nss) -add_subdirectory(loader) -add_subdirectory(installer) - -add_custom_command( - OUTPUT installer/archive.cpio - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build/mkarchive - ${CMAKE_CURRENT_SOURCE_DIR}/cp/config/hvf.directory text 80 - ${CMAKE_CURRENT_SOURCE_DIR}/cp/config/system.config text 80 - ${CMAKE_CURRENT_SOURCE_DIR}/cp/config/local-3215.txt text 80 - ${CMAKE_CURRENT_BINARY_DIR}/cp/hvf bin - ${CMAKE_CURRENT_BINARY_DIR}/loader/eckd.rto bin - ${CMAKE_CURRENT_BINARY_DIR}/loader/loader.rto bin - ${CMAKE_CURRENT_SOURCE_DIR}/doc/installed_files.txt text 80 - ${CMAKE_CURRENT_BINARY_DIR}/nss/8ball/8ball bin - ${CMAKE_CURRENT_BINARY_DIR}/nss/ipldev/ipldev bin - ${CMAKE_CURRENT_BINARY_DIR}/nss/login/login bin - > installer/archive.cpio - DEPENDS hvf 8ball login ipldev loader-rto -) -add_custom_command( - OUTPUT installer.bin - COMMAND ./build/padcat installer/rdr.rto installer/installer.rto installer/archive.cpio > installer.bin - DEPENDS installer-rto installer/archive.cpio -) - -add_custom_target(distro ALL DEPENDS installer.bin) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9952166 --- /dev/null +++ b/Makefile @@ -0,0 +1,70 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +SUBDIRS=lib cp nss loader + +all: build-installer + +clean: +.for s in $(SUBDIRS) + $(MAKE) -C $s clean +.endfor + +build-tools: + cd build && cmake . && $(MAKE) + +clean-tools: + cd build && make clean || true + +build-os: build-tools +.for s in $(SUBDIRS) + $(MAKE) -C $s +.endfor + +clean-os: +.for s in $(SUBDIRS) + $(MAKE) -C $s clean +.endfor + +build-installer: build-os + $(MAKE) -C installer + ${.CURDIR}/build/mkarchive \ + ${.CURDIR}/cp/config/hvf.directory text 80 \ + ${.CURDIR}/cp/config/system.config text 80 \ + ${.CURDIR}/cp/config/local-3215.txt text 80 \ + ${.CURDIR}/cp/hvf bin \ + ${.CURDIR}/loader/eckd-ipl-rec/eckd.raw bin \ + ${.CURDIR}/loader/loader/loader.raw bin \ + ${.CURDIR}/doc/installed_files.txt text 80 \ + ${.CURDIR}/nss/8ball/8ball bin \ + ${.CURDIR}/nss/ipldev/ipldev bin \ + ${.CURDIR}/nss/login/login bin \ + > ${.CURDIR}/installer.cpio + ${.CURDIR}/build/padcat \ + ${.CURDIR}/installer/rdr-ipl-rec/rdr.raw \ + ${.CURDIR}/installer/installer/installer.raw \ + ${.CURDIR}/installer.cpio \ + > ${.CURDIR}/installer.bin + +clean-installer: + $(MAKE) -C installer clean + rm -f installer.cpio installer.bin diff --git a/build.mk b/build.mk new file mode 100644 index 0000000..90700cd --- /dev/null +++ b/build.mk @@ -0,0 +1,124 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +HVF_VERSION= 0.16-rc3 + +SRCTOP!= hg root + +OBJCOPY= s390x-linux-objcopy +SECTIONS?= .text .data .rodata .rodata.str1.2 + +CC= s390x-linux-gcc +CPPFLAGS.ALL= -DVERSION="\"$(HVF_VERSION)\"" \ + -I $(SRCTOP)/include \ + -include $(SRCTOP)/include/types.h \ + $(DEFS) +CPPFLAGS.31= $(CPPFLAGS.ALL) +CPPFLAGS.64= $(CPPFLAGS.ALL) +CFLAGS.ALL= -Wall \ + -O2 \ + -g \ + -m$(BITS) \ + -mbackchain \ + -msoft-float \ + -fno-strict-aliasing \ + -fno-builtin \ + -nostartfiles \ + -nostdlib \ + -nostdinc +CFLAGS.31= $(CFLAGS.ALL) $(CPPFLAGS.31) +CFLAGS.64= $(CFLAGS.ALL) $(CPPFLAGS.64) + +LD= s390x-linux-ld +LINKER_SCRIPT= linker.script +LDFLAGS.ALL= -T$(LINKER_SCRIPT) +LDFLAGS.31= $(LDFLAGS.ALL) -melf_s390 +LDFLAGS.64= $(LDFLAGS.ALL) -melf64_s390 + +AR= s390x-linux-ar + +C_SRCS:=${SRCS:M*.c} +S_SRCS:=${SRCS:M*.s} +Y_SRCS:=${SRCS:M*.y} +L_SRCS:=${SRCS:M*.l} + +GENSRCS:=${Y_SRCS:C/\.y$/.c/} \ + ${L_SRCS:C/\.l$/.c/} +GENHDRS:=${Y_SRCS:C/\.y$/.h/} \ + ${L_SRCS:C/\.l$/.h/} + +OBJS:=${C_SRCS:%.c=%.o} \ + ${S_SRCS:%.s=%.o} \ + ${GENSRCS:%.c=%.o} + +all: bin lib + +clean: +.if defined(BIN) + rm -f $(BIN) $(BIN).raw +.endif +.if defined(LIB) + rm -f $(LIB).a +.endif + rm -f $(OBJS) $(CLEANSRCS) +.if !empty(GENSRCS) || !empty(GENHDRS) + rm -f $(GENSRCS) $(GENHDRS) +.endif + +.if defined(BIN) +bin: $(BIN) +$(BIN): $(OBJS) $(LINKER_SCRIPT) + $(LD) $(LDFLAGS.$(BITS)) -o $(BIN) $(OBJS) $(LD_ADD) + +$(BIN).raw: $(BIN) + $(OBJCOPY) -O binary ${SECTIONS:%=-j %} ${.ALLSRC} ${.TARGET} +.else +bin: +.endif + +.if defined(LIB) +lib: $(LIB).a +$(LIB).a: $(OBJS) + $(AR) cr ${.TARGET} ${.ALLSRC} +.else +lib: +.endif() + +# remove built-in .[yl] -> .o rules +.y.o: +.l.o: + +.c.o: + $(CC) $(CFLAGS.$(BITS)) -c -o ${.TARGET} ${.IMPSRC} + +.s.o: + $(CC) $(CFLAGS.$(BITS)) -D_ASM -x assembler-with-cpp -c -o ${.TARGET} ${.IMPSRC} + +.y.c: + cd ${.IMPSRC:H} && $(SRCTOP)/build/byacc/yacc \ + -b ${.IMPSRC:T:R} \ + -d -P -p ${.IMPSRC:T:R:S/grammar//} \ + -o ${.IMPSRC:T:R}.c ${.IMPSRC:T} + +.l.c: + cd ${.IMPSRC:H} && $(SRCTOP)/build/re2c/re2c \ + -o ${.IMPSRC:T:R}.c ${.IMPSRC:T} diff --git a/build/.hgignore b/build/.hgignore index 7b293b8..f55800a 100644 --- a/build/.hgignore +++ b/build/.hgignore @@ -1,5 +1,10 @@ syntax: glob +CMakeCache.txt +CMakeFiles +Makefile +cmake_install.cmake + ccw_gen padcat mkarchive diff --git a/cp/.hgignore b/cp/.hgignore index e48235a..00f2c5b 100644 --- a/cp/.hgignore +++ b/cp/.hgignore @@ -1,9 +1,3 @@ syntax: glob -*.rto -ipl/ipl_rdr_ccws.s -ipl/ipl_tape.s hvf -loader_rdr.bin -loader_tape.bin -cscope.out diff --git a/cp/CMakeLists.txt b/cp/CMakeLists.txt deleted file mode 100644 index 76c973e..0000000 --- a/cp/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVERSION=\\\"${HVF_VERSION}\\\"") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I ${PROJECT_SOURCE_DIR}/cp/include/") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${PROJECT_SOURCE_DIR}/cp/include/nucleus.h") - -set(CMAKE_EXE_LINKER_FLAGS "-T ${PROJECT_SOURCE_DIR}/cp/scripts/linker-hvf.script") - -add_custom_command( - OUTPUT nucleus/config.tab.h - nucleus/config.tab.c - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/../build/byacc/yacc - -b config -d -P -p config_ config.y - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/nucleus - DEPENDS nucleus/config.y -) -add_custom_command( - OUTPUT nucleus/config.lex.c - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/../build/re2c/re2c - -o config.lex.c config.l - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/nucleus - DEPENDS nucleus/config.l nucleus/config.tab.h -) - -add_custom_command( - OUTPUT nucleus/direct.tab.h - nucleus/direct.tab.c - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/../build/byacc/yacc - -b direct -d -P -p direct_ direct.y - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/nucleus - DEPENDS nucleus/direct.y -) -add_custom_command( - OUTPUT nucleus/direct.lex.c - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/../build/re2c/re2c - -o direct.lex.c direct.l - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/nucleus - DEPENDS nucleus/direct.l nucleus/direct.tab.h -) - -set(SUBDIRS nucleus mm fs drivers shell guest) - -set(SRCFILES "") -foreach(SUBDIR ${SUBDIRS}) - set(FILES "") - include(${SUBDIR}/objs.cmake) - foreach(FILE ${FILES}) - set(SRCFILES ${SRCFILES} ${SUBDIR}/${FILE}) - endforeach() -endforeach() - -add_executable(hvf ${SRCFILES}) - -target_link_libraries(hvf clock) -target_link_libraries(hvf digest) -target_link_libraries(hvf string) -target_link_libraries(hvf ebcdic) -target_link_libraries(hvf errno) diff --git a/cp/Makefile b/cp/Makefile new file mode 100644 index 0000000..7bc5ef0 --- /dev/null +++ b/cp/Makefile @@ -0,0 +1,81 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +BIN= hvf +SRCS= \ + drivers/3215.c \ + drivers/dasd.c \ + drivers/device.c \ + drivers/spooldev.c \ + drivers/spooldev_cons.c \ + drivers/vdevice.c \ + fs/bcache.c \ + fs/bdev.c \ + fs/edf.c \ + fs/spool.c \ + guest/attach.c \ + guest/exception.c \ + guest/init.c \ + guest/instruction.c \ + guest/instruction_priv.c \ + guest/intercept.c \ + guest/ipl.c \ + guest/reset.c \ + guest/run.c \ + guest/system.c \ + mm/buddy.c \ + mm/dat.c \ + mm/page.c \ + mm/slab.c \ + nucleus/config.c \ + nucleus/config_grammar.y \ + nucleus/config_lexer.l \ + nucleus/direct.c \ + nucleus/direct_grammar.y \ + nucleus/direct_lexer.l \ + nucleus/ext.c \ + nucleus/init.c \ + nucleus/int.s \ + nucleus/io.c \ + nucleus/ldep.c \ + nucleus/mch.c \ + nucleus/mutex.c \ + nucleus/pgm.c \ + nucleus/printf.c \ + nucleus/sched.c \ + nucleus/sclp.c \ + nucleus/spinlock.c \ + nucleus/svc.c \ + nucleus/symtab.c \ + nucleus/util.c \ + shell/cmds.c \ + shell/disassm.c \ + shell/init.c +BITS= 64 + +DEFS= -I include \ + -include include/nucleus.h +LD_ADD= $(SRCTOP)/lib/lib.a + +.include <${.CURDIR:H}/build.mk> + +nucleus/direct.c: nucleus/direct_grammar.c diff --git a/cp/drivers/objs.cmake b/cp/drivers/objs.cmake deleted file mode 100644 index b2da2ec..0000000 --- a/cp/drivers/objs.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(FILES device.c 3215.c dasd.c vdevice.c spooldev.c - spooldev_cons.c) diff --git a/cp/fs/objs.cmake b/cp/fs/objs.cmake deleted file mode 100644 index 4a3e6c1..0000000 --- a/cp/fs/objs.cmake +++ /dev/null @@ -1 +0,0 @@ -set(FILES bdev.c edf.c bcache.c spool.c) diff --git a/cp/guest/objs.cmake b/cp/guest/objs.cmake deleted file mode 100644 index be1f98d..0000000 --- a/cp/guest/objs.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(FILES init.c run.c ipl.c system.c reset.c attach.c intercept.c exception.c instruction.c - instruction_priv.c) diff --git a/cp/include/interrupt.h b/cp/include/interrupt.h index 0c079ce..ebbe397 100644 --- a/cp/include/interrupt.h +++ b/cp/include/interrupt.h @@ -1,5 +1,5 @@ /* - * (C) Copyright 2007-2011 Josef 'Jeff' Sipek + * (C) Copyright 2007-2019 Josef 'Jeff' Sipek * * This file is released under the GPLv2. See the COPYING file for more * details. @@ -8,6 +8,8 @@ #ifndef __INTERRUPT_H #define __INTERRUPT_H +#ifndef _ASM + /* * I/O interruptions specific constants & structures */ @@ -103,3 +105,5 @@ extern void __io_int_handler(void); extern u8 *int_stack_ptr; #endif + +#endif diff --git a/cp/include/nucleus.h b/cp/include/nucleus.h index 0998851..113e0ea 100644 --- a/cp/include/nucleus.h +++ b/cp/include/nucleus.h @@ -1,5 +1,5 @@ /* - * (C) Copyright 2007-2011 Josef 'Jeff' Sipek + * (C) Copyright 2007-2019 Josef 'Jeff' Sipek * * This file is released under the GPLv2. See the COPYING file for more * details. @@ -8,6 +8,8 @@ #ifndef __NUCLEUS_H #define __NUCLEUS_H +#ifndef _ASM + #include #include #include @@ -61,3 +63,5 @@ extern int con_printf(struct virt_cons *con, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); #endif + +#endif diff --git a/cp/scripts/linker-hvf.script b/cp/linker.script similarity index 100% rename from cp/scripts/linker-hvf.script rename to cp/linker.script diff --git a/cp/mm/objs.cmake b/cp/mm/objs.cmake deleted file mode 100644 index 3f247bd..0000000 --- a/cp/mm/objs.cmake +++ /dev/null @@ -1 +0,0 @@ -set(FILES buddy.c page.c slab.c dat.c) diff --git a/cp/nucleus/.hgignore b/cp/nucleus/.hgignore index 712e333..4bc993a 100644 --- a/cp/nucleus/.hgignore +++ b/cp/nucleus/.hgignore @@ -1,11 +1,9 @@ syntax: glob -libnucleus.a +config_grammar.c +config_grammar.h +config_lexer.c -config.tab.c -config.tab.h -config.lex.c - -direct.tab.c -direct.tab.h -direct.lex.c +direct_grammar.c +direct_grammar.h +direct_lexer.c diff --git a/cp/nucleus/config.y b/cp/nucleus/config_grammar.y similarity index 100% rename from cp/nucleus/config.y rename to cp/nucleus/config_grammar.y diff --git a/cp/nucleus/config.l b/cp/nucleus/config_lexer.l similarity index 96% rename from cp/nucleus/config.l rename to cp/nucleus/config_lexer.l index 393d4b2..883dec5 100644 --- a/cp/nucleus/config.l +++ b/cp/nucleus/config_lexer.l @@ -1,5 +1,5 @@ /* - * (C) Copyright 2007-2011 Josef 'Jeff' Sipek + * (C) Copyright 2007-2019 Josef 'Jeff' Sipek * * This file is released under the GPLv2. See the COPYING file for more * details. @@ -10,7 +10,7 @@ #include #include -#include "config.tab.h" +#include "config_grammar.h" static int __fill(struct lexer *lexer, int n) { diff --git a/cp/nucleus/direct.c b/cp/nucleus/direct.c index 01aaab5..320e6d8 100644 --- a/cp/nucleus/direct.c +++ b/cp/nucleus/direct.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2007-2011 Josef 'Jeff' Sipek + * (C) Copyright 2007-2019 Josef 'Jeff' Sipek * * This file is released under the GPLv2. See the COPYING file for more * details. @@ -15,7 +15,7 @@ #include #include -#include "direct.tab.h" +#include "direct_grammar.h" static LIST_HEAD(directory); diff --git a/cp/nucleus/direct.y b/cp/nucleus/direct_grammar.y similarity index 100% rename from cp/nucleus/direct.y rename to cp/nucleus/direct_grammar.y diff --git a/cp/nucleus/direct.l b/cp/nucleus/direct_lexer.l similarity index 97% rename from cp/nucleus/direct.l rename to cp/nucleus/direct_lexer.l index 9e25c6d..b74310c 100644 --- a/cp/nucleus/direct.l +++ b/cp/nucleus/direct_lexer.l @@ -1,5 +1,5 @@ /* - * (C) Copyright 2007-2011 Josef 'Jeff' Sipek + * (C) Copyright 2007-2019 Josef 'Jeff' Sipek * * This file is released under the GPLv2. See the COPYING file for more * details. @@ -11,7 +11,7 @@ #include #include -#include "direct.tab.h" +#include "direct_grammar.h" static int __fill(struct lexer *lexer, int n) { diff --git a/cp/nucleus/objs.cmake b/cp/nucleus/objs.cmake deleted file mode 100644 index ed28b3f..0000000 --- a/cp/nucleus/objs.cmake +++ /dev/null @@ -1,4 +0,0 @@ -set(FILES init.c io.c printf.c int.s ext.c svc.c pgm.c mch.c spinlock.c mutex.c - sched.c sclp.c ldep.c util.c config.c config.tab.c config.lex.c - direct.c direct.tab.c direct.lex.c - symtab.c) diff --git a/cp/shell/objs.cmake b/cp/shell/objs.cmake deleted file mode 100644 index 8d6b95f..0000000 --- a/cp/shell/objs.cmake +++ /dev/null @@ -1 +0,0 @@ -set(FILES init.c cmds.c disassm.c) diff --git a/include/types.h b/include/types.h index a9cb8be..2d8a510 100644 --- a/include/types.h +++ b/include/types.h @@ -1,5 +1,5 @@ /* - * (C) Copyright 2007-2010 Josef 'Jeff' Sipek + * (C) Copyright 2007-2019 Josef 'Jeff' Sipek * * This file is released under the GPLv2. See the COPYING file for more * details. @@ -8,6 +8,8 @@ #ifndef __TYPES_H #define __TYPES_H +#ifndef _ASM + #define NULL ((void*) 0) typedef unsigned long long u64; @@ -109,3 +111,5 @@ typedef s64 ptrdiff_t; __val > __max ? __max: __val; }) #endif + +#endif diff --git a/installer/.hgignore b/installer/.hgignore index 393c30a..508ad10 100644 --- a/installer/.hgignore +++ b/installer/.hgignore @@ -1,10 +1 @@ syntax: glob - -*.rto - -rdr -rdr.s - -installer - -archive.cpio diff --git a/installer/CMakeLists.txt b/installer/CMakeLists.txt deleted file mode 100644 index 60478be..0000000 --- a/installer/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os") - -add_executable(installer setmode.s loader_c.c loader_asm.s cpio.c malloc.c - edf.c) -target_link_libraries(installer string) -target_link_libraries(installer ebcdic) -set_target_properties(installer PROPERTIES LINK_FLAGS "-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.script") - -add_custom_command( - OUTPUT installer.rto - COMMAND ${CMAKE_OBJCOPY} -O binary -j .text -j .data -j .rodata -j .rodata.str1.2 installer installer.rto - DEPENDS installer -) - -add_custom_command( - OUTPUT rdr.s - COMMAND ../build/ccw_gen 00080000 80100000 installer.rto 100000 080000 > rdr.s - DEPENDS installer.rto -) - -add_executable(rdr rdr.s) -set_target_properties(rdr PROPERTIES LINK_FLAGS "-T ${CMAKE_CURRENT_SOURCE_DIR}/linker-rdr.script") -add_custom_command( - OUTPUT rdr.rto - COMMAND ${CMAKE_OBJCOPY} -O binary -j .text -j .data -j .rodata -j .rodata.str1.2 rdr rdr.rto - DEPENDS rdr -) - -add_custom_target(installer-rto ALL DEPENDS rdr.rto installer.rto) diff --git a/installer/Makefile b/installer/Makefile new file mode 100644 index 0000000..0c7e424 --- /dev/null +++ b/installer/Makefile @@ -0,0 +1,26 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +all clean: + $(MAKE) -C installer $@ + # depends on installer + $(MAKE) -C rdr-ipl-rec $@ diff --git a/installer/installer/.hgignore b/installer/installer/.hgignore new file mode 100644 index 0000000..ada2f1c --- /dev/null +++ b/installer/installer/.hgignore @@ -0,0 +1,3 @@ +syntax: glob + +installer diff --git a/installer/installer/Makefile b/installer/installer/Makefile new file mode 100644 index 0000000..eaddcbd --- /dev/null +++ b/installer/installer/Makefile @@ -0,0 +1,36 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +BIN= installer +SRCS= setmode.s \ + loader_c.c \ + loader_asm.s \ + cpio.c \ + malloc.c \ + edf.c +BITS= 64 + +LD_ADD= $(SRCTOP)/lib/lib.a + +.include <${.CURDIR:H:H}/build.mk> + +all: installer.raw diff --git a/installer/cpio.c b/installer/installer/cpio.c similarity index 97% rename from installer/cpio.c rename to installer/installer/cpio.c index 4708540..e47b28d 100644 --- a/installer/cpio.c +++ b/installer/installer/cpio.c @@ -34,8 +34,8 @@ static struct table table[] = { {"system.config", "SYSTEM ", "CONFIG ", 80, 1, 0}, {"local-3215.txt", "HVF ", "LOGO ", 80, 1, 0}, {"hvf", "HVF ", "ELF ", 4096, 0, 0}, - {"eckd.rto", "ECKDLOAD", "BIN ", 4096, 0, 1}, - {"loader.rto", "DASDLOAD", "BIN ", 4096, 0, 2}, + {"eckd.raw", "ECKDLOAD", "BIN ", 4096, 0, 1}, + {"loader.raw", "DASDLOAD", "BIN ", 4096, 0, 2}, {"installed_files.txt", "HVF ", "TEXT ", 80, 1, 0}, {"8ball", "8BALL ", "NSS ", 4096, 0, 0}, {"ipldev", "IPLDEV ", "NSS ", 4096, 0, 0}, diff --git a/installer/edf.c b/installer/installer/edf.c similarity index 100% rename from installer/edf.c rename to installer/installer/edf.c diff --git a/installer/linker.script b/installer/installer/linker.script similarity index 75% rename from installer/linker.script rename to installer/installer/linker.script index cd07fd6..4a6edbd 100644 --- a/installer/linker.script +++ b/installer/installer/linker.script @@ -2,7 +2,11 @@ SECTIONS { ENTRY(MAIN) . = 0x100000; - .text : { *(.text) } + + .text : { + *setmode.o(.text) + *(.text) + } .data : { *(.data) } .rodata : { *(.rodata) } .rodata.str1.2 : { *(.rodata.str1.2) } diff --git a/installer/loader.h b/installer/installer/loader.h similarity index 100% rename from installer/loader.h rename to installer/installer/loader.h diff --git a/installer/loader_asm.s b/installer/installer/loader_asm.s similarity index 98% rename from installer/loader_asm.s rename to installer/installer/loader_asm.s index 7cb4d25..3008368 100644 --- a/installer/loader_asm.s +++ b/installer/installer/loader_asm.s @@ -1,9 +1,7 @@ # -# Copyright (c) 2007-2011 Josef 'Jeff' Sipek +# Copyright (c) 2007-2019 Josef 'Jeff' Sipek # -#include "loader.h" - .text .align 4 .globl __wait_for_attn diff --git a/installer/loader_c.c b/installer/installer/loader_c.c similarity index 100% rename from installer/loader_c.c rename to installer/installer/loader_c.c diff --git a/installer/malloc.c b/installer/installer/malloc.c similarity index 100% rename from installer/malloc.c rename to installer/installer/malloc.c diff --git a/installer/setmode.s b/installer/installer/setmode.s similarity index 100% rename from installer/setmode.s rename to installer/installer/setmode.s diff --git a/installer/rdr-ipl-rec/.hgignore b/installer/rdr-ipl-rec/.hgignore new file mode 100644 index 0000000..98a59e6 --- /dev/null +++ b/installer/rdr-ipl-rec/.hgignore @@ -0,0 +1,4 @@ +syntax: glob + +rdr +rdr.s diff --git a/installer/rdr-ipl-rec/Makefile b/installer/rdr-ipl-rec/Makefile new file mode 100644 index 0000000..d617a81 --- /dev/null +++ b/installer/rdr-ipl-rec/Makefile @@ -0,0 +1,34 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +BIN= rdr +SRCS= rdr.s +BITS= 31 + +CLEANSRCS= rdr.s + +.include <${.CURDIR:H:H}/build.mk> + +all: rdr.raw + +rdr.s: ${.CURDIR:H}/installer/installer.raw + ${SRCTOP}/build/ccw_gen 00080000 80100000 ${.ALLSRC} 100000 080000 > ${.TARGET} diff --git a/installer/linker-rdr.script b/installer/rdr-ipl-rec/linker.script similarity index 100% rename from installer/linker-rdr.script rename to installer/rdr-ipl-rec/linker.script diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt deleted file mode 100644 index 2220e20..0000000 --- a/lib/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_library(clock clock.c) -add_library(digest digest.c) -add_library(string string.c vsprintf.c) -add_library(ebcdic ebcdic.c ascii.c) -add_library(errno errno.c) diff --git a/lib/Makefile b/lib/Makefile new file mode 100644 index 0000000..827ea95 --- /dev/null +++ b/lib/Makefile @@ -0,0 +1,33 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +LIB= lib +SRCS= ascii.c \ + clock.c \ + digest.c \ + ebcdic.c \ + errno.c \ + string.c \ + vsprintf.c +BITS= 64 + +.include <${.CURDIR:H}/build.mk> diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt deleted file mode 100644 index b929f5f..0000000 --- a/loader/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -add_executable(loader setmode.s loader_c.c loader_asm.s) -set_target_properties(loader PROPERTIES LINK_FLAGS "-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.script") - -add_custom_command( - OUTPUT loader.rto - COMMAND ${CMAKE_OBJCOPY} -O binary -j .text -j .data -j .rodata -j .rodata.str1.2 loader loader.rto - DEPENDS loader -) - -add_executable(eckd eckd.s) -set_target_properties(eckd PROPERTIES LINK_FLAGS "-T ${CMAKE_CURRENT_SOURCE_DIR}/linker-eckd.script") - -add_custom_command( - OUTPUT eckd.rto - COMMAND ${CMAKE_OBJCOPY} -O binary -j .text -j .data -j .rodata -j .rodata.str1.2 eckd eckd.rto - DEPENDS eckd -) - -add_custom_target(loader-rto ALL DEPENDS eckd.rto loader.rto) diff --git a/loader/Makefile b/loader/Makefile new file mode 100644 index 0000000..be4b575 --- /dev/null +++ b/loader/Makefile @@ -0,0 +1,25 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +all clean: + $(MAKE) -C eckd-ipl-rec $@ + $(MAKE) -C loader $@ diff --git a/loader/.hgignore b/loader/eckd-ipl-rec/.hgignore similarity index 57% copy from loader/.hgignore copy to loader/eckd-ipl-rec/.hgignore index f308e3f..4a07f67 100644 --- a/loader/.hgignore +++ b/loader/eckd-ipl-rec/.hgignore @@ -1,6 +1,3 @@ syntax: glob -*.rto - eckd -loader diff --git a/loader/eckd-ipl-rec/Makefile b/loader/eckd-ipl-rec/Makefile new file mode 100644 index 0000000..5cc49b0 --- /dev/null +++ b/loader/eckd-ipl-rec/Makefile @@ -0,0 +1,29 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +BIN= eckd +SRCS= eckd.s +BITS= 31 + +.include <${.CURDIR:H:H}/build.mk> + +all: eckd.raw diff --git a/loader/eckd.s b/loader/eckd-ipl-rec/eckd.s similarity index 100% rename from loader/eckd.s rename to loader/eckd-ipl-rec/eckd.s diff --git a/loader/linker-eckd.script b/loader/eckd-ipl-rec/linker.script similarity index 100% rename from loader/linker-eckd.script rename to loader/eckd-ipl-rec/linker.script diff --git a/loader/layout.txt b/loader/layout.txt index e4b8829..da41bdd 100644 --- a/loader/layout.txt +++ b/loader/layout.txt @@ -1,8 +1,6 @@ dasd layout: -0,0,1 eckd.s -0,0,2 setmode.s - loader.c - loader_asm.s +0,0,1 eckd-ipl-rec/eckd.raw +0,0,2 loader/loader.raw hvf.elf diff --git a/loader/.hgignore b/loader/loader/.hgignore similarity index 63% rename from loader/.hgignore rename to loader/loader/.hgignore index f308e3f..d6cf056 100644 --- a/loader/.hgignore +++ b/loader/loader/.hgignore @@ -1,6 +1,3 @@ syntax: glob -*.rto - -eckd loader diff --git a/loader/loader/Makefile b/loader/loader/Makefile new file mode 100644 index 0000000..0cc2e04 --- /dev/null +++ b/loader/loader/Makefile @@ -0,0 +1,31 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +BIN= loader +SRCS= setmode.s \ + loader_c.c \ + loader_asm.s +BITS= 64 + +.include <${.CURDIR:H:H}/build.mk> + +all: loader.raw diff --git a/loader/linker.script b/loader/loader/linker.script similarity index 75% rename from loader/linker.script rename to loader/loader/linker.script index 89c07aa..3a874df 100644 --- a/loader/linker.script +++ b/loader/loader/linker.script @@ -2,7 +2,10 @@ SECTIONS { ENTRY(MAIN) . = 0x800000; - .text : { *(.text) } + .text : { + *setmode.o(.text) + *(.text) + } .data : { *(.data) } .rodata : { *(.rodata) } .rodata.str1.2 : { *(.rodata.str1.2) } diff --git a/loader/loader.h b/loader/loader/loader.h similarity index 100% rename from loader/loader.h rename to loader/loader/loader.h diff --git a/loader/loader_asm.s b/loader/loader/loader_asm.s similarity index 99% rename from loader/loader_asm.s rename to loader/loader/loader_asm.s index 08210fd..6164fc1 100644 --- a/loader/loader_asm.s +++ b/loader/loader/loader_asm.s @@ -2,8 +2,6 @@ # Copyright (c) 2007 Josef 'Jeff' Sipek # -#include "loader.h" - .text .align 4 .globl __do_io diff --git a/loader/loader_c.c b/loader/loader/loader_c.c similarity index 97% rename from loader/loader_c.c rename to loader/loader/loader_c.c index f990e43..860d145 100644 --- a/loader/loader_c.c +++ b/loader/loader/loader_c.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2009 Josef 'Jeff' Sipek + * Copyright (c) 2007-2019 Josef 'Jeff' Sipek */ #include "loader.h" @@ -39,22 +39,20 @@ static inline void die(void) for(;;); } -static u64 pgm_new_psw[2] = { - 0x0000000180000000ULL, (u64) &PGMHANDLER, -}; - /* * determine amount of storage */ static u64 sense_memsize(void) { + volatile u64 *pgm_psw = (void *) 0x1d0; u64 size; int cc; #define SKIP_SIZE (1024*1024ULL) /* set new PGM psw */ - memcpy((void*)0x1d0, pgm_new_psw, 16); + pgm_psw[0] = 0x0000000180000000ULL; + pgm_psw[1] = (u64) &PGMHANDLER; for(size = 0; size < ((u64)~SKIP_SIZE)-1; size += SKIP_SIZE) { asm volatile( @@ -81,7 +79,7 @@ static u64 sense_memsize(void) } /* invalidate new PGM psw */ - memset((void*)0x1d0, 0, 16); + memset((void *) pgm_psw, 0, 16); return size; } diff --git a/loader/setmode.s b/loader/loader/setmode.s similarity index 100% rename from loader/setmode.s rename to loader/loader/setmode.s diff --git a/nss/8ball/.hgignore b/nss/8ball/.hgignore index 699abe2..2a78689 100644 --- a/nss/8ball/.hgignore +++ b/nss/8ball/.hgignore @@ -1,5 +1,3 @@ syntax: glob 8ball -8ball.o -8ball.raw diff --git a/nss/8ball/CMakeLists.txt b/nss/8ball/CMakeLists.txt deleted file mode 100644 index 92860d7..0000000 --- a/nss/8ball/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -set(CMAKE_EXE_LINKER_FLAGS "-melf_s390 -T ${CMAKE_CURRENT_SOURCE_DIR}/linker-8ball.script") -set(CMAKE_ASM-ATT_FLAGS "-m31") - -add_executable(8ball 8ball.s) diff --git a/nss/8ball/Makefile b/nss/8ball/Makefile new file mode 100644 index 0000000..8b6eda9 --- /dev/null +++ b/nss/8ball/Makefile @@ -0,0 +1,27 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +BIN= 8ball +SRCS= 8ball.s +BITS= 31 + +.include <${.CURDIR:H:H}/build.mk> diff --git a/nss/8ball/linker-8ball.script b/nss/8ball/linker.script similarity index 100% rename from nss/8ball/linker-8ball.script rename to nss/8ball/linker.script diff --git a/nss/CMakeLists.txt b/nss/CMakeLists.txt deleted file mode 100644 index 8c909c5..0000000 --- a/nss/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_subdirectory(8ball) -add_subdirectory(ipldev) -add_subdirectory(login) diff --git a/nss/Makefile b/nss/Makefile new file mode 100644 index 0000000..1ba78ae --- /dev/null +++ b/nss/Makefile @@ -0,0 +1,26 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +all clean: + $(MAKE) -C 8ball $@ + $(MAKE) -C ipldev $@ + $(MAKE) -C login $@ diff --git a/nss/ipldev/CMakeLists.txt b/nss/ipldev/CMakeLists.txt deleted file mode 100644 index 3a6e67d..0000000 --- a/nss/ipldev/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -set(CMAKE_EXE_LINKER_FLAGS "-melf_s390 -T ${CMAKE_CURRENT_SOURCE_DIR}/linker.script") -set(CMAKE_ASM-ATT_FLAGS "-m31") - -add_executable(ipldev entry.s) diff --git a/nss/ipldev/Makefile b/nss/ipldev/Makefile new file mode 100644 index 0000000..bdca5fd --- /dev/null +++ b/nss/ipldev/Makefile @@ -0,0 +1,27 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +BIN= ipldev +SRCS= entry.s +BITS= 31 + +.include <${.CURDIR:H:H}/build.mk> diff --git a/nss/login/CMakeLists.txt b/nss/login/CMakeLists.txt deleted file mode 100644 index b6f8901..0000000 --- a/nss/login/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I ${CMAKE_CURRENT_SOURCE_DIR}") - -set(CMAKE_EXE_LINKER_FLAGS "-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.script") - -add_executable(login entry.s psa.s int.s die.s main.c io.c mch.c prg.c) diff --git a/nss/login/Makefile b/nss/login/Makefile new file mode 100644 index 0000000..6df3623 --- /dev/null +++ b/nss/login/Makefile @@ -0,0 +1,34 @@ +# +# Copyright (c) 2019 Josef 'Jeff' Sipek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +BIN= login +SRCS= entry.s \ + psa.s \ + int.s \ + die.s \ + main.c \ + io.c \ + mch.c \ + prg.c +BITS= 64 + +.include <${.CURDIR:H:H}/build.mk> diff --git a/nss/login/io.c b/nss/login/io.c index 96ab85d..2273561 100644 --- a/nss/login/io.c +++ b/nss/login/io.c @@ -1,11 +1,11 @@ /* - * (C) Copyright 2007-2011 Josef 'Jeff' Sipek + * (C) Copyright 2007-2019 Josef 'Jeff' Sipek * * This file is released under the GPLv2. See the COPYING file for more * details. */ -#include +#include "misc.h" void io_int() { diff --git a/nss/login/linker.script b/nss/login/linker.script index 34801f8..105fae2 100644 --- a/nss/login/linker.script +++ b/nss/login/linker.script @@ -3,10 +3,10 @@ SECTIONS ENTRY(START) . = 0; - .psa : { *psa.s.o(.data) } + .psa : { *psa.o(.data) } . = 0x100000 - 160; - .stack : { *entry.s.o(.data) } + .stack : { *entry.o(.data) } . = 0x2000; .text : { *(.text) } diff --git a/nss/login/main.c b/nss/login/main.c index 188a3c9..cbe85ac 100644 --- a/nss/login/main.c +++ b/nss/login/main.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2007-2011 Josef 'Jeff' Sipek + * (C) Copyright 2007-2019 Josef 'Jeff' Sipek * * This file is released under the GPLv2. See the COPYING file for more * details. @@ -7,8 +7,8 @@ #include #include -#include -#include +#include "int.h" +#include "misc.h" /* * This guest OS has a very simple purpose. It is responsible for diff --git a/nss/login/mch.c b/nss/login/mch.c index 5faa51c..2bd9bbd 100644 --- a/nss/login/mch.c +++ b/nss/login/mch.c @@ -1,11 +1,11 @@ /* - * (C) Copyright 2007-2011 Josef 'Jeff' Sipek + * (C) Copyright 2007-2019 Josef 'Jeff' Sipek * * This file is released under the GPLv2. See the COPYING file for more * details. */ -#include +#include "misc.h" void mch_int() { diff --git a/nss/login/prg.c b/nss/login/prg.c index ef47f58..4ef0260 100644 --- a/nss/login/prg.c +++ b/nss/login/prg.c @@ -1,11 +1,11 @@ /* - * (C) Copyright 2007-2011 Josef 'Jeff' Sipek + * (C) Copyright 2007-2019 Josef 'Jeff' Sipek * * This file is released under the GPLv2. See the COPYING file for more * details. */ -#include +#include "misc.h" void prg_int() { -- 2.11.4.GIT