mirror of
https://github.com/fail0verflow/mini.git
synced 2024-11-24 12:19:21 +01:00
a little bit of nand cleanup
This commit is contained in:
parent
f806abdac2
commit
4788621a9b
13
nand.c
13
nand.c
@ -1,8 +1,9 @@
|
||||
/*
|
||||
mini - a Free Software replacement for the Nintendo/BroadOn IOS.
|
||||
|
||||
NAND support
|
||||
low-level NAND support
|
||||
|
||||
Copyright (C) 2008, 2009 Haxx Enterprises <bushing@gmail.com>
|
||||
Copyright (C) 2008, 2009 Sven Peter <svenpeter@gmail.com>
|
||||
Copyright (C) 2008, 2009 Hector Martin "marcan" <marcan@marcansoft.com>
|
||||
|
||||
@ -159,8 +160,7 @@ void __nand_setup_dma(u8 *data, u8 *spare) {
|
||||
}
|
||||
}
|
||||
|
||||
int nand_reset(void)
|
||||
{
|
||||
int nand_reset(void) {
|
||||
NAND_debug("nand_reset()\n");
|
||||
// IOS actually uses NAND_FLAGS_IRQ | NAND_FLAGS_WAIT here
|
||||
nand_send_command(NAND_RESET, 0, NAND_FLAGS_WAIT, 0);
|
||||
@ -206,7 +206,7 @@ void nand_read_page(u32 pageno, void *data, void *ecc) {
|
||||
nand_send_command(NAND_READ_POST, 0, NAND_FLAGS_IRQ | NAND_FLAGS_WAIT | NAND_FLAGS_RD | NAND_FLAGS_ECC, 0x840);
|
||||
}
|
||||
|
||||
void nand_wait() {
|
||||
void nand_wait(void) {
|
||||
// power-saving IRQ wait
|
||||
while(!irq_flag) {
|
||||
u32 cookie = irq_kill();
|
||||
@ -220,6 +220,8 @@ void nand_wait() {
|
||||
void nand_write_page(u32 pageno, void *data, void *ecc) {
|
||||
irq_flag = 0;
|
||||
NAND_debug("nand_write_page(%u, %p, %p)\n", pageno, data, ecc);
|
||||
|
||||
// this is a safety check to prevent you from accidentally wiping out boot1 or boot2.
|
||||
if ((pageno < 0x200) || (pageno >= NAND_MAX_PAGE)) {
|
||||
gecko_printf("Error: nand_write to page %d forbidden\n", pageno);
|
||||
return;
|
||||
@ -239,6 +241,8 @@ void nand_write_page(u32 pageno, void *data, void *ecc) {
|
||||
void nand_erase_block(u32 pageno) {
|
||||
irq_flag = 0;
|
||||
NAND_debug("nand_erase_block(%d)\n", pageno);
|
||||
|
||||
// this is a safety check to prevent you from accidentally wiping out boot1 or boot2.
|
||||
if ((pageno < 0x200) || (pageno >= NAND_MAX_PAGE)) {
|
||||
gecko_printf("Error: nand_erase to page %d forbidden\n", pageno);
|
||||
return;
|
||||
@ -248,7 +252,6 @@ void nand_erase_block(u32 pageno) {
|
||||
__nand_wait();
|
||||
nand_send_command(NAND_ERASE_POST, 0, NAND_FLAGS_IRQ | NAND_FLAGS_WAIT, 0);
|
||||
NAND_debug("nand_erase_block(%d) done\n", pageno);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user