diff --git a/libraries/constants.rake b/libraries/constants.rake index af2c9026..a91b881a 100644 --- a/libraries/constants.rake +++ b/libraries/constants.rake @@ -2,10 +2,13 @@ DEFINES = (ENV['DEFINES'] || '') + ' -DPACKAGE=\\"storm\\" -DVERSION=\\"git\\"' +# For a saner gdb experience, you typically want to compile without optimizations unless specifically making a release. +OPTIMIZATION_FLAG = ENV['RELEASE'] ? '-O3' : '-O0' + COMMON_CFLAGS = "-Wall -Wextra -Wshadow -Wpointer-arith -Waggregate-return -Wredundant-decls \ -Winline -Werror -Wcast-align -Wsign-compare -Wmissing-declarations \ - -Wmissing-noreturn -pipe -O3 -fno-builtin -funsigned-char \ + -Wmissing-noreturn -pipe #{OPTIMIZATION_FLAG} -fno-builtin -funsigned-char \ -g -m32 -fomit-frame-pointer -ffreestanding #{ENV['EXTRA_CFLAGS']} #{DEFINES} ".freeze CFLAGS = COMMON_CFLAGS + diff --git a/libraries/file/file.c b/libraries/file/file.c index 08798bed..fab9b60c 100644 --- a/libraries/file/file.c +++ b/libraries/file/file.c @@ -113,7 +113,7 @@ return_type file_open(ipc_structure_type *vfs_structure, char *file_name, file_m } // Read from a file. -return_type file_read(ipc_structure_type *vfs_structure, file_handle_type file_handle, unsigned int length, void *buffer) +return_type file_read(ipc_structure_type *vfs_structure, file_handle_type file_handle, unsigned int length, uint8_t *buffer) { message_parameter_type message_parameter; file_read_type read; diff --git a/libraries/file/functions.h b/libraries/file/functions.h index f9511b9c..2901e39b 100644 --- a/libraries/file/functions.h +++ b/libraries/file/functions.h @@ -12,4 +12,4 @@ extern return_type file_init(ipc_structure_type *vfs_structure, tag_type *tag); extern return_type file_directory_entry_read(ipc_structure_type *vfs_structure, file_directory_entry_read_type *directory_entry); extern return_type file_get_info(ipc_structure_type *vfs_structure, file_verbose_directory_entry_type *directory_entry); extern return_type file_open(ipc_structure_type *vfs_structure, char *file_name, file_mode_type mode, file_handle_type *handle); -extern return_type file_read(ipc_structure_type *vfs_structure, file_handle_type file_handle, unsigned int length, void *buffer); +extern return_type file_read(ipc_structure_type *vfs_structure, file_handle_type file_handle, unsigned int length, uint8_t *buffer); diff --git a/libraries/ipc/file.h b/libraries/ipc/file.h index 3e78f575..f45d1b98 100644 --- a/libraries/ipc/file.h +++ b/libraries/ipc/file.h @@ -88,6 +88,9 @@ typedef struct { // The location where we want this volume to be mounted. char location[MAX_PATH_NAME_LENGTH]; + + // The mailbox ID of the mailbox for talking to the block device server. + mailbox_id_type mailbox_id; } file_mount_type; typedef struct diff --git a/libraries/ipc/virtual_file_system.h b/libraries/ipc/virtual_file_system.h index 42804516..d15ec8c9 100644 --- a/libraries/ipc/virtual_file_system.h +++ b/libraries/ipc/virtual_file_system.h @@ -61,16 +61,6 @@ enum IPC_RETURN_VIRTUAL_FILE_SYSTEM_FUNCTION_UNSUPPORTED, }; -// Type definitions. -typedef struct -{ - // The location where we want this volume to be mounted. - char location[MAX_PATH_NAME_LENGTH]; - - // The mailbox ID of the mailbox for talking to the block device server. - mailbox_id_type mailbox_id; -} virtual_file_system_mount_type; - typedef struct { char meta_location[MAX_PATH_NAME_LENGTH]; diff --git a/menu.lst b/menu.lst index 0604e4c4..8166a422 100644 --- a/menu.lst +++ b/menu.lst @@ -20,8 +20,5 @@ module /servers/ipv4.gz module /servers/pci.gz module /servers/virtual_file_system.gz -# Boot server last, since it kind of expects everything else to be up and running. +# Boot server last, since it more-or-less expects everything else to be up and running. module /servers/boot.gz - -# Cluido temporarily here, until we have resolved https://github.com/chaos4ever/chaos/issues/45 -module /programs/cluido.gz diff --git a/programs/programs.rake b/programs/programs.rake index 8f351204..e5574ef6 100644 --- a/programs/programs.rake +++ b/programs/programs.rake @@ -92,9 +92,9 @@ task :clean do end task install: OUTPUT do - target_path = INSTALL_ROOT + '/programs' + target_path = 'u:/programs' + + sh "mcopy -o #{OUTPUT} #{target_path}" - sh "#{INSTALL_COMMAND} #{OUTPUT} #{target_path}/#{OUTPUT}" - sh "gzip -9f #{target_path}/#{OUTPUT}" puts " Installed #{OUTPUT} in #{target_path}".gray end diff --git a/programs/startup b/programs/startup index 642e7abb..fc7b4969 100644 --- a/programs/startup +++ b/programs/startup @@ -1 +1 @@ -programs/cluido +//ramdisk/PROGRAMS/CLUIDO diff --git a/servers/block/initial_ramdisk/Rakefile b/servers/block/initial_ramdisk/Rakefile index 76f7f77e..8068bf13 100644 --- a/servers/block/initial_ramdisk/Rakefile +++ b/servers/block/initial_ramdisk/Rakefile @@ -15,6 +15,7 @@ LIBRARIES = %w[ OUTPUT = 'initial_ramdisk'.freeze RAMDISK_IMAGE = 'ramdisk.image'.freeze +EXTRA_LDFLAGS_PRE = '-Wl,--defsym=PROCESS_VM_BASE=0x50000000' desc 'Creates the initial ramdisk image' task :create_ramdisk_image do diff --git a/servers/block/initial_ramdisk/initial_ramdisk.c b/servers/block/initial_ramdisk/initial_ramdisk.c index 3de251c6..0d7ae3db 100644 --- a/servers/block/initial_ramdisk/initial_ramdisk.c +++ b/servers/block/initial_ramdisk/initial_ramdisk.c @@ -42,7 +42,7 @@ static void handle_connection(mailbox_id_type *reply_mailbox_id) ipc_structure_type ipc_structure; bool done = FALSE; uint32_t *data; - unsigned int data_size = 1024; + unsigned int data_size = 2048; memory_allocate((void **) &data, data_size); diff --git a/servers/file_system/virtual_file_system/virtual_file_system.c b/servers/file_system/virtual_file_system/virtual_file_system.c index cf5a6ad6..2f3c1f85 100644 --- a/servers/file_system/virtual_file_system/virtual_file_system.c +++ b/servers/file_system/virtual_file_system/virtual_file_system.c @@ -477,16 +477,49 @@ static bool vfs_file_read(file_read_type *read, void *buffer) } // Mount the given service at the given location. -static bool vfs_mount(file_mount_type *mount, ipc_structure_type *ipc_structure) +static bool vfs_mount(file_mount_type *mount) { - memory_copy(&mount_point[mounted_volumes].ipc_structure, ipc_structure, sizeof(ipc_structure_type)); + // FIXME: We only support one file_system implementation for now. A proper implementation would gather a more comprehensive + // list of file system services, attempt to mount the volume with them all and see which one is successful. + mailbox_id_type mailbox_id[1]; + unsigned int services = 1; + + if (ipc_service_resolve("file_system", mailbox_id, &services, 5, &empty_tag) != IPC_RETURN_SUCCESS) + { + log_print_formatted(&log_structure, LOG_URGENCY_ERROR, "vfs_mount: Failed to resolve file_system service"); + return FALSE; + } + + mount_point[mounted_volumes].ipc_structure.output_mailbox_id = mailbox_id[0]; + if (ipc_service_connection_request(&mount_point[mounted_volumes].ipc_structure) != IPC_RETURN_SUCCESS) + { + log_print_formatted(&log_structure, LOG_URGENCY_ERROR, + "vfs_mount: Failed to establish connection with file system service with mailbox ID %u", + mailbox_id[0]); + return FALSE; + } + + message_parameter_type message_parameter; + message_parameter.protocol = IPC_PROTOCOL_FILE; + message_parameter.message_class = IPC_FILE_MOUNT_VOLUME; + message_parameter.length = sizeof(mailbox_id_type); + message_parameter.data = &mount->mailbox_id; + + if (ipc_send(mount_point[mounted_volumes].ipc_structure.output_mailbox_id, &message_parameter) != IPC_RETURN_SUCCESS) + { + log_print_formatted(&log_structure, LOG_URGENCY_ERROR, + "vfs_mount: Failed to send IPC message to mailbox ID %u", + mailbox_id[0]); + return FALSE; + } + mount_point[mounted_volumes].handled_by_vfs = FALSE; string_copy_max(mount_point[mounted_volumes].location, mount->location, MAX_PATH_NAME_LENGTH); mounted_volumes++; log_print_formatted(&log_structure, LOG_URGENCY_INFORMATIVE, "Mounting mailbox %u at //%s.", - ipc_structure->output_mailbox_id, mount->location); + mount->mailbox_id, mount->location); return TRUE; } @@ -552,7 +585,17 @@ static void handle_connection(mailbox_id_type *reply_mailbox_id) { file_verbose_directory_entry_type *directory_entry = (file_verbose_directory_entry_type *) data; - vfs_file_get_info(directory_entry); + if (directory_entry->path_name[0] == '\0') + { + log_print(&log_structure, LOG_URGENCY_ERROR, + "IPC_FILE_GET_INFO: Attempted to get info for a file with an empty path"); + directory_entry->success = FALSE; + } + else + { + vfs_file_get_info(directory_entry); + } + ipc_send(ipc_structure.output_mailbox_id, &message_parameter); break; } @@ -561,7 +604,7 @@ static void handle_connection(mailbox_id_type *reply_mailbox_id) { file_mount_type *mount = (file_mount_type *) data; - vfs_mount(mount, &ipc_structure); + vfs_mount(mount); break; } diff --git a/servers/servers.rake b/servers/servers.rake index a18813b0..c13d6244 100644 --- a/servers/servers.rake +++ b/servers/servers.rake @@ -6,7 +6,10 @@ Rake.application.options.rakelib = ["#{File.dirname(__FILE__)}/../rakelib"] if R LIBRARIES_DIR = "#{File.dirname(__FILE__)}/../libraries".freeze -COMMON_CFLAGS = %w[ +# For a saner gdb experience, you typically want to compile without optimizations unless specifically making a release. +OPTIMIZATION_FLAG = ENV['RELEASE'] ? '-O3' : '-O0' + +COMMON_CFLAGS = %W[ -Wall -Wextra -Wshadow @@ -16,14 +19,15 @@ COMMON_CFLAGS = %w[ -Winline -Werror -Wcast-align + -Wno-pointer-sign -Wsign-compare -Wmissing-declarations -Wmissing-noreturn -pipe - -O3 + #{OPTIMIZATION_FLAG} -fno-builtin -funsigned-char - -g + -ggdb3 -m32 -fomit-frame-pointer -ffreestanding diff --git a/servers/system/boot/Rakefile b/servers/system/boot/Rakefile index a4d8a583..168f52ad 100644 --- a/servers/system/boot/Rakefile +++ b/servers/system/boot/Rakefile @@ -15,5 +15,6 @@ LIBRARIES = %w[ ].freeze OUTPUT = 'boot'.freeze +EXTRA_LDFLAGS_PRE = '-Wl,--defsym=PROCESS_VM_BASE=0x49000000' load '../../servers.rake' diff --git a/servers/system/boot/boot.c b/servers/system/boot/boot.c index a315a28a..883e1f4e 100644 --- a/servers/system/boot/boot.c +++ b/servers/system/boot/boot.c @@ -5,12 +5,16 @@ #include "config.h" -// The maximum number of servers to load. -#define MAX_SERVERS 16 +// The maximum number of programs to load from the startup file. +#define MAX_PROGRAMS 16 -#define STARTUP_FILE "//ramdisk/config/servers/boot/startup" +// FIXME: Workaround for https://github.com/chaos4ever/chaos/issues/107 +#define STARTUP_FILE "//ramdisk/CONFIG/SERVERS/BOOT/STARTUP" static log_structure_type log_structure; +static ipc_structure_type vfs_structure; +static char *program_list_buffer; +static char *programs[MAX_PROGRAMS]; // An empty tag list. tag_type empty_tag = @@ -18,67 +22,106 @@ tag_type empty_tag = 0, 0, "" }; +static void set_process_and_thread_name(void); +static bool resolve_log_service(void); +static bool resolve_vfs_service(void); +static bool resolve_initial_ramdisk_service(mailbox_id_type *initial_ramdisk_mailbox_id); +static void mount_initial_ramdisk(mailbox_id_type initial_ramdisk_mailbox_id); +static bool read_program_list(unsigned int *file_size); +static unsigned int parse_program_list(unsigned int file_size); +static void start_programs(unsigned int number_of_programs); + int main(void) { - file_mount_type mount; - mailbox_id_type mailbox_id[10]; - ipc_structure_type vfs_structure; - message_parameter_type message_parameter; - file_handle_type handle; - file_verbose_directory_entry_type directory_entry; - uint8_t *buffer; - uint8_t **buffer_pointer = &buffer; - char *server_name_buffer; - char *server[MAX_SERVERS]; - unsigned int where, number_of_servers = 0, server_number; - process_id_type process_id; - unsigned int bytes_read; - unsigned int services = 10; - - system_process_name_set(PACKAGE_NAME); - system_thread_name_set("Initialising"); + set_process_and_thread_name(); - if (log_init(&log_structure, PACKAGE_NAME, &empty_tag) != LOG_RETURN_SUCCESS) + if (!resolve_log_service()) { return -1; } - log_print(&log_structure, LOG_URGENCY_DEBUG, "beginning of boot"); + if (!resolve_vfs_service()) + { + return -1; + } - // Mount the initial ramdisk as //ramdisk. To do this, we must first hook up a connection to the VFS service and - // resolve the first block service. - if (ipc_service_resolve("virtual_file_system", mailbox_id, &services, 5, &empty_tag) != IPC_RETURN_SUCCESS) + mailbox_id_type initial_ramdisk_id; + if (!resolve_initial_ramdisk_service(&initial_ramdisk_id)) { - log_print(&log_structure, LOG_URGENCY_EMERGENCY, "Couldn't resolve the VFS service."); + return -1; + } + + mount_initial_ramdisk(initial_ramdisk_id); + unsigned int file_size = 0; + if (!read_program_list(&file_size)) + { return -1; } - vfs_structure.output_mailbox_id = mailbox_id[0]; + unsigned int number_of_programs = parse_program_list(file_size); + log_print_formatted(&log_structure, LOG_URGENCY_DEBUG, "Starting %u programs.", number_of_programs); + start_programs(number_of_programs); - if (ipc_service_connection_request(&vfs_structure) != IPC_RETURN_SUCCESS) + system_call_process_parent_unblock(); + + log_print(&log_structure, LOG_URGENCY_DEBUG, "Boot server completed."); + + return 0; +} + +static void set_process_and_thread_name() +{ + system_process_name_set(PACKAGE_NAME); + system_thread_name_set("Initialising"); +} + +static bool resolve_log_service() +{ + return log_init(&log_structure, PACKAGE_NAME, &empty_tag) == LOG_RETURN_SUCCESS; +} + +static bool resolve_vfs_service() +{ + if (file_init(&vfs_structure, &empty_tag) == FILE_RETURN_SUCCESS) { - log_print(&log_structure, LOG_URGENCY_EMERGENCY, "Couldn't connect to the VFS service."); + return TRUE; + } + else + { + log_print(&log_structure, LOG_URGENCY_EMERGENCY, + "Failed to connect to the VFS service. Is the virtual_file_system server running"); - return -1; + return FALSE; } +} - services = 1; +static bool resolve_initial_ramdisk_service(mailbox_id_type *initial_ramdisk_mailbox_id) +{ + mailbox_id_type mailbox_id[1]; + unsigned int services = 1; - if (ipc_service_resolve("block", mailbox_id, &services, 5, &empty_tag) != IPC_RETURN_SUCCESS) + if (ipc_service_resolve("block", mailbox_id, &services, 5, &empty_tag) == IPC_RETURN_SUCCESS) + { + *initial_ramdisk_mailbox_id = mailbox_id[0]; + return TRUE; + } + else { log_print(&log_structure, LOG_URGENCY_EMERGENCY, "No block services found."); - return -1; + return FALSE; } +} + +static void mount_initial_ramdisk(mailbox_id_type initial_ramdisk_mailbox_id) +{ + file_mount_type mount; - // Obviously this needs to be specified but the neccessary code at the other end (virtual_file_system server) is - // not there so it proved meaningless to add this yet... it just broke other code from compiling. (because I added - // the field to the file_mount_type structure) - // mount.mailbox_id = mailbox_id[0]; + mount.mailbox_id = initial_ramdisk_mailbox_id; string_copy(mount.location, "ramdisk"); - // That's it. Send the message. + message_parameter_type message_parameter; message_parameter.protocol = IPC_PROTOCOL_FILE; message_parameter.message_class = IPC_FILE_MOUNT_VOLUME; message_parameter.data = &mount; @@ -86,64 +129,96 @@ int main(void) message_parameter.block = TRUE; ipc_send(vfs_structure.output_mailbox_id, &message_parameter); - log_print(&log_structure, LOG_URGENCY_DEBUG, "Mounted the first available block service as //ramdisk."); + log_print_formatted(&log_structure, LOG_URGENCY_DEBUG, "Mounted initial ramdisk service (mailbox ID %u) as //ramdisk.", initial_ramdisk_mailbox_id); +} + +static bool read_program_list(unsigned int *file_size) +{ + file_verbose_directory_entry_type directory_entry; - // Now, read the list of servers to start from here. - log_print(&log_structure, LOG_URGENCY_DEBUG, "Reading startup script..."); + log_print(&log_structure, LOG_URGENCY_DEBUG, "Reading list of programs to start"); string_copy(directory_entry.path_name, STARTUP_FILE); if (file_get_info(&vfs_structure, &directory_entry) != FILE_RETURN_SUCCESS) { log_print(&log_structure, LOG_URGENCY_ERROR, STARTUP_FILE " not found."); + return FALSE; + } - return -1; + if (memory_allocate((void **) &program_list_buffer, directory_entry.size) != MEMORY_RETURN_SUCCESS) + { + log_print(&log_structure, LOG_URGENCY_ERROR, "Failed allocating memory for program list."); + return FALSE; } - char **server_name_pointer = &server_name_buffer; - memory_allocate((void **) server_name_pointer, directory_entry.size); + file_handle_type handle; + if (file_open(&vfs_structure, STARTUP_FILE, FILE_MODE_READ, &handle) != FILE_RETURN_SUCCESS) + { + log_print(&log_structure, LOG_URGENCY_ERROR, "Failed opening " STARTUP_FILE); + return FALSE; + } - file_open(&vfs_structure, STARTUP_FILE, FILE_MODE_READ, &handle); - file_read(&vfs_structure, handle, directory_entry.size, &server_name_buffer); + if (file_read(&vfs_structure, handle, directory_entry.size, program_list_buffer) != FILE_RETURN_SUCCESS) + { + log_print(&log_structure, LOG_URGENCY_ERROR, "Failed reading from " STARTUP_FILE); + return FALSE; + } - // Parse the file. - server[0] = &server_name_buffer[0]; - number_of_servers++; + *file_size = directory_entry.size; - for (where = 1; where < directory_entry.size; where++) - { + return TRUE; +} - if (server_name_buffer[where] == '\n') +static unsigned int parse_program_list(unsigned int file_size) +{ + unsigned int number_of_programs = 0; + programs[number_of_programs++] = &program_list_buffer[0]; + + // Convert the LF-terminated file into a buffer o NUL-terminated strings. + for (unsigned int i = 1; i < file_size; i++) + { + if (program_list_buffer[i] == '\n') { - server_name_buffer[where] = '\0'; - if (where + 1 < directory_entry.size) + program_list_buffer[i] = '\0'; + + if (i + 1 < file_size) { - server[number_of_servers] = &server_name_buffer[where + 1]; - number_of_servers++; + // There are remaining characters in the buffer, so we need to create a new entry in the programs array. + programs[number_of_programs] = &program_list_buffer[i + 1]; + number_of_programs++; } } } - log_print_formatted(&log_structure, LOG_URGENCY_DEBUG, "Starting %u servers.", number_of_servers); + return number_of_programs; +} - for (server_number = 0; server_number < number_of_servers; server_number++) +static void start_programs(unsigned int number_of_programs) +{ + uint8_t *buffer; + uint8_t **buffer_pointer = &buffer; + process_id_type process_id; + unsigned int bytes_read; + + for (unsigned int i = 0; i < number_of_programs; i++) { - log_print_formatted(&log_structure, LOG_URGENCY_INFORMATIVE, "Starting %s.", server[server_number]); + log_print_formatted(&log_structure, LOG_URGENCY_INFORMATIVE, "Starting %s.", programs[i]); - string_copy(directory_entry.path_name, server[server_number]); - if (file_get_info(&vfs_structure, &directory_entry) != - FILE_RETURN_SUCCESS) + file_verbose_directory_entry_type directory_entry; + + string_copy(directory_entry.path_name, programs[i]); + if (file_get_info(&vfs_structure, &directory_entry) != FILE_RETURN_SUCCESS) { - log_print_formatted(&log_structure, LOG_URGENCY_ERROR, - "'%s' could not be accessed!", - server[server_number]); + log_print_formatted(&log_structure, LOG_URGENCY_ERROR, "'%s' could not be accessed!", programs[i]); continue; } // Open the file. - file_open(&vfs_structure, server[server_number], FILE_MODE_READ, &handle); + file_handle_type handle; + file_open(&vfs_structure, programs[i], FILE_MODE_READ, &handle); log_print_formatted(&log_structure, LOG_URGENCY_DEBUG, "Allocating %u bytes for %s.", - directory_entry.size, server[server_number]); + directory_entry.size, programs[i]); memory_allocate((void **) buffer_pointer, directory_entry.size); @@ -187,17 +262,11 @@ int main(void) case EXECUTE_ELF_RETURN_FAILED: { - log_print(&log_structure, LOG_URGENCY_ERROR, "system_process_create failed."); + log_print(&log_structure, LOG_URGENCY_ERROR, "system_call_process_create failed."); break; } } memory_deallocate((void **) buffer_pointer); } - - system_call_process_parent_unblock(); - - log_print(&log_structure, LOG_URGENCY_DEBUG, "end of boot"); - - return 0; } diff --git a/servers/system/log/log.c b/servers/system/log/log.c index 79bc4eb8..31e3e8b1 100644 --- a/servers/system/log/log.c +++ b/servers/system/log/log.c @@ -2,7 +2,7 @@ // from the kernel. // Authors: Per Lundberg // Henrik Hallin - +// // © Copyright 1999 chaos development #include "config.h" diff --git a/storm/rakelib/storm.rake b/storm/rakelib/storm.rake index 836e6589..989caaad 100644 --- a/storm/rakelib/storm.rake +++ b/storm/rakelib/storm.rake @@ -4,10 +4,13 @@ DEFINES = (ENV['DEFINES'] || '') + ' -DPACKAGE_NAME=\\"storm\\" -DPACKAGE_VERSION=\\"0.5.1+\\" -DREVISION=\\"`git rev-list HEAD --max-count 1 --abbrev-commit`\\" \ -DCREATOR=\\"`whoami`@`hostname -s`\\"' +# For a saner gdb experience, you typically want to compile without optimizations unless specifically making a release. +OPTIMIZATION_FLAG = ENV['RELEASE'] ? '-O3' : '-O0' + COMMON_CFLAGS = "-Wall -Wextra -Wshadow -Wpointer-arith -Waggregate-return -Wredundant-decls \ -Winline -Werror -Wcast-align -Wsign-compare -Wmissing-declarations \ - -Wmissing-noreturn -pipe -O3 -fno-builtin -fno-asynchronous-unwind-tables -funsigned-char \ + -Wmissing-noreturn -pipe #{OPTIMIZATION_FLAG} -fno-builtin -fno-asynchronous-unwind-tables -funsigned-char \ -g -fomit-frame-pointer -ffreestanding #{ENV['EXTRA_CFLAGS']} #{DEFINES} ".freeze CFLAGS = COMMON_CFLAGS + diff --git a/storm/x86/dispatch.c b/storm/x86/dispatch.c index 9e16493e..512a63ac 100644 --- a/storm/x86/dispatch.c +++ b/storm/x86/dispatch.c @@ -190,6 +190,11 @@ void dispatch_next(void) } #endif + if (!initialised) + { + DEBUG_HALT("dispatch_next should never be called before the kernel initialization is complete."); + } + // Make sure we don't get aborted. mutex_kernel_wait can not be used. // FIXME: This won't always work... tss_tree_mutex = MUTEX_LOCKED; diff --git a/storm/x86/elf.c b/storm/x86/elf.c index 1e85e9e9..5eca4065 100644 --- a/storm/x86/elf.c +++ b/storm/x86/elf.c @@ -1,10 +1,7 @@ // Abstract: Execution of ELF images. // Author: Per Lundberg // -// © Copyright 1999-2000 chaos development -// © Copyright 2007 chaos development -// © Copyright 2013 chaos development -// © Copyright 2015-2016 chaos development +// © Copyright 1999 chaos development #define DEBUG FALSE diff --git a/storm/x86/process.c b/storm/x86/process.c index c874b6d3..bafee850 100644 --- a/storm/x86/process.c +++ b/storm/x86/process.c @@ -118,6 +118,7 @@ static process_id_type process_get_free_id(void) } // Create a new process. +// FIXME: #115: Cleanup this method by taking some first, easy steps. // FIXME: More error checking (especially memory related stuff). // FIXME: Split this function into several, if possible. It's far too long right now. // FIXME: Reimplement the parameter passing (in process_data->parameter_string) @@ -174,6 +175,12 @@ return_type process_create(process_create_type *process_data) // memory_virtual_map_other) DEBUG_MESSAGE(DEBUG, "Allocating memory for the process TSS."); + // We are a bit sloppy here and grab the mutex early, for simplicity. It gets released in all return paths. + if (initialised) + { + mutex_kernel_wait(&memory_mutex); + } + process_tss = (storm_tss_type *) memory_global_allocate(sizeof (storm_tss_type)); memory_set_uint8_t((uint8_t *) process_tss, 0, sizeof (storm_tss_type)); @@ -521,6 +528,7 @@ return_type process_create(process_create_type *process_data) // We are being called from userland. Block. current_tss->state = STATE_BLOCKED_PARENT; mutex_kernel_signal(&tss_tree_mutex); + mutex_kernel_signal(&memory_mutex); dispatch_next(); return STORM_RETURN_SUCCESS; @@ -562,6 +570,12 @@ return_type process_create(process_create_type *process_data) } } } + + if (initialised) + { + mutex_kernel_signal(&memory_mutex); + } + mutex_kernel_signal(&tss_tree_mutex); return STORM_RETURN_SUCCESS;