tools/build-R2_19_3/fsboot/sbl/common.c File Reference

#include <conf.h>
#include <e100boot.h>
#include <pcap.h>
#include "boot_images.h"
#include <reg_des.h>
#include <common.h>
#include <serial.h>
#include <network.h>

Include dependency graph for common.c:

Go to the source code of this file.

Data Structures

struct  label_t

Defines

#define BOOT_CMDS_FILE   "BOOT_CMDS"
#define NR_BOOT_CMDS   (SIZE_OF_BOOT_CMDS/sizeof(unsigned int))
#define SIZE_PATTERN   0x12345678
#define SIZE_POS   (SIZE_OF_FIRST_HEADER + (netBoot ? 0x04 : 0x04))

Functions

FILE * Fopen (char *name, char *mode)
int main (int argc, char *argv[])
int GetNumberOption (int *argNr, int argCount, char *argVect[], unsigned int *ret, char *option, int base)
int GetStringOption (int *argNr, int argCount, char *argVect[], char *ret, char *option)
int GetRegisterOption (int *argNr, int argCount, char *argVect[], unsigned int *ret, char *option, int base)
boot_files_T * allocate_boot_file (struct boot_files_T *bf)
packet_buf * CreateNewBootPacket (void)
packet_buf * allocate_packet (struct packet_buf *p)
void SigHandler (int sig)
void CreateBootLoader (char *filename, unsigned size, unsigned addr)
void FinishBootCmds (void)
void ParseArgs (int argc, char *argv[])
void PrintHelp (void)
void CreateBootCmds (void)
void handle_labels (void)
void new_label (struct label_t **label, udword addr, char *name)
void printData (unsigned char *buf, unsigned addr, unsigned size)
packet_buf * free_packet (struct packet_buf *p)
packet_buf * create_packet (udword seq)
void find_string (char *str)

Variables

char version [] = "Time-stamp: $Id: common.c,v 1.1.1.1 2008/11/27 20:04:03 elphel Exp $"
char needle [MAX_STRING_LEN] = {0,}
int needle_len = 0
int exitonfind = FALSE
int doing_flash = FALSE
int toFiles = FALSE
int cmdsOnly = FALSE
int netBoot = TRUE
int serBoot = FALSE
int listenOnly = FALSE
label_tloop_label = NULL
label_tlabel = NULL
packet_buf * first_packet = NULL
packet_buf * last_packet = NULL
packet_buf * boot_cmds_packet
int create_boot_loader = TRUE
char boot_loader_file [MAX_STRING_LEN] = INTERNAL_NW
int noleds = FALSE
boot_files_T * first_boot_file = NULL
boot_files_T * last_boot_file = NULL
unsigned int boot_cmds [NR_BOOT_CMDS]
int boot_cmds_cnt = 0
int svboot = FALSE
int quiet = 0
packet_header_T send_packet
packet_header_T * receive_packet
int seq_nr = 0
unsigned nrof_net_packets = 0
int db1 = FALSE
int db2 = FALSE
int db3 = FALSE
int db4 = FALSE
int db5 = FALSE
char device [MAX_STRING_LEN] = "eth0"


Define Documentation

#define BOOT_CMDS_FILE   "BOOT_CMDS"

Definition at line 41 of file common.c.

Referenced by CreateBootCmds().

#define NR_BOOT_CMDS   (SIZE_OF_BOOT_CMDS/sizeof(unsigned int))

Definition at line 86 of file common.c.

Referenced by FinishBootCmds().

#define SIZE_PATTERN   0x12345678

Referenced by CreateBootLoader().

#define SIZE_POS   (SIZE_OF_FIRST_HEADER + (netBoot ? 0x04 : 0x04))

Referenced by CreateBootLoader().


Function Documentation

struct boot_files_T * allocate_boot_file ( struct boot_files_T *  bf  ) 

Definition at line 1414 of file common.c.

References malloc().

Referenced by CreateBootCmds(), CreateBootLoader(), and ParseArgs().

struct packet_buf * allocate_packet ( struct packet_buf *  p  ) 

Definition at line 1382 of file common.c.

References db4, and malloc().

Referenced by CreateBootCmds(), CreateBootLoader(), and CreateNewBootPacket().

struct packet_buf* create_packet ( udword  seq  ) 

Definition at line 267 of file common.c.

References CreateNewBootPacket(), db4, and first_packet.

Referenced by NetBoot().

void CreateBootCmds ( void   ) 

Definition at line 1445 of file common.c.

References allocate_boot_file(), allocate_packet(), axis_000200, BOOT_CMDS_FILE, boot_cmds_packet, data, db1, db3, db4, DecodeSvintoBoot(), eth_addr_local, last_packet, malloc(), memcpy(), netBoot, and seq_nr.

void CreateBootLoader ( char *  filename,
unsigned  size,
unsigned  addr 
)

Definition at line 1184 of file common.c.

References allocate_boot_file(), allocate_packet(), axis_000200, buf, create_boot_loader, db1, db2, db3, db4, db5, DecodeSvintoBoot(), eth_addr_local, exit, fd, first_packet, Fopen(), last_packet, malloc(), memcpy(), netBoot, nrof_net_packets, printData(), read, seq_nr, SIZE_PATTERN, and SIZE_POS.

struct packet_buf * CreateNewBootPacket ( void   ) 

Definition at line 1544 of file common.c.

References allocate_packet(), axis_000200, buf, db2, db3, DecodeSvintoBoot(), eth_addr_local, exit, first_boot_file, last_packet, malloc(), memcpy(), memset(), netBoot, seq_nr, and stdin.

Referenced by create_packet().

void find_string ( char *  str  ) 

Definition at line 303 of file common.c.

References exit, exitonfind, needle, needle_len, and s.

Referenced by DecodeSvintoBoot().

void FinishBootCmds ( void   ) 

Definition at line 1505 of file common.c.

References boot_cmds, boot_cmds_cnt, boot_cmds_packet, db3, memcpy(), netBoot, and NR_BOOT_CMDS.

FILE * Fopen ( char *  name,
char *  mode 
)

Definition at line 394 of file common.c.

References db2, db3, fd, and SEEK_SET.

Referenced by CreateBootLoader().

struct packet_buf* free_packet ( struct packet_buf *  p  ) 

Definition at line 239 of file common.c.

References free().

Referenced by NetBoot().

int GetNumberOption ( int *  argNr,
int  argCount,
char *  argVect[],
unsigned int *  ret,
char *  option,
int  base 
)

Definition at line 1033 of file common.c.

References db4, exit, and PrintHelp().

Referenced by ParseArgs().

int GetRegisterOption ( int *  argNr,
int  argCount,
char *  argVect[],
unsigned int *  ret,
char *  option,
int  base 
)

Definition at line 1091 of file common.c.

References exit, and PrintHelp().

Referenced by ParseArgs().

int GetStringOption ( int *  argNr,
int  argCount,
char *  argVect[],
char *  ret,
char *  option 
)

Definition at line 982 of file common.c.

References db4, exit, and PrintHelp().

Referenced by ParseArgs().

void handle_labels ( void   ) 

Definition at line 890 of file common.c.

References label_t::addr, boot_cmds, exit, label, loop_label, match(), label_t::name, and label_t::prev.

Referenced by ParseArgs().

int main ( int  argc,
char *  argv[] 
)

set port, start listening/answering HTTP requests

now try to mmap

These are read from frame zero (they are not frame-related)

now open circbuf

read pointer was invalid - try the earliest frame available

Definition at line 38 of file main.cpp.

References Streamer::Main(), and usage.

void new_label ( struct label_t **  label,
udword  addr,
char *  name 
)

Definition at line 937 of file common.c.

References label_t::addr, boot_cmds_cnt, label, malloc(), label_t::name, and label_t::prev.

Referenced by ParseArgs().

void ParseArgs ( int  argc,
char *  argv[] 
)

Definition at line 438 of file common.c.

References allocate_boot_file(), boot_cmds, boot_cmds_cnt, boot_loader_file, both_addresses, cmdsOnly, db1, db2, db3, db4, db5, device, doing_flash, exit, exitonfind, first_boot_file, GetNumberOption(), GetRegisterOption(), GetStringOption(), handle_labels(), host1, host2, int, label, last_boot_file, listenOnly, loop_label, malloc(), needle, needle_len, netBoot, new_label(), noleds, p_packet_bpl, pPacket, PrintHelp(), printPacketType, promisc, quiet, serBoot, and toFiles.

void printData ( unsigned char *  buf,
unsigned  addr,
unsigned  size 
)

Definition at line 1692 of file common.c.

References db4.

Referenced by CreateBootLoader().

void PrintHelp ( void   ) 

Definition at line 1142 of file common.c.

References version.

Referenced by GetNumberOption(), GetRegisterOption(), GetStringOption(), and ParseArgs().

void SigHandler ( int  sig  ) 


Variable Documentation

unsigned int boot_cmds[NR_BOOT_CMDS]

Definition at line 87 of file common.c.

Referenced by FinishBootCmds(), handle_labels(), and ParseArgs().

int boot_cmds_cnt = 0

Definition at line 89 of file common.c.

Referenced by FinishBootCmds(), new_label(), and ParseArgs().

struct packet_buf* boot_cmds_packet

Definition at line 74 of file common.c.

Referenced by CreateBootCmds(), and FinishBootCmds().

char boot_loader_file[MAX_STRING_LEN] = INTERNAL_NW

Definition at line 79 of file common.c.

Referenced by ParseArgs().

int cmdsOnly = FALSE

Definition at line 62 of file common.c.

Referenced by ParseArgs(), and SendToDevice().

int create_boot_loader = TRUE

Definition at line 76 of file common.c.

Referenced by CreateBootLoader().

int db1 = FALSE

Definition at line 102 of file common.c.

Referenced by ack_on_seq(), CreateBootCmds(), CreateBootLoader(), DecodeSvintoBoot(), GetLocalEthAddr(), Handler(), highest_seq_received(), ParseArgs(), and SendToDevice().

int db2 = FALSE

Definition at line 103 of file common.c.

Referenced by CreateBootLoader(), CreateNewBootPacket(), Fopen(), GetNextPacket(), Handler(), and ParseArgs().

int db3 = FALSE

Definition at line 104 of file common.c.

Referenced by CreateBootCmds(), CreateBootLoader(), CreateNewBootPacket(), FinishBootCmds(), Fopen(), and ParseArgs().

int db4 = FALSE

Definition at line 105 of file common.c.

Referenced by allocate_packet(), create_packet(), CreateBootCmds(), CreateBootLoader(), DecodeSvintoBoot(), GetNumberOption(), GetStringOption(), highest_seq_received(), NetBoot(), ParseArgs(), and printData().

int db5 = FALSE

Definition at line 106 of file common.c.

Referenced by CreateBootLoader(), and ParseArgs().

char device[MAX_STRING_LEN] = "eth0"

Definition at line 108 of file common.c.

int doing_flash = FALSE

Definition at line 57 of file common.c.

Referenced by ParseArgs().

int exitonfind = FALSE

Definition at line 55 of file common.c.

Referenced by find_string(), and ParseArgs().

struct boot_files_T* first_boot_file = NULL

Definition at line 83 of file common.c.

Referenced by CreateNewBootPacket(), and ParseArgs().

struct packet_buf* first_packet = NULL

Definition at line 71 of file common.c.

Referenced by create_packet(), CreateBootLoader(), NetBoot(), and packet_with_seq().

struct label_t* label = NULL

Definition at line 69 of file common.c.

Referenced by handle_labels(), new_label(), and ParseArgs().

struct boot_files_T* last_boot_file = NULL

Definition at line 84 of file common.c.

Referenced by ParseArgs().

struct packet_buf* last_packet = NULL

Definition at line 72 of file common.c.

Referenced by CreateBootCmds(), CreateBootLoader(), and CreateNewBootPacket().

int listenOnly = FALSE

Definition at line 66 of file common.c.

Referenced by Handler(), ParseArgs(), and SendToDevice().

struct label_t* loop_label = NULL

Definition at line 68 of file common.c.

Referenced by handle_labels(), and ParseArgs().

char needle[MAX_STRING_LEN] = {0,}

Definition at line 52 of file common.c.

Referenced by find_string(), and ParseArgs().

int needle_len = 0

Definition at line 53 of file common.c.

Referenced by find_string(), and ParseArgs().

int netBoot = TRUE

Definition at line 63 of file common.c.

Referenced by CreateBootCmds(), CreateBootLoader(), CreateNewBootPacket(), FinishBootCmds(), ParseArgs(), and SendToDevice().

int noleds = FALSE

Definition at line 81 of file common.c.

Referenced by ParseArgs().

unsigned nrof_net_packets = 0

Definition at line 99 of file common.c.

Referenced by CreateBootLoader(), and SendToDevice().

int quiet = 0

Definition at line 93 of file common.c.

Referenced by ParseArgs().

struct packet_header_T* receive_packet

Definition at line 96 of file common.c.

struct packet_header_T send_packet

Definition at line 95 of file common.c.

int seq_nr = 0

Definition at line 98 of file common.c.

Referenced by CreateBootCmds(), CreateBootLoader(), and CreateNewBootPacket().

int serBoot = FALSE

Definition at line 64 of file common.c.

Referenced by ParseArgs().

int svboot = FALSE

Definition at line 91 of file common.c.

int toFiles = FALSE

Definition at line 61 of file common.c.

Referenced by ParseArgs(), and SendToDevice().

char version[] = "Time-stamp: $Id: common.c,v 1.1.1.1 2008/11/27 20:04:03 elphel Exp $"

*************************************************************************** ! ! FILE NAME : common.c ! ! DESCRIPTION: Common functions for boot loader. ! ! ! --------------------------------------------------------------------------- ! HISTORY ! ! DATE NAME CHANGES ! ---- ---- ------- ! ??? ? ???? Ronny Ranerup Initial version ! --------------------------------------------------------------------------- ! (C) Copyright 1999, 2000, Axis Communications AB, LUND, SWEDEN !

Definition at line 23 of file common.c.


Generated on Fri Nov 28 00:08:39 2008 for elphel by  doxygen 1.5.1