mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
Creative ZVM : cosmetics
Use only UNIX line endings, remove trailing whitespace git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19232 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
888c3477bb
commit
aaaf609996
8 changed files with 978 additions and 978 deletions
|
|
@ -1,35 +1,35 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: adc-mr500.c 14817 2007-09-22 15:43:38Z kkurbjun $
|
||||
*
|
||||
* Copyright (C) 2007 by Karl Kurbjun
|
||||
*
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: adc-mr500.c 14817 2007-09-22 15:43:38Z kkurbjun $
|
||||
*
|
||||
* Copyright (C) 2007 by Karl Kurbjun
|
||||
*
|
||||
* 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpu.h"
|
||||
#include "adc.h"
|
||||
#include "adc-target.h"
|
||||
#include "kernel.h"
|
||||
|
||||
void adc_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Called to get the recent ADC reading */
|
||||
inline unsigned short adc_read(int channel)
|
||||
{
|
||||
return (short)channel;
|
||||
}
|
||||
#include "adc.h"
|
||||
#include "adc-target.h"
|
||||
#include "kernel.h"
|
||||
|
||||
void adc_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Called to get the recent ADC reading */
|
||||
inline unsigned short adc_read(int channel)
|
||||
{
|
||||
return (short)channel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,489 +1,489 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2008 by Maurus Cuelenaere
|
||||
*
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2008 by Maurus Cuelenaere
|
||||
*
|
||||
* 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "kernel.h"
|
||||
#include "thread.h"
|
||||
#include "system.h"
|
||||
#include "power.h"
|
||||
#include "panic.h"
|
||||
#include "ata-target.h"
|
||||
#include "dm320.h"
|
||||
#include "ata.h"
|
||||
#include "string.h"
|
||||
#include "buffer.h"
|
||||
|
||||
#undef ata_read_sectors
|
||||
#undef ata_write_sectors
|
||||
|
||||
static void sleep_ms(int ms)
|
||||
{
|
||||
sleep(ms*HZ/1000);
|
||||
}
|
||||
|
||||
void ide_power_enable(bool on)
|
||||
{
|
||||
/* Disabled until figured out what's wrong */
|
||||
#if 0
|
||||
int old_level = disable_irq_save();
|
||||
if(on)
|
||||
{
|
||||
IO_GIO_BITSET0 = (1 << 14);
|
||||
ata_reset();
|
||||
}
|
||||
else
|
||||
IO_GIO_BITCLR0 = (1 << 14);
|
||||
restore_irq(old_level);
|
||||
#else
|
||||
(void)on;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool ide_powered()
|
||||
{
|
||||
#if 0
|
||||
return (IO_GIO_BITSET0 & (1 << 14));
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ata_reset(void)
|
||||
{
|
||||
int old_level = disable_irq_save();
|
||||
if(!ide_powered())
|
||||
{
|
||||
ide_power_enable(true);
|
||||
sleep_ms(150);
|
||||
}
|
||||
else
|
||||
{
|
||||
IO_GIO_BITSET0 = (1 << 5);
|
||||
IO_GIO_BITCLR0 = (1 << 3);
|
||||
sleep_ms(1);
|
||||
}
|
||||
IO_GIO_BITCLR0 = (1 << 5);
|
||||
sleep_ms(10);
|
||||
IO_GIO_BITSET0 = (1 << 3);
|
||||
while(!(ATA_COMMAND & STATUS_RDY))
|
||||
sleep_ms(10);
|
||||
restore_irq(old_level);
|
||||
}
|
||||
|
||||
void ata_enable(bool on)
|
||||
{
|
||||
(void)on;
|
||||
return;
|
||||
}
|
||||
|
||||
bool ata_is_coldstart(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ata_device_init(void)
|
||||
{
|
||||
IO_INTC_EINT1 |= INTR_EINT1_EXT2; /* enable GIO2 interrupt */
|
||||
/* TODO: mimic OF inits... */
|
||||
return;
|
||||
}
|
||||
|
||||
void GIO2(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
logf("GIO2 interrupt...");
|
||||
#endif
|
||||
IO_INTC_IRQ1 = INTR_IRQ1_EXT2; /* Mask GIO2 interrupt */
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
CreativeFileSystem parsing/handling code
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */
|
||||
|
||||
extern int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
|
||||
extern int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
|
||||
|
||||
struct main_header
|
||||
{
|
||||
char mblk[4];
|
||||
unsigned int sector_size;
|
||||
long long disk_size;
|
||||
struct partition_header
|
||||
{
|
||||
unsigned long end;
|
||||
unsigned long start;
|
||||
char name[8];
|
||||
} partitions[31];
|
||||
};
|
||||
|
||||
struct cfs_header
|
||||
{
|
||||
unsigned int unk;
|
||||
unsigned int unk2;
|
||||
unsigned int sector_size;
|
||||
unsigned int unk4;
|
||||
unsigned int unk5;
|
||||
char identifier[4];
|
||||
unsigned int first_inode;
|
||||
unsigned int unk8;
|
||||
unsigned int unk9;
|
||||
unsigned int unk10;
|
||||
unsigned int unk11;
|
||||
};
|
||||
|
||||
struct cfs_inode
|
||||
{
|
||||
unsigned char magic[4];
|
||||
unsigned int number;
|
||||
unsigned int parent;
|
||||
unsigned int unk;
|
||||
unsigned int type;
|
||||
unsigned int created_time;
|
||||
unsigned int lastmodified_time;
|
||||
unsigned int unk2;
|
||||
unsigned int first_class_chain[12];
|
||||
unsigned int unk3;
|
||||
unsigned int unk4;
|
||||
unsigned int second_class_chain_first_cluster;
|
||||
unsigned int unk9;
|
||||
unsigned int unk10;
|
||||
unsigned int second_class_chain_second_cluster;
|
||||
unsigned int unk11;
|
||||
unsigned int unk12;
|
||||
unsigned int unk13;
|
||||
unsigned int filesize;
|
||||
unsigned int serial_number;
|
||||
unsigned int number_of_metadata_records;
|
||||
};
|
||||
|
||||
struct cfs_direntry
|
||||
{
|
||||
unsigned char identifier[4];
|
||||
unsigned int unk;
|
||||
unsigned int items;
|
||||
unsigned int unk2;
|
||||
unsigned char maxlen[2];
|
||||
unsigned char padding[202];
|
||||
/* struct cfs_direntry_item _items[items]; */
|
||||
};
|
||||
struct cfs_direntry_item
|
||||
{
|
||||
unsigned int inode_number;
|
||||
unsigned short strlen;
|
||||
unsigned short bytesperchar;
|
||||
char string[32];
|
||||
};
|
||||
|
||||
static bool cfs_inited = false;
|
||||
static unsigned long cfs_start;
|
||||
static unsigned long *sectors;
|
||||
|
||||
#define CFS_START ( ((hdr->partitions[1].start*hdr->sector_size) & ~0xFFFF) + 0x10000 )
|
||||
#define CFS_CLUSTER2CLUSTER(x) ( CFS_START+((x)-1)*64 )
|
||||
|
||||
/* Limited version of UCS -> ASCII */
|
||||
static char* ucs2letostring(unsigned char* s)
|
||||
{
|
||||
static char res[256];
|
||||
int i;
|
||||
|
||||
for(i=0; (s[i] == 0 && s[i+1] == 0); i++)
|
||||
res[i] = s[i*2];
|
||||
|
||||
return (char*)&res;
|
||||
}
|
||||
|
||||
static void cfs_init(void)
|
||||
{
|
||||
struct main_header *hdr;
|
||||
struct cfs_header *cfs;
|
||||
struct cfs_inode *root_inode, *vfat_inode, *inode;
|
||||
struct cfs_direntry *root_direntry, *vfat_direntry;
|
||||
struct cfs_direntry_item *root_direntry_items, *vfat_direntry_items;
|
||||
unsigned int i, j, k, vfat_inode_nr=0, vfat_inodes_nr[10], vfat_sector_count;
|
||||
unsigned char sector[512];
|
||||
static unsigned int vfat_data[2][0x8000];
|
||||
static unsigned char sector2[0x8000];
|
||||
|
||||
if(cfs_inited)
|
||||
return;
|
||||
|
||||
/* Read MBLK */
|
||||
_ata_read_sectors(0, 1, §or);
|
||||
hdr = (struct main_header*)§or;
|
||||
|
||||
//printf("CFS is at 0x%x", CFS_START);
|
||||
|
||||
/* Read CFS header */
|
||||
_ata_read_sectors(CFS_START/512, 64, §or2);
|
||||
cfs = (struct cfs_header*)§or2;
|
||||
|
||||
//printf("First inode = %d", cfs->first_inode);
|
||||
|
||||
/* Read root inode */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(cfs->first_inode), 64, §or2);
|
||||
root_inode = (struct cfs_inode*)§or2;
|
||||
|
||||
/* Read root inode's first sector */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(root_inode->first_class_chain[0]), 64, §or2);
|
||||
root_direntry = (struct cfs_direntry*)§or2;
|
||||
root_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry));
|
||||
|
||||
/* Search VFAT inode */
|
||||
for(i=0; i < root_direntry->items; i++)
|
||||
{
|
||||
//printf(" * [%s] at 0x%x\n", ucs2letostring(&root_direntry_items[i].string[0]), root_direntry_items[i].inode_number);
|
||||
if(strcmp(ucs2letostring(&root_direntry_items[i].string[0]), "VFAT") == 0)
|
||||
vfat_inode_nr = root_direntry_items[i].inode_number;
|
||||
}
|
||||
|
||||
/* Read VFAT inode */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode_nr), 64, §or2);
|
||||
vfat_inode = (struct cfs_inode*)§or2;
|
||||
|
||||
/* Read VFAT inode's first sector */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode->first_class_chain[0]), 64, §or2);
|
||||
vfat_direntry = (struct cfs_direntry*)§or2;
|
||||
vfat_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry));
|
||||
|
||||
/* Search for VFAT's subinodes */
|
||||
for(i=0; i < vfat_direntry->items; i++)
|
||||
{
|
||||
//printf(" * [%s] at 0x%x\n", ucs2letostring(&vfat_direntry_items[i].string[0]), vfat_direntry_items[i].inode_number);
|
||||
if(i > 0)
|
||||
vfat_inodes_nr[i-1] = vfat_direntry_items[i].inode_number;
|
||||
}
|
||||
|
||||
/* Determine size of VFAT file */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, §or);
|
||||
inode = (struct cfs_inode*)§or;
|
||||
sectors = (unsigned long*)buffer_alloc(VFAT_SECTOR_SIZE(inode->filesize));
|
||||
|
||||
//printf("VFAT file size: 0x%x", inode->filesize);
|
||||
|
||||
/* Clear data sectors */
|
||||
memset(§ors, 0, VFAT_SECTOR_SIZE(inode->filesize)*sizeof(unsigned long));
|
||||
|
||||
/* Read all data sectors' addresses in memory */
|
||||
vfat_sector_count = 0;
|
||||
for(i=0; vfat_inodes_nr[i] != 0; i++)
|
||||
{
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[i]), 1, §or);
|
||||
inode = (struct cfs_inode*)§or;
|
||||
|
||||
/* Read second & third class chain */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_first_cluster), 64, &vfat_data[0]);
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_second_cluster), 64, &vfat_data[1]);
|
||||
|
||||
/* First class chain */
|
||||
for(j=0; j<12; j++)
|
||||
{
|
||||
if( (inode->first_class_chain[j] & 0xFFFF) != 0xFFFF &&
|
||||
inode->first_class_chain[j] != 0
|
||||
)
|
||||
sectors[vfat_sector_count++] = inode->first_class_chain[j];
|
||||
}
|
||||
|
||||
/* Second class chain */
|
||||
for(j=0; j<0x8000/4; j++)
|
||||
{
|
||||
if( (vfat_data[0][j] & 0xFFFF) != 0xFFFF &&
|
||||
vfat_data[0][j] != 0
|
||||
)
|
||||
sectors[vfat_sector_count++] = vfat_data[0][j];
|
||||
}
|
||||
|
||||
/* Third class chain */
|
||||
for(j=0; j<0x8000/4; j++)
|
||||
{
|
||||
if( (vfat_data[1][j] & 0xFFFF) != 0xFFFF &&
|
||||
vfat_data[1][j] != 0
|
||||
)
|
||||
{
|
||||
memset(&vfat_data[0], 0, 0x8000*sizeof(unsigned int));
|
||||
|
||||
/* Read third class subchain(s) */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_data[1][j]), 64, &vfat_data[0]);
|
||||
|
||||
for(k=0; k<0x8000/4; k++)
|
||||
{
|
||||
if( (vfat_data[0][k] & 0xFFFF) != 0xFFFF &&
|
||||
vfat_data[0][k] != 0
|
||||
)
|
||||
sectors[vfat_sector_count++] = vfat_data[0][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//printf("Sector count: %d 0x%x", vfat_sector_count, vfat_sector_count);
|
||||
|
||||
cfs_inited = true;
|
||||
}
|
||||
|
||||
static inline unsigned long map_sector(unsigned long sector)
|
||||
{
|
||||
/*
|
||||
* Sector mapping: start of CFS + FAT_SECTOR2CFS_SECTOR(sector) + missing part
|
||||
* FAT works with sectors of 0x200 bytes, CFS with sectors of 0x8000 bytes.
|
||||
*/
|
||||
return cfs_start+sectors[sector/64]*64+sector%64;
|
||||
}
|
||||
|
||||
int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf)
|
||||
{
|
||||
if(!cfs_inited)
|
||||
cfs_init();
|
||||
|
||||
/* Check if count is lesser than or equal to 1 native CFS sector */
|
||||
if(count <= 64)
|
||||
return _ata_read_sectors(IF_MV2(drive,) map_sector(start), count, buf);
|
||||
else
|
||||
{
|
||||
int i, ret;
|
||||
unsigned char* dest = (unsigned char*)buf;
|
||||
|
||||
/* Read sectors in parts of 0x8000 */
|
||||
for(i=0; i<count; i+=64)
|
||||
{
|
||||
ret = _ata_read_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
|
||||
dest += (count-i >= 64 ? 0x8000 : (count-i)*512);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf)
|
||||
{
|
||||
if(!cfs_inited)
|
||||
cfs_init();
|
||||
|
||||
/* Check if count is lesser than or equal to 1 native CFS sector */
|
||||
if(count <= 64)
|
||||
return _ata_write_sectors(IF_MV2(drive,) map_sector(start), count, buf);
|
||||
else
|
||||
{
|
||||
int i, ret;
|
||||
unsigned char* dest = (unsigned char*)buf;
|
||||
|
||||
/* Read sectors in parts of 0x8000 */
|
||||
for(i=0; i<count; i+=64)
|
||||
{
|
||||
ret = _ata_write_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
|
||||
dest += (count-i >= 64 ? 0x8000 : (count-i)*512);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
MiniFileSystem parsing code
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
struct minifs_file
|
||||
{
|
||||
char name[0x10];
|
||||
unsigned int unk;
|
||||
unsigned long size;
|
||||
unsigned int chain1;
|
||||
unsigned int chain2;
|
||||
};
|
||||
|
||||
struct minifs_chain
|
||||
{
|
||||
unsigned int unknown;
|
||||
unsigned short chain[0x27FE];
|
||||
unsigned int unknown2;
|
||||
unsigned long length;
|
||||
};
|
||||
|
||||
|
||||
#define DIR_BITMAP_START 0x0143
|
||||
#define DIR_START 0x0144
|
||||
#define DATASPACE_BITMAP_START 0x0145
|
||||
#define DATASPACE_START 0x0146
|
||||
|
||||
#define CLUSTER_CHAIN_SIZE 0x5008
|
||||
#define CLUSTER_CHAIN_HEAD 0x0000
|
||||
#define CLUSTER_CHAIN_BITMAP 0x0001
|
||||
#define CLUSTER_CHAIN_CHAIN 0x0002
|
||||
|
||||
|
||||
int load_minifs_file(char* filename, unsigned char* location)
|
||||
{
|
||||
struct main_header *hdr;
|
||||
static struct minifs_file files[128];
|
||||
struct minifs_chain *chain;
|
||||
unsigned int i;
|
||||
int found = -1;
|
||||
unsigned char sector[512];
|
||||
static unsigned char chain_data[42*512]; /* stack overflow if not static */
|
||||
|
||||
/* Read MBLK */
|
||||
_ata_read_sectors(0, 1, §or);
|
||||
hdr = (struct main_header*)§or;
|
||||
|
||||
/* Read directory listing */
|
||||
#define CLUSTER2SECTOR(x) ( (hdr->partitions[0].start + (x)*8) )
|
||||
_ata_read_sectors(CLUSTER2SECTOR(DIR_START), 8, &files);
|
||||
|
||||
for(i=0; i<127; i++)
|
||||
{
|
||||
if(strcmp(files[i].name, filename) == 0)
|
||||
found = i;
|
||||
}
|
||||
|
||||
if(found == -1)
|
||||
return -1;
|
||||
|
||||
#define GET_CHAIN(x) ( CLUSTER2SECTOR(CLUSTER_CHAIN_CHAIN)*512 + (x)*CLUSTER_CHAIN_SIZE )
|
||||
#define FILE2SECTOR(x) ( CLUSTER2SECTOR(DATASPACE_START + (x)) )
|
||||
|
||||
/* Read chain list */
|
||||
_ata_read_sectors(GET_CHAIN(files[found].chain1)/512, 41, &chain_data[0]);
|
||||
|
||||
chain = (struct minifs_chain*)&chain_data[GET_CHAIN(files[found].chain1)%512];
|
||||
|
||||
/* Copy data */
|
||||
for(i=0; i<chain->length; i++)
|
||||
{
|
||||
_ata_read_sectors(FILE2SECTOR(chain->chain[i]), 8, location);
|
||||
location += 0x1000;
|
||||
}
|
||||
|
||||
return files[found].size;
|
||||
}
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "kernel.h"
|
||||
#include "thread.h"
|
||||
#include "system.h"
|
||||
#include "power.h"
|
||||
#include "panic.h"
|
||||
#include "ata-target.h"
|
||||
#include "dm320.h"
|
||||
#include "ata.h"
|
||||
#include "string.h"
|
||||
#include "buffer.h"
|
||||
|
||||
#undef ata_read_sectors
|
||||
#undef ata_write_sectors
|
||||
|
||||
static void sleep_ms(int ms)
|
||||
{
|
||||
sleep(ms*HZ/1000);
|
||||
}
|
||||
|
||||
void ide_power_enable(bool on)
|
||||
{
|
||||
/* Disabled until figured out what's wrong */
|
||||
#if 0
|
||||
int old_level = disable_irq_save();
|
||||
if(on)
|
||||
{
|
||||
IO_GIO_BITSET0 = (1 << 14);
|
||||
ata_reset();
|
||||
}
|
||||
else
|
||||
IO_GIO_BITCLR0 = (1 << 14);
|
||||
restore_irq(old_level);
|
||||
#else
|
||||
(void)on;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool ide_powered()
|
||||
{
|
||||
#if 0
|
||||
return (IO_GIO_BITSET0 & (1 << 14));
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ata_reset(void)
|
||||
{
|
||||
int old_level = disable_irq_save();
|
||||
if(!ide_powered())
|
||||
{
|
||||
ide_power_enable(true);
|
||||
sleep_ms(150);
|
||||
}
|
||||
else
|
||||
{
|
||||
IO_GIO_BITSET0 = (1 << 5);
|
||||
IO_GIO_BITCLR0 = (1 << 3);
|
||||
sleep_ms(1);
|
||||
}
|
||||
IO_GIO_BITCLR0 = (1 << 5);
|
||||
sleep_ms(10);
|
||||
IO_GIO_BITSET0 = (1 << 3);
|
||||
while(!(ATA_COMMAND & STATUS_RDY))
|
||||
sleep_ms(10);
|
||||
restore_irq(old_level);
|
||||
}
|
||||
|
||||
void ata_enable(bool on)
|
||||
{
|
||||
(void)on;
|
||||
return;
|
||||
}
|
||||
|
||||
bool ata_is_coldstart(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ata_device_init(void)
|
||||
{
|
||||
IO_INTC_EINT1 |= INTR_EINT1_EXT2; /* enable GIO2 interrupt */
|
||||
/* TODO: mimic OF inits... */
|
||||
return;
|
||||
}
|
||||
|
||||
void GIO2(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
logf("GIO2 interrupt...");
|
||||
#endif
|
||||
IO_INTC_IRQ1 = INTR_IRQ1_EXT2; /* Mask GIO2 interrupt */
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
CreativeFileSystem parsing/handling code
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */
|
||||
|
||||
extern int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
|
||||
extern int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
|
||||
|
||||
struct main_header
|
||||
{
|
||||
char mblk[4];
|
||||
unsigned int sector_size;
|
||||
long long disk_size;
|
||||
struct partition_header
|
||||
{
|
||||
unsigned long end;
|
||||
unsigned long start;
|
||||
char name[8];
|
||||
} partitions[31];
|
||||
};
|
||||
|
||||
struct cfs_header
|
||||
{
|
||||
unsigned int unk;
|
||||
unsigned int unk2;
|
||||
unsigned int sector_size;
|
||||
unsigned int unk4;
|
||||
unsigned int unk5;
|
||||
char identifier[4];
|
||||
unsigned int first_inode;
|
||||
unsigned int unk8;
|
||||
unsigned int unk9;
|
||||
unsigned int unk10;
|
||||
unsigned int unk11;
|
||||
};
|
||||
|
||||
struct cfs_inode
|
||||
{
|
||||
unsigned char magic[4];
|
||||
unsigned int number;
|
||||
unsigned int parent;
|
||||
unsigned int unk;
|
||||
unsigned int type;
|
||||
unsigned int created_time;
|
||||
unsigned int lastmodified_time;
|
||||
unsigned int unk2;
|
||||
unsigned int first_class_chain[12];
|
||||
unsigned int unk3;
|
||||
unsigned int unk4;
|
||||
unsigned int second_class_chain_first_cluster;
|
||||
unsigned int unk9;
|
||||
unsigned int unk10;
|
||||
unsigned int second_class_chain_second_cluster;
|
||||
unsigned int unk11;
|
||||
unsigned int unk12;
|
||||
unsigned int unk13;
|
||||
unsigned int filesize;
|
||||
unsigned int serial_number;
|
||||
unsigned int number_of_metadata_records;
|
||||
};
|
||||
|
||||
struct cfs_direntry
|
||||
{
|
||||
unsigned char identifier[4];
|
||||
unsigned int unk;
|
||||
unsigned int items;
|
||||
unsigned int unk2;
|
||||
unsigned char maxlen[2];
|
||||
unsigned char padding[202];
|
||||
/* struct cfs_direntry_item _items[items]; */
|
||||
};
|
||||
struct cfs_direntry_item
|
||||
{
|
||||
unsigned int inode_number;
|
||||
unsigned short strlen;
|
||||
unsigned short bytesperchar;
|
||||
char string[32];
|
||||
};
|
||||
|
||||
static bool cfs_inited = false;
|
||||
static unsigned long cfs_start;
|
||||
static unsigned long *sectors;
|
||||
|
||||
#define CFS_START ( ((hdr->partitions[1].start*hdr->sector_size) & ~0xFFFF) + 0x10000 )
|
||||
#define CFS_CLUSTER2CLUSTER(x) ( CFS_START+((x)-1)*64 )
|
||||
|
||||
/* Limited version of UCS -> ASCII */
|
||||
static char* ucs2letostring(unsigned char* s)
|
||||
{
|
||||
static char res[256];
|
||||
int i;
|
||||
|
||||
for(i=0; (s[i] == 0 && s[i+1] == 0); i++)
|
||||
res[i] = s[i*2];
|
||||
|
||||
return (char*)&res;
|
||||
}
|
||||
|
||||
static void cfs_init(void)
|
||||
{
|
||||
struct main_header *hdr;
|
||||
struct cfs_header *cfs;
|
||||
struct cfs_inode *root_inode, *vfat_inode, *inode;
|
||||
struct cfs_direntry *root_direntry, *vfat_direntry;
|
||||
struct cfs_direntry_item *root_direntry_items, *vfat_direntry_items;
|
||||
unsigned int i, j, k, vfat_inode_nr=0, vfat_inodes_nr[10], vfat_sector_count;
|
||||
unsigned char sector[512];
|
||||
static unsigned int vfat_data[2][0x8000];
|
||||
static unsigned char sector2[0x8000];
|
||||
|
||||
if(cfs_inited)
|
||||
return;
|
||||
|
||||
/* Read MBLK */
|
||||
_ata_read_sectors(0, 1, §or);
|
||||
hdr = (struct main_header*)§or;
|
||||
|
||||
//printf("CFS is at 0x%x", CFS_START);
|
||||
|
||||
/* Read CFS header */
|
||||
_ata_read_sectors(CFS_START/512, 64, §or2);
|
||||
cfs = (struct cfs_header*)§or2;
|
||||
|
||||
//printf("First inode = %d", cfs->first_inode);
|
||||
|
||||
/* Read root inode */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(cfs->first_inode), 64, §or2);
|
||||
root_inode = (struct cfs_inode*)§or2;
|
||||
|
||||
/* Read root inode's first sector */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(root_inode->first_class_chain[0]), 64, §or2);
|
||||
root_direntry = (struct cfs_direntry*)§or2;
|
||||
root_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry));
|
||||
|
||||
/* Search VFAT inode */
|
||||
for(i=0; i < root_direntry->items; i++)
|
||||
{
|
||||
//printf(" * [%s] at 0x%x\n", ucs2letostring(&root_direntry_items[i].string[0]), root_direntry_items[i].inode_number);
|
||||
if(strcmp(ucs2letostring(&root_direntry_items[i].string[0]), "VFAT") == 0)
|
||||
vfat_inode_nr = root_direntry_items[i].inode_number;
|
||||
}
|
||||
|
||||
/* Read VFAT inode */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode_nr), 64, §or2);
|
||||
vfat_inode = (struct cfs_inode*)§or2;
|
||||
|
||||
/* Read VFAT inode's first sector */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode->first_class_chain[0]), 64, §or2);
|
||||
vfat_direntry = (struct cfs_direntry*)§or2;
|
||||
vfat_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry));
|
||||
|
||||
/* Search for VFAT's subinodes */
|
||||
for(i=0; i < vfat_direntry->items; i++)
|
||||
{
|
||||
//printf(" * [%s] at 0x%x\n", ucs2letostring(&vfat_direntry_items[i].string[0]), vfat_direntry_items[i].inode_number);
|
||||
if(i > 0)
|
||||
vfat_inodes_nr[i-1] = vfat_direntry_items[i].inode_number;
|
||||
}
|
||||
|
||||
/* Determine size of VFAT file */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, §or);
|
||||
inode = (struct cfs_inode*)§or;
|
||||
sectors = (unsigned long*)buffer_alloc(VFAT_SECTOR_SIZE(inode->filesize));
|
||||
|
||||
//printf("VFAT file size: 0x%x", inode->filesize);
|
||||
|
||||
/* Clear data sectors */
|
||||
memset(§ors, 0, VFAT_SECTOR_SIZE(inode->filesize)*sizeof(unsigned long));
|
||||
|
||||
/* Read all data sectors' addresses in memory */
|
||||
vfat_sector_count = 0;
|
||||
for(i=0; vfat_inodes_nr[i] != 0; i++)
|
||||
{
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[i]), 1, §or);
|
||||
inode = (struct cfs_inode*)§or;
|
||||
|
||||
/* Read second & third class chain */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_first_cluster), 64, &vfat_data[0]);
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_second_cluster), 64, &vfat_data[1]);
|
||||
|
||||
/* First class chain */
|
||||
for(j=0; j<12; j++)
|
||||
{
|
||||
if( (inode->first_class_chain[j] & 0xFFFF) != 0xFFFF &&
|
||||
inode->first_class_chain[j] != 0
|
||||
)
|
||||
sectors[vfat_sector_count++] = inode->first_class_chain[j];
|
||||
}
|
||||
|
||||
/* Second class chain */
|
||||
for(j=0; j<0x8000/4; j++)
|
||||
{
|
||||
if( (vfat_data[0][j] & 0xFFFF) != 0xFFFF &&
|
||||
vfat_data[0][j] != 0
|
||||
)
|
||||
sectors[vfat_sector_count++] = vfat_data[0][j];
|
||||
}
|
||||
|
||||
/* Third class chain */
|
||||
for(j=0; j<0x8000/4; j++)
|
||||
{
|
||||
if( (vfat_data[1][j] & 0xFFFF) != 0xFFFF &&
|
||||
vfat_data[1][j] != 0
|
||||
)
|
||||
{
|
||||
memset(&vfat_data[0], 0, 0x8000*sizeof(unsigned int));
|
||||
|
||||
/* Read third class subchain(s) */
|
||||
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_data[1][j]), 64, &vfat_data[0]);
|
||||
|
||||
for(k=0; k<0x8000/4; k++)
|
||||
{
|
||||
if( (vfat_data[0][k] & 0xFFFF) != 0xFFFF &&
|
||||
vfat_data[0][k] != 0
|
||||
)
|
||||
sectors[vfat_sector_count++] = vfat_data[0][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//printf("Sector count: %d 0x%x", vfat_sector_count, vfat_sector_count);
|
||||
|
||||
cfs_inited = true;
|
||||
}
|
||||
|
||||
static inline unsigned long map_sector(unsigned long sector)
|
||||
{
|
||||
/*
|
||||
* Sector mapping: start of CFS + FAT_SECTOR2CFS_SECTOR(sector) + missing part
|
||||
* FAT works with sectors of 0x200 bytes, CFS with sectors of 0x8000 bytes.
|
||||
*/
|
||||
return cfs_start+sectors[sector/64]*64+sector%64;
|
||||
}
|
||||
|
||||
int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf)
|
||||
{
|
||||
if(!cfs_inited)
|
||||
cfs_init();
|
||||
|
||||
/* Check if count is lesser than or equal to 1 native CFS sector */
|
||||
if(count <= 64)
|
||||
return _ata_read_sectors(IF_MV2(drive,) map_sector(start), count, buf);
|
||||
else
|
||||
{
|
||||
int i, ret;
|
||||
unsigned char* dest = (unsigned char*)buf;
|
||||
|
||||
/* Read sectors in parts of 0x8000 */
|
||||
for(i=0; i<count; i+=64)
|
||||
{
|
||||
ret = _ata_read_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
|
||||
dest += (count-i >= 64 ? 0x8000 : (count-i)*512);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf)
|
||||
{
|
||||
if(!cfs_inited)
|
||||
cfs_init();
|
||||
|
||||
/* Check if count is lesser than or equal to 1 native CFS sector */
|
||||
if(count <= 64)
|
||||
return _ata_write_sectors(IF_MV2(drive,) map_sector(start), count, buf);
|
||||
else
|
||||
{
|
||||
int i, ret;
|
||||
unsigned char* dest = (unsigned char*)buf;
|
||||
|
||||
/* Read sectors in parts of 0x8000 */
|
||||
for(i=0; i<count; i+=64)
|
||||
{
|
||||
ret = _ata_write_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
|
||||
dest += (count-i >= 64 ? 0x8000 : (count-i)*512);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
MiniFileSystem parsing code
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
struct minifs_file
|
||||
{
|
||||
char name[0x10];
|
||||
unsigned int unk;
|
||||
unsigned long size;
|
||||
unsigned int chain1;
|
||||
unsigned int chain2;
|
||||
};
|
||||
|
||||
struct minifs_chain
|
||||
{
|
||||
unsigned int unknown;
|
||||
unsigned short chain[0x27FE];
|
||||
unsigned int unknown2;
|
||||
unsigned long length;
|
||||
};
|
||||
|
||||
|
||||
#define DIR_BITMAP_START 0x0143
|
||||
#define DIR_START 0x0144
|
||||
#define DATASPACE_BITMAP_START 0x0145
|
||||
#define DATASPACE_START 0x0146
|
||||
|
||||
#define CLUSTER_CHAIN_SIZE 0x5008
|
||||
#define CLUSTER_CHAIN_HEAD 0x0000
|
||||
#define CLUSTER_CHAIN_BITMAP 0x0001
|
||||
#define CLUSTER_CHAIN_CHAIN 0x0002
|
||||
|
||||
|
||||
int load_minifs_file(char* filename, unsigned char* location)
|
||||
{
|
||||
struct main_header *hdr;
|
||||
static struct minifs_file files[128];
|
||||
struct minifs_chain *chain;
|
||||
unsigned int i;
|
||||
int found = -1;
|
||||
unsigned char sector[512];
|
||||
static unsigned char chain_data[42*512]; /* stack overflow if not static */
|
||||
|
||||
/* Read MBLK */
|
||||
_ata_read_sectors(0, 1, §or);
|
||||
hdr = (struct main_header*)§or;
|
||||
|
||||
/* Read directory listing */
|
||||
#define CLUSTER2SECTOR(x) ( (hdr->partitions[0].start + (x)*8) )
|
||||
_ata_read_sectors(CLUSTER2SECTOR(DIR_START), 8, &files);
|
||||
|
||||
for(i=0; i<127; i++)
|
||||
{
|
||||
if(strcmp(files[i].name, filename) == 0)
|
||||
found = i;
|
||||
}
|
||||
|
||||
if(found == -1)
|
||||
return -1;
|
||||
|
||||
#define GET_CHAIN(x) ( CLUSTER2SECTOR(CLUSTER_CHAIN_CHAIN)*512 + (x)*CLUSTER_CHAIN_SIZE )
|
||||
#define FILE2SECTOR(x) ( CLUSTER2SECTOR(DATASPACE_START + (x)) )
|
||||
|
||||
/* Read chain list */
|
||||
_ata_read_sectors(GET_CHAIN(files[found].chain1)/512, 41, &chain_data[0]);
|
||||
|
||||
chain = (struct minifs_chain*)&chain_data[GET_CHAIN(files[found].chain1)%512];
|
||||
|
||||
/* Copy data */
|
||||
for(i=0; i<chain->length; i++)
|
||||
{
|
||||
_ata_read_sectors(FILE2SECTOR(chain->chain[i]), 8, location);
|
||||
location += 0x1000;
|
||||
}
|
||||
|
||||
return files[found].size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,130 +1,130 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2008 by Maurus Cuelenaere
|
||||
*
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2008 by Maurus Cuelenaere
|
||||
*
|
||||
* 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "kernel.h"
|
||||
#include "thread.h"
|
||||
#include "system.h"
|
||||
#include "dma-target.h"
|
||||
#include "dm320.h"
|
||||
#include "ata-target.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define CS1_START 0x50000000
|
||||
#define CS2_START 0x60000000
|
||||
#define SDRAM_START 0x00900000
|
||||
#define FLASH_START 0x00100000
|
||||
#define CF_START 0x40000000
|
||||
#define SSFDC_START 0x48000000
|
||||
|
||||
static struct wakeup transfer_completion_signal;
|
||||
|
||||
static bool dma_in_progress = false;
|
||||
|
||||
void MTC0(void)
|
||||
{
|
||||
IO_INTC_IRQ1 = INTR_IRQ1_MTC0;
|
||||
wakeup_signal(&transfer_completion_signal);
|
||||
dma_in_progress = false;
|
||||
}
|
||||
|
||||
void dma_start(const void* addr, size_t size)
|
||||
{
|
||||
/* Compatibility with Gigabeat S in dma_start.c */
|
||||
(void) addr;
|
||||
(void) size;
|
||||
}
|
||||
|
||||
#define ATA_DEST (ATA_IOBASE-CS1_START)
|
||||
void dma_ata_read(unsigned char* buf, int shortcount)
|
||||
{
|
||||
if(dma_in_progress)
|
||||
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
|
||||
|
||||
while((unsigned long)buf & 0x1F)
|
||||
{
|
||||
unsigned short tmp;
|
||||
tmp = ATA_DATA;
|
||||
*buf++ = tmp & 0xFF;
|
||||
*buf++ = tmp >> 8;
|
||||
shortcount--;
|
||||
}
|
||||
|
||||
if (!shortcount)
|
||||
return;
|
||||
|
||||
IO_SDRAM_SDDMASEL = 0x0820; /* 32-byte burst mode transfer */
|
||||
IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */
|
||||
IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & 0x7FFF; /* Set variable address */
|
||||
IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF;
|
||||
IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */
|
||||
IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF;
|
||||
IO_EMIF_DMASIZE = shortcount/2; /* 16-bits *2 = 1 word */
|
||||
IO_EMIF_DMACTL = 3; /* Select MTC->AHB and start transfer */
|
||||
|
||||
dma_in_progress = true;
|
||||
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
|
||||
|
||||
if(shortcount % 2)
|
||||
{
|
||||
unsigned short tmp;
|
||||
tmp = ATA_DATA;
|
||||
*buf++ = tmp & 0xFF;
|
||||
*buf++ = tmp >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
void dma_ata_write(unsigned char* buf, int wordcount)
|
||||
{
|
||||
if(dma_in_progress)
|
||||
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
|
||||
|
||||
while((unsigned long)buf & 0x1F)
|
||||
{
|
||||
unsigned short tmp;
|
||||
tmp = (unsigned short) *buf++;
|
||||
tmp |= (unsigned short) *buf++ << 8;
|
||||
SET_16BITREG(ATA_DATA, tmp);
|
||||
wordcount--;
|
||||
}
|
||||
|
||||
if (!wordcount)
|
||||
return;
|
||||
|
||||
IO_SDRAM_SDDMASEL = 0x0830; /* 32-byte burst mode transfer */
|
||||
IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */
|
||||
IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & ~(1 << 15); /* Set variable address */
|
||||
IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF;
|
||||
IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */
|
||||
IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF;
|
||||
IO_EMIF_DMASIZE = (wordcount+1)/2;
|
||||
IO_EMIF_DMACTL = 1; /* Select AHB->MTC and start transfer */
|
||||
|
||||
dma_in_progress = true;
|
||||
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
|
||||
}
|
||||
|
||||
void dma_init(void)
|
||||
{
|
||||
IO_INTC_EINT1 |= INTR_EINT1_MTC0; /* enable MTC interrupt */
|
||||
wakeup_init(&transfer_completion_signal);
|
||||
dma_in_progress = false;
|
||||
}
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "kernel.h"
|
||||
#include "thread.h"
|
||||
#include "system.h"
|
||||
#include "dma-target.h"
|
||||
#include "dm320.h"
|
||||
#include "ata-target.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define CS1_START 0x50000000
|
||||
#define CS2_START 0x60000000
|
||||
#define SDRAM_START 0x00900000
|
||||
#define FLASH_START 0x00100000
|
||||
#define CF_START 0x40000000
|
||||
#define SSFDC_START 0x48000000
|
||||
|
||||
static struct wakeup transfer_completion_signal;
|
||||
|
||||
static bool dma_in_progress = false;
|
||||
|
||||
void MTC0(void)
|
||||
{
|
||||
IO_INTC_IRQ1 = INTR_IRQ1_MTC0;
|
||||
wakeup_signal(&transfer_completion_signal);
|
||||
dma_in_progress = false;
|
||||
}
|
||||
|
||||
void dma_start(const void* addr, size_t size)
|
||||
{
|
||||
/* Compatibility with Gigabeat S in dma_start.c */
|
||||
(void) addr;
|
||||
(void) size;
|
||||
}
|
||||
|
||||
#define ATA_DEST (ATA_IOBASE-CS1_START)
|
||||
void dma_ata_read(unsigned char* buf, int shortcount)
|
||||
{
|
||||
if(dma_in_progress)
|
||||
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
|
||||
|
||||
while((unsigned long)buf & 0x1F)
|
||||
{
|
||||
unsigned short tmp;
|
||||
tmp = ATA_DATA;
|
||||
*buf++ = tmp & 0xFF;
|
||||
*buf++ = tmp >> 8;
|
||||
shortcount--;
|
||||
}
|
||||
|
||||
if (!shortcount)
|
||||
return;
|
||||
|
||||
IO_SDRAM_SDDMASEL = 0x0820; /* 32-byte burst mode transfer */
|
||||
IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */
|
||||
IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & 0x7FFF; /* Set variable address */
|
||||
IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF;
|
||||
IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */
|
||||
IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF;
|
||||
IO_EMIF_DMASIZE = shortcount/2; /* 16-bits *2 = 1 word */
|
||||
IO_EMIF_DMACTL = 3; /* Select MTC->AHB and start transfer */
|
||||
|
||||
dma_in_progress = true;
|
||||
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
|
||||
|
||||
if(shortcount % 2)
|
||||
{
|
||||
unsigned short tmp;
|
||||
tmp = ATA_DATA;
|
||||
*buf++ = tmp & 0xFF;
|
||||
*buf++ = tmp >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
void dma_ata_write(unsigned char* buf, int wordcount)
|
||||
{
|
||||
if(dma_in_progress)
|
||||
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
|
||||
|
||||
while((unsigned long)buf & 0x1F)
|
||||
{
|
||||
unsigned short tmp;
|
||||
tmp = (unsigned short) *buf++;
|
||||
tmp |= (unsigned short) *buf++ << 8;
|
||||
SET_16BITREG(ATA_DATA, tmp);
|
||||
wordcount--;
|
||||
}
|
||||
|
||||
if (!wordcount)
|
||||
return;
|
||||
|
||||
IO_SDRAM_SDDMASEL = 0x0830; /* 32-byte burst mode transfer */
|
||||
IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */
|
||||
IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & ~(1 << 15); /* Set variable address */
|
||||
IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF;
|
||||
IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */
|
||||
IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF;
|
||||
IO_EMIF_DMASIZE = (wordcount+1)/2;
|
||||
IO_EMIF_DMACTL = 1; /* Select AHB->MTC and start transfer */
|
||||
|
||||
dma_in_progress = true;
|
||||
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
|
||||
}
|
||||
|
||||
void dma_init(void)
|
||||
{
|
||||
IO_INTC_EINT1 |= INTR_EINT1_MTC0; /* enable MTC interrupt */
|
||||
wakeup_init(&transfer_completion_signal);
|
||||
dma_in_progress = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,30 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2008 by Maurus Cuelenaere
|
||||
*
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2008 by Maurus Cuelenaere
|
||||
*
|
||||
* 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef DMA_TARGET_H
|
||||
#define DMA_TARGET_H
|
||||
|
||||
void dma_start(const void* addr, size_t size); /* Compatibility with Gigabeat S in dma_start.c */
|
||||
void dma_ata_read(unsigned char* buf, int wordcount);
|
||||
void dma_ata_write(unsigned char* buf, int wordcount);
|
||||
void dma_init(void);
|
||||
|
||||
#endif
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef DMA_TARGET_H
|
||||
#define DMA_TARGET_H
|
||||
|
||||
void dma_start(const void* addr, size_t size); /* Compatibility with Gigabeat S in dma_start.c */
|
||||
void dma_ata_read(unsigned char* buf, int wordcount);
|
||||
void dma_ata_write(unsigned char* buf, int wordcount);
|
||||
void dma_init(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,117 +1,117 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007 by Karl Kurbjun
|
||||
*
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007 by Karl Kurbjun
|
||||
*
|
||||
* 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "logf.h"
|
||||
#include "audio.h"
|
||||
#include "sound.h"
|
||||
#include "file.h"
|
||||
#include "dm320.h"
|
||||
#include "audiohw.h"
|
||||
#include "dsp-target.h"
|
||||
|
||||
void pcm_play_dma_init(void)
|
||||
{
|
||||
IO_CLK_O1DIV = 3;
|
||||
/* Set GIO25 to CLKOUT1A */
|
||||
IO_GIO_FSEL2 |= 3;
|
||||
sleep(5);
|
||||
|
||||
audiohw_init();
|
||||
|
||||
audiohw_set_frequency(1);
|
||||
|
||||
/* init DSP */
|
||||
dsp_init();
|
||||
}
|
||||
|
||||
void pcm_postinit(void)
|
||||
{
|
||||
audiohw_postinit();
|
||||
/* wake DSP */
|
||||
dsp_wake();
|
||||
}
|
||||
|
||||
/* set frequency used by the audio hardware */
|
||||
void pcm_set_frequency(unsigned int frequency)
|
||||
{
|
||||
int index;
|
||||
|
||||
switch(frequency)
|
||||
{
|
||||
case SAMPR_11:
|
||||
case SAMPR_22:
|
||||
index = 0;
|
||||
break;
|
||||
default:
|
||||
case SAMPR_44:
|
||||
index = 1;
|
||||
break;
|
||||
case SAMPR_88:
|
||||
index = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
audiohw_set_frequency(index);
|
||||
} /* pcm_set_frequency */
|
||||
|
||||
const void * pcm_play_dma_get_peak_buffer(int *count)
|
||||
{
|
||||
(void) count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pcm_apply_settings(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pcm_play_dma_start(const void *addr, size_t size)
|
||||
{
|
||||
(void)addr;
|
||||
(void)size;
|
||||
DEBUGF("pcm_play_dma_start(0x%x, %d)", addr, size);
|
||||
}
|
||||
|
||||
void pcm_play_dma_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pcm_play_lock(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pcm_play_unlock(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pcm_play_dma_pause(bool pause)
|
||||
{
|
||||
(void) pause;
|
||||
}
|
||||
|
||||
size_t pcm_get_bytes_waiting(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "logf.h"
|
||||
#include "audio.h"
|
||||
#include "sound.h"
|
||||
#include "file.h"
|
||||
#include "dm320.h"
|
||||
#include "audiohw.h"
|
||||
#include "dsp-target.h"
|
||||
|
||||
void pcm_play_dma_init(void)
|
||||
{
|
||||
IO_CLK_O1DIV = 3;
|
||||
/* Set GIO25 to CLKOUT1A */
|
||||
IO_GIO_FSEL2 |= 3;
|
||||
sleep(5);
|
||||
|
||||
audiohw_init();
|
||||
|
||||
audiohw_set_frequency(1);
|
||||
|
||||
/* init DSP */
|
||||
dsp_init();
|
||||
}
|
||||
|
||||
void pcm_postinit(void)
|
||||
{
|
||||
audiohw_postinit();
|
||||
/* wake DSP */
|
||||
dsp_wake();
|
||||
}
|
||||
|
||||
/* set frequency used by the audio hardware */
|
||||
void pcm_set_frequency(unsigned int frequency)
|
||||
{
|
||||
int index;
|
||||
|
||||
switch(frequency)
|
||||
{
|
||||
case SAMPR_11:
|
||||
case SAMPR_22:
|
||||
index = 0;
|
||||
break;
|
||||
default:
|
||||
case SAMPR_44:
|
||||
index = 1;
|
||||
break;
|
||||
case SAMPR_88:
|
||||
index = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
audiohw_set_frequency(index);
|
||||
} /* pcm_set_frequency */
|
||||
|
||||
const void * pcm_play_dma_get_peak_buffer(int *count)
|
||||
{
|
||||
(void) count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pcm_apply_settings(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pcm_play_dma_start(const void *addr, size_t size)
|
||||
{
|
||||
(void)addr;
|
||||
(void)size;
|
||||
DEBUGF("pcm_play_dma_start(0x%x, %d)", addr, size);
|
||||
}
|
||||
|
||||
void pcm_play_dma_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pcm_play_lock(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pcm_play_unlock(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pcm_play_dma_pause(bool pause)
|
||||
{
|
||||
(void) pause;
|
||||
}
|
||||
|
||||
size_t pcm_get_bytes_waiting(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,70 +1,70 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: power-mr500.c 15599 2007-11-12 18:49:53Z amiconn $
|
||||
*
|
||||
* Copyright (C) 2007 by Karl Kurbjun
|
||||
*
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: power-mr500.c 15599 2007-11-12 18:49:53Z amiconn $
|
||||
*
|
||||
* Copyright (C) 2007 by Karl Kurbjun
|
||||
*
|
||||
* 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include <stdbool.h>
|
||||
#include "kernel.h"
|
||||
#include "system.h"
|
||||
#include "power.h"
|
||||
#include "backlight.h"
|
||||
#include "backlight-target.h"
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
void power_init(void)
|
||||
{
|
||||
/* Initialize IDE power pin */
|
||||
/* set ATA power on and output */
|
||||
/* Charger detect */
|
||||
}
|
||||
|
||||
bool charger_inserted(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Returns true if the unit is charging the batteries. */
|
||||
bool charging_state(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void power_off(void)
|
||||
{
|
||||
}
|
||||
|
||||
#else /* SIMULATOR */
|
||||
|
||||
bool charger_inserted(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void charger_enable(bool on)
|
||||
{
|
||||
(void)on;
|
||||
}
|
||||
|
||||
void power_off(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* SIMULATOR */
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include <stdbool.h>
|
||||
#include "kernel.h"
|
||||
#include "system.h"
|
||||
#include "power.h"
|
||||
#include "backlight.h"
|
||||
#include "backlight-target.h"
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
void power_init(void)
|
||||
{
|
||||
/* Initialize IDE power pin */
|
||||
/* set ATA power on and output */
|
||||
/* Charger detect */
|
||||
}
|
||||
|
||||
bool charger_inserted(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Returns true if the unit is charging the batteries. */
|
||||
bool charging_state(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void power_off(void)
|
||||
{
|
||||
}
|
||||
|
||||
#else /* SIMULATOR */
|
||||
|
||||
bool charger_inserted(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void charger_enable(bool on)
|
||||
{
|
||||
(void)on;
|
||||
}
|
||||
|
||||
void power_off(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* SIMULATOR */
|
||||
|
|
|
|||
|
|
@ -1,59 +1,59 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007 by Karl Kurbjun
|
||||
*
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007 by Karl Kurbjun
|
||||
*
|
||||
* 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "adc.h"
|
||||
#include "powermgmt.h"
|
||||
#include "kernel.h"
|
||||
|
||||
/* THIS CONTAINS CURRENTLY DUMMY CODE! */
|
||||
|
||||
unsigned short current_voltage = 3910;
|
||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||
{
|
||||
{ 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320 },
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||
const unsigned short percent_to_volt_charge[11] =
|
||||
{
|
||||
100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320,
|
||||
};
|
||||
void read_battery_inputs(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Returns battery voltage from ADC [millivolts] */
|
||||
unsigned int battery_adc_voltage(void)
|
||||
{
|
||||
return current_voltage;
|
||||
}
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "adc.h"
|
||||
#include "powermgmt.h"
|
||||
#include "kernel.h"
|
||||
|
||||
/* THIS CONTAINS CURRENTLY DUMMY CODE! */
|
||||
|
||||
unsigned short current_voltage = 3910;
|
||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||
{
|
||||
{ 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320 },
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||
const unsigned short percent_to_volt_charge[11] =
|
||||
{
|
||||
100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320,
|
||||
};
|
||||
void read_battery_inputs(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Returns battery voltage from ADC [millivolts] */
|
||||
unsigned int battery_adc_voltage(void)
|
||||
{
|
||||
return current_voltage;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,81 +1,81 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2008 by Maurus Cuelenaere
|
||||
*
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2008 by Maurus Cuelenaere
|
||||
*
|
||||
* 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef USB_TARGET_H
|
||||
#define USB_TARGET_H
|
||||
|
||||
#include "dm320.h"
|
||||
|
||||
/* General purpose memory region #2 */
|
||||
#define ISP1583_IOBASE 0x60FFC000
|
||||
#define ISP1583_H_OVERRIDE
|
||||
|
||||
#define ISP1583_INIT_ADDRESS (*((volatile unsigned char*)(ISP1583_IOBASE+0x0))) //char
|
||||
#define ISP1583_INIT_MODE (*((volatile unsigned short*)(ISP1583_IOBASE+0xC*2)))
|
||||
#define ISP1583_INIT_INTCONF (*((volatile unsigned char*)(ISP1583_IOBASE+0x10*2))) //char
|
||||
#define ISP1583_INIT_OTG (*((volatile unsigned char*)(ISP1583_IOBASE+0x12*2))) //char
|
||||
#define ISP1583_INIT_INTEN_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2)))
|
||||
#define ISP1583_INIT_INTEN_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2+4)))
|
||||
#define ISP1583_INIT_INTEN_READ (unsigned long)( (ISP1583_INIT_INTEN_A & 0xFFFF) | ((ISP1583_INIT_INTEN_B & 0xFFFF) << 16) )
|
||||
/* Data flow registers */
|
||||
#define ISP1583_DFLOW_EPINDEX (*((volatile unsigned char*)(ISP1583_IOBASE+0xC2*2))) //char
|
||||
#define ISP1583_DFLOW_CTRLFUN (*((volatile unsigned char*)(ISP1583_IOBASE+0x28*2))) //char
|
||||
#define ISP1583_DFLOW_DATA (*((volatile unsigned short*)(ISP1583_IOBASE+0x20*2)))
|
||||
#define ISP1583_DFLOW_BUFLEN (*((volatile unsigned short*)(ISP1583_IOBASE+0x1C*2)))
|
||||
#define ISP1583_DFLOW_BUFSTAT (*((volatile unsigned char*)(ISP1583_IOBASE+0x1E*2))) //char
|
||||
#define ISP1583_DFLOW_MAXPKSZ (*((volatile unsigned short*)(ISP1583_IOBASE+0x04*2)))
|
||||
#define ISP1583_DFLOW_EPTYPE (*((volatile unsigned short*)(ISP1583_IOBASE+0x08*2)))
|
||||
/* DMA registers */
|
||||
#define ISP1583_DMA_ENDPOINT (*((volatile unsigned char*)(ISP1583_IOBASE+0x58*2)))
|
||||
/* General registers */
|
||||
#define ISP1583_GEN_INT_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2)))
|
||||
#define ISP1583_GEN_INT_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2+4)))
|
||||
#define ISP1583_GEN_INT_READ (unsigned long)( (ISP1583_GEN_INT_A & 0xFFFF) | ((ISP1583_GEN_INT_B & 0xFFFF) << 16))
|
||||
#define ISP1583_GEN_CHIPID_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x70*2)))
|
||||
#define ISP1583_GEN_CHIPID_B (*((volatile unsigned char*)(ISP1583_IOBASE+0x70*2+4))) //char
|
||||
#define ISP1583_GEN_CHIPID (unsigned long)( (ISP1583_GEN_CHIPID_A & 0xFFFF) | ((ISP1583_GEN_CHIPID_B & 0xFFFF) << 16) )
|
||||
#define ISP1583_GEN_FRAMEN0 (*((volatile unsigned short*)(ISP1583_IOBASE+0x74*2)))
|
||||
#define ISP1583_GEN_SCRATCH (*((volatile unsigned short*)(ISP1583_IOBASE+0x78*2)))
|
||||
#define ISP1583_GEN_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C*2)))
|
||||
#define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84*2))) //char
|
||||
|
||||
#define EN_INT_CPU_TARGET IO_INTC_EINT1 |= INTR_EINT1_EXT7
|
||||
#define DIS_INT_CPU_TARGET IO_INTC_EINT1 &= ~INTR_EINT1_EXT7
|
||||
#define INT_CONF_TARGET 0
|
||||
//#define INT_CONF_TARGET 2
|
||||
#define set_int_value(a,b,value) a = value & 0xFFFF; \
|
||||
b = value >> 16;
|
||||
|
||||
|
||||
#define ZVM_SPECIFIC asm volatile( \
|
||||
"LDR R12, =0x50FFC000\n" \
|
||||
"LDRH R12, [R12]\n" \
|
||||
: : : "r12")
|
||||
//#define ZVM_SPECIFIC
|
||||
|
||||
#define USE_IRAM
|
||||
|
||||
#include <stdbool.h>
|
||||
int usb_detect(void);
|
||||
void usb_init_device(void);
|
||||
bool usb_drv_connected(void);
|
||||
|
||||
#endif
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef USB_TARGET_H
|
||||
#define USB_TARGET_H
|
||||
|
||||
#include "dm320.h"
|
||||
|
||||
/* General purpose memory region #2 */
|
||||
#define ISP1583_IOBASE 0x60FFC000
|
||||
#define ISP1583_H_OVERRIDE
|
||||
|
||||
#define ISP1583_INIT_ADDRESS (*((volatile unsigned char*)(ISP1583_IOBASE+0x0))) //char
|
||||
#define ISP1583_INIT_MODE (*((volatile unsigned short*)(ISP1583_IOBASE+0xC*2)))
|
||||
#define ISP1583_INIT_INTCONF (*((volatile unsigned char*)(ISP1583_IOBASE+0x10*2))) //char
|
||||
#define ISP1583_INIT_OTG (*((volatile unsigned char*)(ISP1583_IOBASE+0x12*2))) //char
|
||||
#define ISP1583_INIT_INTEN_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2)))
|
||||
#define ISP1583_INIT_INTEN_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2+4)))
|
||||
#define ISP1583_INIT_INTEN_READ (unsigned long)( (ISP1583_INIT_INTEN_A & 0xFFFF) | ((ISP1583_INIT_INTEN_B & 0xFFFF) << 16) )
|
||||
/* Data flow registers */
|
||||
#define ISP1583_DFLOW_EPINDEX (*((volatile unsigned char*)(ISP1583_IOBASE+0xC2*2))) //char
|
||||
#define ISP1583_DFLOW_CTRLFUN (*((volatile unsigned char*)(ISP1583_IOBASE+0x28*2))) //char
|
||||
#define ISP1583_DFLOW_DATA (*((volatile unsigned short*)(ISP1583_IOBASE+0x20*2)))
|
||||
#define ISP1583_DFLOW_BUFLEN (*((volatile unsigned short*)(ISP1583_IOBASE+0x1C*2)))
|
||||
#define ISP1583_DFLOW_BUFSTAT (*((volatile unsigned char*)(ISP1583_IOBASE+0x1E*2))) //char
|
||||
#define ISP1583_DFLOW_MAXPKSZ (*((volatile unsigned short*)(ISP1583_IOBASE+0x04*2)))
|
||||
#define ISP1583_DFLOW_EPTYPE (*((volatile unsigned short*)(ISP1583_IOBASE+0x08*2)))
|
||||
/* DMA registers */
|
||||
#define ISP1583_DMA_ENDPOINT (*((volatile unsigned char*)(ISP1583_IOBASE+0x58*2)))
|
||||
/* General registers */
|
||||
#define ISP1583_GEN_INT_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2)))
|
||||
#define ISP1583_GEN_INT_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2+4)))
|
||||
#define ISP1583_GEN_INT_READ (unsigned long)( (ISP1583_GEN_INT_A & 0xFFFF) | ((ISP1583_GEN_INT_B & 0xFFFF) << 16))
|
||||
#define ISP1583_GEN_CHIPID_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x70*2)))
|
||||
#define ISP1583_GEN_CHIPID_B (*((volatile unsigned char*)(ISP1583_IOBASE+0x70*2+4))) //char
|
||||
#define ISP1583_GEN_CHIPID (unsigned long)( (ISP1583_GEN_CHIPID_A & 0xFFFF) | ((ISP1583_GEN_CHIPID_B & 0xFFFF) << 16) )
|
||||
#define ISP1583_GEN_FRAMEN0 (*((volatile unsigned short*)(ISP1583_IOBASE+0x74*2)))
|
||||
#define ISP1583_GEN_SCRATCH (*((volatile unsigned short*)(ISP1583_IOBASE+0x78*2)))
|
||||
#define ISP1583_GEN_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C*2)))
|
||||
#define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84*2))) //char
|
||||
|
||||
#define EN_INT_CPU_TARGET IO_INTC_EINT1 |= INTR_EINT1_EXT7
|
||||
#define DIS_INT_CPU_TARGET IO_INTC_EINT1 &= ~INTR_EINT1_EXT7
|
||||
#define INT_CONF_TARGET 0
|
||||
//#define INT_CONF_TARGET 2
|
||||
#define set_int_value(a,b,value) a = value & 0xFFFF; \
|
||||
b = value >> 16;
|
||||
|
||||
|
||||
#define ZVM_SPECIFIC asm volatile( \
|
||||
"LDR R12, =0x50FFC000\n" \
|
||||
"LDRH R12, [R12]\n" \
|
||||
: : : "r12")
|
||||
//#define ZVM_SPECIFIC
|
||||
|
||||
#define USE_IRAM
|
||||
|
||||
#include <stdbool.h>
|
||||
int usb_detect(void);
|
||||
void usb_init_device(void);
|
||||
bool usb_drv_connected(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue