Get sip,gip from bootph, call tftp_open

This commit is contained in:
Thomas Oltmann 2026-05-21 15:57:46 +02:00
parent b047e34dcb
commit 8dbeccbe75
2 changed files with 51 additions and 11 deletions

View file

@ -1,2 +1,2 @@
#!/bin/sh #!/bin/sh
qemu-system-x86_64 -netdev user,id=n1,net=10.0.0.5/24,tftp=.,bootfile=/boot.bin -device virtio-net-pci,netdev=n1,bootindex=0 "$@" qemu-system-x86_64 -netdev user,id=n1,net=10.0.0.5/24,tftp=serve/,bootfile=/boot.bin -device virtio-net-pci,netdev=n1,bootindex=0 "$@"

View file

@ -159,6 +159,24 @@ struct exPXE {
uint32_t pmentry; uint32_t pmentry;
}; };
struct bootph {
uint8_t opcode;
uint8_t hardware;
uint8_t hardlen;
uint8_t gatehops;
uint32_t ident;
uint16_t seconds;
uint16_t flags;
uint32_t cip;
uint32_t yip;
uint32_t sip;
uint32_t gip;
uint8_t caddr[16];
uint8_t sname[64];
uint8_t bootfile[128];
uint8_t vendor[64];
};
extern uint32_t pxe_entry; extern uint32_t pxe_entry;
extern uint32_t pxe_call(uint16_t func, uint16_t segment, uint16_t offset); extern uint32_t pxe_call(uint16_t func, uint16_t segment, uint16_t offset);
@ -224,16 +242,6 @@ main()
pg_setup(); pg_setup();
#if 0
t_PXENV_TFTP_OPEN *t_open = (void *)pxe_cmd_buf;
t_open->status = 0;
t_open->server_ip = 0x0100000Au;
t_open->gateway_ip = 0;
memcpy(t_open->filename, "/initrd", 8);
t_open->tftp_port = 69 << 8;
t_open->packet_size = 512;
#endif
#if 1 #if 1
t_PXENV_GET_CACHED *t_get = (void *)pxe_cmd_buf; t_PXENV_GET_CACHED *t_get = (void *)pxe_cmd_buf;
t_get->status = 0; t_get->status = 0;
@ -249,6 +257,38 @@ main()
debug_write_uint(ret); debug_write_uint(ret);
debug_write("\r\nstatus="); debug_write("\r\nstatus=");
debug_write_uint(t_get->status); debug_write_uint(t_get->status);
debug_write("\r\n");
#endif
debug_write("buffer_off=");
debug_write_uint(t_get->buffer_offset);
debug_write("\r\nbuffer_seg=");
debug_write_uint(t_get->buffer_seg);
struct bootph *bootph = (void *)(t_get->buffer_offset + 16 * t_get->buffer_seg);
uint32_t sip = bootph->sip;
uint32_t gip = bootph->gip;
debug_write("\r\nsip=");
debug_write_uint(sip);
debug_write("\r\ngip=");
debug_write_uint(gip);
debug_write("\r\n");
#if 1
t_PXENV_TFTP_OPEN *t_open = (void *)pxe_cmd_buf;
t_open->status = 0;
t_open->server_ip = sip;
t_open->gateway_ip = gip;
memcpy(t_open->filename, "/initrd", 8);
t_open->tftp_port = 69 << 8;
t_open->packet_size = 512;
debug_write("Performing PXE OPEN call\r\n");
ret = pxe_call(PXENV_TFTP_OPEN, (uint16_t)(uintptr_t)pxe_cmd_buf, 0x0000);
debug_write("Still alive!\r\n");
debug_write("ret=");
debug_write_uint(ret);
debug_write("\r\nstatus=");
debug_write_uint(t_open->status);
debug_write("\r\n");
#endif #endif
#if 0 #if 0