Add subprocesses and convert terminal to an app

This commit is contained in:
2026-06-17 21:20:14 +03:00
parent 1c935cf154
commit 03b3ddac73
28 changed files with 490 additions and 247 deletions
+70 -21
View File
@@ -38,7 +38,15 @@ kernel_entry_o = custom_target(
command: [nasm, '-f', 'elf64', '@INPUT@', '-o', '@OUTPUT@'],
)
syscall_o = custom_target('syscall',
process_o = custom_target(
'process',
input: 'src/kernel/process.asm',
output: 'process.o',
command: [nasm, '-f', 'elf64', '@INPUT@', '-o', '@OUTPUT@'],
)
syscall_o = custom_target(
'syscall',
input: 'src/kernel/syscall.asm',
output: 'syscall.o',
command: [nasm, '-f', 'elf64', '@INPUT@', '-o', '@OUTPUT@'],
@@ -46,10 +54,12 @@ syscall_o = custom_target('syscall',
cc = meson.get_compiler('c')
kernel_sources = files(
'src/kernel/app/cat.c',
'src/kernel/app/ls.c',
'src/kernel/app/terminal.c',
lib_sources = files([
'src/lib/memory.c',
'src/lib/string.c',
])
kernel_sources = files([
'src/kernel/ata.c',
'src/kernel/fat16.c',
'src/kernel/fs.c',
@@ -65,13 +75,11 @@ kernel_sources = files(
'src/kernel/syscall.c',
'src/kernel/tss.c',
'src/kernel/vga.c',
'src/lib/memory.c',
'src/lib/string.c',
)
])
kernel_elf = executable(
'kernel.elf',
sources: [kernel_entry_o, syscall_o, kernel_sources],
sources: [kernel_entry_o, process_o, syscall_o, lib_sources, kernel_sources],
c_args: [
'-ffreestanding',
'-nostdlib',
@@ -99,28 +107,29 @@ custom_target(
build_by_default: true,
)
hello_start = custom_target(
'hello_start',
terminal_start = custom_target(
'terminal_start',
input: 'src/user/start.asm',
output: 'hello_start.o',
output: 'terminal_start.o',
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
)
hello_syscall = custom_target(
'hello_syscall',
terminal_syscall = custom_target(
'terminal_syscall',
input: 'src/user/syscall.asm',
output: 'hello_syscall.o',
output: 'terminal_syscall.o',
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
)
hello_elf = executable(
'hello.elf',
sources: [hello_start, hello_syscall, 'src/user/app/hello/hello.c'],
terminal_elf = executable(
'terminal.elf',
sources: [terminal_start, terminal_syscall, lib_sources, 'src/user/app/terminal/terminal.c'],
c_args: [
'-ffreestanding',
'-nostdlib',
'-fno-stack-protector',
'-mcmodel=large',
'-DVERSION="' + meson.project_version() + '"',
],
link_args: [
'-T', meson.project_source_root() / 'src/user/linker.ld',
@@ -130,9 +139,49 @@ hello_elf = executable(
)
custom_target(
'hello_bin',
input: hello_elf,
output: 'hello.bin',
'terminal',
input: terminal_elf,
output: 'terminal',
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
build_by_default: true,
)
echo_start = custom_target(
'echo_start',
input: 'src/user/start.asm',
output: 'echo_start.o',
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
)
echo_syscall = custom_target(
'echo_syscall',
input: 'src/user/syscall.asm',
output: 'echo_syscall.o',
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
)
echo_elf = executable(
'echo.elf',
sources: [echo_start, echo_syscall, lib_sources, 'src/user/app/echo/echo.c'],
c_args: [
'-ffreestanding',
'-nostdlib',
'-fno-stack-protector',
'-mcmodel=large',
'-DVERSION="' + meson.project_version() + '"',
],
link_args: [
'-T', meson.project_source_root() / 'src/user/linker.ld',
'-nostdlib',
],
link_depends: 'src/user/linker.ld',
)
custom_target(
'echo',
input: echo_elf,
output: 'echo',
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
build_by_default: true,
)