On 8/29/07, Uwe Hermann <[EMAIL PROTECTED]> wrote:
> On Wed, Aug 29, 2007 at 09:20:05AM -0700, ron minnich wrote:
> > Signed-off-by: Ronald G. Minnich <[EMAIL 
> > PROTECTED]>===================================================================
>
> What's up with that "============" line?

my mistake.

>
>
> > --- lib/lar.c (revision 480)
> > +++ lib/lar.c (working copy)
> > @@ -31,6 +31,13 @@
> >  #define ntohl(x) (x)
> >  #endif
> >
> > +int run_address(void *f)
> > +{
> > +     int (*v) (void);
> > +     v = f;
> > +     return v();
> > +}
>
> Add a doxygen comment please.

done. Please note that I did not write this stuff, there were never
comments in there :-)

>
>
> >  int find_file(struct mem_file *archive, char *filename, struct mem_file 
> > *result)
>
> Same here.

done.
>
> filename can be 'const char *filename' I guess.

done. The next patch will include a patch to lar.h for this change.

> > +                     result->entry = (void *)ntohl(header->entry);
> > +                     result->loadaddress = (void 
> > *)ntohl(header->loadaddress);
>
> Just curious, is the cast to (void *) really needed?

yes. ntohl is a long. To get to void * you need the cast.

> > +void *load_file(struct mem_file *archive, char *filename)
>
> Add doxygen comment, please.


done

> > +             return (void *)-1;
>
> Uh? What is '(void *)-1' supposed to be? Will that work? Is the cast needed?

(void *)-1 is a commonly used synonym for "bad address". It's the most
portable way to indicate a bad address.

> > -
> > +     printk(BIOS_SPEW, "where is %p\n", where);
> >       v = where;
> > -     return v();
> > +     ret =  v();
>              ^^
> Two spaces where only one should be.

fixed.

new patch attached.

ron
Add doxygen, change some params to const. 

Signed-off-by: Ronald G. Minnich <[EMAIL PROTECTED]>

Index: lib/lar.c
===================================================================
--- lib/lar.c	(revision 484)
+++ lib/lar.c	(working copy)
@@ -31,6 +31,13 @@
 #define ntohl(x) (x)
 #endif
 
+/**
+ * run_address is passed the address of a function taking no parameters and
+ * jumps to it, returning the result. 
+ * @param v the address to call as a function. 
+ * returns value returned by the function. 
+ */
+
 int run_address(void *f)
 {
 	int (*v) (void);
@@ -38,7 +45,18 @@
 	return v();
 }
 
-int find_file(struct mem_file *archive, char *filename, struct mem_file *result)
+/**
+ * Given a file name in the LAR , search for it, and fill out a return struct with the 
+ * result. 
+ * @param archive A descriptor for current archive. This is actually a mem_file type, 
+ *    which is a machine-dependent representation of hte actual archive. In particular, 
+ *    things like u32 are void * in the mem_file struct. 
+ * @param filename filename to find
+ * @param result pointer to mem_file struct which is filled in if the file is found
+ * returns 0 on success, -1 otherwise
+ */
+
+int find_file(struct mem_file *archive, const char *filename, struct mem_file *result)
 {
 	char *walk, *fullname;
 	struct lar_header *header;
@@ -105,8 +123,15 @@
 	return 1;
 }
 
+/**
+ * Given a file name in the LAR , search for it, and load it into memory, using 
+ * the loadaddress pointer in the mem_file struct. 
+ * @param archive A descriptor for current archive.
+ * @param filename filename to find
+ * returns 0 on success, -1 otherwise
+ */
 
-void *load_file(struct mem_file *archive, char *filename)
+void *load_file(struct mem_file *archive, const char *filename)
 {
 	int ret;
 	struct mem_file result;
@@ -149,7 +174,15 @@
 }
 
 /* FIXME -- most of copy_file should be replaced by load_file */
-int copy_file(struct mem_file *archive, char *filename, void *where)
+/**
+ * Given a file name in the LAR , search for it, and load it into memory, 
+ * using the passed-in pointer as the address
+ * @param archive A descriptor for current archive.
+ * @param filename filename to find
+ * @param where pointer to where to load the data
+ * returns 0 on success, -1 otherwise
+ */
+int copy_file(struct mem_file *archive, const char *filename, void *where)
 {
 	int ret;
 	struct mem_file result;
@@ -190,10 +223,15 @@
 
 
 /**
- * Find the file in the LAR header, copy it to the desired location,
- * and execute it. A location of 0xFFFFFFFF means execute in place (XIP).
+ * Given a file name in the LAR , search for it, and load it into memory, 
+ * using the passed-in pointer as the address; jump to the file. 
+ * If the passed-in pointer is (void *)-1, then execute the file in place. 
+ * @param archive A descriptor for current archive.
+ * @param filename filename to find
+ * @param where pointer to where to load the data
+ * returns 0 on success, -1 otherwise
  */
-int run_file(struct mem_file *archive, char *filename, void *where)
+int run_file(struct mem_file *archive, const char *filename, void *where)
 {
 	int (*v) (void);
 	struct mem_file result;
@@ -217,15 +255,18 @@
 	}
 	printk(BIOS_SPEW, "where is %p\n", where);
 	v = where;
-	ret =  v();
+	ret = v();
 	printk(BIOS_SPEW, "run_file returns with %d\n", ret);
 	return ret;
 }
 
 /**
- * Call run_file() to execute in place.
+ * Given a file name in the LAR , search for it, and execute it in place. 
+ * @param archive A descriptor for current archive.
+ * @param filename filename to find
+ * returns 0 on success, -1 otherwise
  */
-int execute_in_place(struct mem_file *archive, char *filename)
+int execute_in_place(struct mem_file *archive, const char *filename)
 {
 	return run_file(archive, filename, (void *) 0xFFFFFFFF);
 }
Index: include/lar.h
===================================================================
--- include/lar.h	(revision 483)
+++ include/lar.h	(working copy)
@@ -83,10 +83,10 @@
 };
 
 /* Prototypes. */
-int find_file(struct mem_file *archive, char *filename, struct mem_file *result);
-int copy_file(struct mem_file *archive, char *filename, void *where);
-int run_file(struct mem_file *archive, char *filename, void *where);
-int execute_in_place(struct mem_file *archive, char *filename);
+int find_file(struct mem_file *archive, const char *filename, struct mem_file *result);
+int copy_file(struct mem_file *archive, const char *filename, void *where);
+int run_file(struct mem_file *archive, const char *filename, void *where);
+int execute_in_place(struct mem_file *archive, const char *filename);
 int run_address(void *f);
-void *load_file(struct mem_file *archive, char *filename);
+void *load_file(struct mem_file *archive, const char *filename);
 #endif /* LAR_H */
-- 
linuxbios mailing list
[email protected]
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to