trying and failing to receive a whole file ...
This commit is contained in:
parent
48f1e90744
commit
5631354405
2 changed files with 42 additions and 73 deletions
111
src/main.c
111
src/main.c
|
|
@ -181,11 +181,13 @@ 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);
|
||||||
|
|
||||||
extern unsigned char pxe_cmd_buf[512];
|
extern unsigned char pxe_cmd_buf[512];
|
||||||
|
extern unsigned char pxe_dat_buf[512];
|
||||||
extern struct PXENV *PXENV;
|
extern struct PXENV *PXENV;
|
||||||
extern struct exPXE *exPXE;
|
extern struct exPXE *exPXE;
|
||||||
|
|
||||||
#define PXENV_GET_CACHED 0x0071
|
#define PXENV_GET_CACHED 0x0071
|
||||||
#define PXENV_TFTP_OPEN 0x0020
|
#define PXENV_TFTP_OPEN 0x0020
|
||||||
|
#define PXENV_TFTP_CLOSE 0x0021
|
||||||
#define PXENV_TFTP_READ 0x0022
|
#define PXENV_TFTP_READ 0x0022
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) s_PXENV_GET_CACHED {
|
typedef struct __attribute__((packed)) s_PXENV_GET_CACHED {
|
||||||
|
|
@ -214,6 +216,10 @@ typedef struct __attribute__((packed)) s_PXENV_TFTP_READ {
|
||||||
uint16_t buffer_seg;
|
uint16_t buffer_seg;
|
||||||
} t_PXENV_TFTP_READ;
|
} t_PXENV_TFTP_READ;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) s_PXENV_TFTP_CLOSE {
|
||||||
|
uint16_t status;
|
||||||
|
} t_PXENV_TFTP_CLOSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return type for fs drivers
|
* return type for fs drivers
|
||||||
*/
|
*/
|
||||||
|
|
@ -320,13 +326,23 @@ receive_file(void)
|
||||||
debug_write("\r\n");
|
debug_write("\r\n");
|
||||||
|
|
||||||
uint16_t packet_size = t_open->packet_size;
|
uint16_t packet_size = t_open->packet_size;
|
||||||
|
debug_write("packet_size=");
|
||||||
|
debug_write_uint(t_open->packet_size);
|
||||||
|
debug_write("\r\n");
|
||||||
|
|
||||||
#if 0
|
/*
|
||||||
|
__asm__ ("cli");
|
||||||
|
for (;;) {}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if 1
|
||||||
for (;;) {
|
for (;;) {
|
||||||
t_PXENV_TFTP_READ *t_read = (void *)pxe_cmd_buf;
|
t_PXENV_TFTP_READ *t_read = (void *)pxe_cmd_buf;
|
||||||
t_read->status = 0;
|
t_read->status = 0;
|
||||||
t_read->buffer_offset = ;
|
uintptr_t lin_addr = (uintptr_t)pxe_dat_buf;
|
||||||
t_read->buffer_seg = ;
|
t_read->buffer_seg = lin_addr >> 4;
|
||||||
|
t_read->buffer_offset = lin_addr - 16 * t_read->buffer_seg;
|
||||||
|
t_read->buffer_size = 512;
|
||||||
|
|
||||||
ret = pxe_call(PXENV_TFTP_READ, (uint16_t)(uintptr_t)pxe_cmd_buf, 0x0000);
|
ret = pxe_call(PXENV_TFTP_READ, (uint16_t)(uintptr_t)pxe_cmd_buf, 0x0000);
|
||||||
debug_write("ret=");
|
debug_write("ret=");
|
||||||
|
|
@ -338,15 +354,30 @@ receive_file(void)
|
||||||
if (t_read->buffer_size < packet_size) {
|
if (t_read->buffer_size < packet_size) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TEMP
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
t_PXENV_TFTP_CLOSE *t_close = (void *)pxe_cmd_buf;
|
||||||
|
t_close->status = 0;
|
||||||
|
debug_write("Calling TFTP_CLOSE\r\n");
|
||||||
|
ret = pxe_call(PXENV_TFTP_CLOSE, (uint16_t)(uintptr_t)pxe_cmd_buf, 0x0000);
|
||||||
|
debug_write("ret=");
|
||||||
|
debug_write_uint(ret);
|
||||||
|
debug_write(" status=");
|
||||||
|
debug_write_uint(t_open->status);
|
||||||
|
debug_write("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
blank_screen(0x10);
|
blank_screen(0x10);
|
||||||
move_cursor(0, 0);
|
move_cursor(0, 0);
|
||||||
|
*/
|
||||||
//display_string(0x14, "Netboot via fernlader v2 ...\r\n");
|
//display_string(0x14, "Netboot via fernlader v2 ...\r\n");
|
||||||
debug_write("Going well ...\r\n");
|
debug_write("Going well ...\r\n");
|
||||||
|
|
||||||
|
|
@ -361,14 +392,13 @@ main()
|
||||||
pxe_entry = exPXE->rmentry;
|
pxe_entry = exPXE->rmentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
memcpy(bootboot.magic, BOOTBOOT_MAGIC, sizeof bootboot.magic);
|
memcpy(bootboot.magic, BOOTBOOT_MAGIC, sizeof bootboot.magic);
|
||||||
bootboot.size = 128;
|
bootboot.size = 128;
|
||||||
bootboot.protocol = PROTOCOL_MINIMAL | LOADER_BIOS;
|
bootboot.protocol = PROTOCOL_MINIMAL | LOADER_BIOS;
|
||||||
bootboot.numcores = 1;
|
bootboot.numcores = 1;
|
||||||
|
|
||||||
//display_string(0x0E, "init\r\n");
|
|
||||||
struct e820_entry *end = bios_getmap(memmap);
|
struct e820_entry *end = bios_getmap(memmap);
|
||||||
//display_string(0x0E, "karlos\r\n");
|
|
||||||
for (int i = 0; ; i++) {
|
for (int i = 0; ; i++) {
|
||||||
if (&memmap[i] >= end) break;
|
if (&memmap[i] >= end) break;
|
||||||
char buf[2];
|
char buf[2];
|
||||||
|
|
@ -376,80 +406,15 @@ main()
|
||||||
buf[1] = 0;
|
buf[1] = 0;
|
||||||
debug_write(buf);
|
debug_write(buf);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
pg_setup();
|
//pg_setup();
|
||||||
|
|
||||||
get_cached();
|
get_cached();
|
||||||
receive_file();
|
receive_file();
|
||||||
|
|
||||||
#if 0
|
|
||||||
#if 1
|
|
||||||
t_PXENV_GET_CACHED *t_cached = (void *)pxe_cmd_buf;
|
|
||||||
t_cached->status = 0;
|
|
||||||
t_cached->packet_type = 2;
|
|
||||||
t_cached->buffer_size = 0;
|
|
||||||
t_cached->buffer_offset = 0;
|
|
||||||
t_cached->buffer_seg = 0;
|
|
||||||
t_cached->buffer_limit = 0xFFFFu;
|
|
||||||
debug_write("Performing PXE call\r\n");
|
|
||||||
unsigned ret = pxe_call(PXENV_GET_CACHED, (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_cached->status);
|
|
||||||
debug_write("\r\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
debug_write("buffer_off=");
|
|
||||||
debug_write_uint(t_cached->buffer_offset);
|
|
||||||
debug_write("\r\nbuffer_seg=");
|
|
||||||
debug_write_uint(t_cached->buffer_seg);
|
|
||||||
struct bootph *bootph = (void *)(t_cached->buffer_offset + 16 * t_cached->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
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
uint32_t reg[7];
|
|
||||||
reg[0] = (0x0E << 8) + 'J';
|
|
||||||
reg[1] = 0;
|
|
||||||
reg[2] = 0;
|
|
||||||
reg[3] = 0;
|
|
||||||
reg[4] = 0;
|
|
||||||
reg[5] = 0;
|
|
||||||
reg[6] = 0;
|
|
||||||
bios_func(0x10, reg);
|
|
||||||
|
|
||||||
debug_write("what?\r\n");
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
__asm__ ("cli");
|
__asm__ ("cli");
|
||||||
for (;;) {
|
for (;;) {
|
||||||
//__asm__ ("sti");
|
__asm__ ("hlt");
|
||||||
//__asm__ ("hlt");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,10 @@ real_es: .word 0
|
||||||
.global pxe_cmd_buf
|
.global pxe_cmd_buf
|
||||||
pxe_cmd_buf:.space 512, 0
|
pxe_cmd_buf:.space 512, 0
|
||||||
|
|
||||||
|
.align 512
|
||||||
|
.global pxe_dat_buf
|
||||||
|
pxe_dat_buf:.space 512, 0
|
||||||
|
|
||||||
.global GDT
|
.global GDT
|
||||||
GDT: // entry 0: null descriptor
|
GDT: // entry 0: null descriptor
|
||||||
.space 8, 0
|
.space 8, 0
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue