diff --git a/Makefile b/Makefile index e283d22..812ce22 100644 --- a/Makefile +++ b/Makefile @@ -139,9 +139,16 @@ DriverSources = drivers/ata.c DriverObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(DriverSources)) DriverDep=$(patsubst %.c,$(KOBJDIR)/%.d,$(DriverSources)) +# Userspace sources +UserSources = user/test/test.c + +UserObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(UserSources)) +UserDep=$(patsubst %.c,$(KOBJDIR)/%.d,$(UserSources)) + -include $(LibCDep) -include $(KernDep) -include $(DriverDep) +-include $(UserDep) ## MISC MAKEFILE ------------------------------------------------------------- # @@ -275,6 +282,12 @@ $(KOBJDIR)/drivers/ata.o: $(KALEIDDIR)/drivers/ata.c $(KALEIDDIR)/drivers/ata.as @rm -f $@.1 $@.2 @echo ${CL2}[$@] ${CL}Compiled.${CL3} +## USERSPACE SPECIAL RECIPES MAKEFILE ---------------------------------------- # + +$(KOBJDIR)/user/test/test.o: $(KALEIDDIR)/user/test/test.asm | $(KOBJDIR) + @mkdir -p $(shell dirname $@) + @$(ASM) $(ASMFLAGS) $(KALEIDDIR)/user/test/test.asm -o $@ + @echo ${CL2}[$@] ${CL}Compiled.${CL3} ## DEPENDENCIES MAKEFILE ----------------------------------------------------- # @@ -297,12 +310,12 @@ $(BINDIR)/kaleid: $(LOBJDIR)/kaleid.x86_64 $(BINDIR)/kaleid @echo ${CL2}[$@] ${CL}Success.${CL3} -$(LOBJDIR)/kaleid.x86_64: $(LibCObj) $(KernObj) $(DriverObj) \ +$(LOBJDIR)/kaleid.x86_64: $(LibCObj) $(KernObj) $(DriverObj) $(UserObj) \ $(LOBJDIR)/loader.o $(BUILDDIR)/kernel.ld @echo ${CL2}[$@] ${NC}Linking kernel objects...${CL3} @mkdir -p $(shell dirname $@) @$(LD) $(LDFLAGS) -T $(BUILDDIR)/kernel.ld \ - $(LOBJDIR)/loader.o $(KernObj) $(DriverObj) $(LibCObj) \ + $(LOBJDIR)/loader.o $(KernObj) $(DriverObj) $(LibCObj) $(UserObj) \ -o $(LOBJDIR)/kaleid.x86_64 @echo ${CL2}[$@] ${CL}Success.${CL3} diff --git a/ProjectTree b/ProjectTree index cec7fd2..63f33e2 100644 --- a/ProjectTree +++ b/ProjectTree @@ -165,16 +165,19 @@ │   │   ├── bscan.c │   │   ├── bscroll.c │   │   └── bwrite.c -│   └── libc -│   ├── atoi.c -│   ├── ctype.c -│   ├── errno.c -│   ├── itoa.c -│   ├── mem.c -│   ├── rand.c -│   ├── sprintf.c -│   ├── string.c -│   └── strtol.c +│   ├── libc +│   │   ├── atoi.c +│   │   ├── ctype.c +│   │   ├── errno.c +│   │   ├── itoa.c +│   │   ├── mem.c +│   │   ├── rand.c +│   │   ├── sprintf.c +│   │   ├── string.c +│   │   └── strtol.c +│   └── user +│   └── test +│   └── test.asm ├── AUTHORS ├── ChangeLog ├── COPYING @@ -182,4 +185,4 @@ ├── ProjectTree └── README.md -39 directories, 118 files +41 directories, 119 files diff --git a/kaleid/user/test/test.asm b/kaleid/user/test/test.asm new file mode 100644 index 0000000..808d813 --- /dev/null +++ b/kaleid/user/test/test.asm @@ -0,0 +1,39 @@ +;=----------------------------------------------------------------------------=; +; OS on Kaleid ; +; ; +; Desc: Usermode test code ; +; ; +; ; +; Copyright © 2018-2021 The OS/K Team ; +; ; +; This file is part of OS/K. ; +; ; +; OS/K is free software: you can redistribute it and/or modify ; +; it under the terms of the GNU General Public License as published by ; +; the Free Software Foundation, either version 3 of the License, or ; +; (at your option) any later version. ; +; ; +; OS/K is distributed in the hope that it will be useful, ; +; but WITHOUT ANY WARRANTY; without even the implied warranty of ; +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; +; GNU General Public License for more details. ; +; ; +; You should have received a copy of the GNU General Public License ; +; along with OS/K. If not, see . ; +;=----------------------------------------------------------------------------=; + +[BITS 64] + +global UserTest +global EndOfUser + +UserTest: + mov rdi, 13 + int 0x80 + +.clone: + nop + jmp .clone + +EndOfUser: + nop