Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sharedpage.c
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | shared_page_fill(int size, int align, const void *data) | ||||
res = shared_page_alloc_locked(size, align); | res = shared_page_alloc_locked(size, align); | ||||
if (res != -1) | if (res != -1) | ||||
shared_page_write(res, size, data); | shared_page_write(res, size, data); | ||||
sx_xunlock(&shared_page_alloc_sx); | sx_xunlock(&shared_page_alloc_sx); | ||||
return (res); | return (res); | ||||
} | } | ||||
static void | static void | ||||
shared_page_init(void *dummy __unused) | shared_page_init(void) | ||||
{ | { | ||||
vm_page_t m; | vm_page_t m; | ||||
vm_offset_t addr; | vm_offset_t addr; | ||||
sx_init(&shared_page_alloc_sx, "shpsx"); | sx_init(&shared_page_alloc_sx, "shpsx"); | ||||
shared_page_obj = vm_pager_allocate(OBJT_PHYS, 0, PAGE_SIZE, | shared_page_obj = vm_pager_allocate(OBJT_PHYS, 0, PAGE_SIZE, | ||||
VM_PROT_DEFAULT, 0, NULL); | VM_PROT_DEFAULT, 0, NULL); | ||||
VM_OBJECT_WLOCK(shared_page_obj); | VM_OBJECT_WLOCK(shared_page_obj); | ||||
m = vm_page_grab(shared_page_obj, 0, VM_ALLOC_ZERO); | m = vm_page_grab(shared_page_obj, 0, VM_ALLOC_ZERO); | ||||
VM_OBJECT_WUNLOCK(shared_page_obj); | VM_OBJECT_WUNLOCK(shared_page_obj); | ||||
vm_page_valid(m); | vm_page_valid(m); | ||||
vm_page_xunbusy(m); | vm_page_xunbusy(m); | ||||
addr = kva_alloc(PAGE_SIZE); | addr = kva_alloc(PAGE_SIZE); | ||||
pmap_qenter(addr, &m, 1); | pmap_qenter(addr, &m, 1); | ||||
shared_page_mapping = (char *)addr; | shared_page_mapping = (char *)addr; | ||||
} | } | ||||
SYSINIT(shp, SI_SUB_EXEC, SI_ORDER_FIRST, (sysinit_cfunc_t)shared_page_init, | SYSINIT(shp, SI_SUB_EXEC, SI_ORDER_FIRST, shared_page_init); | ||||
NULL); | |||||
/* | /* | ||||
* Push the timehands update to the shared page. | * Push the timehands update to the shared page. | ||||
* | * | ||||
* The lockless update scheme is similar to the one used to update the | * The lockless update scheme is similar to the one used to update the | ||||
* in-kernel timehands, see sys/kern/kern_tc.c:tc_windup() (which | * in-kernel timehands, see sys/kern/kern_tc.c:tc_windup() (which | ||||
* calls us after the timehands are updated). | * calls us after the timehands are updated). | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 250 Lines • Show Last 20 Lines |