Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "console.h"
- static inline void lcr3(unsigned int val)
- {
- asm volatile("movl %0,%%cr3" : : "r" (val));
- }
- static inline void halt(void)
- {
- asm volatile("hlt" : : );
- }
- int main(void)
- {
- int i;
- int sum = 0;
- // Initialize the console
- uartinit();
- printk("Hello from C\n");
- unsigned int ptd_table[1024] __attribute__((aligned(4096)));
- unsigned int pt_table1[1024] __attribute__((aligned(4096)));
- unsigned int pt_table2[1024] __attribute__((aligned(4096)));
- ptd_table[0] = (unsigned int)pt_table1 | 3;
- ptd_table[1] = (unsigned int)pt_table2 | 3;
- for (i = 0; i < 1024; i++) {
- pt_table1[i] = (i * 4096) | 3;
- }
- for (i = 0; i < 1024; i++) {
- pt_table2[i] = ((1024 * 4096) + (i * 4096)) | 3;
- }
- // Create your page table here
- lcr3((unsigned int)ptd_table);
- for (i = 0; i < 64; i++) {
- int *p = (int *)(i * 4096 * 32);
- sum += *p;
- printk("page\n");
- }
- halt();
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement