Skip to content

Commit a371a1f

Browse files
authored
Fix hazard3 CSR bug and compile errors (#418)
1 parent d28ad3b commit a371a1f

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

port/raspberrypi/rp2xxx/src/cpus/hazard3.zig

+12-7
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,18 @@ pub const csr = struct {
443443
reserved0: u11,
444444
window: u16,
445445
});
446-
pub const meipra = CSR(0xbe2, packed struct {
446+
pub const meipra = CSR(0xbe3, packed struct {
447447
index: u5,
448448
reserved0: u11,
449449
window: u16,
450450
});
451+
pub const meinext = CSR(0xbe4, packed struct {
452+
update: u1,
453+
reserved0: u1,
454+
irq: u9,
455+
reserved1: u20,
456+
noirq: u1,
457+
});
451458
};
452459

453460
// TODO: maybe this should be relocated somewhere else
@@ -461,11 +468,9 @@ pub const csr = struct {
461468
const Self = @This();
462469

463470
pub inline fn read_raw() u32 {
464-
var value: u32 = undefined;
465-
asm volatile ("csrr %[value], " ++ ident
466-
: [value] "+r" (value),
471+
return asm volatile ("csrr %[value], " ++ ident
472+
: [value] "=r" (-> u32),
467473
);
468-
return value;
469474
}
470475

471476
pub inline fn read() T {
@@ -521,7 +526,7 @@ pub const csr = struct {
521526

522527
pub inline fn read_set_raw(bits: u32) u32 {
523528
return asm volatile ("csrrs %[value], " ++ ident ++ ", %[bits]"
524-
: [value] "r" (-> u32),
529+
: [value] "=r" (-> u32),
525530
: [bits] "r" (bits),
526531
);
527532
}
@@ -532,7 +537,7 @@ pub const csr = struct {
532537

533538
pub inline fn read_clear_raw(bits: u32) u32 {
534539
return asm volatile ("csrrc %[value], " ++ ident ++ ", %[bits]"
535-
: [value] "r" (-> u32),
540+
: [value] "=r" (-> u32),
536541
: [bits] "r" (bits),
537542
);
538543
}

0 commit comments

Comments
 (0)