fw_download_extflash.c File Reference

#include "wl_api.h"
#include "fw_download.h"
#include "nor_flash.h"
#include "printf-stdarg.h"

Go to the source code of this file.

Functions

void fw_download_cb (void *ctx, uint8_t **buf, uint32_t *len)
int fw_download_init (void)


Function Documentation

void fw_download_cb ( void *  ctx,
uint8_t **  buf,
uint32_t *  len 
)

Definition at line 39 of file fw_download_extflash.c.

References flash_read(), printk(), and SECTOR_SIZE.

00040 {
00041     /* remember accross different calls */
00042         static uint8_t* fw_buf = NULL;
00043         static uint32_t offset = 0;
00044 
00045         /* when firmware download is completed, this function will be invoked
00046          * on additional time with the input value of len set to 0. we can free
00047          * the firmware buffer at this time since it's no longer needed.
00048          */
00049         if (*len == 0) {
00050                 if (fw_buf)
00051                         free(fw_buf);
00052                 return;
00053         }
00054 
00055         /* first call? then initialize flash and allocate a buffer to hold
00056          * firmware data.
00057          */
00058         if (fw_buf == NULL) {
00059                 fw_buf = malloc(SECTOR_SIZE);
00060                 
00061                 if (fw_buf == NULL) {
00062                         printk("could not allocate firmware buffer\n");
00063                         *len = 0;
00064                         return;
00065                 }
00066         }
00067 
00068         /* decide how much to read. we know *len bytes remains, but we only have
00069          * room for SECTOR_SIEZ bytes in our buffer (fw_buf)
00070          */
00071     uint32_t fw_len = *len > SECTOR_SIZE ? SECTOR_SIZE : *len;
00072         
00073         /* read data and update output parameters */
00074         flash_read(offset, fw_buf, fw_len);
00075     *buf = fw_buf;
00076     *len = fw_len;
00077 
00078         /* we need to know where to start reading upon next call */
00079         offset += fw_len;
00080 }

int fw_download_init ( void   ) 

Definition at line 33 of file fw_download_extflash.c.

References flash_init().

00034 {
00035        flash_init();
00036        return 0;
00037 }


Generated on Fri Feb 19 02:24:07 2010 for AVR32 - H&D by  doxygen 1.5.5