X-Git-Url: http://git.ozlabs.org/?p=yaboot.git;a=blobdiff_plain;f=second%2Fprom.c;h=d48ede52b071025e12a5514f8e604d89c5e9e400;hp=e9c5843e1efec04b25baa7185e16a9025b8e0905;hb=1f0f86b8e9cb113674bec055c2d0f182a28a5bd2;hpb=6084bb9a372a5fb9fa3e63a26c1770036c31883d diff --git a/second/prom.c b/second/prom.c index e9c5843..d48ede5 100644 --- a/second/prom.c +++ b/second/prom.c @@ -568,6 +568,25 @@ prom_sleep (int seconds) while (prom_getms() <= end); } +/* if address given is claimed look for other addresses to get the needed + * space before giving up + */ +void * +prom_claim_chunk(void *virt, unsigned int size, unsigned int align) +{ + void *found, *addr; + for(addr=virt; addr <= (void*)PROM_CLAIM_MAX_ADDR; + addr+=(0x100000/sizeof(addr))) { + found = prom_claim(addr, size, 0); + if (found != (void *)-1) { + DEBUG_F("claimed %i at 0x%x (0x%x)\n",size,(int)found,(int)virt); + return(found); + } + } + prom_printf("Claim error, can't allocate %x at 0x%x\n",size,(int)virt); + return((void*)-1); +} + void * prom_claim (void *virt, unsigned int size, unsigned int align) { @@ -664,6 +683,10 @@ struct bootp_packet * prom_get_netinfo (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])) @@ -688,7 +711,7 @@ struct bootp_packet * prom_get_netinfo (void) if (size <= 0) return NULL; - if (sizeof(*packet) > size - offset) { + if (packet_size > size - offset) { prom_printf("Malformed %s property?\n", propname); return NULL; }