diff options
| author | Michal Idziorek <m.i@gmx.at> | 2015-05-15 02:06:48 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2015-05-15 02:06:48 +0200 |
| commit | 0365bbb5c58912fd24b3d33b90477d3de5d46d96 (patch) | |
| tree | 0e171394f0e9f508b6ff1a7971ce61ddf8b2f989 /fs | |
| parent | fb8a5f18835e8811dd1a98b8eb5352151fc2df31 (diff) | |
fixes and imporvements
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/elf.c | 7 | ||||
| -rw-r--r-- | fs/ext2.c | 9 | ||||
| -rw-r--r-- | fs/fs.c | 19 | ||||
| -rw-r--r-- | fs/fs.h | 6 |
4 files changed, 29 insertions, 12 deletions
@@ -69,8 +69,9 @@ Elf32_Phdr; // returns elf entry point uint32_t load_elf(char *name, uint32_t *alloc) { + uint32_t ext2_ramimage= fs_get_root_ext2_ramimage(); - int inode_nr=ext2_filename_to_inode(EXT2_RAM_ADDRESS,name); + int inode_nr=ext2_filename_to_inode(ext2_ramimage,name); if(inode_nr<1)return 0; //TODO: load ELF binary and move this to own compilation unit @@ -80,8 +81,8 @@ uint32_t load_elf(char *name, uint32_t *alloc) uint32_t vaddr=0x08000000; log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"loading %s",name); - ext2_check(EXT2_RAM_ADDRESS); - ext2_inode_content(EXT2_RAM_ADDRESS,inode_nr,vaddr,0x100000); // load 1mb; + ext2_check(ext2_ramimage); + ext2_inode_content(ext2_ramimage,inode_nr,vaddr,0x100000); // load 1mb; log(FOOLOS_MODULE_NAME,FOOLOS_LOG_DEBUG,"ELF File loaded to final destination."); Elf32_Ehdr *elf; @@ -120,7 +120,8 @@ int ext2_check(uint8_t *ram) ram_read(ptr,&super,sizeof(super),1); if(super.ext2_sig!=0xef53){ - panic(FOOLOS_MODULE_NAME,"no ext2 signature found, where ram-image expected!"); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"addr: 0x%08X",ram); + panic(FOOLOS_MODULE_NAME,"no ext2 signature found, where ram-image expected"); } } @@ -134,7 +135,11 @@ ext2_inode ext2_get_inode(uint8_t *ram,int inode_num) uint8_t *ptr=ram+1024; ram_read(ptr,&super,sizeof(super),1); - if(super.ext2_sig!=0xef53)panic(FOOLOS_MODULE_NAME,"no ext2 signature found, where ram-image expected!"); + if(super.ext2_sig!=0xef53) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"addr: 0x%08X",ram); + panic(FOOLOS_MODULE_NAME,"no ext2 signature found, where ram-image expected!"); + } int block_group=(inode_num-1)/super.inodes_per_group; @@ -2,17 +2,28 @@ #include "fs.h" #include "ext2.h" + + +static uint32_t root_ext2_ramimage=0; + // // returns number of entries in the directory specified by name. // fills 0-max into *dirs int fs_readdir(const char *name,fs_dirent *dirs,int max) { - int inode_nr=ext2_filename_to_inode(EXT2_RAM_ADDRESS,name); + + int inode_nr=ext2_filename_to_inode(root_ext2_ramimage,name); if(inode_nr<1)return -1; - return ext2_read_dir(EXT2_RAM_ADDRESS, inode_nr,dirs,max); // TODO: hardcoded, fix this + return ext2_read_dir(root_ext2_ramimage, inode_nr,dirs,max); // TODO: hardcoded, fix this } +void fs_mount(uint32_t ext2_ramimage) +{ + root_ext2_ramimage=ext2_ramimage; +} - - +uint32_t fs_get_root_ext2_ramimage() +{ + return root_ext2_ramimage; +} @@ -3,9 +3,6 @@ #include <stdint.h> - -#define EXT2_RAM_ADDRESS 0x124000 // here the bootloader puts our image - enum FS_FILE_TYPE{ FS_FILE_TYPE_DIR = 1, @@ -20,6 +17,9 @@ typedef struct fs_dirent_struct uint8_t type; char name[256]; }fs_dirent; + int fs_readdir(const char *name,fs_dirent *dirs,int max); +void fs_mount(uint32_t ext2_ramimage); // all you can mount so far is just one single + // ext2 ramimage as root #endif |
