[coreboot] libpayload: Add larfptr function

Jordan Crouse jordan.crouse at amd.com
Thu May 15 01:08:13 CEST 2008


On 14/05/08 10:11 -0600, Myles Watson wrote:
> 
> 
> > -----Original Message-----
> > From: coreboot-bounces at coreboot.org [mailto:coreboot-bounces at coreboot.org]
> > On Behalf Of jordan.crouse at amd.com
> > Sent: Tuesday, May 13, 2008 5:34 PM
> > To: coreboot at coreboot.org
> > Cc: Jordan Crouse
> > Subject: [coreboot] [patch 3/5] libpayload: Add larfptr function
> > 
> > Add a function to get a pointer to the start of a LAR entry.
> > 
> > Signed-off-by: Jordan Crouse <jordan.crouse at amd.com>
> > Index: libpayload/include/libpayload.h
> > ===================================================================
> > --- libpayload.orig/include/libpayload.h	2008-05-13
> 13:40:12.000000000 -
> > 0600
> > +++ libpayload/include/libpayload.h	2008-05-13 15:23:18.000000000 -0600
> > @@ -247,6 +247,7 @@
> >  struct larent *readlar(struct LAR *lar);
> >  void rewindlar(struct LAR *lar);
> >  int larstat(struct LAR *lar, const char *path, struct larstat *buf);
> > +void *larfptr(struct LAR *lar, const char *filename);
> >  struct LFILE * lfopen(struct LAR *lar, const char *filename);
> >  int lfread(void *ptr, size_t size, size_t nmemb, struct LFILE *stream);
> > 
> > Index: libpayload/libc/lar.c
> > ===================================================================
> > --- libpayload.orig/libc/lar.c	2008-05-13 13:40:12.000000000 -0600
> > +++ libpayload/libc/lar.c	2008-05-13 13:42:59.000000000 -0600
> > @@ -218,6 +218,16 @@
> >  	return 0;
> >  }
> > 
> > +void * larfptr(struct LAR *lar, const char *filename)
> > +{
> > +	struct lar_header *header = get_header_by_name(lar, filename);
> > +
> > +	if (header == NULL)
> > +		return NULL;
> > +
> > +	return (void *) ((u8 *) header + ntohl(header->offset));
> > +}
> > +
> 
> Why do we want it to return a void*?

I tend to to use void when I can because its is maliable, but I can
be convinced to use u8 * or unsigned long *.

Jordan


-- 
Jordan Crouse
Systems Software Development Engineer 
Advanced Micro Devices, Inc.





More information about the coreboot mailing list