Update to sector size of 512
This commit is contained in:
parent
68d9e64f93
commit
9e48568e22
@ -3,25 +3,16 @@ _start:
|
|||||||
move.b #0x4, d0
|
move.b #0x4, d0
|
||||||
bsr.w find_first_card
|
bsr.w find_first_card
|
||||||
| Load the header sector for the kernel binary
|
| Load the header sector for the kernel binary
|
||||||
move.l #0x1, (a0) | Set the sector number to 1
|
move.l #0x200, a1 | Set the destination address to 0x200
|
||||||
| Transfer 0x100 (256) bytes from the storage card's data register to 0x100
|
move.l #0x1, d0 | Set the starting sector number to 1
|
||||||
move.w #0x100, a1 | Load a1, the destination address register, with 0x100
|
move.l #0x1, d1 | Set the sector count to 1
|
||||||
move.w #0xFF, d0 | Load d0 with the sector size - 1.
|
bsr.w read_sectors
|
||||||
hdr_sector_loop:
|
|
||||||
move.b (4, a0), (a1)+ | Transfer a byte of sector data to the destination
|
|
||||||
dbra d0, hdr_sector_loop | Loop back if there is more to transfer
|
|
||||||
move.w (0x102), d0 | Load d0 with the number of sectors for the kernel - 1
|
|
||||||
subq.w #0x1, d0
|
|
||||||
| load the ELF kernel binary off the disk
|
| load the ELF kernel binary off the disk
|
||||||
move.l #0x2, (a0) | Set the sector number to 2
|
move.l #0xA000, a1 | Set the destination address to 0xA000
|
||||||
| Transfer 0x100 (256) * d0 bytes from the storage card's data register to 0xA000
|
move.l #0x2, d0 | Set the starting sector number to 2
|
||||||
move.l #0xA000, a1 | Load a1, the destination address register, with 0xA000
|
clr.l d1
|
||||||
sectors_loop:
|
move.w (0x202), d1 | Set the sector count
|
||||||
move.w #0xFF, d1 | Load d0 with the sector size - 1.
|
bsr.b read_sectors
|
||||||
sector_loop:
|
|
||||||
move.b (4, a0), (a1)+ | Transfer a byte of sector data to the destination
|
|
||||||
dbra d1, sector_loop | Loop back if there is more to transfer
|
|
||||||
dbra d0, sectors_loop | Loop back if there are more sectors to transfer
|
|
||||||
move.l (0xA01C), d0 | Load the offset of the program headers in the file
|
move.l (0xA01C), d0 | Load the offset of the program headers in the file
|
||||||
move.l #0xA000, a0 | Put the address of the program headers in a0
|
move.l #0xA000, a0 | Put the address of the program headers in a0
|
||||||
adda.w d0, a0
|
adda.w d0, a0
|
||||||
@ -72,8 +63,32 @@ ffc_done:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
.if . != 256
|
| Reads sectors from a storage card
|
||||||
.org 255
|
| Card base in a0
|
||||||
|
| Destination in a1
|
||||||
|
| Start sector in d0.l
|
||||||
|
| Sector count in d1.l
|
||||||
|
| Clobbers a1, d1
|
||||||
|
read_sectors:
|
||||||
|
move.l d0, (a0) | Set the sector number
|
||||||
|
move.l d1, (4, a0) | Set the sector count
|
||||||
|
move.w #0x0, (8, a0) | Issue a read command
|
||||||
|
| Transfer 0x200 (512) * sector_count bytes from the storage card's data register to (a1)
|
||||||
|
lsl.l #8, d1 | d0 = d0 * 256 to compute the number of words to transfer
|
||||||
|
subq.l #0x1, d1 | Subtract 1 from the word count to account for the extra loop done by dbra
|
||||||
|
bra.b rs_loop
|
||||||
|
rs_loop_swap:
|
||||||
|
swap.w d1
|
||||||
|
rs_loop:
|
||||||
|
move.w (0xA, a0), (a1)+ | Transfer a word of sector data to the destination
|
||||||
|
dbra.w d1, rs_loop
|
||||||
|
swap.w d1
|
||||||
|
dbra.w d1, rs_loop_swap
|
||||||
|
rts
|
||||||
|
|
||||||
|
.if . != 512
|
||||||
|
.org 511
|
||||||
.byte 0
|
.byte 0
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@ use std::{
|
|||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
const BLOCK_SIZE: u16 = 256;
|
const BLOCK_SIZE: u16 = 512;
|
||||||
|
const MAX_NAME_LEN: u16 = BLOCK_SIZE - 8;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut archive = File::create("initrd").expect("Could not open initrd");
|
let mut archive = File::create("initrd").expect("Could not open initrd");
|
||||||
@ -13,9 +14,12 @@ fn main() {
|
|||||||
let file_path = Path::new(&file_path);
|
let file_path = Path::new(&file_path);
|
||||||
let file_name = file_path.file_name().unwrap();
|
let file_name = file_path.file_name().unwrap();
|
||||||
let file_name_len =
|
let file_name_len =
|
||||||
u8::try_from(file_name.len()).expect("File name length greater than 256 bytes");
|
u16::try_from(file_name.len()).expect("File name length greater than 256 bytes");
|
||||||
if file_name_len > 252 {
|
if file_name_len > MAX_NAME_LEN {
|
||||||
panic!("File {:?} has name longer than 252 bytes", file_name);
|
panic!(
|
||||||
|
"File {:?} has name longer than {} bytes",
|
||||||
|
file_name, MAX_NAME_LEN
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let mut file = File::open(file_path).expect("File did not exist");
|
let mut file = File::open(file_path).expect("File did not exist");
|
||||||
let length = u16::try_from(file.metadata().expect("Could not get file metadata").len())
|
let length = u16::try_from(file.metadata().expect("Could not get file metadata").len())
|
||||||
@ -24,7 +28,7 @@ fn main() {
|
|||||||
let mut header_block = Vec::new();
|
let mut header_block = Vec::new();
|
||||||
header_block.extend_from_slice(&length.to_be_bytes());
|
header_block.extend_from_slice(&length.to_be_bytes());
|
||||||
header_block.extend_from_slice(&file_num_blocks.to_be_bytes());
|
header_block.extend_from_slice(&file_num_blocks.to_be_bytes());
|
||||||
header_block.push(file_name_len);
|
header_block.extend_from_slice(&file_name_len.to_be_bytes());
|
||||||
header_block.extend_from_slice(file_name.to_str().unwrap().as_bytes());
|
header_block.extend_from_slice(file_name.to_str().unwrap().as_bytes());
|
||||||
header_block.push(0);
|
header_block.push(0);
|
||||||
header_block.resize(BLOCK_SIZE as usize, 0);
|
header_block.resize(BLOCK_SIZE as usize, 0);
|
||||||
@ -41,6 +45,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
archive
|
archive
|
||||||
.write_all(&[0; 256])
|
.write_all(&[0; BLOCK_SIZE as usize])
|
||||||
.expect("Could not write to initrd");
|
.expect("Could not write to initrd");
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
.global _start
|
.global _start
|
||||||
_start:
|
_start:
|
||||||
|
move.b #'H', 0xFF0200
|
||||||
|
move.b #'i', 0xFF0200
|
||||||
|
move.b #0xA, 0xFF0200
|
||||||
stop #0x2700
|
stop #0x2700
|
||||||
|
Loading…
Reference in New Issue
Block a user