Skip to content
Rhodri James edited this page Dec 7, 2015 · 6 revisions

UPC2 Application Front-End

The bulk of the code in progs/upc2.c is taken up with parsing the command line parameters; not entirely trivial with multi-stage booting! The code maintains an array of up_load_arg_t structures containing the parameters for each bootload stage, which are then passed to the core code. New protocols may need to add new parameters and extend the up_load_arg_t structure, defined in include/upc2/up.h:

typedef struct up_load_arg_struct {
    const char          *file_name;
    int                  fd;
    const up_protocol_t *protocol;
    void                *protocol_handle;
    int                  baud;
    int                  deferred;
} up_load_arg_t;

The protocol field should be a valid protocol descriptor; NULL is not acceptable.

The protocol_handle field is the opaque handle to be passed to this instance of the protocol whenever any of its functions are called.

The deferred flag causes the core logic to go into console mode on entering this boot stage so that the user can intervene (for example, to interrupt a uboot automatic start-up).

Relatively little checking is done at this stage; in particular baud rates must be syntactically valid but need not be acceptable to the relevant protocol. Files are checked for existence (and indeed opened) before any further processing occurs.

Then it's just a matter of invoking the core functions:

  1. Create a "context" to control the application.
  2. Create a backend for the serial connection and attach it to the context.
  3. Attach the log file descriptor to the context.
  4. Run the core logic.
Clone this wiki locally