mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
unit test for "hello multiverse"
four cores started all at once, each responsible for updating a byte of the GPIO range, in unison.
This commit is contained in:
parent
0045e32508
commit
153db680f2
1 changed files with 33 additions and 14 deletions
|
|
@ -49,24 +49,40 @@ pub fn hello_multiverse() {
|
|||
bio_ss.bio.wo(utra::bio::SFR_QDIV1, 0x20_0000);
|
||||
bio_ss.bio.wo(utra::bio::SFR_QDIV2, 0x20_0000);
|
||||
bio_ss.bio.wo(utra::bio::SFR_QDIV3, 0x20_0000);
|
||||
// snap GPIO outputs to the quantum
|
||||
bio_ss.bio.wo(utra::bio::SFR_CONFIG,
|
||||
bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_TO_QUANTUM, 1)
|
||||
| bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_TO_QUANTUM, 2) // arbitrary choice, they should all be the same
|
||||
);
|
||||
// start all the machines, all at once
|
||||
bio_ss.bio.wo(utra::bio::SFR_CTRL, 0xfff);
|
||||
report_api(0x1310_10FF);
|
||||
}
|
||||
|
||||
bio_code!(multiverse_code, MULTIVERSE_START, MULTIVERSE_END,
|
||||
"jal x0, 0f",
|
||||
// reset vectors for each machine
|
||||
// use `jal x0, target` encoding to force non-C interpretation
|
||||
// as the reset vectors for each core are aligned to 4-byte boundaries
|
||||
"jal x0, 0f",
|
||||
"jal x0, 1f",
|
||||
"jal x0, 2f",
|
||||
"jal x0, 3f",
|
||||
// Reset vectors for each core are aligned to 4-byte boundaries
|
||||
// As long as the jump target is <2kiB from reset, this will emit
|
||||
// a C-instruction, so it needs padding with a NOP. Unfortunately,
|
||||
// I can't seem to figure out a way to force the assembler to always
|
||||
// encode as uncompressed, so, you have to be aware of the jump destination
|
||||
// for the assembler output to line up according to your expectation :(
|
||||
//
|
||||
// using 'c.j' syntax for the jump causes the assembler to emit an error,
|
||||
// but the code still compiles, so...avoiding that for now. might be a bug,
|
||||
// but I am very not interested in fixing that today.
|
||||
"j 0f",
|
||||
"nop",
|
||||
"j 1f",
|
||||
"nop",
|
||||
"j 2f",
|
||||
"nop",
|
||||
"j 3f",
|
||||
"nop",
|
||||
// mach 0 code
|
||||
"0:",
|
||||
// x26 sets the GPIO mask
|
||||
"li x26, 0xFF",
|
||||
"li x2, 0xFF", // load constants into r0-15 bank first
|
||||
"mv x26, x2", // it's not legal to do anything other than mv to x26
|
||||
"add x1, zero, 0x10",
|
||||
"4:",
|
||||
"add x1, x1, 0x1",
|
||||
|
|
@ -77,7 +93,8 @@ bio_code!(multiverse_code, MULTIVERSE_START, MULTIVERSE_END,
|
|||
"j 4b",
|
||||
// mach 1 code
|
||||
"1:",
|
||||
"li x26, 0xFF00",
|
||||
"li x2, 0xFF00",
|
||||
"mv x26, x2",
|
||||
"add x1, zero, 0x20",
|
||||
"5:",
|
||||
"add x1, x1, 0x1",
|
||||
|
|
@ -86,8 +103,9 @@ bio_code!(multiverse_code, MULTIVERSE_START, MULTIVERSE_END,
|
|||
"j 5b",
|
||||
// mach 2 code
|
||||
"2:",
|
||||
"li x26, 0xFF0000",
|
||||
"add x1, zero, 0x20",
|
||||
"li x2, 0xFF0000",
|
||||
"mv x26, x2",
|
||||
"add x1, zero, 0x30",
|
||||
"6:",
|
||||
"add x1, x1, 0x1",
|
||||
"slli x21, x1, 16",
|
||||
|
|
@ -95,8 +113,9 @@ bio_code!(multiverse_code, MULTIVERSE_START, MULTIVERSE_END,
|
|||
"j 6b",
|
||||
// mach 3 code
|
||||
"3:",
|
||||
"li x26, 0xFF0000",
|
||||
"add x1, zero, 0x20",
|
||||
"li x2, 0xFF000000",
|
||||
"mv x26, x2",
|
||||
"add x1, zero, 0x40",
|
||||
"7:",
|
||||
"add x1, x1, 0x1",
|
||||
"slli x21, x1, 24",
|
||||
|
|
|
|||
Loading…
Reference in a new issue