Changeset 225
- Timestamp:
- Jul 18, 2017, 11:05:17 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_gpt.c
r224 r225 247 247 ***************************************************************************************/ 248 248 249 uint32_t GPT_MAPPED; 250 uint32_t GPT_SMALL; 251 uint32_t GPT_READABLE; 252 uint32_t GPT_WRITABLE; 253 uint32_t GPT_EXECUTABLE; 254 uint32_t GPT_CACHABLE; 255 uint32_t GPT_USER; 256 uint32_t GPT_DIRTY; 257 uint32_t GPT_ACCESSED; 258 uint32_t GPT_GLOBAL; 259 uint32_t GPT_COW; 260 uint32_t GPT_SWAP; 261 uint32_t GPT_LOCKED; 262 263 error_t hal_gpt_create( gpt_t * gpt ) 264 { 265 x86_panic((char *)__func__); 249 uint32_t GPT_MAPPED; 250 uint32_t GPT_SMALL; 251 uint32_t GPT_READABLE; 252 uint32_t GPT_WRITABLE; 253 uint32_t GPT_EXECUTABLE; 254 uint32_t GPT_CACHABLE; 255 uint32_t GPT_USER; 256 uint32_t GPT_DIRTY; 257 uint32_t GPT_ACCESSED; 258 uint32_t GPT_GLOBAL; 259 uint32_t GPT_COW; 260 uint32_t GPT_SWAP; 261 uint32_t GPT_LOCKED; 262 263 error_t hal_gpt_create(gpt_t *gpt) 264 { 265 page_t *page; 266 267 /* check page size */ 268 if (CONFIG_PPM_PAGE_SIZE != 4096) { 269 printk("\n[PANIC] in %s : For x86, the page must be 4 Kbytes\n", __FUNCTION__); 270 hal_core_sleep(); 271 } 272 273 /* allocate a physical page for L4 */ 274 kmem_req_t req; 275 req.type = KMEM_PAGE; 276 req.size = 1; 277 req.flags = AF_KERNEL | AF_ZERO; 278 page = (page_t *)kmem_alloc(&req); 279 280 if (page == NULL) { 281 printk("\n[ERROR] in %s : cannot allocate physical memory for PT1\n", __FUNCTION__); 282 return ENOMEM; 283 } 284 285 /* populate the kernel entries */ 286 pt_entry_t *L4src, *L4dst; 287 extern paddr_t L4paddr; // XXX XXX smp 288 vaddr_t L4vaddr = L4paddr + KERNBASE; // XXX 289 L4src = (pt_entry_t *)L4vaddr; 290 L4dst = (pt_entry_t *)ppm_page2vaddr(page); 291 memcpy(&L4dst[256], &L4src[256], 256 * sizeof(pt_entry_t)); 292 L4dst[L4_SLOT_PTE] = (ppm_page2ppn(page) >> CONFIG_PPM_PAGE_SHIFT) | 293 PG_V | PG_KW | PG_NX; 294 295 /* initialize generic page table descriptor */ 296 gpt->ptr = ppm_page2vaddr(page); 297 gpt->ppn = ppm_page2ppn(page); 298 gpt->page = page; 299 300 /* initialize PTE entries attributes masks */ 301 GPT_MAPPED = PG_V; 302 GPT_SMALL = 0; 303 GPT_READABLE = PG_V; 304 GPT_WRITABLE = PG_RW; 305 GPT_EXECUTABLE = 0; 306 GPT_CACHABLE = 0; 307 GPT_USER = PG_u; 308 GPT_DIRTY = 0; 309 GPT_ACCESSED = 0; 310 GPT_GLOBAL = PG_G; 311 GPT_COW = 0; 312 GPT_SWAP = 0; 313 GPT_LOCKED = 0; 314 266 315 return 0; 267 316 }
Note: See TracChangeset
for help on using the changeset viewer.