-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bb4870
commit 4344338
Showing
5 changed files
with
149 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright 2024, UNSW | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
#pragma once | ||
|
||
#include <microkit.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
/* This sets up the resources needed by a userspace driver. Includes registering the uio virq and notify region. | ||
* The uio driver will write into the notify region in order to transfer execution to the VMM for it to then notify | ||
* other microkit components. | ||
*/ | ||
bool uio_register_driver(int irq, microkit_channel ch, uintptr_t region_base, size_t region_size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
/* | ||
* Copyright 2024, UNSW | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <microkit.h> | ||
#include <libvmm/util/util.h> | ||
#include <libvmm/arch/aarch64/fault.h> | ||
#include <libvmm/virq.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
bool uio_notify_fault_handle(size_t vcpu_id, size_t offset, size_t fsr, seL4_UserContext *regs, void *data) | ||
{ | ||
microkit_channel ch = *(microkit_channel *)data; | ||
if (fault_is_read(fsr)) { | ||
LOG_VMM_ERR("Read into VMM notify region, but uio driver should never do that\n"); | ||
assert(false); | ||
} else { | ||
microkit_notify(ch); | ||
} | ||
} | ||
|
||
void uio_ack(size_t vcpu_id, int irq, void *cookie) | ||
{ | ||
/* Do nothing for UIO ack */ | ||
} | ||
|
||
bool uio_register_driver(int irq, microkit_channel ch, uintptr_t region_base, size_t region_size) | ||
{ | ||
bool success = virq_register(GUEST_VCPU_ID, irq, uio_ack, NULL); | ||
assert(success); | ||
success = fault_register_vm_exception_handler(region_base, | ||
region_size, | ||
&uio_notify_fault_handle, | ||
&(void *)ch); | ||
if (!success) { | ||
LOG_VMM_ERR("Could not register uio virtual memory fault handler for " | ||
"uio notify region [0x%lx..0x%lx)\n", region_base, region_base + region_size); | ||
return false; | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters