1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-11-27 11:24:34 -05:00

Some refactoring

This commit is contained in:
Braiden Vasco 2017-11-08 08:12:19 +00:00
parent 46a7796dd7
commit 837d2a3034
2 changed files with 5 additions and 3 deletions

View file

@ -6,7 +6,7 @@ Message queue with additional IPC capabilities implemented as multiboot microker
Glossary Glossary
-------- --------
* `addr` - physical address (`unsigned long`) * `addr` - aligned physical address, shifted right with number of zero bits (`unsigned long`)
* `base` - physical or virtual start address (`unsigned long`) * `base` - physical or virtual start address (`unsigned long`)
* `limit` - physical or virtual end address (included, `unsigned long`) * `limit` - physical or virtual end address (included, `unsigned long`)
* `size` - size in bytes (`unsigned long`) * `size` - size in bytes (`unsigned long`)

View file

@ -24,6 +24,8 @@
#define I386_CR4_MCE 0x00000040 // Machine check enable #define I386_CR4_MCE 0x00000040 // Machine check enable
#define I386_CR4_PGE 0x00000080 // Global page flag enable #define I386_CR4_PGE 0x00000080 // Global page flag enable
#define BIG_PAGE_BASE_TO_ADDR(base) ((base) >> 12)
struct entry { struct entry {
unsigned int present : 1; unsigned int present : 1;
unsigned int writable : 1; unsigned int writable : 1;
@ -86,7 +88,7 @@ void paging_clear()
void paging_identity() void paging_identity()
{ {
for (int i = 0; i < PAGE_DIR_LENGTH; ++i) { for (int i = 0; i < PAGE_DIR_LENGTH; ++i) {
pagedir[i].addr = (i * PAGE_BIG_SIZE) >> 12; pagedir[i].addr = BIG_PAGE_BASE_TO_ADDR(i * PAGE_BIG_SIZE);
pagedir[i].unused = 0; pagedir[i].unused = 0;
pagedir[i].ignored = 0; pagedir[i].ignored = 0;
@ -112,7 +114,7 @@ int paging_mapkernel(const struct KernelMQ_Info *const kinfo)
unsigned long kern_phys = kinfo->kernel_phys_base; unsigned long kern_phys = kinfo->kernel_phys_base;
while (mapped < kinfo->kernel_size) { while (mapped < kinfo->kernel_size) {
pagedir[pde].addr = kern_phys >> 12; pagedir[pde].addr = BIG_PAGE_BASE_TO_ADDR(kern_phys);
pagedir[pde].unused = 0; pagedir[pde].unused = 0;
pagedir[pde].ignored = 0; pagedir[pde].ignored = 0;