Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4ca65e96
authored
Dec 13, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
trying to make things work
parent
ae98eb9f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
12 deletions
src/PCB.c
src/PCB.h
src/elf.c
src/kern.c
src/pit.c
src/switch.asm
src/PCB.c
View file @
4ca65e96
...
@@ -31,7 +31,13 @@ void schedule()
...
@@ -31,7 +31,13 @@ void schedule()
{
{
curproc
=
(
curproc
<
NUM_PROCS
-
1
)
?
curproc
+
1
:
0
;
curproc
=
(
curproc
<
NUM_PROCS
-
1
)
?
curproc
+
1
:
0
;
}
}
context_switch
(
&
procs
[
old
]
->
ctxt
,
procs
[
curproc
]
->
ctxt
);
serial_writestring
(
"Gonna context switch with:
\n
eip "
);
serial_hexword
(
procs
[
curproc
]
->
ctxt
->
eip
);
serial_writestring
(
"
\n
ebp "
);
serial_hexword
(
procs
[
curproc
]
->
ctxt
->
ebp
);
serial_writestring
(
"
\n
"
);
context_switch
(
&
procs
[
old
]
->
ctxt
,
procs
[
curproc
]
->
ctxt
,
procs
[
curproc
]
->
mem
);
serial_writestring
(
"Switched
\n
"
);
//procs[old]->state=RUNNABLE;
//procs[old]->state=RUNNABLE;
procs
[
curproc
]
->
state
=
RUNNING
;
procs
[
curproc
]
->
state
=
RUNNING
;
//process* t = curproc;
//process* t = curproc;
...
...
src/PCB.h
View file @
4ca65e96
...
@@ -63,10 +63,10 @@ typedef struct
...
@@ -63,10 +63,10 @@ typedef struct
enum
procstate
state
;
enum
procstate
state
;
}
__attribute__
((
packed
))
process
;
}
__attribute__
((
packed
))
process
;
extern
void
context_switch
(
context
**
old
,
context
*
new
);
extern
void
context_switch
(
context
**
old
,
context
*
new
,
page_directory_entry
*
cr3
);
void
syscall
();
void
syscall
();
void
addproc
(
process
*
proc
);
void
addproc
(
process
*
proc
);
void
settf
(
trapframe
*
tf
);
void
settf
(
trapframe
*
tf
);
void
proc_setup
();
void
proc_setup
();
int
yield
();
#endif
#endif
src/elf.c
View file @
4ca65e96
...
@@ -83,5 +83,5 @@ void load_elf(elf_header* elf_start)
...
@@ -83,5 +83,5 @@ void load_elf(elf_header* elf_start)
pcb
->
tf
->
eip
=
(
uint32_t
)
elf_start
->
program_entry_position
;
pcb
->
tf
->
eip
=
(
uint32_t
)
elf_start
->
program_entry_position
;
addproc
(
pcb
);
addproc
(
pcb
);
asm
(
"mov $3, %eax; int 0x80"
);
//
asm("mov $3, %eax; int 0x80");
}
}
src/kern.c
View file @
4ca65e96
...
@@ -38,12 +38,10 @@ void kernel_main(multiboot_info* mbt, uint32_t magic)
...
@@ -38,12 +38,10 @@ void kernel_main(multiboot_info* mbt, uint32_t magic)
serial_writestring
(
"IDT initialized
\n
"
);
serial_writestring
(
"IDT initialized
\n
"
);
disable_int
();
disable_int
();
pic_init
(
0x20
,
0x28
);
pic_init
(
0x20
,
0x28
);
pit_init
();
//
pit_init();
io_init
();
io_init
();
proc_setup
();
proc_setup
();
pit_start_counter
(
100
,
PIT_OCW_CONT_0
,
PIT_OCW_MODE_SQWVGEN
);
enable_int
();
/* Since there is no support for newlines in terminal_putchar
/* Since there is no support for newlines in terminal_putchar
* yet, '\n' will produce some VGA specific character instead.
* yet, '\n' will produce some VGA specific character instead.
* This is normal.
* This is normal.
...
@@ -83,7 +81,12 @@ void kernel_main(multiboot_info* mbt, uint32_t magic)
...
@@ -83,7 +81,12 @@ void kernel_main(multiboot_info* mbt, uint32_t magic)
serial_writestring
(
"
\n
"
);
serial_writestring
(
"
\n
"
);
load_elf
((
elf_header
*
)
&
elf_hello
);
load_elf
((
elf_header
*
)
&
elf_hello
);
pit_init
();
pit_start_counter
(
100
,
PIT_OCW_CONT_0
,
PIT_OCW_MODE_SQWVGEN
);
serial_writestring
(
"Enabling interrupts
\n
"
);
enable_int
();
//schedule();
test_idt
();
test_idt
();
while
(
true
)
while
(
true
)
{
{
...
...
src/pit.c
View file @
4ca65e96
...
@@ -16,6 +16,7 @@ void pit_irq()
...
@@ -16,6 +16,7 @@ void pit_irq()
_pit_ticks
++
;
_pit_ticks
++
;
//serial_writestring("PIT tick\n");
//serial_writestring("PIT tick\n");
pic_command
(
0
,
PIC_OCW2_EOI
);
pic_command
(
0
,
PIC_OCW2_EOI
);
yield
();
//serial_writestring("PIT tickn\n");
//serial_writestring("PIT tickn\n");
//asm volatile("nop;nop;nop;popa; iret;");
//asm volatile("nop;nop;nop;popa; iret;");
}
}
...
...
src/switch.asm
View file @
4ca65e96
...
@@ -2,7 +2,8 @@ global context_switch
...
@@ -2,7 +2,8 @@ global context_switch
context_switch
:
context_switch
:
mov
eax
,
[
esp
+
4
]
mov
eax
,
[
esp
+
4
]
mov
edx
,
[
esp
+
8
]
mov
edx
,
[
esp
+
8
]
mov
ecx
,
[
esp
+
12
]
push
ebp
push
ebp
push
ebx
push
ebx
push
esi
push
esi
...
@@ -10,10 +11,11 @@ context_switch:
...
@@ -10,10 +11,11 @@ context_switch:
mov
[eax],
esp
mov
[eax],
esp
mov
esp
,
edx
mov
esp
,
edx
pop
edi
pop
edi
pop
esi
pop
esi
pop
ebx
pop
ebx
pop
ebp
pop
ebp
mov
cr3
,
ecx
ret
ret
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment