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
7ad4babe
authored
Dec 07, 2015
by
triazo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Comment out function and map everything.
parent
ebfd2cc5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
29 deletions
src/elf.c
src/mem.c
src/elf.c
View file @
7ad4babe
...
@@ -45,8 +45,7 @@ void load_elf(elf_header* elf_start)
...
@@ -45,8 +45,7 @@ void load_elf(elf_header* elf_start)
size_t
offset
=
(
pg
>
ph
->
p_vaddr
)
?
0
:
ph
->
p_vaddr
-
pg
;
size_t
offset
=
(
pg
>
ph
->
p_vaddr
)
?
0
:
ph
->
p_vaddr
-
pg
;
// do some memcpy stuff
// do some memcpy stuff
serial_hexword
((
uint32_t
)
real_page
);
page_table_inspect
(
kernel_page_directory
,
real_page
);
serial_writechar
(
'\n'
);
memcpy
(
real_page
+
offset
,
start
,
size
);
memcpy
(
real_page
+
offset
,
start
,
size
);
// save the highest start
// save the highest start
...
...
src/mem.c
View file @
7ad4babe
...
@@ -94,60 +94,64 @@ page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot
...
@@ -94,60 +94,64 @@ page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot
page_allocate
();
page_allocate
();
}
}
// Make a page directory structure easily
// Initilize a directory mapped to everything
page_directory_entry
*
kern_page_dir
=
initiate_directory
();
page_directory_entry
*
kern_page_dir
=
kernel_page_directory
;
page_everything
(
kern_page_dir
);
// _kern_end is defined in the linker script
// _kern_end is defined in the linker script
/* page_table_entry* next_table = (page_table_entry*) &_kernel_end; */
/* page_table_entry* next_table = (page_table_entry*) &_kernel_end; */
int
current_dir_entry
=
0
;
//int current_dir_entry = 0;
uint32_t
totalmem
=
0
;
// For each entry in the memory map
// For each entry in the memory map
while
(
mmap
<
mmap_end
)
while
(
mmap
<
mmap_end
)
{
{
void
*
next_table
=
page_allocate
();
//
void* next_table = page_allocate();
// Special case for the first memory segment - it gets its own directory entry
// Special case for the first memory segment - it gets its own directory entry
if
(
mmap
->
base_addr
==
0
)
if
(
mmap
->
base_addr
==
0
)
{
{
// Lower memory should be first in the page directory and
// Lower memory should be first in the page directory and
// mapped one to one
// mapped one to one
populate_page_table
(
next_table
,
0
,
1024
,
0
);
/* populate_page_table(next_table, 0, 1024, 0); */
kern_page_dir
[
0
]
=
(
uint32_t
)
next_table
;
/* kern_page_dir[0] = (uint32_t) next_table; */
kern_page_dir
[
0
]
|=
PAGE_WRITABLE
|
PAGE_PRESENT
;
/* kern_page_dir[0] |= PAGE_WRITABLE | PAGE_PRESENT; */
current_dir_entry
=
1
;
/* current_dir_entry = 1; */
/* next_table += 0x1000; */
/* next_table += 0x1000; */
}
}
else
if
(
mmap
->
type
==
1
)
else
if
(
mmap
->
type
==
1
)
{
{
uint32_t
i
;
totalmem
+=
mmap
->
length
;
for
(
i
=
0
;
i
+
0x1000000
<
mmap
->
length
;
i
+=
0x1000000
)
/* uint32_t i; */
{
/* for (i = 0; i+0x1000000 < mmap->length; i += 0x1000000) */
populate_page_table
(
next_table
,
(
void
*
)(
intptr_t
)
mmap
->
base_addr
+
i
,
1024
,
0
);
/* { */
kern_page_dir
[
current_dir_entry
]
=
(
uint32_t
)
next_table
;
/* populate_page_table(next_table, (void*)(intptr_t) mmap->base_addr + i, 1024 ,0); */
kern_page_dir
[
current_dir_entry
]
|=
PAGE_WRITABLE
|
PAGE_PRESENT
;
/* kern_page_dir[current_dir_entry] = (uint32_t) next_table; */
/* kern_page_dir[current_dir_entry] |= PAGE_WRITABLE | PAGE_PRESENT; */
current_dir_entry
+=
1
;
/* next_table += 0x1000; */
/* current_dir_entry += 1; */
}
/* /\* next_table += 0x1000; *\/ */
/* } */
// There will be an edge case where there is less than a
// There will be an edge case where there is less than a
// full page table to be mapped. This handlis this case.
// full page table to be mapped. This handlis this case.
if
(
i
!=
mmap
->
length
)
/* if (i != mmap->length) */
{
/* { */
populate_page_table
(
next_table
,
(
void
*
)(
intptr_t
)
mmap
->
base_addr
+
i
,
(
mmap
->
length
-
i
)
/
0x1000
,
0
);
/* populate_page_table(next_table, (void*)(intptr_t) mmap->base_addr + i, (mmap->length - i) / 0x1000 ,0); */
kern_page_dir
[
current_dir_entry
]
=
(
uint32_t
)
next_table
;
/* kern_page_dir[current_dir_entry] = (uint32_t) next_table; */
kern_page_dir
[
current_dir_entry
]
|=
PAGE_WRITABLE
|
PAGE_PRESENT
;
/* kern_page_dir[current_dir_entry] |= PAGE_WRITABLE | PAGE_PRESENT; */
current_dir_entry
+=
1
;
/* current_dir_entry += 1; */
/* next_table += 0x1000;
*/
/* /\* next_table += 0x1000; *\/
*/
}
/* } */
}
}
mmap
=
(
multiboot_memory_map
*
)((
uint32_t
)
mmap
+
mmap
->
size
+
sizeof
(
uint32_t
));
mmap
=
(
multiboot_memory_map
*
)((
uint32_t
)
mmap
+
mmap
->
size
+
sizeof
(
uint32_t
));
}
}
// let the memory allocator work freely with all remaining memory
// let the memory allocator work freely with all remaining memory
memory_mark
=
page_allocate
();
/* memory_mark = page_allocate(); */
return
kern_page_dir
;
return
kern_page_dir
;
}
}
...
...
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