# SFBCodeFlow.h File Reference

The SFB Code Flow protocol allows SFB's to program each other. More...

`#include "SFBTypes.h"`
`#include "SFBConstants.h"`
`#include "SFBAssert.h"`
`#include "SFBProvenance.h"`
`#include "SFBSerial.h"`

Include dependency graph for SFBCodeFlow.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Typedefs
typedef void(* | CodeFlowStatusCallback )(u8 face, CodeFlowStatus status)
## Enumerations
enum | { CHECKSUM_IGNORE, CHECKSUM_CHECK, CHECKSUM_GENERATE }
enum | CodeFlowStatus { CODE_FLOW_INIT, CODE_FLOW_IDLE, CODE_FLOW_ACTIVE, CODE_FLOW_SUCCEEDED }
## Functions
u8 | sectorOfAddress (u32 address)
u32 | sectorStart (u8 sectorNumber)
u32 | sectorSize (u8 sectorNumber)
u32 | sectorEnd (u8 sectorNumber)
bool | plausibleProvenance (SFBProvenance *p, uptr startAddr, uptr endAddr)
| Do limited checks on the potential validity of a provenance, considering sanity checks that depend only on the contents of the provenance block itself.
bool | validProvenance (SFBProvenance *p, uptr startAddr, uptr endAddr, int checksumMode=CHECKSUM_CHECK)
| Do a full check of a provenance+contiguous program.
SFBProvenance * | findProvenance (uptr startAddr, uptr endAddr, int checksumMode=CHECKSUM_CHECK)
void | programServerDispatcher (u8 *packet)
void | programServerInit (u8 face)
void | programServerSetSketch (const volatile SFBProvenance *theSketch, u32 startAddress, uptr addressOffset, u8 pflags=0)
void | printPhSketchInfo (u8 toFace, const volatile SFBProvenance *theSketch)
bool | announcePhSketchInfoIfAny (u8 toFace)
void | setCodeFlowStatusCallback (CodeFlowStatusCallback ptr)
int | wantPhPacketCodeUpdate (u8 *packet) __attribute__((weak))
| 0 if we want the code <0 if packet is not a valid 'Ph' format >0 if packet is a valid 'Ph' but we don't want what it offers
void | initProgramServerSketch () __attribute__((weak))

## Detailed Description

The SFB Code Flow protocol allows SFB's to program each other.

Author:
  David H. Ackley.

Date:
  (C) 2008 All rights reserved.

Code License:
  The GNU Lesser General Public License

License Note:
  All code samples shown in documentation are placed into the public domain.

## Function Documentation

bool plausibleProvenance | ( | SFBProvenance * | p,
|  | uptr | startAddr,
|  | uptr | endAddr |
| ) |  |  |

Do limited checks on the potential validity of a provenance, considering sanity checks that depend only on the contents of the provenance block itself.

(Meaning: No checksum computation, and no footer checking.) plausibleProvenance can be called on a 'detached' provenance, so long as the startAddr and endAddr are specified properly. For size computation purposes, it is assumed that the provenance would be found directly at startAddr.

bool validProvenance | ( | SFBProvenance * | p,
|  | uptr | startAddr,
|  | uptr | endAddr,
|  | int | checksumMode |
| ) |  |  |

Do a full check of a provenance+contiguous program.

The entire address range implied by the provenance and its program length must fit in startAddr..endAddr, the provenance must be sane, and the checksum may be calculated and checked or stored, as indicated by checksumMode.

A 'detached' provenance cannot be checked by this method. (See plausibleProvenance).