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
f68e09e4
authored
Oct 19, 2015
by
triazo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add very simple malloc function
parent
271e64a3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
19 deletions
src/mem.c
src/mem.h
src/mem.c
View file @
f68e09e4
...
...
@@ -132,24 +132,9 @@ page_directory_entry* initiate_directory()
return
page_directory
;
}
void
initiate_page_table
(
page_directory_entry
*
page_dir
)
void
*
malloc
(
uint32_t
bytes
)
{
// holds the physical address where we want to start mapping these pages to.
// in this case, we want to map these pages to the very beginning of memory.
unsigned
int
i
;
//we will fill all 1024 entries in the table, mapping 4 megabytes
for
(
i
=
0
;
i
<
1024
;
i
++
)
{
// As the address is page aligned, it will always leave 12 bits zeroed.
// Those bits are used by the attributes:
// -> supervisor level, read/write, present.
page_table_one
[
i
]
=
0
;
page_table_one
[
i
]
|=
i
<<
12
;
page_table_one
[
i
]
|=
PAGE_WRITABLE
|
PAGE_PRESENT
;
}
// attributes: supervisor level, read/write, present
page_dir
[
0
]
=
(
uint32_t
)
page_table_one
;
page_dir
[
0
]
|=
PAGE_WRITABLE
|
PAGE_PRESENT
;
void
*
old_mark
=
memory_mark
;
memory_mark
=
(
void
*
)((
uint32_t
)
memory_mark
+
bytes
);
return
old_mark
;
}
src/mem.h
View file @
f68e09e4
...
...
@@ -31,4 +31,11 @@ extern void enablePaging();
page_directory_entry
*
initiate_directory
();
page_directory_entry
*
mem_init_kern_tables
(
multiboot_memory_map
*
mmap
,
multiboot_memory_map
*
mmap_end
);
// memory mark stores a counter of bytes for the most recently used
// memory. Everything before it is used and all valid memory after it
// is free
void
*
memory_mark
;
void
*
malloc
(
uint32_t
bytes
);
#endif
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