| Index: embios/trunk/target/ipodnano2g/storage_nand.c |
| — | — | @@ -1,110 +1,110 @@ |
| 2 | | -/*************************************************************************** |
| 3 | | - * __________ __ ___. |
| 4 | | - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 5 | | - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 6 | | - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 7 | | - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 8 | | - * \/ \/ \/ \/ \/ |
| 9 | | - * $Id$ |
| 10 | | - * |
| 11 | | - * Copyright (C) 2007 Dave Chapman |
| 12 | | - * |
| 13 | | - * This program is free software; you can redistribute it and/or |
| 14 | | - * modify it under the terms of the GNU General Public License |
| 15 | | - * as published by the Free Software Foundation; either version 2 |
| 16 | | - * of the License, or (at your option) any later version. |
| 17 | | - * |
| 18 | | - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 | | - * KIND, either express or implied. |
| 20 | | - * |
| 21 | | - ****************************************************************************/ |
| 22 | | -#include "global.h" |
| 23 | | -#include "thread.h" |
| 24 | | -#include "disk.h" |
| 25 | | -#include "storage.h" |
| 26 | | -#include "panic.h" |
| 27 | | -#include "ftl.h" |
| 28 | | -#include "nand.h" |
| 29 | | - |
| 30 | | -/** static, private data **/ |
| 31 | | -static bool initialized = false; |
| 32 | | - |
| 33 | | -/* API Functions */ |
| 34 | | -int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount, |
| 35 | | - void* inbuf) |
| 36 | | -{ |
| 37 | | - return ftl_read(start, incount, inbuf); |
| 38 | | -} |
| 39 | | - |
| 40 | | -int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, |
| 41 | | - const void* outbuf) |
| 42 | | -{ |
| 43 | | - return ftl_write(start, count, outbuf); |
| 44 | | -} |
| 45 | | - |
| 46 | | -void nand_spindown(int seconds) |
| 47 | | -{ |
| 48 | | - (void)seconds; |
| 49 | | -} |
| 50 | | - |
| 51 | | -void nand_sleep(void) |
| 52 | | -{ |
| 53 | | - nand_power_down(); |
| 54 | | -} |
| 55 | | - |
| 56 | | -void nand_sleepnow(void) |
| 57 | | -{ |
| 58 | | - nand_power_down(); |
| 59 | | -} |
| 60 | | - |
| 61 | | -void nand_spin(void) |
| 62 | | -{ |
| 63 | | - nand_set_active(); |
| 64 | | -} |
| 65 | | - |
| 66 | | -void nand_enable(bool on) |
| 67 | | -{ |
| 68 | | - (void)on; |
| 69 | | -} |
| 70 | | - |
| 71 | | -void nand_get_info(IF_MD2(int drive,) struct storage_info *info) |
| 72 | | -{ |
| 73 | | - uint32_t ppb = ftl_banks * (*ftl_nand_type).pagesperblock; |
| 74 | | - (*info).sector_size = SECTOR_SIZE; |
| 75 | | - (*info).num_sectors = (*ftl_nand_type).userblocks * ppb; |
| 76 | | - (*info).vendor = "Apple"; |
| 77 | | - (*info).product = "iPod Nano 2G"; |
| 78 | | - (*info).revision = "1.0"; |
| 79 | | -} |
| 80 | | - |
| 81 | | -long nand_last_disk_activity(void) |
| 82 | | -{ |
| 83 | | - return nand_last_activity(); |
| 84 | | -} |
| 85 | | - |
| 86 | | -#ifdef HAVE_STORAGE_FLUSH |
| 87 | | -int nand_flush(void) |
| 88 | | -{ |
| 89 | | - int rc = ftl_sync(); |
| 90 | | - if (rc != 0) panicf(PANIC_FATAL, "Failed to unmount flash: %X", rc); |
| 91 | | - return rc; |
| 92 | | -} |
| 93 | | -#endif |
| 94 | | - |
| 95 | | -int nand_init(void) |
| 96 | | -{ |
| 97 | | - if (ftl_init()) return 1; |
| 98 | | - |
| 99 | | - initialized = true; |
| 100 | | - return 0; |
| 101 | | -} |
| 102 | | - |
| 103 | | -#ifdef CONFIG_STORAGE_MULTI |
| 104 | | -int nand_num_drives(int first_drive) |
| 105 | | -{ |
| 106 | | - /* We don't care which logical drive number(s) we have been assigned */ |
| 107 | | - (void)first_drive; |
| 108 | | - |
| 109 | | - return 1; |
| 110 | | -} |
| 111 | | -#endif |
| | 2 | +/***************************************************************************
|
| | 3 | + * __________ __ ___.
|
| | 4 | + * Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
| | 5 | + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
| | 6 | + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
| | 7 | + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
| | 8 | + * \/ \/ \/ \/ \/
|
| | 9 | + * $Id$
|
| | 10 | + *
|
| | 11 | + * Copyright (C) 2007 Dave Chapman
|
| | 12 | + *
|
| | 13 | + * This program is free software; you can redistribute it and/or
|
| | 14 | + * modify it under the terms of the GNU General Public License
|
| | 15 | + * as published by the Free Software Foundation; either version 2
|
| | 16 | + * of the License, or (at your option) any later version.
|
| | 17 | + *
|
| | 18 | + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
| | 19 | + * KIND, either express or implied.
|
| | 20 | + *
|
| | 21 | + ****************************************************************************/
|
| | 22 | +#include "global.h"
|
| | 23 | +#include "thread.h"
|
| | 24 | +#include "disk.h"
|
| | 25 | +#include "storage.h"
|
| | 26 | +#include "panic.h"
|
| | 27 | +#include "ftl.h"
|
| | 28 | +#include "nand.h"
|
| | 29 | +
|
| | 30 | +/** static, private data **/
|
| | 31 | +static bool initialized = false;
|
| | 32 | +
|
| | 33 | +/* API Functions */
|
| | 34 | +int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
|
| | 35 | + void* inbuf)
|
| | 36 | +{
|
| | 37 | + return ftl_read(start, incount, inbuf);
|
| | 38 | +}
|
| | 39 | +
|
| | 40 | +int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
| | 41 | + const void* outbuf)
|
| | 42 | +{
|
| | 43 | + return ftl_write(start, count, outbuf);
|
| | 44 | +}
|
| | 45 | +
|
| | 46 | +void nand_spindown(int seconds)
|
| | 47 | +{
|
| | 48 | + (void)seconds;
|
| | 49 | +}
|
| | 50 | +
|
| | 51 | +void nand_sleep(void)
|
| | 52 | +{
|
| | 53 | + nand_power_down();
|
| | 54 | +}
|
| | 55 | +
|
| | 56 | +void nand_sleepnow(void)
|
| | 57 | +{
|
| | 58 | + nand_power_down();
|
| | 59 | +}
|
| | 60 | +
|
| | 61 | +void nand_spin(void)
|
| | 62 | +{
|
| | 63 | + nand_set_active();
|
| | 64 | +}
|
| | 65 | +
|
| | 66 | +void nand_enable(bool on)
|
| | 67 | +{
|
| | 68 | + (void)on;
|
| | 69 | +}
|
| | 70 | +
|
| | 71 | +void nand_get_info(IF_MD2(int drive,) struct storage_info *info)
|
| | 72 | +{
|
| | 73 | + uint32_t ppb = ftl_banks * (*ftl_nand_type).pagesperblock;
|
| | 74 | + (*info).sector_size = SECTOR_SIZE;
|
| | 75 | + (*info).num_sectors = (*ftl_nand_type).userblocks * ppb;
|
| | 76 | + (*info).vendor = "Apple";
|
| | 77 | + (*info).product = "iPod Nano 2G";
|
| | 78 | + (*info).revision = "1.0";
|
| | 79 | +}
|
| | 80 | +
|
| | 81 | +long nand_last_disk_activity(void)
|
| | 82 | +{
|
| | 83 | + return nand_last_activity();
|
| | 84 | +}
|
| | 85 | +
|
| | 86 | +#ifdef HAVE_STORAGE_FLUSH
|
| | 87 | +int nand_flush(void)
|
| | 88 | +{
|
| | 89 | + int rc = ftl_sync();
|
| | 90 | + if (rc != 0) panicf(PANIC_KILLUSERTHREADS, "Failed to unmount flash: %X", rc);
|
| | 91 | + return rc;
|
| | 92 | +}
|
| | 93 | +#endif
|
| | 94 | +
|
| | 95 | +int nand_init(void)
|
| | 96 | +{
|
| | 97 | + if (ftl_init()) return 1;
|
| | 98 | +
|
| | 99 | + initialized = true;
|
| | 100 | + return 0;
|
| | 101 | +}
|
| | 102 | +
|
| | 103 | +#ifdef CONFIG_STORAGE_MULTI
|
| | 104 | +int nand_num_drives(int first_drive)
|
| | 105 | +{
|
| | 106 | + /* We don't care which logical drive number(s) we have been assigned */
|
| | 107 | + (void)first_drive;
|
| | 108 | +
|
| | 109 | + return 1;
|
| | 110 | +}
|
| | 111 | +#endif
|
| Index: embios/trunk/target/ipodnano2g/config.h |
| — | — | @@ -25,16 +25,16 @@ |
| 26 | 26 | #define __CONFIG_H__
|
| 27 | 27 |
|
| 28 | 28 |
|
| 29 | | -//#define NAND_DEBUG
|
| 30 | | -//#define NAND_TRACE
|
| 31 | | -//#define VFL_DEBUG
|
| 32 | | -//#define VFL_TRACE
|
| 33 | | -//#define FTL_DEBUG
|
| 34 | | -//#define FTL_TRACE
|
| | 29 | +#define NAND_DEBUG
|
| | 30 | +#define NAND_TRACE
|
| | 31 | +#define VFL_DEBUG
|
| | 32 | +#define VFL_TRACE
|
| | 33 | +#define FTL_DEBUG
|
| | 34 | +#define FTL_TRACE
|
| 35 | 35 |
|
| 36 | 36 |
|
| 37 | | -//#define DEBUG_CONSOLES 2
|
| 38 | | -//#define DEBUG_PRINT_SOURCE_LINE
|
| | 37 | +#define DEBUG_CONSOLES 2
|
| | 38 | +#define DEBUG_PRINT_SOURCE_LINE
|
| 39 | 39 |
|
| 40 | 40 |
|
| 41 | 41 | #endif |
| \ No newline at end of file |