Roman,
Here is my code so you can see what is happening with the "no files" alert:
Code: Select all
puts("Now starting 'Yoda' OS, Pre-Alpha 0.0.2. Copyright 2015 Walt Pach, all rights reserved.\n\n");
PRINT("Setting up system boot information...");
DEBUG("Checking multiboot header...");
ASSERT(mboot_ptr->mods_count > 0);
DEBUG("Multiboot header successfuly checked.");
DEBUG("Allocating memory for Initial Ramdisk location object...");
u32int initrd_location = mboot_ptr->mods_addr;//malloc(sizeof(mboot_ptr->mods_addr));
DEBUG_HEX("Memory allocation successful. Location = ", initrd_location);
DEBUG("Allocating memory for Initial Ramdisk end location object...");
u32int initrd_end = mboot_ptr->mods_addr+4;//malloc(sizeof(mboot_ptr->mods_addr + 4));
DEBUG_HEX("Memory allocation successful. End location = ", initrd_end);
// initrd_location = mboot_ptr->mods_addr;
DEBUG_HEX("Initial Ramdisk location (from multiboot) = ", initrd_location);
//initrd_end = mboot_ptr->mods_addr+4;
DEBUG_HEX("Initial Ramdisk end location (from algorithm) = ", initrd_end);
// Don't trample our module with placement accesses, please!
placement_address = initrd_end;
DEBUG_HEX("Placement address = ", initrd_end);
//initialise_paging();
PRINT("Initialising filesystem root...");
fs_root = initialise_initrd(initrd_location);
PRINT("Done initialising filesystem root.");
int i = 0;
struct dirent *node = 0;
while ( (node = readdir_fs(fs_root, i)) != 0)
{
puts("Found file ");
puts(node->name);
fs_node_t *fsnode = finddir_fs(fs_root, node->name);
if ((fsnode->flags&0x7) == FS_DIRECTORY)
puts("\n\t(directory)\n");
else
{
puts("\n\t contents: \"");
char buf[256];
u32int sz = read_fs(fsnode, 0, 256, buf);
int j;
for (j = 0; j < sz; j++)
putch(buf[j]);
puts("\"\n");
}
i++;
}
Here is my code for the initialise_initrd function (where it trips up and throws a page fault):
Code: Select all
fs_node_t *initialise_initrd(u32int location){
PRINT("Starting initialisation of Initial Ramdisk...");
PRINT("Setting Initial Ramdisk header and file headers.");
initrd_header = (initrd_header_t *)location;
PRINT_HEX("Initrd header at location: ", initrd_header);
file_headers = (initrd_file_header_t *) (location + sizeof(initrd_header_t));
PRINT_HEX("File headers at location: ", file_headers);
PRINT("Setting initrd root.");
initrd_root = (fs_node_t*)malloc(sizeof(fs_node_t));
PRINT("Copying initrd name.");
strcpy(initrd_root->name, "initrd");
PRINT("Setting flags and operations of initrd_root.");
initrd_root->mask = initrd_root->uid = initrd_root-> gid = initrd_root->inode = initrd_root->length = 0;
initrd_root->flags = FS_DIRECTORY;
initrd_root->read = 0;
initrd_root->write = 0;
initrd_root->open = 0;
initrd_root->close = 0;
initrd_root->readdir = &initrd_readdir;
initrd_root->finddir = &initrd_finddir;
initrd_root->ptr = 0;
initrd_root->impl = 0;
PRINT("Allocating memory for initrd_dev.");
initrd_dev = (fs_node_t*)malloc(sizeof(fs_node_t));
PRINT_HEX("Memory allocated to: ", initrd_dev);
PRINT("Setting name of initrd_dev.");
strcpy(initrd_dev->name, "dev");
PRINT("Settings flags and operations of initrd_dev.");
initrd_dev->mask = initrd_dev->uid = initrd_dev->gid = initrd_dev->inode = initrd_dev->length = 0;
initrd_dev->flags = FS_DIRECTORY;
initrd_dev->read = 0;
initrd_dev->write = 0;
initrd_dev->open = 0;
initrd_dev->close = 0;
initrd_dev->readdir = &initrd_readdir;
initrd_dev->finddir = &initrd_finddir;
initrd_dev->ptr = 0;
initrd_dev->impl = 0;
PRINT("Allocating memory for root nodes.");
PRINT_DEC("Number of files: ", initrd_header->nfiles);
root_nodes = (fs_node_t*)malloc(sizeof(fs_node_t) * initrd_header->nfiles);
PRINT_HEX("Memory allocated to: ", initrd_dev);
PRINT("Setting number of root nodes.");
nroot_nodes = initrd_header->nfiles;
int i;
for(i = 0; i < initrd_header->nfiles; i++){
file_headers[i].offset += location;
strcpy(root_nodes[i].name, &file_headers[i].name);
root_nodes[i].mask = root_nodes[i].uid = root_nodes[i].gid = 0;
root_nodes[i].length = file_headers[i].length;
root_nodes[i].inode = i;
root_nodes[i].flags = FS_FILE;
root_nodes[i].read = &initrd_read;
root_nodes[i].write = 0;
root_nodes[i].readdir = 0;
root_nodes[i].finddir = 0;
root_nodes[i].open = 0;
root_nodes[i].close = 0;
root_nodes[i].impl = 0;
}
return initrd_root;
As you can see from the screenshot, the page fault is happening when I try and access the initrd header. Now, I will make a new image and test it, but I didn't make any changes to the current build so all the code is the same.
And one more thing, I belive it has been stated that I should initialise paging after setting up the locations, why? Can't I just set the superglobal and then when the paging uses it it finds it set to a diffirent value?
When I say superglobal I mean the placement_address object.
Thanks!