This repository has been archived by the owner on Aug 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This test sends messages between two secondary VMs. The message is send from the primary, to relay_a, to relay_b and finally back to the primary. Bug: 116705004 Change-Id: Iff5b1726b870e9f502dedd9a4075da2529f50a09
- Loading branch information
1 parent
4b6c2fc
commit 3a94257
Showing
5 changed files
with
147 additions
and
10 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
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,32 @@ | ||
#include <stdalign.h> | ||
#include <stdint.h> | ||
|
||
#include "hf/mm.h" | ||
#include "hf/std.h" | ||
|
||
#include "vmapi/hf/call.h" | ||
|
||
#define FORWARD_VM_ID 2 | ||
|
||
alignas(4096) uint8_t kstack[4096]; | ||
|
||
static alignas(PAGE_SIZE) uint8_t send_page[PAGE_SIZE]; | ||
static alignas(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE]; | ||
|
||
static hf_ipaddr_t send_page_addr = (hf_ipaddr_t)send_page; | ||
static hf_ipaddr_t recv_page_addr = (hf_ipaddr_t)recv_page; | ||
|
||
void kmain(void) | ||
{ | ||
hf_vm_configure(send_page_addr, recv_page_addr); | ||
hf_vm_configure(send_page_addr, recv_page_addr); | ||
|
||
/* Loop, forward messages to the next VM. */ | ||
for (;;) { | ||
uint64_t ret = hf_mailbox_receive(true); | ||
uint32_t size = HF_MAILBOX_RECEIVE_SIZE(ret); | ||
memcpy(send_page, recv_page, size); | ||
hf_mailbox_clear(); | ||
hf_mailbox_send(FORWARD_VM_ID, 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,30 @@ | ||
#include <stdalign.h> | ||
#include <stdint.h> | ||
|
||
#include "hf/mm.h" | ||
#include "hf/std.h" | ||
|
||
#include "vmapi/hf/call.h" | ||
|
||
alignas(4096) uint8_t kstack[4096]; | ||
|
||
static alignas(PAGE_SIZE) uint8_t send_page[PAGE_SIZE]; | ||
static alignas(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE]; | ||
|
||
static hf_ipaddr_t send_page_addr = (hf_ipaddr_t)send_page; | ||
static hf_ipaddr_t recv_page_addr = (hf_ipaddr_t)recv_page; | ||
|
||
void kmain(void) | ||
{ | ||
hf_vm_configure(send_page_addr, recv_page_addr); | ||
hf_vm_configure(send_page_addr, recv_page_addr); | ||
|
||
/* Loop, forward messages to the primary. */ | ||
for (;;) { | ||
uint64_t ret = hf_mailbox_receive(true); | ||
uint32_t size = HF_MAILBOX_RECEIVE_SIZE(ret); | ||
memcpy(send_page, recv_page, size); | ||
hf_mailbox_clear(); | ||
hf_mailbox_send(HF_PRIMARY_VM_ID, size); | ||
} | ||
} |