Skip to content
Snippets Groups Projects
Commit 81baf6dd authored by Adama SANGARE's avatar Adama SANGARE
Browse files

simple mm maping virtual to physic

parent 5ba3db33
No related branches found
No related tags found
No related merge requests found
__attribute__((fastcall)) void call_user(void (*user_fct)(), void *user_stack);
File added
......@@ -3,6 +3,10 @@ ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.user 0x00400000 :
{
src/user.o (.text* .data .rodata .bss)
}
.text phys : AT(phys)
{
code = .; _code = .; __code = .;
......
File added
File added
File added
File added
File added
global call_user
call_user:
mov ax, 0x28
ltr ax
mov ax, 0x23
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
push 0x23
push edx ; second arg of call_user stack
pushf
push 0x1B
push ecx ; first arg of call_user fct
iret
src/gdt.o 0 → 100644
File added
src/idt.o 0 → 100644
File added
File added
#include "gdt.h"
#include "idt.h"
#include "minilib.h"
#include "mmu.h"
#include "call_user.h"
extern void user_entry();
void empty_irq(int_regs_t *r)
{
}
extern char user_stack[];
void page_fault_handler(int_regs_t *r)
{
puts("page call\n");
for(;;);
}
void sys_handler(int_regs_t *r)
{
}
/* multiboot entry-point with datastructure as arg. */
void main(unsigned int * mboot_info)
{
......@@ -24,10 +37,13 @@ void main(unsigned int * mboot_info)
idt_setup_int_handler(0, empty_irq);
idt_setup_int_handler(1, empty_irq);
idt_setup_int_handler(14, page_fault_handler);
__asm volatile("sti");
/* minimal setup done ! */
setup_mmu();
call_user(user_entry, user_stack);
puts("Going idle\n");
for(;;) ; /* nothing more to do... really nothing ! */
......
File added
File added
src/mmu.o 0 → 100644
File added
src/tss.o 0 → 100644
File added
char user_stack[65536];
static void putc(int c) {
asm("movl $1, %%eax" "\n\t" "movl %0, %%edi" "\n\t" "int $87" : : "r"(c) : "eax", "edi");
}
// static void putc(int c) {
// asm("movl $1, %%eax" "\n\t" "movl %0, %%edi" "\n\t" "int $87" : : "r"(c) : "eax", "edi");
// }
static void puts(char *s) {
int i;
for (i = 0; s[i] != 0; i++) {
putc(s[i]);
}
}
// static void puts(char *s) {
// int i;
// for (i = 0; s[i] != 0; i++) {
// putc(s[i]);
// }
// }
int variable = 200;
void user_entry() {
puts("Hello from userland\n");
//puts("Hello from userland\n");
char *ptr = (char*) 0x800000;
*ptr = 42;
puts("Write succeeded!\n");
//puts("Write succeeded!\n");
for(;;);
}
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment