Compare commits
8 Commits
c476b08c03
...
fe3b014e09
| Author | SHA1 | Date | |
|---|---|---|---|
| fe3b014e09 | |||
| 67ae16a756 | |||
| 5bc9ff4fd1 | |||
| 728e1f057c | |||
| b62052f619 | |||
| 2c41f1a77a | |||
| 7a51a56909 | |||
| cff399fdba |
@@ -16,6 +16,9 @@ include(Templates)
|
||||
bsp_reset()
|
||||
sysroot_reset()
|
||||
|
||||
sysroot_set_base(
|
||||
PATH ${CMAKE_SOURCE_DIR}/base)
|
||||
|
||||
add_subdirectory(kernel)
|
||||
add_subdirectory(sys)
|
||||
add_subdirectory(lib)
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
include(System-Disk)
|
||||
include(QEMU)
|
||||
include(Bochs)
|
||||
|
||||
18
arch/x86_64/Bochs.cmake
Normal file
18
arch/x86_64/Bochs.cmake
Normal file
@@ -0,0 +1,18 @@
|
||||
find_program(BOCHS bochs)
|
||||
|
||||
if (NOT BOCHS)
|
||||
message(STATUS "Bochs: cannot find bochs")
|
||||
return()
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET cdrom)
|
||||
message(STATUS "Bochs: CD-ROM image creation is unavailable. Cannot use bochs")
|
||||
return()
|
||||
endif ()
|
||||
|
||||
message(STATUS "Bochs: Enable CD-ROM boot")
|
||||
add_custom_target(run-cdrom-bochs
|
||||
COMMAND ${BOCHS} -q -f ${CMAKE_SOURCE_DIR}/arch/${CMAKE_SYSTEM_PROCESSOR}/bochsrc.bxrc
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
DEPENDS cdrom)
|
||||
@@ -1,27 +1,34 @@
|
||||
find_program(QEMU qemu-system-${TARGET_ARCH} REQUIRED)
|
||||
find_program(LLDB lldb REQUIRED)
|
||||
if (NOT QEMU)
|
||||
message(STATUS "QEMU: Cannot find qemu-system-${TARGET_ARCH}. Direct-kernel boot unavailable")
|
||||
return()
|
||||
endif ()
|
||||
|
||||
find_program(LLDB lldb)
|
||||
find_program(GDB gdb)
|
||||
|
||||
set(patched_kernel ${CMAKE_CURRENT_BINARY_DIR}/kernel/${kernel_name}.elf32)
|
||||
|
||||
add_custom_command(OUTPUT ${patched_kernel}
|
||||
DEPENDS ${kernel_name}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
$<TARGET_FILE:${kernel_name}>
|
||||
${patched_kernel}
|
||||
COMMAND ${BUILD_TOOLS_DIR}/e64patch ${patched_kernel}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Patching kernel elf64 image"
|
||||
)
|
||||
|
||||
message(STATUS "QEMU: Enable direct-kernel boot")
|
||||
add_custom_target(run-kernel
|
||||
COMMAND
|
||||
${QEMU}
|
||||
-kernel $<TARGET_FILE:${kernel_name}>
|
||||
-kernel ${patched_kernel}
|
||||
-initrd ${sys_dir}/${bsp_name}
|
||||
-m 1G -serial stdio
|
||||
-m 1G -serial stdio -enable-kvm
|
||||
--append kernel.early-console=ttyS0
|
||||
USES_TERMINAL
|
||||
DEPENDS ${kernel_name} bsp)
|
||||
|
||||
add_custom_target(debug-kernel
|
||||
COMMAND
|
||||
${QEMU}
|
||||
-kernel $<TARGET_FILE:${kernel_name}>
|
||||
-initrd ${sys_dir}/${bsp_name}
|
||||
-m 1G -s -S &
|
||||
${LLDB}
|
||||
-o "file ${CMAKE_BINARY_DIR}/kernel/${kernel_name}.debug"
|
||||
-o "gdb-remote localhost:1234"
|
||||
USES_TERMINAL
|
||||
DEPENDS ${kernel_name} bsp)
|
||||
DEPENDS ${patched_kernel} bsp)
|
||||
|
||||
add_custom_target(run-kernel-monitor
|
||||
COMMAND
|
||||
@@ -31,3 +38,73 @@ add_custom_target(run-kernel-monitor
|
||||
-m 1G -monitor stdio
|
||||
USES_TERMINAL
|
||||
DEPENDS ${kernel_name} bsp)
|
||||
|
||||
if (image_cdrom)
|
||||
message(STATUS "QEMU: Enable CD-ROM boot")
|
||||
add_custom_target(run-cdrom
|
||||
COMMAND
|
||||
${QEMU}
|
||||
-cdrom ${image_cdrom}
|
||||
-m 1G
|
||||
-serial stdio
|
||||
USES_TERMINAL
|
||||
DEPENDS ${image_cdrom})
|
||||
endif ()
|
||||
|
||||
if (LLDB)
|
||||
message(STATUS "QEMU: Enable direct-kernel debug with LLDB")
|
||||
add_custom_target(debug-kernel
|
||||
COMMAND
|
||||
${QEMU}
|
||||
-kernel $<TARGET_FILE:${kernel_name}>
|
||||
-initrd ${sys_dir}/${bsp_name}
|
||||
-enable-kvm
|
||||
-m 1G -s -S &
|
||||
${LLDB}
|
||||
-o "file ${CMAKE_BINARY_DIR}/kernel/${kernel_name}.debug"
|
||||
-o "gdb-remote localhost:1234"
|
||||
USES_TERMINAL
|
||||
DEPENDS ${kernel_name} bsp)
|
||||
|
||||
if (image_cdrom)
|
||||
message(STATUS "QEMU: Enable CD-ROM debug with LLDB")
|
||||
add_custom_target(debug-cdrom
|
||||
COMMAND
|
||||
${QEMU}
|
||||
-cdrom ${image_cdrom}
|
||||
-m 1G -s -S &
|
||||
${LLDB}
|
||||
-o "file ${CMAKE_BINARY_DIR}/kernel/${kernel_name}.debug"
|
||||
-o "target remote localhost:1234"
|
||||
USES_TERMINAL
|
||||
DEPENDS cdrom)
|
||||
endif ()
|
||||
elseif (GDB)
|
||||
message(STATUS "QEMU: Enable direct-kernel debug with GDB")
|
||||
add_custom_target(debug-kernel
|
||||
COMMAND
|
||||
${QEMU}
|
||||
-kernel $<TARGET_FILE:${kernel_name}>
|
||||
-initrd ${sys_dir}/${bsp_name}
|
||||
-m 1G -s -S &
|
||||
${GDB}
|
||||
-o "file ${CMAKE_BINARY_DIR}/kernel/${kernel_name}.debug"
|
||||
-o "remote localhost:1234"
|
||||
USES_TERMINAL
|
||||
DEPENDS ${kernel_name} bsp)
|
||||
|
||||
if (image_cdrom)
|
||||
message(STATUS "QEMU: Enable CD-ROM debug with GDB")
|
||||
add_custom_target(debug-cdrom
|
||||
COMMAND
|
||||
${QEMU}
|
||||
-cdrom ${image_cdrom}
|
||||
-m 1G -s -S &
|
||||
${GDB} -tui
|
||||
-s "${CMAKE_BINARY_DIR}/kernel/${kernel_name}.debug"
|
||||
-ex "target remote localhost:1234"
|
||||
USES_TERMINAL
|
||||
DEPENDS ${image_cdrom})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
17
arch/x86_64/System-Disk.cmake
Normal file
17
arch/x86_64/System-Disk.cmake
Normal file
@@ -0,0 +1,17 @@
|
||||
find_program(GRUB_MKRESCUE grub-mkrescue)
|
||||
|
||||
if (GRUB_MKRESCUE)
|
||||
message(STATUS "GRUB: Found grub-mkrescue. Bootable CD-ROM image creation is enabled")
|
||||
set(image_cdrom ${CMAKE_CURRENT_BINARY_DIR}/rosetta-system.iso)
|
||||
|
||||
add_custom_target(cdrom
|
||||
DEPENDS sysroot
|
||||
COMMAND ${GRUB_MKRESCUE}
|
||||
-o ${image_cdrom}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/sysroot
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Building GRUB CD-ROM image"
|
||||
)
|
||||
else ()
|
||||
message(STATUS "Cannot find grub-mkrescue. Bootable CD-ROM image creation is unavailable")
|
||||
endif ()
|
||||
53
arch/x86_64/bochsrc.bxrc
Normal file
53
arch/x86_64/bochsrc.bxrc
Normal file
@@ -0,0 +1,53 @@
|
||||
# configuration file generated by Bochs
|
||||
plugin_ctrl: unmapped=true, biosdev=true, speaker=true, extfpuirq=true, parallel=true, serial=true, iodebug=true
|
||||
config_interface: textconfig
|
||||
display_library: sdl2
|
||||
memory: guest=128, host=128, block_size=128
|
||||
romimage: file="/usr/local/share/bochs/BIOS-bochs-latest", address=0x00000000, options=none, flash_data=none
|
||||
vgaromimage: file="/usr/local/share/bochs/VGABIOS-lgpl-latest.bin"
|
||||
boot: cdrom
|
||||
floppy_bootsig_check: disabled=0
|
||||
floppya: type=1_44
|
||||
# no floppyb
|
||||
ata0: enabled=true, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
|
||||
ata0-master: type=cdrom, path="rosetta-system.iso", status=inserted, model="Generic 1234", biosdetect=auto
|
||||
ata0-slave: type=none
|
||||
ata1: enabled=true, ioaddr1=0x170, ioaddr2=0x370, irq=15
|
||||
ata1-master: type=none
|
||||
ata1-slave: type=none
|
||||
ata2: enabled=false
|
||||
ata3: enabled=false
|
||||
optromimage1: file=none
|
||||
optromimage2: file=none
|
||||
optromimage3: file=none
|
||||
optromimage4: file=none
|
||||
optramimage1: file=none
|
||||
optramimage2: file=none
|
||||
optramimage3: file=none
|
||||
optramimage4: file=none
|
||||
pci: enabled=1, chipset=i440fx, slot1=none, slot2=none, slot3=none, slot4=none, slot5=none
|
||||
vga: extension=vbe, update_freq=10, realtime=1, ddc=builtin, vbe_memsize=16
|
||||
cpu: count=1:1:1, ips=4000000, quantum=16, model=core2_penryn_t9600, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0
|
||||
print_timestamps: enabled=0
|
||||
debugger_log: -
|
||||
magic_break: enabled=1 0x0
|
||||
port_e9_hack: enabled=false, all_rings=false
|
||||
iodebug: all_rings=0
|
||||
private_colormap: enabled=0
|
||||
clock: sync=none, time0=local, rtc_sync=0
|
||||
# no cmosimage
|
||||
log: -
|
||||
logprefix: %t%e%d
|
||||
debug: action=ignore
|
||||
info: action=report
|
||||
error: action=report
|
||||
panic: action=ask
|
||||
keyboard: type=mf, serial_delay=150, paste_delay=100000, user_shortcut=none
|
||||
mouse: type=ps2, enabled=false, toggle=ctrl+mbutton
|
||||
speaker: enabled=true, mode=system
|
||||
parport1: enabled=true, file=none
|
||||
parport2: enabled=false
|
||||
com1: enabled=true, mode=null
|
||||
com2: enabled=false
|
||||
com3: enabled=false
|
||||
com4: enabled=false
|
||||
11
base/boot/grub/grub.cfg
Normal file
11
base/boot/grub/grub.cfg
Normal file
@@ -0,0 +1,11 @@
|
||||
menuentry "Rosetta" {
|
||||
multiboot /boot/mango_kernel
|
||||
module /boot/rosetta-system.bsp
|
||||
boot
|
||||
}
|
||||
|
||||
menuentry "Rosetta (Serial Log)" {
|
||||
multiboot /boot/mango_kernel kernel.early-console=ttyS0
|
||||
module /boot/rosetta-system.bsp
|
||||
boot
|
||||
}
|
||||
@@ -9,6 +9,34 @@ function(sysroot_reset)
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
endfunction(sysroot_reset)
|
||||
|
||||
function(sysroot_set_base)
|
||||
set(options)
|
||||
set(one_value_args PATH)
|
||||
set(multi_value_args)
|
||||
|
||||
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||
"${options}"
|
||||
"${one_value_args}"
|
||||
"${multi_value_args}")
|
||||
|
||||
set(sysroot_target_name _sysroot-base)
|
||||
|
||||
get_property(sysroot_targets GLOBAL PROPERTY sysroot_target_list)
|
||||
list(LENGTH sysroot_targets nr_sysroot_targets)
|
||||
if (${nr_sysroot_targets} GREATER 0)
|
||||
math(EXPR serialiser_index "${nr_sysroot_targets}-1")
|
||||
list(GET sysroot_targets ${serialiser_index} serialiser)
|
||||
endif ()
|
||||
|
||||
add_custom_target(${sysroot_target_name}
|
||||
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
|
||||
set-base ${sysroot_manifest} ${arg_PATH}
|
||||
COMMENT "Preparing sysroot base"
|
||||
DEPENDS ${serialiser})
|
||||
|
||||
set_property(GLOBAL PROPERTY sysroot_target_list ${sysroot_targets} ${sysroot_target_name})
|
||||
endfunction(sysroot_set_base)
|
||||
|
||||
function(sysroot_add_library)
|
||||
set(options)
|
||||
set(one_value_args NAME HEADER_DIR LIB_DIR)
|
||||
@@ -93,7 +121,6 @@ function(sysroot_add_object_library)
|
||||
endif ()
|
||||
|
||||
get_property(tmp TARGET ${target_name} PROPERTY SUFFIX)
|
||||
message(STATUS ${tmp})
|
||||
|
||||
set_property(GLOBAL PROPERTY sysroot_target_list ${sysroot_targets} ${sysroot_target_name})
|
||||
endfunction(sysroot_add_object_library)
|
||||
|
||||
2
kernel
2
kernel
Submodule kernel updated: 9a90662eaa...b2d04c5983
@@ -21,8 +21,8 @@
|
||||
/* TODO in case we ever support ELF32 images */
|
||||
#define elf_class_bits(x) (64)
|
||||
|
||||
#define PAGE_SIZE (page_size())
|
||||
#define PAGE_MASK (page_size() - 1)
|
||||
#define PAGE_SIZE (image->e_page_size)
|
||||
#define PAGE_MASK (image->e_page_size - 1)
|
||||
#define PAGE_OFFSET(v) ((v) & (PAGE_SIZE - 1))
|
||||
#define PAGE_ALIGN_DOWN(v) (v) &= ~(PAGE_SIZE - 1)
|
||||
#define PAGE_ALIGN_UP(v) \
|
||||
@@ -35,16 +35,6 @@
|
||||
|
||||
#undef DEBUG_LOG
|
||||
|
||||
static size_t page_size(void)
|
||||
{
|
||||
static size_t pagesz = 0;
|
||||
if (pagesz == 0) {
|
||||
kern_config_get(KERN_CFG_PAGE_SIZE, &pagesz, sizeof pagesz);
|
||||
}
|
||||
|
||||
return pagesz;
|
||||
}
|
||||
|
||||
static enum launch_status elf_validate_ehdr(elf_ehdr_t *hdr)
|
||||
{
|
||||
if (hdr->e_ident[EI_MAG0] != ELF_MAG0) {
|
||||
@@ -488,6 +478,7 @@ void elf_image_init(struct elf_image *out)
|
||||
{
|
||||
memset(out, 0x0, sizeof(*out));
|
||||
|
||||
kern_config_get(KERN_CFG_PAGE_SIZE, &out->e_page_size, sizeof out->e_page_size);
|
||||
out->e_image = KERN_HANDLE_INVALID;
|
||||
out->e_data = KERN_HANDLE_INVALID;
|
||||
out->e_local_space = KERN_HANDLE_INVALID;
|
||||
|
||||
@@ -289,6 +289,7 @@ struct bootdata;
|
||||
struct bootfs_file;
|
||||
|
||||
struct elf_image {
|
||||
size_t e_page_size;
|
||||
kern_handle_t e_image, e_data;
|
||||
kern_handle_t e_local_space, e_remote_space;
|
||||
kern_handle_t e_local_exec, e_remote_exec;
|
||||
|
||||
@@ -9,6 +9,8 @@ SECTIONS {
|
||||
.data ALIGN(4K) : {
|
||||
*(.data)
|
||||
*(.bss)
|
||||
*(.got*)
|
||||
*(.eh_frame)
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
|
||||
Submodule sys/ropkg updated: abf86b1733...10603ed2d1
@@ -58,20 +58,22 @@ class Component:
|
||||
class Manifest:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
self.base = None
|
||||
self.components = {}
|
||||
|
||||
def load(self):
|
||||
with open(self.path, 'r') as f:
|
||||
self.data = json.load(f)
|
||||
|
||||
if 'components' not in self.data:
|
||||
return 0
|
||||
|
||||
if 'components' in self.data:
|
||||
for n, t in self.data['components'].items():
|
||||
component = Component()
|
||||
component.deserialise(t)
|
||||
self.components[n] = component
|
||||
|
||||
if 'base' in self.data:
|
||||
self.base = self.data['base']
|
||||
|
||||
|
||||
def save(self):
|
||||
component_data = {}
|
||||
@@ -81,6 +83,9 @@ class Manifest:
|
||||
|
||||
self.data['components'] = component_data
|
||||
|
||||
if self.base is not None:
|
||||
self.data['base'] = self.base
|
||||
|
||||
with open(self.path, 'w') as f:
|
||||
json.dump(self.data, f, indent=4)
|
||||
|
||||
@@ -97,5 +102,14 @@ class Manifest:
|
||||
self.components[name] = component
|
||||
return component
|
||||
|
||||
|
||||
def set_base(self, path):
|
||||
self.base = path
|
||||
|
||||
|
||||
def get_base(self):
|
||||
return self.base
|
||||
|
||||
|
||||
def get_all_components(self):
|
||||
return self.components
|
||||
|
||||
@@ -16,6 +16,24 @@ def reset():
|
||||
return 0
|
||||
|
||||
|
||||
def set_base():
|
||||
if len(sys.argv) < 4:
|
||||
print("USAGE: {} set-base <manifest-path> <base-directory>".format(sys.argv[0]))
|
||||
return -1
|
||||
|
||||
manifest_path = sys.argv[2]
|
||||
base_path = sys.argv[3]
|
||||
|
||||
manifest = Manifest(manifest_path)
|
||||
manifest.load()
|
||||
|
||||
manifest.set_base(base_path)
|
||||
|
||||
manifest.save()
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def add_headers():
|
||||
if len(sys.argv) < 6:
|
||||
print("USAGE: {} add-headers <manifest-path> <component-name> <dest-directory> <source-directory>".format(sys.argv[0]))
|
||||
@@ -73,6 +91,13 @@ def build_sysroot():
|
||||
manifest = Manifest(manifest_path)
|
||||
manifest.load()
|
||||
|
||||
base_dir = manifest.get_base()
|
||||
if base_dir is not None:
|
||||
shutil.copytree(
|
||||
base_dir,
|
||||
sysroot_path,
|
||||
dirs_exist_ok=True)
|
||||
|
||||
for n, c in manifest.get_all_components().items():
|
||||
for h in c.get_headers():
|
||||
header_src = h['src']
|
||||
@@ -122,6 +147,7 @@ if len(sys.argv) < 2:
|
||||
|
||||
commands = {
|
||||
'reset': reset,
|
||||
'set-base': set_base,
|
||||
'add-headers': add_headers,
|
||||
'add-binary': add_binary,
|
||||
'build-sysroot': build_sysroot,
|
||||
|
||||
Reference in New Issue
Block a user