Subject: Flash Rom problem
To: 'port-powerpc@NetBSD.ORG' <port-powerpc@NetBSD.ORG>
From: James He <James.He@raidtec.ie>
List: port-powerpc
Date: 02/20/2001 10:43:53
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C09B2A.073D4400
Content-Type: text/plain;
	charset="iso-8859-1"

> Hello,Dear:
> 
> I'm engineer from Raidtec Ireland,we adopt open firmware in network
> storage access equipment.
> now our system has some problem with openfirmware,totally the model
> has one 2M OFW BOOT FLASH and 2x8M SYSTEM FLASH. now the first 8M system
> flash work,but another 8M Flash(latter address) doesn't work because
> loading fail when we download over 8M linux image into system flash.
> I think that code OFW code FLASH.FTH has bug.
> could you advise me the process how to compile,download the OFW
> image into first 2M boot FLASH? 
>  <<flash>> 
> Look forward to your reply!
> Thanks in advance!
> James

------_=_NextPart_000_01C09B2A.073D4400
Content-Type: application/octet-stream;
	name="flash"
Content-Disposition: attachment;
	filename="flash"

purpose: Setup for Flash ROM access
copyright: Copyright 1995-1999 Firmworks.  All Rights Reserved.

false to 16-bit?
d#     32 to #sectors
h# 1.0000 to /block		\ in bytes
h# 8.0000 to /flash		\ in bytes
h# ff90.0000 value rom-pa	\ OFW address
0 value flashbase

headerless
\ Use the following set for the boot rom
: (fctl-b!)   ( n a -- )  flashbase +  c!  ;  
: (fctl-b@)   ( a -- n )  flashbase +  c@  ;  
: (fdata-b!)  ( n a -- )  flashbase +  c!  ;
: (fdata-b@)  ( a -- n )  flashbase +  c@  ;

\ Use the following set for the flash chips
: (fdata-w!)  ( n a -- )  flashbase +  w!  ;
: (fdata-w@)  ( a -- n )  flashbase +  w@  ;

: set-rom-!@  ( -- )
   0 to flashbase
   false to 16-bit?
   ['] (fctl-b!)  to fctl!
   ['] (fctl-b@)  to fctl@
   ['] (fdata-b!) to fdata!
   ['] (fdata-b@) to fdata@
;
headers
: use-rom  ( -- )			\ select entire boot rom
   set-rom-!@
   d# 32 to #sectors
   h# 1.0000 to /block			\ in bytes
   h# 20.0000 to /flash			\ in bytes
;

: use-vmlinux  ( -- )			\ select entire boot rom
   set-rom-!@
   d# 15 to #sectors
   h# 1.0000 to /block			\ in bytes
   h# f.e000 to /flash			\ in bytes
   h# ff80.0000 to rom-pa
;


: (use-rom)  ( -- )			\ divide boot rom to 4 parts
   d# 8 to #sectors
   h# 1.0000 to /block			\ in bytes
   h# 8.0000 to /flash			\ in bytes
;
: use-rom0  ( -- )
   set-rom-!@
   (use-rom)
   h# ff80.0000 to rom-pa
;
: use-rom1  ( -- )
   set-rom-!@
   (use-rom)
   h# ff88.0000 to rom-pa
;
: use-rom2  ( -- )			\ OFW portion of ROM
   set-rom-!@
   (use-rom)
   h# ff90.0000 to rom-pa
;
: use-rom3  ( -- )
   set-rom-!@
   (use-rom)
   h# ff98.0000 to rom-pa
;
alias use-ofw use-rom3

use-ofw

: set-flash-!@  ( -- )
   0 to flashbase
   true to 16-bit?
   ['] (fctl-b!)  to fctl!
   ['] (fctl-b@)  to fctl@
   ['] (fdata-w!) to fdata!
   ['] (fdata-w@) to fdata@
;

: use-flash  ( -- )			\ select both flash chips
   d# 128 to #sectors
   h#   2.0000 to /block		\ in bytes
   h# 100.0000 to /flash		\ in bytes
   set-flash-!@
   h# fd00.0000 to rom-pa
;

: (use-flash)  ( -- )
   d# 64 to #sectors
   h#  2.0000 to /block			\ in bytes
   h# 80.0000 to /flash	                \ in bytes
   set-flash-!@ 
;

: use-flash1  ( -- )			\ select flash 1
   (use-flash)
   h# fd00.0000 to rom-pa
;

alias use-ramdisk use-flash1

: use-flash2  ( -- )			\ select flash 2
   (use-flash)
   h# fd80.0000 to rom-pa
;

: open-flash  ( -- )
   flashbase 0=  if
      rom-pa /flash  root-map-in  to flashbase
   then
   h# a8 config-l@  h# 00001000 or  h# a8 config-l!
;
: close-flash  ( -- )
   flashbase /flash  root-map-out  0 to flashbase
   h# a8 config-l@  h# 00001000 invert and  h# a8 config-l!
;
' open-flash to enable-flash-writes

\ Alternate version of standard flash and $flash
: $flash-decomp ( adr len -- )
   ." Reading..." cr
   $read-file 2drop          ( )
   ?inflate-loaded           ( )
   loaded		     ( adr len )
   (flash)                   ( )
;

: flash-decomp  ( -- $name )
   safe-parse-word      ( name$ )
   $flash-decomp
;
   
headers

------_=_NextPart_000_01C09B2A.073D4400--