36 Rabbit
2000
Microprocessor
10.1
Writing
Your
Own
Flash
Driver
If
a
user
wishes
to
install
a
flash
memory
not
listed
in
Table
3,
custom
functions
need
to
be
written
for
the
new
flash.
This
section
explains
the
requirements
of
these
three
user-writ-
ten
functions.
_InitFlashDriver
Called
from
the
BIOS,
this
function
initializes
all
the
necessary
values
for
the
flash
driver.
The
memory
quadrants
that
are
mapped
to
flash
memory
are
passed
to
it
as
a
bitmap,
i.e.,
0x01
=
the
first
quadrant,
0x02
=
the
second
quadrant,
0x0C
=
the
topmost
two
quadrants,
and
so
on.
_WriteFlash
The
low-level
sector
writing
function
--
the
user
will
normally
call
the
WriteFlash
function
(below).
This
function
writes
one
sector
of
data
from
RAM
to
flash
memory,
aligned
along
a
flash
sector
boundary.
Below
is
the
C
struct
used
by
the
Z-World
flash
driver
to
hold
the
required
information
about
the
flash
memory
installed.
The
_InitFlashDriver
function
is
called
early
in
the
BIOS
to
fill
this
struct
before
any
accesses
to
the
flash.
struct {
char flashXPC; // XPC required to access flash via XMEM
int sectorSize; // byte size of one flash memory sector
int numSectors; // number of sectors on flash
char writeMode; // write method used by the flash
void *eraseChipPtr; // pointer to erase chip function in RAM
void *writePtr;
// ptr to write flash sector function (RAM)
} _FlashInfo;
The
field
flashXPC
contains
the
XPC
required
to
access
the
first
flash
physical
memory
location
via
XMEM
address
E000h.
The
pointers
writePtr
and
eraseChipPtr
should
point
to
a
function
in
RAM
to
avoid
accessing
the
flash
memory
while
working
*. Package
Types:
1.
32-pin
PDIP
2.
32-pin
PLCC
3.
32-pin
TSOP
(8
mm
×
14
mm)
4.
32-pin
TSOP
(8
mm
×
20
mm)
**.
Dynamic
C
Versions
6.04-6.1x:
The
FLASH_SIZE
parameter
in
the
JRABBIOS.C
file
needs
to
be
changed
to
reflect
the
correct
number
of
4K
pages
for
the
selected
device.
By
default,
the
FLASH_SIZE
parameter
contains
a
0x20
that
corre-
sponds
to
a
128K
x
8
device
with
thirty-two
4K
pages
of
flash.
Dynamic
C
versions
6.5x
and
greater
determine
the
flash
size
automatically
and
no
code
change
is
required.