Skip to content

Commit bf7cf48

Browse files
committed
update: partial start TurboVision
1 parent a6214f6 commit bf7cf48

File tree

21 files changed

+1624
-301
lines changed

21 files changed

+1624
-301
lines changed

.c

Lines changed: 0 additions & 6 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ log/
1414
/build/obj
1515
/build/dep
1616
/build/dep/coff
17+
/build
18+
/build/dep

Makefile

Lines changed: 77 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# -----------------------------------------------------------------------------
22
# \file Makefile
3-
# \note (c) 2025, 2026 by Jens Kallup - paule32
3+
# \note (c) 2025 by Jens Kallup - paule32
44
# all rights reserved.
55
# -----------------------------------------------------------------------------
66
# we only support MinGW 32-bit and Linux Systems ...
77
# -----------------------------------------------------------------------------
8-
.ONESHELL:
9-
SHELL := /bin/sh
108
CYGPATH := cygpath
119

1210
MAKE_VERSION_LINE := $(shell $(MAKE) --version 2>/dev/null | head -n 1)
@@ -143,7 +141,7 @@ endif
143141
# GNU Toolchain binary avatar's ...
144142
# -----------------------------------------------------------------------------
145143
MAKE := $(shell command which make )$(EXT)
146-
AS := $(shell command which nasm )$(EXT)
144+
AS := $(shell command which as )$(EXT)
147145
ECHO := $(shell command which echo )$(EXT)
148146
GZIP := $(shell command which gzip )$(EXT)
149147
RM := $(shell command which rm )$(EXT)
@@ -171,11 +169,15 @@ OBJCOPY := $(shell command which objcopy)$(EXT)
171169
# LICENSE in the root directory of this reporsitory.
172170
# -----------------------------------------------------------------------------
173171
#.PHONY: confirm
174-
all: confirm clean setup $(BIN_DIR)/bootcd.iso shell32
172+
all: confirm clean setup shell32 $(BIN_DIR)/bootcd.iso
175173
setup:
176174
$(MKDIR) -p $(BUI_DIR) $(BUI_DIR)/bin $(BUI_DIR)/bin/content $(BUI_DIR)/hex
177175
$(MKDIR) -p $(BIN_DIR)/content/img $(BUI_DIR)/obj $(BUI_DIR)/obj/pe
178-
$(MKDIR) -p $(OBJ_DIR)/user32 $(OBJ_DIR)/user32/rtl
176+
$(MKDIR) -p $(OBJ_DIR)/user32/TurboVision/platform
177+
$(MKDIR) -p $(OBJ_DIR)/user32/TurboVision
178+
$(MKDIR) -p $(OBJ_DIR)/user32/rtl
179+
$(MKDIR) -p $(OBJ_DIR)/user32/shell32
180+
179181
$(COPY) $(IMG_DIR)/*.bmp $(BIN_DIR)/content/img
180182
( cd $(SRC_DIR)/fntres ;\
181183
$(SRC_DIR)/fntres/build.sh ;\
@@ -257,7 +259,10 @@ CFLAGS_C := -m32 -O1 -ffreestanding -Wall -Wextra \
257259
-Wno-missing-field-initializers \
258260
-D__BUILD_DATE__=\"$(DATE_YMD)\" \
259261
-D__BUILD_TIME__=\"$(TIME_HMS)\" \
260-
-I$(SRC_DIR)/kernel/include \
262+
-I$(SRC_DIR)/kernel/include \
263+
-I$(SRC_DIR)/user32 \
264+
-I$(SRC_DIR)/user32/TurboVision \
265+
-I$(SRC_DIR)/user32/TurboVision/include \
261266
-I$(SRC_DIR)/fntres
262267

263268
CFLAGS_CC:= -std=c++20 $(CFLAGS_C) \
@@ -297,11 +302,15 @@ BIN := $(BASEDIR)/build/bin
297302
PART_START_SECTOR := 2048
298303
USB_SIZE_MIB := 64
299304

305+
KERNEL_PASS := 0
306+
SHELL32_PASS := 1
307+
300308
# -----------------------------------------------------------------------------
301309
# source files for the C-kernel ...
302310
# -----------------------------------------------------------------------------
303311
SRC_SHELL :=\
304-
$(SRC)/user32/shell32/shell.cc
312+
$(SRC)/user32/shell32/shell32.cc \
313+
$(SRC)/user32/rtl/rtl_ExitProcess.c
305314

306315
RUN_CPO := \
307316
$(OBJ_DIR)/coff/cpp_runtime.o \
@@ -402,15 +411,16 @@ OBJS := $(OBJ_DIR)/coff/ckernel.o \
402411
# -----------------------------------------------------------------------------
403412
# *.o bject files for linkage stage of the shell ...
404413
# -----------------------------------------------------------------------------
405-
SHOBJS :=
414+
SHOBJS := \
415+
$(OBJ_DIR)/user32/shell32/shell32.o \
416+
$(OBJ_DIR)/user32/TurboVision/Hardware.o \
417+
$(OBJ_DIR)/user32/TurboVision/platform/strings.o \
418+
$(OBJ_DIR)/user32/rtl/rtl_ExitProcess.o
406419

407420
ISO_FILES := /boot2.bin /kernel.bin
408421
LBA := $(COR_DIR)/lba.inc
409422
ISO := $(BIN_DIR)/bootcd.iso
410423

411-
#all: $(OBJ)/coff/data.o
412-
#$(BIN)/bootcd.iso
413-
414424
# -----------------------------------------------------------------------------
415425
# Ziel-Datei mit den extrahierten Infos
416426
# -----------------------------------------------------------------------------
@@ -457,16 +467,23 @@ define MOD-LBA
457467
sub(/^\/+/ , "", name); \
458468
sub(/\.[^./]*$$/, "", name); \
459469
name = toupper(name); \
460-
print name "_LBA equ ", $$6 " ; start LBA ", name; \
461-
print name "_SECTORS equ ", $$8 " ; 2048 * " , $$8 ; \
470+
print name "_LBA equ ", $$6, " ; start LBA ", name; \
471+
print name "_SECTORS equ ", $$8, " ; 2048 * " , $$8 ; \
462472
print "; -----------------------------------------------------"; \
463473
} }' >> $(LBA); \
464474
done \
465475
)
466476
@echo "VBE_INFO_ADDR equ 0x0A00" >> $(LBA)
467477

468-
$(AS) -DLBA_FILE=\"$(COR_DIR)/lba.inc\" -f bin $(COR_DIR)/boot/boot1.asm -o $(BIN_DIR)/content/boot1.bin
469-
$(AS) -DLBA_FILE=\"$(COR_DIR)/lba.inc\" -f bin $(COR_DIR)/boot/boot2.asm -o $(BIN_DIR)/content/boot2.bin
478+
nasm -DLBA_FILE=\"$(COR_DIR)/lba.inc\" \
479+
-f bin $(COR_DIR)/boot/boot1.asm \
480+
-o $(BIN_DIR)/content/boot1.bin \
481+
-l $(BIN_DIR)/boot1.lst
482+
483+
nasm -DLBA_FILE=\"$(COR_DIR)/lba.inc\" \
484+
-f bin $(COR_DIR)/boot/boot2.asm \
485+
-o $(BIN_DIR)/content/boot2.bin \
486+
-l $(BIN_DIR)/boot2.lst
470487

471488
$(XORRISO) -as mkisofs -o $(BIN_DIR)/bootcd.iso \
472489
-b boot1.bin \
@@ -480,52 +497,60 @@ endef
480497
# loader to load the system from DOS console ...
481498
# -----------------------------------------------------------------------------
482499
$(BIN_DIR)/content/boot1.bin: $(COR_DIR)/boot/boot1.asm
483-
$(AS) -DLBA_FILE=\"$(COR_DIR)/lba.inc\" -f bin $< -o $@
500+
nasm -DLBA_FILE=\"$(COR_DIR)/lba.inc\" -f bin $< -o $@
484501
$(BIN_DIR)/content/boot2.bin: $(COR_DIR)/boot/boot2.asm
485-
$(AS) -DLBA_FILE=\"$(COR_DIR)/lba.inc\" -f bin $< -o $@
502+
nasm -DLBA_FILE=\"$(COR_DIR)/lba.inc\" -f bin $< -o $@
486503
# -----------------------------------------------------------------------------
487504
# compile all *.c, *.cc, and *.asm files to *.o bject files ...
488505
# -----------------------------------------------------------------------------
489506
define compile_rule
490-
$(OBJ_DIR)/coff/%.s: $(1)/%.c
507+
$(2)/%.s: $(3)/%.c
491508
$(MKDIR) -p $(dir $$@) $(DEP_DIR)/coff/$(dir $$*)
492509
$(GCC) -m32 $(CFLAGS_C) -MMD -MP \
493510
-MF $(DEP_DIR)/coff/$$*.d -MT $$@ \
494511
-S $$< -o $$@
495-
$(OBJ_DIR)/coff/%.o: $(OBJ_DIR)/coff/%.s
496-
$(SED) -i "/^[[:space:]]*\.ident[[:space:]]*\"GCC:/d" $$<
497-
$(GCC) -m32 $(CFLAGS_C) -MMD -MP \
498-
-MF $(DEP_DIR)/coff/$$*.d -MT $$@ \
499-
-c $$< -o $$@
512+
@if [ "$(1)" = "$(SHELL32_PASS)" ]; then \
513+
@echo "PASS=$(1) SHELL32_PASS=$(SHELL32_PASS)" ;\
514+
$(SED) -i "/^[[:space:]]*\.ident[[:space:]]*\"GCC:/d" $$@; \
515+
fi
500516

501-
$(OBJ_DIR)/coff/%.s: $(1)/%.cc
517+
$(2)/%.s: $(3)/%.cc
502518
$(MKDIR) -p $(dir $$@) $(DEP_DIR)/coff/$(dir $$*)
503519
$(CPP) -m32 $(CFLAGS_CC) -MMD -MP \
504520
-MF $(DEP_DIR)/coff/$$*.d -MT $$@ \
505521
-S $$< -o $$@
506-
$(OBJ_DIR)/coff/%.o: $(OBJ_DIR)/coff/%.s
507-
$(SED) -i "/^[[:space:]]*\.ident[[:space:]]*\"GCC:/d" $$<
508-
$(GCC) $(CFLAGS_C) -MMD -MP \
509-
-MF $(DEP_DIR)/coff/$$*.d -MT $$@ \
510-
-c $$< -o $$@
522+
@if [ "$(1)" = "$(SHELL32_PASS)" ]; then \
523+
@echo "PASS=$(1) SHELL32_PASS=$(SHELL32_PASS)" ;\
524+
$(SED) -i "/^[[:space:]]*\.ident[[:space:]]*\"GCC:/d" $$@; \
525+
fi
511526

512-
$(OBJ_DIR)/coff/%.o: $(1)/%.asm
527+
$(2)/%.o: $(3)/%.s
528+
$(GCC) -m32 $(CFLAGS_C) -c $$< -o $$(patsubst %.s,%.o,$$@)
529+
530+
$(2)/%.o: $(3)/%.asm
513531
$(MKDIR) -p $(dir $$@)
514-
$(AS) $(ASMFLAGS) $$< -o $$@
532+
nasm $(ASMFLAGS) $$< -o $$@
515533
endef
516534

517-
$(eval $(call compile_rule,$(COR_DIR)))
518-
$(eval $(call compile_rule,$(COR_DIR)/fs/iso9660))
519-
$(eval $(call compile_rule,$(COR_DIR)/video))
535+
$(eval $(call compile_rule,$(KERNEL_PASS),$(OBJ_DIR)/coff,$(COR_DIR)))
536+
$(eval $(call compile_rule,$(KERNEL_PASS),$(OBJ_DIR)/coff,$(COR_DIR)/fs/iso9660))
537+
$(eval $(call compile_rule,$(KERNEL_PASS),$(OBJ_DIR)/coff,$(COR_DIR)/video))
520538

521539
# -----------------------------------------------------------------------------
522540
# compile rule for program loaders ...
523541
# -----------------------------------------------------------------------------
524-
$(eval $(call compile_rule,$(COR_DIR)/loader/elf))
525-
$(eval $(call compile_rule,$(COR_DIR)/loader/pe))
542+
$(eval $(call compile_rule,$(KERNEL_PASS),$(OBJ_DIR)/coff,$(COR_DIR)/loader/elf))
543+
$(eval $(call compile_rule,$(KERNEL_PASS),$(OBJ_DIR)/coff,$(COR_DIR)/loader/pe))
544+
545+
$(eval $(call compile_rule,$(KERNEL_PASS),$(OBJ_DIR)/coff,$(SRC_DIR)/fntres))
526546

527-
$(eval $(call compile_rule,$(SRC_DIR)/fntres))
528-
$(eval $(call compile_rule,$(SRC_DIR)/user32/shell32))
547+
# -----------------------------------------------------------------------------
548+
# static RTL - run time library ...
549+
# -----------------------------------------------------------------------------
550+
$(eval $(call compile_rule,$(SHELL32_PASS),$(OBJ_DIR)/user32/TurboVision,$(SRC_DIR)/user32/TurboVision/src))
551+
$(eval $(call compile_rule,$(SHELL32_PASS),$(OBJ_DIR)/user32/TurboVision/platform,$(SRC_DIR)/user32/TurboVision/src/platform))
552+
$(eval $(call compile_rule,$(SHELL32_PASS),$(OBJ_DIR)/user32/rtl,$(SRC_DIR)/user32/rtl))
553+
$(eval $(call compile_rule,$(SHELL32_PASS),$(OBJ_DIR)/user32/shell32,$(SRC_DIR)/user32/shell32))
529554

530555
DEPS := $(patsubst $(OBJ_DIR)/coff/%.o,$(DEP_DIR)/coff/%.d,$(OBJS))
531556
-include $(DEPS)
@@ -538,103 +563,40 @@ $(OBJ_DIR)/coff/kernel.o: $(OBJS) $(COR_DIR)/kernel.ld
538563
-Wl,-T,$(COR_DIR)/kernel.ld -Wl,-Map,$(BIN_DIR)/kernel.map \
539564
-o $@ $(OBJS)
540565

541-
# $(LD) $(LDFLAGS) -o $(OBJ_DIR)/coff/kernel.o $(OBJS)
542566
$(OBJ_DIR)/kernel.bin: $(OBJ_DIR)/coff/kernel.o
543567
$(OBJCOPY) -O binary $< $@
544568
# -----------------------------------------------------------------------------
545-
$(OBJ)/data.o: $(SRC)/initrd.dat $(SRC)/data.asm
546-
$(AS) $(ASMFLAGS) $(SRC)/data.asm -o $(OBJ)/data.o
547-
# -----------------------------------------------------------------------------
548-
# create the initial ram disk ...
549-
# -----------------------------------------------------------------------------
550-
$(SRC)/initrd.dat: $(BIN)/INITRD.EXE
551-
$(BIN)/INITRD.EXE \
552-
test1.txt file1 \
553-
test2.txt file2 \
554-
test3.txt file3
555-
556-
$(BIN)/INITRD.EXE: $(OBJ)/make_initrd.o
557-
$(GCC) -m32 -mconsole -O2 -Wall -Wextra -o $@ $<
558-
$(STRIP) $@
559-
# -----------------------------------------------------------------------------
560-
# ELF shell32 application
569+
# create PE32 shell32 application
561570
# -----------------------------------------------------------------------------
562-
define shell32_build
563-
$(CPP) -m32 -mconsole $(CFLAGS_C) \
564-
-o $(OBJ_DIR)/user32/shell32/$(1).s \
565-
-S $(SRC_DIR)/user32/shell32/$(1).$(2)
566-
567-
$(SED) -i "/^[[:space:]]*\.ident[[:space:]]*\"GCC:/d" \
568-
$(OBJ_DIR)/user32/shell32/$(1).s
569-
570-
$(GCC) -m32 -mconsole $(CFLAGS_C) \
571-
-o $(OBJ_DIR)/user32/shell32/$(1).o \
572-
-c $(OBJ_DIR)/user32/shell32/$(1).s
573-
574-
$(eval SHOBJS += $(OBJ_DIR)/user32/shell32/$(1).o)
575-
endef
576-
$(BIN_DIR)/content/shell32.exe: shell32_importer $(SHOBJS) \
571+
$(BIN_DIR)/content/shell32.exe: $(SHOBJS) \
577572
$(SRC_DIR)/user32/shell32/shell32.ld
578-
$(MKDIR) -p $(OBJ_DIR)/user32/shell32
579-
$(call shell32_build,shell32,cc)
580573
$(GCC) -m32 -mconsole $(CFLAGS_C) -o $(BIN_DIR)/content/shell32.exe $(SHOBJS)
581574

582575
shell32: $(BIN_DIR)/content/shell32.exe
583576
strip $(BIN_DIR)/content/shell32.exe
577+
objcopy --remove-section .eh_frame \
578+
--remove-section .eh_frame_hdr \
579+
--remove-section .gcc_except_table \
580+
$(BIN_DIR)/content/shell32.exe \
581+
$(BIN_DIR)/content/shell32.exe
584582
echo "dodo"
585-
586-
define shell32_imports
587-
mkdir -p $(OBJ_DIR)/user32/rtl
588-
awk -v pat="$(2)" '
589-
BEGIN {
590-
print "# include \"stdint.h\"";
591-
print "# include \"proto.h\"";
592-
print "";
593-
}
594-
$$0 ~ pat {
595-
name=$$NF;
596-
sub(/\(.*/, "", name);
597-
printf "__attribute__((section(\".symbol\"), used))\n";
598-
printf "uint32_t %s = %s;\n\n", name, $$1
599-
};
600-
' $(BIN_DIR)/kernel.map > $(OBJ_DIR)/user32/rtl/imp_$(2).c
601-
602-
$(GCC) -m32 $(CFLAGS_C) -o $(OBJ_DIR)/user32/rtl/imp_$(2).s -S $(OBJ_DIR)/user32/rtl/imp_$(2).c
603-
$(SED) -i "/^[[:space:]]*\.ident[[:space:]]*\"GCC:/d" $(OBJ_DIR)/user32/rtl/imp_$(2).s
604-
$(GCC) -m32 $(CFLAGS_C) -o $(OBJ_DIR)/user32/rtl/imp_$(2).o -c $(OBJ_DIR)/user32/rtl/imp_$(2).s
605-
606-
$(GCC) -m32 $(CFLAGS_C) -o $(OBJ_DIR)/user32/rtl/rtl_$(1).s -S $(SRC_DIR)/user32/rtl/rtl_$(1).c
607-
$(SED) -i "/^[[:space:]]*\.ident[[:space:]]*\"GCC:/d" $(OBJ_DIR)/user32/rtl/rtl_$(1).s
608-
$(GCC) -m32 $(CFLAGS_C) -o $(OBJ_DIR)/user32/rtl/rtl_$(1).o -c $(OBJ_DIR)/user32/rtl/rtl_$(1).s
609-
610-
$(eval SHOBJS += $(OBJ_DIR)/user32/rtl/rtl_$(1).o)
611-
$(eval SHOBJS += $(OBJ_DIR)/user32/rtl/imp_$(2).o)
612-
613-
614-
echo $(SHOBJS)
615-
endef
616-
617-
shell32_importer:
618-
$(MKDIR) -p $(OBJ_DIR)/user32
619-
$(call shell32_imports,ExitProcess,RtlExitProcess)
620583

621584
$(BIN_DIR)/bootcd.iso: \
622-
$(BIN_DIR)/content/boot1.bin $(BIN_DIR)/content/boot2.bin \
623-
$(OBJ_DIR)/coff/int86_blob.o \
624-
$(OBJ_DIR)/kernel.bin
585+
$(BIN_DIR)/content/boot1.bin $(BIN_DIR)/content/boot2.bin \
586+
$(OBJ_DIR)/coff/int86_blob.o \
587+
$(OBJ_DIR)/kernel.bin
625588
@( export __BIN_DIR=$(BIN_DIR) ;\
626589
export __COR_DIR=$(COR_DIR) ;\
627590
export __OBJ_DIR=$(OBJ_DIR)/coff ;\
628-
export __BIN_AS=$(AS) ;\
591+
export __BIN_AS=nasm ;\
629592
$(COR_DIR)/create_iso.sh ;\
630593
)
631594
$(MOD-LBA)
632-
$(shell32)
633595

634596
$(OBJ_DIR)/coff/int86_switch.bin: $(COR_DIR)/int86_switch.asm
635-
$(AS) -f bin -o $(OBJ_DIR)/coff/int86_switch.bin $(COR_DIR)/int86_switch.asm
597+
nasm -f bin -o $(OBJ_DIR)/coff/int86_switch.bin $(COR_DIR)/int86_switch.asm
636598
$(OBJ_DIR)/coff/int86_blob.o: $(OBJ_DIR)/coff/int86_switch.bin
637-
$(AS) -DSWITCH_BLOB=\"$(OBJ_DIR)/coff/int86_switch.bin\" -f win32 -o $(OBJ_DIR)/coff/int86_blob.o $(COR_DIR)/int86_blob.asm
599+
nasm -DSWITCH_BLOB=\"$(OBJ_DIR)/coff/int86_switch.bin\" -f win32 -o $(OBJ_DIR)/coff/int86_blob.o $(COR_DIR)/int86_blob.asm
638600
# -----------------------------------------------------------------------------
639601
# prepare font ...
640602
# -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)