ihandle prom_stdin, prom_stdout;
-//extern int vsprintf(char *buf, const char *fmt, va_list args);
-
static ihandle prom_mem, prom_mmu;
static ihandle prom_chosen, prom_options;
int
prom_getchar ()
{
- char c[4];
+ char c;
int a;
- while ((a = (int)call_prom ("read", 3, 1, prom_stdin, c, 4)) == 0)
+ while ((a = (int)call_prom ("read", 3, 1, prom_stdin, &c, 1)) == 0)
;
if (a == -1)
prom_abort ("EOF on console\n");
- if (a == 3 && c[0] == '\e' && c[1] == '[')
- return 0x100 | c[2];
- return c[0];
+ return c;
}
int
while (i < len-1 && (c = prom_getchar ()) != '\r')
{
- if (c >= 0x100)
- continue;
if (c == 8)
{
if (i > 0)
prom_release(void *virt, unsigned int size)
{
call_prom ("release", 2, 0, virt, size);
-#if 0 /* this is bullshit, newworld OF RELEASE method works fine. */
-
- /* release in not enough, it needs also an unmap call. This bit of forth
- * code inspired from Darwin's bootloader but could be replaced by direct
- * calls to the MMU package if needed
- */
- call_prom ("interpret", 3, 1,
-#if DEBUG
- ".\" ReleaseMem:\" 2dup . . cr "
-#endif
- "over \" translate\" ^mmu " // Find out physical base
- "^on0 " // Bail if translation failed
- "drop " // Leaving phys on top of stack
- "2dup \" unmap\" ^mmu " // Unmap the space first
- "2dup \" release\" ^mmu " // Then free the virtual pages
- "\" release\" ^mem " // Then free the physical pages
- ,size, virt
- );
-#endif /* bullshit */
}
void
void *bootp_response = NULL;
char *propname;
struct bootp_packet *packet;
+ /* struct bootp_packet contains a VLA, so sizeof won't work.
+ the VLA /must/ be the last field in the structure so use it's
+ offset as a good estimate of the packet size */
+ size_t packet_size = offsetof(struct bootp_packet, options);
int i = 0, size, offset = 0;
prom_handle chosen;
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
if (size <= 0)
return NULL;
- if (sizeof(*packet) > size - offset) {
+ if (packet_size > size - offset) {
prom_printf("Malformed %s property?\n", propname);
return NULL;
}