OSDN Git Service

client 0.6.2 release
[unagi/old-svn-converted.git] / client / tag / 0.6.2 / flashmemory.h
1 /*
2 famicom ROM cartridge utility - unagi
3 flash memory driver
4
5 Copyright (C) 2008-2009 ±·³«È¯¶¨Æ±Áȹç
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 flashmemory.c ¤À¤±¤Î·Ù¹ð
22 ¤³¤Î¥½¡¼¥¹¥³¡¼¥É¤ò»²¹Í¡¢Å¾ÍѤ·¤Æ¥·¥§¥¢¥¦¥§¥¢¤Ê¤É¤ÇÍø±×¤òÆÀ¤Ê¤¤¤³¤È¡£
23 ȽÌÀ¤·¤¿¾ì¹ç¤Ï LGPL ¤¬Å¬ÍѤµ¤ì¡¢³ºÅö²Õ½ê¤Î¥½¡¼¥¹¤ò¸ø³«¤¹¤ëɬÍפ¬¤¢¤ë¡£
24 */
25 #ifndef _FLASHMEMORY_H_
26 #define _FLASHMEMORY_H_
27
28 struct flash_order{
29         //JEDEC command ¤ò½¼¤Æ¤ë CPU/PPU ÏÀÍý¥¢¥É¥ì¥¹
30         long command_0000, command_2aaa, command_5555;
31         long command_mask;
32         long pagesize;
33         //struct reader_driver ¤Î´Ø¿ô¥Ý¥¤¥ó¥¿¤òÅϤ¹¾ì½ê
34         void (*config)(long c000, long c2aaa, long c5555, long unit, bool retry);
35         void (*erase)(long address, bool dowait);
36         void (*write)(long address, long length, uint8_t *data);
37         long (*program)(long address, long length, const uint8_t *data, bool dowait, bool skip);
38 };
39
40 struct memory;
41 struct flash_driver{
42         const char *name;
43         long capacity, pagesize;
44         long command_mask;
45         long erase_wait; //unit is msec
46         u8 id_manufacurer, id_device;
47         int (*productid_check)(const struct flash_order *d, const struct flash_driver *f);
48         void (*init)(const struct flash_order *d, long wait);
49         void (*program)(const struct flash_order *d, long address, long length, const struct memory *m);
50 };
51 const struct flash_driver FLASH_DRIVER_UNDEF;
52 const struct flash_driver *flash_driver_get(const char *name);
53
54 //0x80 °Ê¹ß¤ÏËÜÅö¤Î¥Ç¥Ð¥¤¥¹½ÅÊ£¤·¤Ê¤¤¤È»×¤¦. Ã¯¤« JEDEC ¤Î¤È¤³¤ò¤·¤é¤Ù¤Æ.
55 enum{
56         FLASH_ID_DEVICE_SRAM = 0xf0, 
57         FLASH_ID_DEVICE_DUMMY
58 };
59 #endif