Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

loader.c File Reference

BrickOS task downloading. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
#include <sys/lnp.h>
#include <sys/lnp-logical.h>
#include "rcxtty.h"
#include "keepalive.h"
#include <lx.h>
#include <getopt.h>

Go to the source code of this file.

Defines

#define MAX_DATA_CHUNK   0xf8
 maximum data bytes/packet for boot protocol
#define XMIT_RETRIES   5
 number of packet transmit retries
#define REPLY_TIMEOUT   750000
 timeout for reply
#define BYTE_TIME   (1000*LNP_BYTE_TIME)
 time to transmit a byte.
#define PROG_MIN   1
#define PROG_MAX   8
#define ADDR_MIN   0
#define ADDR_MAX   15
#define DEFAULT_DEST   0
#define DEFAULT_PROGRAM   PROG_MIN
#define DEFAULT_SRCPORT   0
#define DEFAULT_PRIORITY   10
#define HAVE_GETOPT_LONG   1

Enumerations

enum  packet_cmd_t {
  CMDacknowledge, CMDdelete, CMDcreate, CMDoffsets,
  CMDdata, CMDrun, CMDirmode, CMDsethost,
  CMDlast
}

Functions

void io_handler (void)
int lnp_logical_write (const void *data, size_t length)
int lnp_assured_write (const unsigned char *data, unsigned char length, unsigned char dest, unsigned char srcport)
 send a LNP layer 0 packet of given length
void LNPinit (const char *tty)
void ahandler (const unsigned char *data, unsigned char len, unsigned char src)
void lnp_download (const lx_t *lx)
int main (int argc, char **argv)
 the user main()

Variables

const struct option long_options []
volatile int receivedAck = 0
volatile unsigned short relocate_to = 0
unsigned int rcxaddr
int run_flag = 0
int verbose_flag = 0
 display some diagnostics if non-zero
int tty_usb = 0
int pdelete_flag = 0
int hostaddr_flag = 0


Detailed Description

BrickOS task downloading.

Author:
Markus L. Noga <markus@noga.de>

Definition in file loader.c.


Define Documentation

#define ADDR_MAX   15
 

Definition at line 94 of file loader.c.

Referenced by main().

#define ADDR_MIN   0
 

Definition at line 93 of file loader.c.

#define BYTE_TIME   (1000*LNP_BYTE_TIME)
 

time to transmit a byte.

Definition at line 88 of file loader.c.

#define DEFAULT_DEST   0
 

Definition at line 96 of file loader.c.

#define DEFAULT_PRIORITY   10
 

Definition at line 99 of file loader.c.

#define DEFAULT_PROGRAM   PROG_MIN
 

Definition at line 97 of file loader.c.

#define DEFAULT_SRCPORT   0
 

Definition at line 98 of file loader.c.

#define HAVE_GETOPT_LONG   1
 

Definition at line 116 of file loader.c.

#define MAX_DATA_CHUNK   0xf8
 

maximum data bytes/packet for boot protocol

Definition at line 85 of file loader.c.

#define PROG_MAX   8
 

Definition at line 91 of file loader.c.

Referenced by main().

#define PROG_MIN   1
 

Definition at line 90 of file loader.c.

#define REPLY_TIMEOUT   750000
 

timeout for reply

Definition at line 87 of file loader.c.

Referenced by io_handler(), and lnp_assured_write().

#define XMIT_RETRIES   5
 

number of packet transmit retries

Definition at line 86 of file loader.c.


Enumeration Type Documentation

enum packet_cmd_t
 

Enumeration values:
CMDacknowledge  1:
CMDdelete  1+ 1: b[nr]
CMDcreate  1+12: b[nr] s[textsize] s[datasize] s[bsssize] s[stacksize] s[start] b[prio]
CMDoffsets  1+ 7: b[nr] s[text] s[data] s[bss]
CMDdata  1+>3: b[nr] s[offset] array[data]
CMDrun  1+ 1: b[nr]
CMDirmode  1+ 1: b[0=near/1=far]
CMDsethost  1+ 1: b[hostaddr]
CMDlast  ?

Definition at line 101 of file loader.c.


Function Documentation

void ahandler const unsigned char *  data,
unsigned char  len,
unsigned char  src
 

Definition at line 342 of file loader.c.

References receivedAck, and relocate_to.

Referenced by main().

void io_handler void   ) 
 

Definition at line 238 of file loader.c.

References NULL, rcxFD(), REPLY_TIMEOUT, and tty_usb.

Referenced by lnp_assured_write().

int lnp_assured_write const unsigned char *  data,
unsigned char  length,
unsigned char  dest,
unsigned char  srcport
 

send a LNP layer 0 packet of given length

Returns:
0 on success.

Definition at line 189 of file loader.c.

References io_handler(), NULL, rcxFD(), receivedAck, and REPLY_TIMEOUT.

Referenced by lnp_download(), and main().

void lnp_download const lx_t lx  ) 
 

Definition at line 353 of file loader.c.

References lx_t::data_size, exit(), lnp_assured_write(), memcpy(), rcxaddr, size_t, lx_t::text, and lx_t::text_size.

Referenced by main().

int lnp_logical_write const void *  data,
size_t  length
 

blocking I/R write. ! return number of bytes written, or negative for error.

Definition at line 162 of file loader.c.

References keepaliveRenew(), mywrite(), NULL, rcxFD(), and tty_usb.

void LNPinit const char *  tty  ) 
 

Definition at line 291 of file loader.c.

References exit(), keepaliveInit(), myperror(), rcxFD(), rcxInit(), and tty_usb.

Referenced by main().

int main int  argc,
char **  argv
 

the user main()

Definition at line 379 of file loader.c.

References ADDR_MAX, ahandler(), lx_t::bss_size, lx_t::data_size, hostaddr_flag, lnp_assured_write(), lnp_download(), LNPinit(), long_options, lx_read(), lx_relocate(), lx_t::offset, pdelete_flag, PROG_MAX, rcxaddr, relocate_to, run_flag, lx_t::stack_size, lx_t::text_size, tty_usb, TTY_VARIABLE, and verbose_flag.


Variable Documentation

int hostaddr_flag = 0
 

Definition at line 155 of file loader.c.

Referenced by main().

const struct option long_options[] [static]
 

Initial value:

{
  {"rcxaddr",required_argument,0,'r'},
  {"program",required_argument,0,'p'},
  {"delete", required_argument,0,'d'},
  {"srcport",required_argument,0,'s'},
  {"tty",    required_argument,0,'t'},
  {"irmode", required_argument,0,'i'},
  {"node"  , required_argument,0,'n'},
  {"execute",no_argument      ,0,'e'},
  {"verbose",no_argument      ,0,'v'},
  {0        ,0                ,0,0  }
}

Definition at line 122 of file loader.c.

Referenced by main().

int pdelete_flag = 0
 

Definition at line 154 of file loader.c.

Referenced by main().

unsigned int rcxaddr
 

Initial value:

 DEFAULT_DEST
              prog    = DEFAULT_PROGRAM
              srcport = DEFAULT_SRCPORT
              hostaddr = DEFAULT_DEST
                  irmode  = -1

Definition at line 145 of file loader.c.

Referenced by lnp_download(), and main().

volatile int receivedAck = 0
 

Definition at line 141 of file loader.c.

Referenced by ahandler(), and lnp_assured_write().

volatile unsigned short relocate_to = 0
 

Definition at line 143 of file loader.c.

Referenced by ahandler(), and main().

int run_flag = 0
 

Definition at line 151 of file loader.c.

Referenced by main().

int tty_usb = 0
 

Definition at line 153 of file loader.c.

Referenced by io_handler(), lnp_logical_write(), LNPinit(), main(), nbread(), rcx_init(), rcx_send(), rcxInit(), and rx_flush().

int verbose_flag = 0
 

display some diagnostics if non-zero

Definition at line 152 of file loader.c.


Generated on Fri Feb 25 08:02:45 2005 for brickos by  doxygen 1.3.9.1