Browse Source

Lots of fixes

K. Lange 2 years ago
parent
commit
16e1386c86
7 changed files with 15 additions and 177 deletions
  1. 2 2
      Makefile
  2. 11 6
      boot/moremultiboot.h
  3. 0 33
      modules/crash.c
  4. 0 53
      modules/test-write.c
  5. 0 58
      modules/test.c
  6. 0 25
      modules/testb.c
  7. 2 0
      util/mkdisk.sh

+ 2 - 2
Makefile

@@ -181,7 +181,7 @@ EFI_XORRISO=-eltorito-alt-boot -e fat.img -no-emul-boot -isohybrid-gpt-basdat
 EFI_BOOT=cdrom/fat.img
 EFI_UPDATE=python util/update-extents.py
 
-image.iso: ${EFI_BOOT} cdrom/boot.sys fatbase/netinit ${MODULES}
+image.iso: ${EFI_BOOT} cdrom/boot.sys fatbase/netinit ${MODULES} util/update-extents.py
 	xorriso -as mkisofs -R -J -c bootcat \
 	  -b boot.sys -no-emul-boot -boot-load-size 24 \
 	  ${EFI_XORRISO} \
@@ -190,7 +190,7 @@ image.iso: ${EFI_BOOT} cdrom/boot.sys fatbase/netinit ${MODULES}
 
 # Boot loader
 
-cdrom/fat.img: fatbase/ramdisk.img ${MODULES} fatbase/kernel fatbase/netinit fatbase/efi/boot/bootia32.efi
+cdrom/fat.img: fatbase/ramdisk.img ${MODULES} fatbase/kernel fatbase/netinit fatbase/efi/boot/bootia32.efi util/mkdisk.sh
 	util/mkdisk.sh $@ fatbase
 
 EFI_CFLAGS=-fno-stack-protector -fpic -DEFI_FUNCTION_WRAPPER -m32 -DEFI_PLATFORM -ffreestanding -fshort-wchar -I /usr/include/efi -I /usr/include/efi/ia32 -mno-red-zone

+ 11 - 6
boot/moremultiboot.h

@@ -478,27 +478,32 @@ void show_menu(void) {
 static EFI_GUID efi_simple_file_system_protocol_guid =
 	{0x0964e5b22,0x6459,0x11d2,0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b};
 
+static EFI_GUID efi_loaded_image_protocol_guid =
+	{0x5B1B31A1,0x9562,0x11d2, {0x8E,0x3F,0x00,0xA0,0xC9,0x69,0x72,0x3B}};
+
 static void boot(void) {
 	UINTN count;
 	EFI_HANDLE * handles;
+	EFI_LOADED_IMAGE * loaded_image;
 	EFI_FILE_IO_INTERFACE *efi_simple_filesystem;
 	EFI_FILE *root;
+	EFI_STATUS status;
 
 	clear_();
 
-	EFI_STATUS status = uefi_call_wrapper(ST->BootServices->LocateHandleBuffer,
-			5, ByProtocol, &efi_simple_file_system_protocol_guid,
-			NULL, &count, &handles);
+	status = uefi_call_wrapper(ST->BootServices->HandleProtocol,
+			3, ImageHandleIn, &efi_loaded_image_protocol_guid,
+			(void **)&loaded_image);
 
 	if (EFI_ERROR(status)) {
-		print_("There was an error.\n");
+		print_("There was an error (init)\n");
 		while (1) {};
 	}
 
-	print_("Found "); print_hex_(count); print_(" handles.\n");
+	print_("Found loaded image...\n");
 
 	status = uefi_call_wrapper(ST->BootServices->HandleProtocol,
-			3, handles[0], &efi_simple_file_system_protocol_guid,
+			3, loaded_image->DeviceHandle, &efi_simple_file_system_protocol_guid,
 			(void **)&efi_simple_filesystem);
 
 	if (EFI_ERROR(status)) {

+ 0 - 33
modules/crash.c

@@ -1,33 +0,0 @@
-/* vim: tabstop=4 shiftwidth=4 noexpandtab
- * This file is part of ToaruOS and is released under the terms
- * of the NCSA / University of Illinois License - see LICENSE.md
- * Copyright (C) 2014-2018 K. Lange
- */
-#include <kernel/module.h>
-#include <kernel/printf.h>
-#include <kernel/mod/shell.h>
-
-DEFINE_SHELL_FUNCTION(crash, "Dereference NULL.") {
-	fprintf(tty, "*0x0 = %x\n", *((int *)0x00));
-	*((int *)0x0) = 0x42;
-	fprintf(tty, "*0x0 = %x\n", *((int *)0x00));
-	return 0;
-}
-
-DEFINE_SHELL_FUNCTION(assert_false, "assert(0)") {
-	assert(0);
-	return 0;
-}
-
-static int crash_init(void) {
-	BIND_SHELL_FUNCTION(crash);
-	BIND_SHELL_FUNCTION(assert_false);
-	return 0;
-}
-
-static int crash_fini(void) {
-	return 0;
-}
-
-MODULE_DEF(crash, crash_init, crash_fini);
-MODULE_DEPENDS(debugshell);

+ 0 - 53
modules/test-write.c

@@ -1,53 +0,0 @@
-/* vim: tabstop=4 shiftwidth=4 noexpandtab
- * This file is part of ToaruOS and is released under the terms
- * of the NCSA / University of Illinois License - see LICENSE.md
- * Copyright (C) 2014-2018 K. Lange
- */
-#include <kernel/system.h>
-#include <kernel/module.h>
-#include <kernel/fs.h>
-#include <kernel/printf.h>
-#include <kernel/mod/shell.h>
-
-DEFINE_SHELL_FUNCTION(testwrite, "Test write") {
-
-	fs_node_t * f = NULL;
-	char * file = "/dev/hdb";
-
-	if (argc > 1) {
-		file = argv[1];
-	}
-
-	f = kopen(file, 0);
-
-	if (!f) {
-		fprintf(tty, "No device: %s\n", file);
-		return 1;
-	}
-
-	char * s = malloc(1024);
-
-	sprintf(s, "Hello World!");
-
-	write_fs(f, 0, strlen(s), (uint8_t *)s);
-	write_fs(f, 2, strlen(s), (uint8_t *)s);
-	write_fs(f, 523, strlen(s), (uint8_t *)s);
-
-	write_fs(f, 1024*12, 1024, (uint8_t *)s);
-
-	free(s);
-
-	return 0;
-}
-
-static int init(void) {
-	BIND_SHELL_FUNCTION(testwrite);
-	return 0;
-}
-
-static int fini(void) {
-	return 0;
-}
-
-MODULE_DEF(testwrite, init, fini);
-MODULE_DEPENDS(debugshell);

+ 0 - 58
modules/test.c

@@ -1,58 +0,0 @@
-/* vim: tabstop=4 shiftwidth=4 noexpandtab
- * This file is part of ToaruOS and is released under the terms
- * of the NCSA / University of Illinois License - see LICENSE.md
- * Copyright (C) 2014-2018 K. Lange
- */
-#include <kernel/system.h>
-#include <kernel/module.h>
-#include <kernel/logging.h>
-#include <kernel/printf.h>
-#include <kernel/mod/shell.h>
-
-#include <toaru/hashmap.h>
-
-extern char * special_thing;
-
-char test_module_string[] = "I am a char[] in the module.";
-char * test_module_string_ptr = "I am a char * in the module.";
-
-int a_function(void) {
-	debug_print(WARNING, ("I am an exported function in the module."));
-	return 42;
-}
-
-DEFINE_SHELL_FUNCTION(test_mod, "A function installed by a module!") {
-	fprintf(tty, "Hello world!\n");
-	return 0;
-}
-
-static int hello(void) {
-	debug_print(NOTICE, special_thing);
-	a_function();
-	debug_print(NOTICE, test_module_string);
-	debug_print(NOTICE, test_module_string_ptr);
-
-	hashmap_t * map = hashmap_create(10);
-
-	debug_print(NOTICE, "Inserting into hashmap...");
-
-	hashmap_set(map, "hello", (void *)"cake");
-	debug_print(NOTICE, "getting value: %s", hashmap_get(map, "hello"));
-
-	hashmap_free(map);
-	free(map);
-
-	debug_shell_install(&shell_test_mod_desc);
-	BIND_SHELL_FUNCTION(test_mod);
-
-	return 25;
-}
-
-static int goodbye(void) {
-	debug_print(NOTICE, "Goodbye!");
-	return 0;
-}
-
-MODULE_DEF(test, hello, goodbye);
-MODULE_DEPENDS(debugshell);
-

+ 0 - 25
modules/testb.c

@@ -1,25 +0,0 @@
-/* vim: tabstop=4 shiftwidth=4 noexpandtab
- * This file is part of ToaruOS and is released under the terms
- * of the NCSA / University of Illinois License - see LICENSE.md
- * Copyright (C) 2014-2018 K. Lange
- */
-#include <kernel/system.h>
-#include <kernel/module.h>
-#include <kernel/logging.h>
-
-extern int a_function(void);
-
-static int hello(void) {
-	debug_print(NOTICE, "Calling a_function from other module.");
-	a_function();
-	return 0;
-}
-
-static int goodbye(void) {
-	debug_print(NOTICE, "Goodbye!");
-	return 0;
-}
-
-MODULE_DEF(testb, hello, goodbye);
-MODULE_DEPENDS(test);
-

+ 2 - 0
util/mkdisk.sh

@@ -28,3 +28,5 @@ do
     fi
 done
 
+rm cdrom/efi/boot/bootia32.efi # Otherwise virtualbox may erroneously try to load from this
+