Add a userspace code source

This commit is contained in:
Adrien Bourmault 2021-03-04 09:51:25 +01:00
parent 675d3a5924
commit 904492298f
Signed by: neox
GPG Key ID: 6EB408FE0ACEC664
3 changed files with 68 additions and 13 deletions

View File

@ -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}

View File

@ -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

39
kaleid/user/test/test.asm Normal file
View File

@ -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 <https://www.gnu.org/licenses/>. ;
;=----------------------------------------------------------------------------=;
[BITS 64]
global UserTest
global EndOfUser
UserTest:
mov rdi, 13
int 0x80
.clone:
nop
jmp .clone
EndOfUser:
nop