summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/ext2.c25
-rw-r--r--fs/ext2.h6
-rw-r--r--kernel/kernel.c1
-rw-r--r--kernel/kernel.h3
-rw-r--r--kernel/smp.c1
-rw-r--r--test/pipetest.c55
-rw-r--r--test/selftest.c14
-rw-r--r--test/selftest.h1
-rw-r--r--[l---------]userspace/crt0.s41
9 files changed, 59 insertions, 88 deletions
diff --git a/fs/ext2.c b/fs/ext2.c
index b062973..d99fba7 100644
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -1,18 +1,14 @@
-#include "kernel/kernel.h"
-#include "log.h"
-// ext2 minidriver
-// based on osdev wiki article: http://wiki.osdev.org/Ext2
-//
-//
-#include "lib/string/string.h"
+#include <stdbool.h>
+#include <stdint.h>
+#include "kernel.h"
+#include "ext2.h"
+#include "log.h"
-#include <stdbool.h>
-#include <stdint.h>
+#include "lib/string/string.h"
#include "fs.h"
-#include "ext2.h"
typedef struct ext2_superblock_struct
{
@@ -27,18 +23,19 @@ typedef struct ext2_superblock_struct
uint32_t blocks_per_group;
uint32_t fragments_per_group;
uint32_t inodes_per_group;
- uint8_t skip[12]; // maybe we will look at these fields later...
+ uint8_t skip[12]; // last mount time, last written time, numer of times mounted, number of mounts before checking.
uint16_t ext2_sig; // 0xef5
uint16_t fs_state;
uint16_t error_handle;
uint16_t version_minor;
- uint8_t skip2[8]; // maybe we will look at these fields later...
+ uint8_t skip2[8]; // last check, check interval
uint32_t os_id;
uint32_t version_major;
uint16_t uid_reserved;
uint16_t gid_reserved;
}ext2_superblock;
+/* we dont use this yet
typedef struct ext2_superblock_ext_struct
{
uint32_t first_inode;
@@ -62,6 +59,7 @@ typedef struct ext2_superblock_ext_struct
uint32_t orpan_head;
}ext2_superblock_ext;
+*/
typedef struct ext2_blockgroup_desc_struct
{
@@ -112,13 +110,12 @@ void ram_read(char *in,char *out,int size, int count)
{
out[i]=in[i];
}
-
}
int ext2_check(uint8_t *ram)
{
ext2_superblock super;
- ext2_superblock_ext super_ext;
+// ext2_superblock_ext super_ext;
uint8_t *ptr=ram+1024;
ram_read((char*)ptr,&super,sizeof(super),1);
diff --git a/fs/ext2.h b/fs/ext2.h
index 066a769..8b9b76b 100644
--- a/fs/ext2.h
+++ b/fs/ext2.h
@@ -1,3 +1,9 @@
+/**
+ * @file
+// ext2 minidriver
+// based on osdev wiki article: http://wiki.osdev.org/Ext2
+*/
+
#include <stdint.h>
#include "fs.h"
diff --git a/kernel/kernel.c b/kernel/kernel.c
index ef9a08d..cf9fef9 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -33,7 +33,6 @@
#include "driver/vesa.h"
#include "asm_pit.h"
-#include "test/selftest.h"
/* F00L 0S Entry point (called directly from asm/multiboot.asm */
void kernel_main(uint32_t eax,uint32_t ebx)
diff --git a/kernel/kernel.h b/kernel/kernel.h
index 7198c74..3baef97 100644
--- a/kernel/kernel.h
+++ b/kernel/kernel.h
@@ -67,7 +67,8 @@ REFERENCES
#define VMEM_CPU_STACK_TOP 0xF3000000 // 4 pages / per cpu
#define VMEM_COPY_PAGE 0xF4000000 // 1 page / temporery map-in tables for copying
-//TODO: do not hardcode in crt0.s
+
+//TODO: do not hardcode in crt0.s!
#define VMEM_USER_NEWLIB 0xF5000000 // 1 page / newlib reentrancy struct. 1 per thread
#define VMEM_FRAMEBUFFER 0xF6000000 // 8192 pages (32megs) / identity mapped
diff --git a/kernel/smp.c b/kernel/smp.c
index 8eb8dad..a92eee6 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -15,7 +15,6 @@
#include "apic.h"
#include "vesa.h"
#include "syscalls.h"
-#include "test/selftest.h"
// set cpu private value
void smp_set(uint32_t offset, uint32_t value)
diff --git a/test/pipetest.c b/test/pipetest.c
deleted file mode 100644
index 448f001..0000000
--- a/test/pipetest.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-
-int main(int argc, char *argv[])
-{
- printf("LINUX PIPE TEST\n");
-
- if(argc<=1)
- {
- printf("one argument please [read|write]\n");
- }
-
- if(!strcmp(argv[1],"read"))
- {
- FILE *p=fopen("./testpipe","r");
- printf("opened for reading\n");
- printf("feof: %i\n",feof(p));
-
- if(p==NULL)
- {
- int err=errno;
- printf("Opening pipe failed with errno %d : %s\n",err,strerror(err));
- }
-
- while(1)
- {
- char buf[256];
- int ret=fread(buf,1,10,p);
- buf[10]=0;
- printf("read: %i %s\n",ret,buf);
- printf("feof: %i\n",feof(p));
- if (feof(p)) break;
- }
- }
-
- if(!strcmp(argv[1],"write"))
- {
- FILE *p=fopen("./testpipe","a");
- printf("opened for writing\n");
- if(p==NULL)
- {
- int err=errno;
- printf("Opening pipe failed with errno %d : %s\n",err,strerror(err));
- }
- fwrite("DUPA123",1,7,p);
- fwrite("DUPA123",1,7,p);
- for(int i=0;i<10000;i++)
- {
- fwrite("DUPA123",1,7,p);
- }
- //fclose(p);
- }
- return 0;
-}
diff --git a/test/selftest.c b/test/selftest.c
deleted file mode 100644
index ef0b80a..0000000
--- a/test/selftest.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "kernel.h"
-#include "log.h"
-
-void selftest_stack_overflow()
-{
- klog("recurse..");
- selftest_stack_overflow();
-}
-
-void selftest_run()
-{
- klog ("RUNNING SOME IN-KERNEL SELFTESTS");
- selftest_stack_overflow();
-}
diff --git a/test/selftest.h b/test/selftest.h
deleted file mode 100644
index f95ebda..0000000
--- a/test/selftest.h
+++ /dev/null
@@ -1 +0,0 @@
-void selftest_run();
diff --git a/userspace/crt0.s b/userspace/crt0.s
index 8d17c13..ad9884f 120000..100644
--- a/userspace/crt0.s
+++ b/userspace/crt0.s
@@ -1 +1,40 @@
-../newlib/crt0.s \ No newline at end of file
+.global _start
+
+_start:
+
+# copy reent to this page
+push %ebx
+push %ecx
+
+mov _impure_ptr,%eax
+mov $0xf5000000,%ebx
+copy:
+mov (%eax),%ecx
+mov %ecx,(%ebx)
+add $4, %ebx
+add $4, %eax
+cmp $0xf5001000,%ebx
+jne copy
+
+pop %ecx
+pop %ebx
+
+# environment adress was passed on stack
+
+movl $0xf5000000, _impure_ptr
+
+pop %eax
+mov %eax, environ
+
+
+# call main (argc and argv are on the stack)
+call main
+
+# push exit code and pass to _exit syscall
+push %eax
+call _exit
+
+# this should never be reached!
+.wait:
+ hlt
+jmp .wait