1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-07-02 21:34:32 +03:00
iris/source/nand.ccp
2010-08-22 22:03:06 +02:00

101 lines
2.7 KiB
COBOL

#pypp 0
// Iris: micro-kernel for a capability-based operating system.
// boot-programs/nand.ccp: NAND driver.
// Copyright 2009 Bas Wijnen <wijnen@debian.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DELAY Iris::schedule
#include "devices.hh"
#define ARCH
#include "arch.hh"
#define debug Iris::debug
#include "nand.hh"
extern "C":
extern char file_start, file_mid, file_end
Iris::Num start ():
//kdebug ("starting nand operation in 10 seconds\n")
//Iris::sleep (10 * HZ)
map_emc ()
map_gpio ()
// Arbitrary addresses where the pages are mapped.
command = (volatile char *)0x15000
address = (volatile char *)0x16000
data = (volatile char *)0x17000
Iris::Page data_page = Iris::my_memory.create_page ()
Iris::Page command_page = Iris::my_memory.create_page ()
Iris::Page address_page = Iris::my_memory.create_page ()
unsigned base = 0x18000000
data_page.alloc_physical (base, false, false)
command_page.alloc_physical (base + 0x8000, false, false)
address_page.alloc_physical (base + 0x10000, false, false)
Iris::my_memory.map (data_page, (unsigned)data)
Iris::my_memory.map (command_page, (unsigned)command)
Iris::my_memory.map (address_page, (unsigned)address)
Iris::free_cap (data_page)
Iris::free_cap (command_page)
Iris::free_cap (address_page)
reset ()
#if 1
erase (0)
char *source = &file_start
unsigned a = 0
while source < &file_mid:
write (a, source)
a += 0x800
source += 0x800
source = &file_mid
a = 0x4000
while source < &file_end:
write (a, source)
a += 0x800
source += 0x800
#endif
char buffer[0x200]
// Send nand contents to serial port.
for unsigned a = 0; a < 0x400; a += 0x200:
read (a, buffer)
for unsigned s = 0; s < 0x8; ++s:
for unsigned t = 0; t < 0x40; ++t:
kdebug (" ")
kdebug_num (buffer[s * 0x40 + t], 2)
kdebug ("\n")
kdebug ("\n")
// Exit.
return 0
asm volatile ("\t.set noreorder\n"
"\t.globl file_start\n"
"\t.globl file_mid\n"
"\t.globl file_end\n"
"\t.text\n"
"file_start:\n"
"\t.incbin \"mips/nanonote/nand-boot.raw\"\n"
"file_mid:\n"
"\t.incbin \"iris-sd.raw\"\n"
"file_end:\n"
".set reorder")