|
|
1.1 root 1: \ *****************************************************************************
2: \ * Copyright (c) 2004, 2008 IBM Corporation
3: \ * All rights reserved.
4: \ * This program and the accompanying materials
5: \ * are made available under the terms of the BSD License
6: \ * which accompanies this distribution, and is available at
7: \ * http://www.opensource.org/licenses/bsd-license.php
8: \ *
9: \ * Contributors:
10: \ * IBM Corporation - initial implementation
11: \ ****************************************************************************/
12:
13:
14: \ we do all flash accesses as 8-bit
15:
16: 9f000000 CONSTANT citrine-flash-addr
17:
18: : >citrine-flash citrine-flash-addr + ;
19: : citrine-flash@ >citrine-flash rb@ ;
20: : citrine-flash! >citrine-flash rb! ;
21: : wait-for-citrine-flash-ready BEGIN 0 citrine-flash@ 80 and UNTIL ;
22: : erase-citrine-flash-block ( offset -- )
23: cr dup 8 .r ." Erasing..."
24: 20 over citrine-flash! d0 swap citrine-flash! wait-for-citrine-flash-ready ;
25: : write-citrine-flash ( data offset -- )
26: over ff = IF 2drop EXIT THEN
27: 40 over citrine-flash! citrine-flash! wait-for-citrine-flash-ready ;
28: : write-citrine-flash-block ( addr offset -- ) \ always writes 128kB!
29: ." Writing..."
30: 20000 0 DO over i + c@ over i + write-citrine-flash LOOP 2drop
31: ." Done." ;
32: : citrine-flash ( addr offset size -- )
33: BEGIN dup 0 > WHILE >r dup erase-citrine-flash-block
34: 2dup write-citrine-flash-block >r 20000 + r> 20000 + r> 20000 - REPEAT
35: drop 2drop -1 0 citrine-flash! ;
36:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.