From bcaa93b023e9d92b24c105537f2994e070e5d06e Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Tue, 11 Mar 2014 01:55:51 -0700 Subject: [PATCH] more random housecleaning --- Makefile | 23 +++-- util/cpad.sh | 0 util/generate_symbols.py | 0 util/grab-binaries.sh | 22 ----- util/mrboots-installer.c | 176 --------------------------------------- util/run-fullscreen.sh | 9 -- util/run-tests.py | 0 7 files changed, 16 insertions(+), 214 deletions(-) mode change 100644 => 100755 util/cpad.sh mode change 100644 => 100755 util/generate_symbols.py delete mode 100755 util/grab-binaries.sh delete mode 100644 util/mrboots-installer.c delete mode 100755 util/run-fullscreen.sh mode change 100644 => 100755 util/run-tests.py diff --git a/Makefile b/Makefile index 7f999d05..a69825de 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,10 @@ EMUARGS += -hda toaruos-disk.img -k en-us -no-frame EMUARGS += -rtc base=localtime -net nic,model=rtl8139 -net user EMUKVM = -enable-kvm -.PHONY: all system clean clean-once clean-hard clean-soft clean-bin clean-aux clean-core install run test-thing +.PHONY: all system install test +.PHONY: clean clean-soft clean-hard clean-bin clean-mods clean-core clean-disk clean-once +.PHONY: run vga term debug headless run-config +.PHONY: kvm vga-kvm term-kvm debug-term debug-vga # Prevents Make from removing intermediary files on failure .SECONDARY: @@ -177,17 +180,16 @@ clean-bin: @-rm -f hdd/bin/* @${ENDRM} "RM" "Cleaned native binaries" +clean-mods: + @${BEGRM} "RM" "Cleaning kernel modules..." + @-rm -f hdd/mod/* + @${ENDRM} "RM" "Cleaned kernel modules" + clean-core: @${BEGRM} "RM" "Cleaning final output..." @-rm -f toaruos-kernel @${ENDRM} "RM" "Cleaned final output" -clean: clean-soft clean-core - @${INFO} "--" "Finished soft cleaning" - -clean-hard: clean clean-bin - @${INFO} "--" "Finished hard cleaning" - clean-disk: @${BEGRM} "RM" "Deleting hard disk image..." @-rm -f toaruos-disk.img @@ -198,6 +200,13 @@ clean-once: @-rm -f .passed @${ENDRM} "RM" "Cleaned one-time files" +clean: clean-soft clean-core + @${INFO} "--" "Finished soft cleaning" + +clean-hard: clean clean-bin clean-mods + @${INFO} "--" "Finished hard cleaning" + + # vim:noexpandtab # vim:tabstop=4 # vim:shiftwidth=4 diff --git a/util/cpad.sh b/util/cpad.sh old mode 100644 new mode 100755 diff --git a/util/generate_symbols.py b/util/generate_symbols.py old mode 100644 new mode 100755 diff --git a/util/grab-binaries.sh b/util/grab-binaries.sh deleted file mode 100755 index af525560..00000000 --- a/util/grab-binaries.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -BINARIES="http://dl.dropbox.com/u/44305966/toaru-bin-current.tar.gz" - -$DIR/mk-beg "wget" "Pulling binaries..." -wget --quiet -O /tmp/`whoami`-toaru-bin.tar.gz "$BINARIES" -$DIR/mk-end "wget" "Binaries retreived!" - -$DIR/mk-beg "tar" "Extracting binaries..." -tar -xf /tmp/`whoami`-toaru-bin.tar.gz -C $DIR/../hdd/bin/ -$DIR/mk-end "tar" "Binaries extracted." - -$DIR/mk-beg "rm" "Removing hard disk image to ensure rebuild..." -rm -f $DIR/../toaruos-disk.img 2>/dev/null -$DIR/mk-end "rm" "Hard disk image removed." - -$DIR/mk-beg "rm" "Cleaning up..." -rm /tmp/`whoami`-toaru-bin.tar.gz -$DIR/mk-end "rm" "Cleaned up." - -$DIR/mk-info " --- Done!" diff --git a/util/mrboots-installer.c b/util/mrboots-installer.c deleted file mode 100644 index ba42c8f8..00000000 --- a/util/mrboots-installer.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Mr Boots Installer - * - * Installs Mr. Boots onto a generated disk image. - * Compile me with your standard C library and for whatever - * architecture you feel like running me on, though I much - * prefer something simple and 32-bit. - */ -#include -#include -#include -#include -#include -/* The EXT2 header is smart enough to know to grab us stdint.h rather than types.h... */ -#include "../kernel/include/ext2.h" - -#define ext2_get_block(block) ((uintptr_t)hdd_dump + (0x400 << sblock->log_block_size) * block) -#define ext2_get_block_offset(block) ((0x400 << sblock->log_block_size) * block) - -char * hdd_dump = NULL; -ext2_superblock_t * sblock; -ext2_inodetable_t * itable; - -ext2_inodetable_t * -ext2_get_inode( - uint32_t inode - ) { - return (ext2_inodetable_t *)((uintptr_t)itable + sblock->inode_size * (inode - 1)); -} - -ext2_inodetable_t * -ext2_finddir( - ext2_inodetable_t * rnode, - char * name - ) { - - void * block; - ext2_dir_t * direntry = NULL; - block = (void *)ext2_get_block((rnode->block[0])); - - uint32_t dir_offset; - dir_offset = 0; - /* - * Look through the requested entries until we find what we're looking for - */ - while (dir_offset < rnode->size) { - ext2_dir_t * d_ent = (ext2_dir_t *)((uintptr_t)block + dir_offset); - char * dname = malloc(sizeof(char) * (d_ent->name_len + 1)); - memcpy(dname, &d_ent->name, d_ent->name_len); - dname[d_ent->name_len] = '\0'; - if (!strcmp(dname, name)) { - free(dname); - direntry = d_ent; - break; - } - free(dname); - dir_offset += d_ent->rec_len; - } - if (!direntry) { - /* - * We could not find the requested entry in this directory. - */ - fprintf(stderr, "Failed to locate %s!\n", name); - return NULL; - } else { - return ext2_get_inode(direntry->inode); - } - -} - -/* - * Retreive the node for the requested path - */ -ext2_inodetable_t * -iopen( - ext2_inodetable_t * root, - const char *filename - ) { - size_t path_len = strlen(filename); - if (path_len == 1) { - return root; - } - char * path = (char *)malloc(sizeof(char) * (path_len + 1)); - memcpy(path, filename, path_len); - char * path_offset = path; - uint32_t path_depth = 0; - while (path_offset < path + path_len) { - if (*path_offset == '/') { - *path_offset = '\0'; - path_depth++; - } - path_offset++; - } - path[path_len] = '\0'; - path_offset = path + 1; - uint32_t depth; - ext2_inodetable_t * node_ptr = root; - for (depth = 0; depth < path_depth; ++depth) { - node_ptr = ext2_finddir(node_ptr, path_offset); - if (!node_ptr) { - free((void *)path); - return NULL; - } else if (depth == path_depth - 1) { - return node_ptr; - } - path_offset += strlen(path_offset) + 1; - } - free((void *)path); - return NULL; -} - -uint32_t -ext2_get_inode_block_num( - ext2_inodetable_t * inode, - uint32_t block - ) { - if (block < 12) { - return inode->block[block]; - } else if (block < 12 + (1024 << sblock->log_block_size) / sizeof(uint32_t)) { - return *(uint32_t*)((uintptr_t)ext2_get_block(inode->block[12]) + (block - 12) * sizeof(uint32_t)); - } - return 0; -} - -int main(int argc, char ** argv) { - if (argc < 3) { - fprintf(stderr, "Expected two additional arguments: a ramdisk, and a file path to second stage to find in it.\n"); - return -1; - } - fprintf(stderr, "I will look for %s in %s and generate appropriate output.\n", argv[2], argv[1]); - /* Open sesame! */ - FILE * hdd = fopen(argv[1], "r"); - fseek(hdd, 0, SEEK_END); - /* Get size of file */ - uint32_t hdd_size = ftell(hdd); - fprintf(stderr, "HDD image is %d bytes.\n", hdd_size); - fseek(hdd, 0, SEEK_SET); - /* Allocate us up some mems for the hard disk image */ - hdd_dump = malloc(sizeof(char) * hdd_size); - /* Read 'er in. */ - fread(hdd_dump, hdd_size, 1, hdd); - /* And lets make us some pointers. */ - sblock = (ext2_superblock_t *)((uintptr_t)hdd_dump + 0x400); - assert(sblock->magic == EXT2_SUPER_MAGIC); - if (sblock->inode_size == 0) { - sblock->inode_size = 128; - } - /* More pointers! */ - ext2_bgdescriptor_t * rblock = (ext2_bgdescriptor_t *)((uintptr_t)hdd_dump + 0x400 + 0x400); - /* Inode table */ - itable = (ext2_inodetable_t *)((uintptr_t)hdd_dump + (0x400 << sblock->log_block_size) * rblock->inode_table); - /* Root node */ - ext2_inodetable_t * rnode = (ext2_inodetable_t *)((uintptr_t)itable + sblock->inode_size); - ext2_inodetable_t * fnode = iopen(rnode, argv[2]); - if (!fnode) { - fprintf(stderr,"Failed to locate the requested file on the disk image.\n"); - return -1; - } - uint32_t offset = 0x10000; /* Destination offset */ - uint32_t _block = 0; - uint32_t _block_last = 0; - for (uint32_t i = 0; i < fnode->blocks; ++i) { - uint32_t block = ext2_get_inode_block_num(fnode, i); - if (_block == 0 || block != _block_last + 1) { - if (_block != 0) { - uint32_t size = (_block_last - _block + 1) * (0x400 << sblock->log_block_size); - uint32_t place = ext2_get_block_offset(_block); - fprintf(stdout, "read(0x%x, 0x%x, 0x%x, 0x%x);\n", size / 512, place / 512, 0x1000, offset % 0x10000); - offset += size; - } - if (block == 0) { break; } - _block = block; - } - _block_last = block; - } -} diff --git a/util/run-fullscreen.sh b/util/run-fullscreen.sh deleted file mode 100755 index 1d04b151..00000000 --- a/util/run-fullscreen.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# Script to start at full screen resolution - -RAM=1024 -KVM="-enable-kvm" -FULLSCREEN="-no-frame" -RESOLUTION=`xrandr -q|perl -F'\s|,' -lane "/^Sc/&&print join '',@F[8..10]" | sed 's/x/=/'` - -qemu-system-i386 -kernel toaruos-kernel -m $RAM -k en-us -append "vid=qemu=$RESOLUTION hdd" -serial stdio -vga std -hda toaruos-disk.img $KVM $FULLSCREEN diff --git a/util/run-tests.py b/util/run-tests.py old mode 100644 new mode 100755