Changeset 440 for trunk/kernel/mm/vmm.h
- Timestamp:
- May 3, 2018, 5:51:22 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/vmm.h
r437 r440 293 293 294 294 /********************************************************************************************* 295 * This function allocates physical memory from the local cluster to map all PTEs296 * of a "kernel" vseg (type KCODE , KDATA, or KDEV) in the page table of process_zero.297 * WARNING : It should not be used for "user" vsegs, that must be mapped using the298 * "on-demand-paging" policy.299 *********************************************************************************************300 * @ vseg : pointer on the vseg to be mapped.301 * @ attr : GPT attributes to be set for all vseg pages.302 * @ returns 0 if success / returns ENOMEM if no memory303 ********************************************************************************************/304 error_t vmm_map_kernel_vseg( vseg_t * vseg,305 uint32_t attr );306 307 /*********************************************************************************************308 295 * This function removes a given region (defined by a base address and a size) from 309 296 * the VMM of a given process descriptor. This can modify the number of vsegs: … … 335 322 * @ process : [in] pointer on process descriptor 336 323 * @ vaddr : [in] virtual address 337 * @ vseg : [out] pointer on foundvseg338 * @ returns 0 if success / returns -1 if user error .324 * @ vseg : [out] local pointer on local vseg 325 * @ returns 0 if success / returns -1 if user error (out of segment). 339 326 *********************************************************************************************/ 340 327 error_t vmm_get_vseg( struct process_s * process, … … 343 330 344 331 /********************************************************************************************* 345 * This function is called by the generic exception handler when a page-fault event 346 * has been detected for a given process in a given cluster. 347 * - If the local cluster is the reference, it call directly the vmm_get_pte() function. 348 * - If the local cluster is not the reference cluster, it send a RPC_VMM_GET_PTE 349 * to the reference cluster to get the missing PTE attributes and PPN, 350 * and update the local page table. 351 ********************************************************************************************* 352 * @ process : pointer on process descriptor. 353 * @ vpn : VPN of the missing PTE. 354 * @ returns 0 if success / returns ENOMEM if no memory. 332 * This function is called by the generic exception handler in case of page-fault, 333 * or copy-on-write event locally detected for a given <vpn> in a given <process> 334 * as defined by the <is_cow> argument. 335 * 1) For a Page-Fault: 336 * - If the local cluster is the reference, or for the STACK and CODE segment types, 337 * it call directly the vmm_get_pte() function to access the local VMM. 338 * - Otherwise, it send a RPC_VMM_GET_PTE to the reference cluster to get the missing 339 * PTE attributes and PPN. 340 * This function check that the missing VPN belongs to a registered vseg, allocates 341 * a new physical page if required, and updates the local page table. 342 * 2) For a Copy-On-Write: 343 * - If no pending fork, it reset the COW flag and set the WRITE flag in the reference 344 * GPT entry, and in all the GPT copies. 345 * - If there is a pending fork, it allocates a new physical page from the cluster defined 346 * by the vseg type, copies the old physical page content to the new physical page, 347 * and decrements the pending_fork counter in old physical page descriptor. 348 ********************************************************************************************* 349 * @ process : pointer on local process descriptor copy. 350 * @ vpn : VPN of the missing or faulting PTE. 351 * @ is_cow : Copy-On-Write event if true / Page-fault if false. 352 * @ returns 0 if success / returns ENOMEM if no memory or illegal VPN. 355 353 ********************************************************************************************/ 356 354 error_t vmm_handle_page_fault( struct process_s * process, 357 vpn_t vpn ); 358 359 /********************************************************************************************* 360 * This function is called by the generic exception handler when a copy-on-write event 361 * has been detected for a given process in a given cluster. 362 * It takes the lock protecting the physical page, and test the pending forks counter. 363 * If no pending fork: 364 * - it reset the COW flag and set the WRITE flag in the reference GPT entry, and in all 365 * the GPT copies 366 367 * If there is a pending forkon the 368 * - It get the involved vseg pointer. 369 * - It allocates a new physical page from the cluster defined by the vseg type. 370 * - It copies the old physical page content to the new physical page. 371 * - It decrements the pending_fork counter in old physical page descriptor. 372 373 ********************************************************************************************* 374 * @ process : pointer on process descriptor. 375 * @ vpn : VPN of the missing PTE. 376 * @ returns 0 if success / returns ENOMEM if no memory. 377 ********************************************************************************************/ 378 error_t vmm_handle_cow( struct process_s * process, 379 vpn_t vpn ); 380 381 /********************************************************************************************* 382 * This function handle both the "page-fault" and "copy-on_write" events for a given <vpn> 383 * in a given <process>. The <cow> argument defines the type of event to be handled. 384 * This function must be called by a thread running in reference cluster, and the vseg 385 * containing the searched VPN must be registered in the reference VMM. 355 vpn_t vpn, 356 bool_t is_cow ); 357 358 /********************************************************************************************* 359 * This function is called by the vmm_handle_page_fault() to handle both the "page-fault", 360 * and the "copy-on_write" events for a given <vpn> in a given <process>, as defined 361 * by the <is_cow> argument. 362 * The vseg containing the searched VPN must be registered in the reference VMM. 386 363 * - for an page-fault, it allocates the missing physical page from the target cluster 387 364 * defined by the vseg type, initializes it, and updates the reference GPT, but not … … 390 367 * initialise it from the old physical page, and updates the reference GPT and all 391 368 * the GPT copies, for coherence. 392 * I n both cases, it calls the RPC_PMEM_GET_PAGES to get the new physical page when393 * the target cluster is not the reference cluster.369 * It calls the RPC_PMEM_GET_PAGES to get the new physical page when the target cluster 370 * is not the local cluster, 394 371 * It returns in the <attr> and <ppn> arguments the accessed or modified PTE. 395 372 ********************************************************************************************* 396 373 * @ process : [in] pointer on process descriptor. 397 374 * @ vpn : [in] VPN defining the missing PTE. 398 * @ cow: [in] "copy_on_write" if true / "page_fault" if false.375 * @ is_cow : [in] "copy_on_write" if true / "page_fault" if false. 399 376 * @ attr : [out] PTE attributes. 400 377 * @ ppn : [out] PTE ppn. … … 403 380 error_t vmm_get_pte( struct process_s * process, 404 381 vpn_t vpn, 405 bool_t cow,382 bool_t is_cow, 406 383 uint32_t * attr, 407 384 ppn_t * ppn ); … … 428 405 ppn_t * ppn ); 429 406 430 /*********************************************************************************************431 * This function makes the virtual to physical address translation, using the calling432 * process page table. It uses identity mapping if required by the <ident> argument.433 * This address translation is required to configure the peripherals having a DMA434 * capability, or to implement the software L2/L3 cache cohérence, using the MMC device435 * synchronisation primitives.436 * WARNING : the <ident> value must be defined by the CONFIG_KERNEL_IDENTITY_MAP parameter.437 *********************************************************************************************438 * @ ident : [in] uses identity mapping if true.439 * @ ptr : [in] virtual address.440 * @ paddr : [out] pointer on buffer for physical address.441 * @ returns 0 if success / returns ENOMEM if error.442 ********************************************************************************************/443 error_t vmm_v2p_translate( bool_t ident,444 void * ptr,445 paddr_t * paddr );446 447 448 407 449 408 #endif /* _VMM_H_ */
Note: See TracChangeset
for help on using the changeset viewer.