2011-8-7 17:52:56

来源:互联网 发布:淘宝女装店名起名大全 编辑:程序博客网 时间:2024/05/01 21:49
 

 

 

2011-8-7 17:52:56

 

 
 typedef enum {
 fromFlash = 0,
 fromDownload = 1
} block_source_t;


typedef struct {
 int kernelSize;
 block_source_t kernelType;
 u32 kernel_md5_digest[4];

 int paramSize;
 block_source_t paramType;
 u32 param_md5_digest[4];

 int ramdiskSize;
 block_source_t ramdiskType;
 u32 ramdisk_md5_digest[4];

 int blobSize;
 block_source_t blobType;
 u32 blob_md5_digest[4];

 serial_baud_t downloadSpeed;
 serial_baud_t terminalSpeed;
 
 int load_ramdisk;
 int boot_delay; /* -1 == no-autoboot */
 
 char cmdline[COMMAND_LINE_SIZE];
 
} blob_status_t;


extern blob_status_t blob_status;


 blob_status.paramType = fromFlash;
 blob_status.kernelType = fromFlash;
 blob_status.ramdiskType = fromFlash;
 blob_status.downloadSpeed = baud_38400;
 blob_status.terminalSpeed = TERMINAL_SPEED;
 blob_status.load_ramdisk = LOAD_RAMDISK;
 blob_status.cmdline[0] = '\0';

初试化了一些状态

/* export serial driver */
serial_driver_t mhn_serial_driver = {
 init:  mhn_serial_init,
 read:  mhn_serial_read,
 write:  mhn_serial_write,
 poll:  mhn_serial_poll,
 flush_input: mhn_serial_flush_input,
 flush_output: mhn_serial_flush_output
};


也需要串口
int UartSetGPIO()

static int mhn_serial_read(void)
{
 int rv;

 for(;;) {
  rv = mhn_serial_poll();

  if(rv < 0)
   return rv;

  if(rv > 0)
   return SerialDATA & 0xff;
 }
}


设置串口的读写

int mhn_serial_write(int c)
{
 /* wait for room in the transmit FIFO */
 while((SerialLSR & LSR_TDRQ) == 0) {
 }

 SerialDATA = c & 0xff;

 return 0;
}

 

static int mhn_serial_flush_input(void)
{
 volatile u32 tmp;

 /* keep on reading as long as the receiver is not empty */
 while(SerialLSR & LSR_DR) {
  if(SerialLSR & (LSR_FE | LSR_PE | LSR_OE))
   return -ESERIAL;

  tmp = SerialDATA;
 }

 return 0;
}


/* flush output queue. returns 0 on success or negative error number
 * otherwise.  This only waits for space in the tx fifo, NOT until the fifo
 * has completely emptied.
 */
static int mhn_serial_flush_output(void)
{
 /* wait until the transmitter is no longer busy */
 while(SerialLSR & ~LSR_TDRQ) ;

 return 0;
}


刷新串口输入队列和输出队列

 

原创粉丝点击