1- use core:: arch:: { asm, global_asm } ;
1+ use core:: arch:: asm;
22
33#[ repr( packed) ]
4+ #[ allow( dead_code) ] // the structure format is defined by the hardware
45pub struct DiskAddressPacket {
56 /// Size of the DAP structure
67 packet_size : u8 ,
@@ -17,17 +18,6 @@ pub struct DiskAddressPacket {
1718}
1819
1920impl DiskAddressPacket {
20- pub fn new ( memory_buffer_start : u16 , file_offset : u64 , bytes : u32 ) -> Self {
21- Self {
22- packet_size : 0x10 ,
23- zero : 0 ,
24- number_of_sectors : ( bytes / 512 ) as u16 ,
25- offset : memory_buffer_start,
26- segment : 0 ,
27- start_lba : file_offset / 512 ,
28- }
29- }
30-
3121 pub fn from_lba ( memory_buffer_start : u16 , start_lba : u64 , number_of_sectors : u16 ) -> Self {
3222 Self {
3323 packet_size : 0x10 ,
@@ -41,18 +31,20 @@ impl DiskAddressPacket {
4131
4232 pub unsafe fn perform_load ( & self , disk_number : u16 ) {
4333 let self_addr = self as * const Self as u16 ;
44- asm ! (
45- "push 0x7a" , // error code `z`, passed to `fail` on error
46- "mov {1:x}, si" ,
47- "mov si, {0:x}" ,
48- "int 0x13" ,
49- "jc fail" ,
50- "pop si" , // remove error code again
51- "mov si, {1:x}" ,
52- in( reg) self_addr,
53- out( reg) _,
54- in( "ax" ) 0x4200u16 ,
55- in( "dx" ) disk_number,
56- ) ;
34+ unsafe {
35+ asm ! (
36+ "push 0x7a" , // error code `z`, passed to `fail` on error
37+ "mov {1:x}, si" ,
38+ "mov si, {0:x}" ,
39+ "int 0x13" ,
40+ "jc fail" ,
41+ "pop si" , // remove error code again
42+ "mov si, {1:x}" ,
43+ in( reg) self_addr,
44+ out( reg) _,
45+ in( "ax" ) 0x4200u16 ,
46+ in( "dx" ) disk_number,
47+ ) ;
48+ }
5749 }
5850}
0 commit comments