@@ -70,24 +70,40 @@ pub fn call_host_function(
7070
7171 push_shared_output_data ( host_function_call_buffer) ?;
7272
73- outb ( OutBAction :: CallFunction as u16 , 0 ) ;
73+ outb ( OutBAction :: CallFunction as u16 , & [ 0 ] ) ;
7474
7575 Ok ( ( ) )
7676}
7777
78- pub fn outb ( port : u16 , value : u8 ) {
78+ pub fn outb ( port : u16 , data : & [ u8 ] ) {
7979 unsafe {
8080 match RUNNING_MODE {
8181 RunMode :: Hypervisor => {
82- hloutb ( port, value) ;
82+ for chunk in data. chunks ( 4 ) {
83+ let val = match chunk {
84+ [ a, b, c, d] => u32:: from_le_bytes ( [ * a, * b, * c, * d] ) ,
85+ [ a, b, c] => u32:: from_le_bytes ( [ * a, * b, * c, 0 ] ) ,
86+ [ a, b] => u32:: from_le_bytes ( [ * a, * b, 0 , 0 ] ) ,
87+ [ a] => u32:: from_le_bytes ( [ * a, 0 , 0 , 0 ] ) ,
88+ [ ] => break ,
89+ _ => unreachable ! ( ) ,
90+ } ;
91+
92+ hloutd ( val, port) ;
93+ }
8394 }
8495 RunMode :: InProcessLinux | RunMode :: InProcessWindows => {
8596 if let Some ( outb_func) = OUTB_PTR_WITH_CONTEXT {
8697 if let Some ( peb_ptr) = P_PEB {
87- outb_func ( ( * peb_ptr) . pOutbContext , port, value) ;
98+ outb_func (
99+ ( * peb_ptr) . pOutbContext ,
100+ port,
101+ data. as_ptr ( ) ,
102+ data. len ( ) as u64 ,
103+ ) ;
88104 }
89105 } else if let Some ( outb_func) = OUTB_PTR {
90- outb_func ( port, value ) ;
106+ outb_func ( port, data . as_ptr ( ) , data . len ( ) as u64 ) ;
91107 } else {
92108 panic ! ( "Tried to call outb without hypervisor and without outb function ptrs" ) ;
93109 }
@@ -100,7 +116,7 @@ pub fn outb(port: u16, value: u8) {
100116}
101117
102118extern "win64" {
103- fn hloutb ( port : u16 , value : u8 ) ;
119+ fn hloutd ( value : u32 , port : u16 ) ;
104120}
105121
106122pub fn print_output_as_guest_function ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
@@ -120,13 +136,15 @@ pub fn print_output_as_guest_function(function_call: &FunctionCall) -> Result<Ve
120136 }
121137}
122138
123- // port: RCX(cx), value: RDX(dl)
139+ pub fn debug_print ( msg : & str ) {
140+ outb ( OutBAction :: DebugPrint as u16 , msg. as_bytes ( ) ) ;
141+ }
142+
124143global_asm ! (
125- ".global hloutb
126- hloutb:
127- xor rax, rax
128- mov al, dl
129- mov dx, cx
130- out dx, al
131- ret"
144+ ".global hloutd
145+ hloutd:
146+ mov eax, ecx
147+ mov dx, dx
148+ out dx, eax
149+ ret"
132150) ;
0 commit comments