From 093969301e8ff8a40650285aef10a32f31c1c558 Mon Sep 17 00:00:00 2001 From: Thomas Oltmann Date: Wed, 9 Jul 2025 19:29:27 +0200 Subject: [PATCH] Trying to debug failing TFTP open --- lboot.S | 75 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/lboot.S b/lboot.S index 0b734b0..88bf871 100644 --- a/lboot.S +++ b/lboot.S @@ -89,6 +89,8 @@ _start: cli add $12, %sp mov tx_buf+20, %eax mov %eax, server_ip + mov tx_buf+24, %eax + mov %eax, gateway_ip mov $msg_unreal, %si call print @@ -323,16 +325,30 @@ tftp_open: push %ecx push %bp mov %sp, %bp + mov %esi, %ebx + + mov $msg_topen, %si + call print + push $PACKET_SIZE push $69<<8 mov $128, %ecx - sub %cx, %sp + sub %cx, %sp mov %ss, %edi shl $4, %edi add %esp, %edi + xor %ax, %ax + cld + addr32 rep stosb + mov %ebx, %esi + mov $6, %ecx + mov %ss, %edi + shl $4, %edi + add %esp, %edi + cld addr32 rep movsb - push $0 - push $0 + push gateway_ip+2 + push gateway_ip push server_ip+2 push server_ip push $0 @@ -348,6 +364,9 @@ tftp_open: push %ecx tftp_close: push %bp mov %sp, %bp + mov $msg_tclose, %si + call print + push $0 pxe_call PXE_TFTP_CLOSE @@ -359,6 +378,9 @@ tftp_read: push %ebx push %bp mov %sp, %bp + mov $msg_tread, %si + call print + push %cs push $tx_buf push $0 @@ -377,7 +399,14 @@ out_of_mem: mov $msg_memerr, %si jmp hang // print: print NUL-terminated string pointed to by SI -print: xor %bx, %bx +print: push %eax + push %ebx + push %edx + push %esi + push %bp + mov %sp, %bp + + xor %bx, %bx _prnext: mov $COM1+5, %dx inb %dx, %al @@ -395,7 +424,12 @@ _prnext: mov $COM1+5, %dx int $0x10 jmp _prnext -_prdone: ret +_prdone: leave + pop %esi + pop %edx + pop %ebx + pop %eax + ret // long: Enter long mode long: @@ -434,33 +468,8 @@ long: hang: hlt jmp hang -_pcerr: push %cx - - mov $msg_pcerr, %si +_pcerr: mov $msg_pcerr, %si call print - - pop %cx - push %cx - - xor %bx, %bx - mov %ch, %bl - mov hex_digits(%bx), %bl - mov %bx, tx_buf - mov $tx_buf, %si - call print - - pop %cx - push %cx - - xor %bx, %bx - mov %cl, %bl - mov hex_digits(%bx), %bl - mov %bx, tx_buf - mov $tx_buf, %si - call print - - pop %cx - jmp hang // gdt16: Protected mode / Unreal mode 16-bit GDT @@ -522,11 +531,15 @@ msg_long: .asciz " * Long Mode\r\n" msg_pserr: .asciz "panic: Missing !PXE structure.\r\n" msg_pcerr: .asciz "panic: PXE call failed.\r\n" msg_memerr: .asciz "panic: Out of heap space.\r\n" +msg_topen: .asciz "tftp_open\r\n" +msg_tclose: .asciz "tftp_close\r\n" +msg_tread: .asciz "tftp_read\r\n" fn_initrd: .asciz "initrd" pxe_api: .long 0 server_ip: .space 4 +gateway_ip: .space 4 heap_ptr: .long 0 heap_end: .long 0