Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ mainmenu "Zeal 8-bit OS Configuration"
endif

source "kernel/Kconfig"
source "romdisk/Kconfig"
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ else
export KCONFIG_CONFIG = $(ZOS_CONFIG)
endif
endif
# Convert to absolute path
override KCONFIG_CONFIG := $(abspath $(KCONFIG_CONFIG))
export KCONFIG_CONFIG

export MENUCONFIG_STYLE = aquatic
export OSCONFIG_ASM = include/osconfig.asm
Expand All @@ -52,7 +55,7 @@ INCLUDEDIRS:=
PRECMD :=
POSTCMD :=

# Before including the Makefiles, include the configuration one if it exists
# Before including the Makefiles, include the configuration once if it exists
-include $(KCONFIG_CONFIG)

# Define the TARGET as a make variable. In other words, remove the quotes which surround
Expand Down
12 changes: 11 additions & 1 deletion configs/zeal8bit.default
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,21 @@ CONFIG_KERNEL_MAX_LOADED_DRIVERS=16
CONFIG_KERNEL_MAX_OPENED_DEVICES=16
CONFIG_KERNEL_MAX_OPENED_FILES=16
CONFIG_KERNEL_PATH_MAX=128
CONFIG_KERNEL_INIT_EXECUTABLE="A:/init.bin"
CONFIG_KERNEL_INIT_EXECUTABLE_ADDR=0x4000
CONFIG_KERNEL_LOG_BOOT_MOUNTED_DISKS=y
CONFIG_KERNEL_ENABLE_ZEALFS_SUPPORT=y
# CONFIG_KERNEL_ZEALFS_V1 is not set
CONFIG_KERNEL_ZEALFS_V2=y
CONFIG_KERNEL_ENABLE_MBR_SUPPORT=y
# end of Kernel configuration

#
# Romdisk
#
CONFIG_KERNEL_INIT_EXECUTABLE="A:/init.bin"
CONFIG_ROMDISK_EXTRA_FILES=""
CONFIG_ROMDISK_INCLUDE_INIT_BIN=y
# CONFIG_INITBIN_ENABLE_COREUTILS is not set
CONFIG_ROMDISK_INCLUDE_SIMPLE_TXT=y
CONFIG_ROMDISK_IGNORE_HIDDEN=y
# end of Romdisk
12 changes: 11 additions & 1 deletion configs/zealemu.default
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,21 @@ CONFIG_KERNEL_MAX_LOADED_DRIVERS=16
CONFIG_KERNEL_MAX_OPENED_DEVICES=16
CONFIG_KERNEL_MAX_OPENED_FILES=16
CONFIG_KERNEL_PATH_MAX=128
CONFIG_KERNEL_INIT_EXECUTABLE="A:/init.bin"
CONFIG_KERNEL_INIT_EXECUTABLE_ADDR=0x4000
CONFIG_KERNEL_LOG_BOOT_MOUNTED_DISKS=y
CONFIG_KERNEL_ENABLE_ZEALFS_SUPPORT=y
# CONFIG_KERNEL_ZEALFS_V1 is not set
CONFIG_KERNEL_ZEALFS_V2=y
CONFIG_KERNEL_ENABLE_MBR_SUPPORT=y
# end of Kernel configuration

#
# Romdisk
#
CONFIG_KERNEL_INIT_EXECUTABLE="A:/init.bin"
CONFIG_ROMDISK_EXTRA_FILES=""
CONFIG_ROMDISK_INCLUDE_INIT_BIN=y
# CONFIG_INITBIN_ENABLE_COREUTILS is not set
CONFIG_ROMDISK_INCLUDE_SIMPLE_TXT=y
CONFIG_ROMDISK_IGNORE_HIDDEN=y
# end of Romdisk
8 changes: 1 addition & 7 deletions kernel/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ menu "Kernel configuration"
Maximum length of a single absolute file path. Incrementing this value will make
the kernel use more RAM.

config KERNEL_INIT_EXECUTABLE
string "Executable to launch on boot"
default "A:/init.bin"
help
Executable to load and execute on after system boot

config KERNEL_INIT_EXECUTABLE_ADDR
hex "Virtual address to load the initial program in"
range 0x4000 0xFF00
Expand Down Expand Up @@ -174,4 +168,4 @@ menu "Kernel configuration"
parsing Master Boot Record (MBR) partition tables. Disable this option if
MBR support is not required to reduce kernel size.

endmenu
endmenu
51 changes: 51 additions & 0 deletions romdisk/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
menu "Romdisk"

config KERNEL_INIT_EXECUTABLE
string "Executable to launch on boot"
default "A:/init.bin"
help
Executable to load and execute on after system boot

config ROMDISK_EXTRA_FILES
string "Paths to extra files (space-separated)"
default ""
help
Space-separated list of paths to additional files to include in the ROM disk.
Example: "path/to/file1.bin path/to/file2.txt ../another/file.dat"

config ROMDISK_INCLUDE_INIT_BIN
bool
prompt "Include init.bin"
default n
help
Boolean to mark whether to include init.bin in the romdisk.
If this option is selected, "init.bin" will be included on A:/

config INITBIN_ENABLE_COREUTILS
bool
prompt "Enable zeal-coreutils"
depends on ROMDISK_INCLUDE_INIT_BIN
default n
help
Boolean to mark whether the user is including zeal-coreutils.
If this option is selected, the "coreutils" commands will be ommited from
the init.bin shell (ie; ls, cp, mkdir, rm, etc)


config ROMDISK_INCLUDE_SIMPLE_TXT
bool
prompt "Include simple.txt"
default n
help
Boolean to mark whether to include simple.txt on A:/
If this option is selected, "simple.txt" will be included on A:/

config ROMDISK_IGNORE_HIDDEN
bool
prompt "Ignore hidden and dot files"
default y
help
Boolean to mark whether to include hidden and dot files in the romdisk.
If this option is selected, hidden and dot files will be omitted from A:/

endmenu
40 changes: 34 additions & 6 deletions romdisk/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
# Before including the Makefiles, include the configuration one if it exists
-include $(KCONFIG_CONFIG)

# Final binary name
BIN=init.bin
# Source files to assemble
SRCS=init.asm parse.asm cat.asm ls.asm less.asm opt.asm mkdir.asm cd.asm rm.asm \
errors.asm uart.asm date.asm cp.asm misc.asm hexdump.asm \
sleep.asm expr.asm echo.asm xfer.asm

# shell core
SRCS=init.asm parse.asm opt.asm errors.asm uart.asm date.asm misc.asm
# shell commands that always exist
SRCS += cd.asm sleep.asm expr.asm

# Output directory to place binaries in
BUILDIR=build

# Name of the image file to make
IMG=disk.img
# Files to pack inside the image file
FILES_IN_IMG=$(BUILDIR)/$(BIN) simple.txt
FILES_IN_IMG=

ifdef CONFIG_ROMDISK_INCLUDE_INIT_BIN
FILES_IN_IMG += $(BUILDIR)/$(BIN)
endif

ifdef CONFIG_ROMDISK_INCLUDE_SIMPLE_TXT
FILES_IN_IMG += simple.txt
endif

EXTRA_ROMDISK_FILES := $(wildcard $(EXTRA_ROMDISK_FILES))


# If z88dk has been install through snap, the binary may be prefixed with "z88dk"
# So choose any of z88dk-* or z88dk.z88dk-*, as long as one exists
Expand All @@ -24,19 +41,30 @@ LIBS=-L$(ZOS_PATH)/kernel_headers/z88dk-z80asm/lib
ASMFLAGS=$(INCLUDES) $(LIBS) -lstrutils.lib -m -b


ifdef CONFIG_INITBIN_ENABLE_COREUTILS
ASMFLAGS += -DCONFIG_ENABLE_COREUTILS=1
else
SRCS += cat.asm mkdir.asm rm.asm cp.asm hexdump.asm echo.asm less.asm xfer.asm ls.asm
endif


.PHONY: all clean

all: clean
ifdef CONFIG_ROMDISK_INCLUDE_INIT_BIN
@mkdir -p $(BUILDIR)
@echo "Creating romdisk"
$(CC) $(ASMFLAGS) $(SRCS)
@echo "Moving generated files"
mv *.o ./$(BUILDIR) && mv *.map ./$(BUILDIR) && mv $(basename $(BIN))*.bin ./$(BUILDIR)
@# For some reasons, z88dk-z80asm will create an empty `init.bin` file, remove it
@rm -f $(BUILDIR)/$(BIN) && mv $(BUILDIR)/*_TEXT.bin $(BUILDIR)/$(BIN)
else
@echo "Skipping init.bin build (CONFIG_ROMDISK_INCLUDE_INIT_BIN not set)"
endif

with_image: all
@echo "Packing the files"
${ZOS_PATH}/tools/pack.py ${IMG} ${FILES_IN_IMG} ${EXTRA_ROMDISK_FILES}
${ZOS_PATH}/tools/pack.py ${IMG} ${FILES_IN_IMG}

clean:
rm -rf build/ $(IMG)
12 changes: 11 additions & 1 deletion romdisk/errors.asm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ _error_print_no_default:
ld (hl), 0
ret

PUBLIC open_error
open_error:
neg
ld de, str_open_err
ld bc, str_open_err_end - str_open_err
call error_print
ld a, 1
ret
str_open_err: DEFM "open error: "
str_open_err_end:

; Get the string associated to the given error code
; The returned address must NOT be altered.
Expand Down Expand Up @@ -200,4 +210,4 @@ err_not_a_dir: DEFM "Not a directory", 0
err_not_a_file: DEFM "Not a file", 0
err_entry_corrupted: DEFM "Entry corrupted", 0
err_dir_not_empty: DEFM "Directory not empty", 0
err_dir_not_empty_end:
err_dir_not_empty_end:
12 changes: 1 addition & 11 deletions romdisk/ls.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
; Routine to parse the options given in the command line
EXTERN get_options
EXTERN error_print
EXTERN open_error

; A static buffer that can be used across the commands implementation
EXTERN init_static_buffer
Expand Down Expand Up @@ -277,17 +278,6 @@ str_usage: DEFM "usage: ls <-options>\n"
DEFM " x - hex output\n"
str_usage_end:

PUBLIC open_error
open_error:
neg
ld de, str_open_err
ld bc, str_open_err_end - str_open_err
call error_print
ld a, 1
ret
str_open_err: DEFM "open error: "
str_open_err_end:

readdir_error:
ld de, str_rddir_err
ld bc, str_rddir_err_end - str_rddir_err
Expand Down
14 changes: 14 additions & 0 deletions romdisk/parse.asm
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,19 @@ help_msg_end:

SECTION DATA
system_commands_begin:
IF CONFIG_ENABLE_COREUTILS
NEW_COMMAND("cd", cd_main)
NEW_COMMAND("clear", clear_main)
NEW_COMMAND("date", date_main)
NEW_COMMAND("exec", exec_main)
NEW_COMMAND("expr", expr_main)
NEW_COMMAND("help", help_main)
NEW_COMMAND("load", load_main)
NEW_COMMAND("reset", reset_main)
NEW_COMMAND("sleep", sleep_main)
NEW_COMMAND("uartrcv", uartrcv_main)
NEW_COMMAND("uartsnd", uartsnd_main)
ELSE
NEW_COMMAND("cat", cat_main)
NEW_COMMAND("cd", cd_main)
NEW_COMMAND("clear", clear_main)
Expand All @@ -541,6 +554,7 @@ system_commands_begin:
NEW_COMMAND("uartrcv", uartrcv_main)
NEW_COMMAND("uartsnd", uartsnd_main)
NEW_COMMAND("xfer", xfer_main)
ENDIF
; Commands related to I2C
; DEFS MAX_COMMAND_NAME, "i2cdetect"
; DEFW i2cdetect_main
Expand Down
Loading