PowerNet.bld - primary build file

When all else fails, read the source code.

PowerNet contains a large number of confiration options. These are contained in PNconfig.fth. You should make a copy in your application folder or use an existing configuration file.

Heap

PowerNet needs a heap. The bigger the heap, the more traffic PowerNet can handle. 32kb is good for initial testing if the number of free PBUFFS in PNconfig.fth (see below) is kept low. If you have too low a heap size or request too many resources, PowerNet will complain at start up.


 $0000:8000 equ sizeofheap \ 0=no heap, nz=size of heap
   1 equ heap-diags?       \   true to include diagnostic code

Multitasker

The multitasker is required.


1 equ tasking?             \ true if multitasker needed
  6 cells equ tcb-size     \   for internal consistency check
  0 equ event-handler?     \   true to include event handler
  0 equ message-handler?   \   true to include message handler
  1 equ semaphores?        \ true to include semaphores

Other Forth equates

The equate RP-SIZE should be set to $0200 bytes. Powernet is particularly heavy in its use of locals and hence of the return stack.

Configuring the stack

First of all you must add a text macro to your main control file to tell it where the stack is located. The code below was used during development.


c" C:\buildkit.dev\software\AddOns\PowerNet\Dev"
               setmacro IpStack \ where the PowerNet stack lives

The macro IPSTACK tells the cross compiler where the file POWERNET.BLD is located.

By default, PowerNet.bld compiles configuration data from the file PNconfig.fth, which is always provided with PowerNet. If you need a different configuration, create a different file based on PNconfig.fth. The EQUate PNconfigured? must be present and non-zero in your configuration file. It permits you to compile your configuration file before compiling PowerNet.bld and prevents compilation of the default configuration file.

create PNETver$ \ -- addr
PowerNet version string.

: .PNET         \ --
Display PowerNet version string.

Default console I/O for tasks

All PowerNet tasks should define an input/output device used for debugging. By default, this is CONSOLE as set up for the interactive Forth. If you need to change this, modify the word ConsoleIO below or provide a version before PowerNet is compiled.

: ConsoleIO     \ --
Define the default debug device for PowerNet tasks.

: >pos          \ n --
Move to position n in the output stream for EMIT and friends.

Later versions of the MPE kernel code use a simpler timing mechanism by default.

Default Ethernet and IP addresses

These are compiled if they have not been previously defined.

create EtherAddress     \ -- addr
Holds the Ethernet MAC address (six bytes). Note that you must obtain these from the IEEE (www.ieee.org) or from other sources. This definition is usually provided by the Ethernet driver which must be compiled first.

create IpAddress        \ -- addr
Holds the Ethernet IP address (four bytes). The range 192.168.xxx.yyy is commonly used for private networks. This definition is usually provided by the Ethernet driver which must be compiled first. The data is in network order.

create EnetIPMask       \ -- addr
IP mask for addresses on Ethernet port. The data is in network order.

create IPGateway        \ -- addr
Gateway attached to Ethernet port. The data is in network order. Set to 0.0.0.0 if there is no gateway.

Compiler extensions

These words will probably be removed in a future release.

: mask-ints     \ --
Disable interrupts. Needed with pre-emptive schedulers.

: unmask-ints   \ --
Re-enable interrupts. Needed with pre-emptive schedulers.

: flushDebug    \ -- ; SFP003
Flush the debug queue. Needed if debug is handled through some buffered serial lines, SLIP or Telnet.

Compiling PowerNet

This section of POWERNET.BLD pulls in all the required files. Note that if you have coded versions of the network order memory words and/or the Internet checksum routine (heavily used), you can use an existing (or create your own) for the CPU you are using. The file for CPU specific code is NETCODE.FTH. If you define an EQUATE CPU=xxx where xxx is one of ARM, 386, 68k and so on, a CPU-specific code definition will be compiled, otherwise a default high level (and slower) version will be used

Compile the required services

This section compiles the required services and establishes a task to handle any output they may need.

: RunServices   \ -- ; task action
This is the action of SERVICETASK, which provides I/O support for all the services to avoid blocking problems in the service tasks themselves.

task ServiceTask        \ -- addr
The task used to provide I/O for services.

: RunServiceTask        \ --
Run the service task.

Initialisation

Some initialisation code is provided in POWERNET.BLD to make it easier to manage extensions.

: initip        \ -- ; initialise the data structures
Initialise the PowerNet data structures and the multitasker.

: iptasks       \ -- ; start required tasks
Start all the required tasks.

: PowerNet      \ --
Start PowerNet.

: .PowerNet     \ --
Display PowerNet state.

Sanity checks

Next-user @ up-size > [if]
Check that the USER area is large enough.