Skip to content

Commit f2a5044

Browse files
authored
Merge pull request greatbridf#51 from SMS-Derfflinger/fix-loongarch
fix(hal): fix loongarch's boot falut
2 parents 4bb09f5 + c2e8f82 commit f2a5044

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

crates/eonix_hal/src/arch/loongarch64/bootstrap.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,29 @@ struct PageTable([u64; 512]);
4242
#[unsafe(link_section = ".bootstrap.page_table.1")]
4343
static BOOT_PAGE_TABLE: PageTable = {
4444
let mut arr = [0; 512];
45-
arr[0] = 0 | 0x11d3; // G | W | P | H | Cached | D | V
46-
arr[510] = 0 | 0x11d3; // G | W | P | H | Cached | D | V
47-
arr[511] = 0x8000_2000 | (1 << 60); // PT1, PT
45+
arr[0] = 0x8000_2000 | (1 << 60);
46+
arr[510] = 0x8000_2000 | (1 << 60);
47+
arr[511] = 0x8000_3000 | (1 << 60);
4848

4949
PageTable(arr)
5050
};
5151

5252
#[unsafe(link_section = ".bootstrap.page_table.2")]
5353
#[used]
5454
static PT1: PageTable = {
55+
let mut arr: [u64; 512] = [0; 512];
56+
let mut i: usize = 0;
57+
while i < 512 {
58+
arr[i] = (i as u64 * 0x4000_0000) | 0x11d3;
59+
i += 1;
60+
}
61+
62+
PageTable(arr)
63+
};
64+
65+
#[unsafe(link_section = ".bootstrap.page_table.3")]
66+
#[used]
67+
static PT2: PageTable = {
5568
let mut arr = [0; 512];
5669
arr[510] = 0x8000_0000 | 0x11d3; // G | W | P | H | Cached | D | V
5770

crates/eonix_hal/src/arch/loongarch64/link.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SECTIONS {
99
. = ORIGIN(RAM) + 0x1000;
1010
KEEP(*(.bootstrap.page_table.1));
1111
KEEP(*(.bootstrap.page_table.2));
12+
KEEP(*(.bootstrap.page_table.3));
1213

1314
. = ALIGN(16);
1415
KEEP(*(.bootstrap.stack));

0 commit comments

Comments
 (0)