1
0
Fork 0
forked from len0rd/rockbox

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:
Rafaël Carré 2008-11-26 15:38:10 +00:00
parent 888c3477bb
commit aaaf609996
8 changed files with 978 additions and 978 deletions

View file

@ -1,35 +1,35 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id: adc-mr500.c 14817 2007-09-22 15:43:38Z kkurbjun $ * $Id: adc-mr500.c 14817 2007-09-22 15:43:38Z kkurbjun $
* *
* Copyright (C) 2007 by Karl Kurbjun * Copyright (C) 2007 by Karl Kurbjun
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "cpu.h" #include "cpu.h"
#include "adc.h" #include "adc.h"
#include "adc-target.h" #include "adc-target.h"
#include "kernel.h" #include "kernel.h"
void adc_init(void) void adc_init(void)
{ {
} }
/* Called to get the recent ADC reading */ /* Called to get the recent ADC reading */
inline unsigned short adc_read(int channel) inline unsigned short adc_read(int channel)
{ {
return (short)channel; return (short)channel;
} }

View file

@ -1,489 +1,489 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id$ * $Id$
* *
* Copyright (C) 2008 by Maurus Cuelenaere * Copyright (C) 2008 by Maurus Cuelenaere
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "config.h" #include "config.h"
#include "cpu.h" #include "cpu.h"
#include "kernel.h" #include "kernel.h"
#include "thread.h" #include "thread.h"
#include "system.h" #include "system.h"
#include "power.h" #include "power.h"
#include "panic.h" #include "panic.h"
#include "ata-target.h" #include "ata-target.h"
#include "dm320.h" #include "dm320.h"
#include "ata.h" #include "ata.h"
#include "string.h" #include "string.h"
#include "buffer.h" #include "buffer.h"
#undef ata_read_sectors #undef ata_read_sectors
#undef ata_write_sectors #undef ata_write_sectors
static void sleep_ms(int ms) static void sleep_ms(int ms)
{ {
sleep(ms*HZ/1000); sleep(ms*HZ/1000);
} }
void ide_power_enable(bool on) void ide_power_enable(bool on)
{ {
/* Disabled until figured out what's wrong */ /* Disabled until figured out what's wrong */
#if 0 #if 0
int old_level = disable_irq_save(); int old_level = disable_irq_save();
if(on) if(on)
{ {
IO_GIO_BITSET0 = (1 << 14); IO_GIO_BITSET0 = (1 << 14);
ata_reset(); ata_reset();
} }
else else
IO_GIO_BITCLR0 = (1 << 14); IO_GIO_BITCLR0 = (1 << 14);
restore_irq(old_level); restore_irq(old_level);
#else #else
(void)on; (void)on;
#endif #endif
} }
inline bool ide_powered() inline bool ide_powered()
{ {
#if 0 #if 0
return (IO_GIO_BITSET0 & (1 << 14)); return (IO_GIO_BITSET0 & (1 << 14));
#else #else
return true; return true;
#endif #endif
} }
void ata_reset(void) void ata_reset(void)
{ {
int old_level = disable_irq_save(); int old_level = disable_irq_save();
if(!ide_powered()) if(!ide_powered())
{ {
ide_power_enable(true); ide_power_enable(true);
sleep_ms(150); sleep_ms(150);
} }
else else
{ {
IO_GIO_BITSET0 = (1 << 5); IO_GIO_BITSET0 = (1 << 5);
IO_GIO_BITCLR0 = (1 << 3); IO_GIO_BITCLR0 = (1 << 3);
sleep_ms(1); sleep_ms(1);
} }
IO_GIO_BITCLR0 = (1 << 5); IO_GIO_BITCLR0 = (1 << 5);
sleep_ms(10); sleep_ms(10);
IO_GIO_BITSET0 = (1 << 3); IO_GIO_BITSET0 = (1 << 3);
while(!(ATA_COMMAND & STATUS_RDY)) while(!(ATA_COMMAND & STATUS_RDY))
sleep_ms(10); sleep_ms(10);
restore_irq(old_level); restore_irq(old_level);
} }
void ata_enable(bool on) void ata_enable(bool on)
{ {
(void)on; (void)on;
return; return;
} }
bool ata_is_coldstart(void) bool ata_is_coldstart(void)
{ {
return true; return true;
} }
void ata_device_init(void) void ata_device_init(void)
{ {
IO_INTC_EINT1 |= INTR_EINT1_EXT2; /* enable GIO2 interrupt */ IO_INTC_EINT1 |= INTR_EINT1_EXT2; /* enable GIO2 interrupt */
/* TODO: mimic OF inits... */ /* TODO: mimic OF inits... */
return; return;
} }
void GIO2(void) void GIO2(void)
{ {
#ifdef DEBUG #ifdef DEBUG
logf("GIO2 interrupt..."); logf("GIO2 interrupt...");
#endif #endif
IO_INTC_IRQ1 = INTR_IRQ1_EXT2; /* Mask GIO2 interrupt */ IO_INTC_IRQ1 = INTR_IRQ1_EXT2; /* Mask GIO2 interrupt */
return; return;
} }
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
CreativeFileSystem parsing/handling code CreativeFileSystem parsing/handling code
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
#define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */ #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_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); extern int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
struct main_header struct main_header
{ {
char mblk[4]; char mblk[4];
unsigned int sector_size; unsigned int sector_size;
long long disk_size; long long disk_size;
struct partition_header struct partition_header
{ {
unsigned long end; unsigned long end;
unsigned long start; unsigned long start;
char name[8]; char name[8];
} partitions[31]; } partitions[31];
}; };
struct cfs_header struct cfs_header
{ {
unsigned int unk; unsigned int unk;
unsigned int unk2; unsigned int unk2;
unsigned int sector_size; unsigned int sector_size;
unsigned int unk4; unsigned int unk4;
unsigned int unk5; unsigned int unk5;
char identifier[4]; char identifier[4];
unsigned int first_inode; unsigned int first_inode;
unsigned int unk8; unsigned int unk8;
unsigned int unk9; unsigned int unk9;
unsigned int unk10; unsigned int unk10;
unsigned int unk11; unsigned int unk11;
}; };
struct cfs_inode struct cfs_inode
{ {
unsigned char magic[4]; unsigned char magic[4];
unsigned int number; unsigned int number;
unsigned int parent; unsigned int parent;
unsigned int unk; unsigned int unk;
unsigned int type; unsigned int type;
unsigned int created_time; unsigned int created_time;
unsigned int lastmodified_time; unsigned int lastmodified_time;
unsigned int unk2; unsigned int unk2;
unsigned int first_class_chain[12]; unsigned int first_class_chain[12];
unsigned int unk3; unsigned int unk3;
unsigned int unk4; unsigned int unk4;
unsigned int second_class_chain_first_cluster; unsigned int second_class_chain_first_cluster;
unsigned int unk9; unsigned int unk9;
unsigned int unk10; unsigned int unk10;
unsigned int second_class_chain_second_cluster; unsigned int second_class_chain_second_cluster;
unsigned int unk11; unsigned int unk11;
unsigned int unk12; unsigned int unk12;
unsigned int unk13; unsigned int unk13;
unsigned int filesize; unsigned int filesize;
unsigned int serial_number; unsigned int serial_number;
unsigned int number_of_metadata_records; unsigned int number_of_metadata_records;
}; };
struct cfs_direntry struct cfs_direntry
{ {
unsigned char identifier[4]; unsigned char identifier[4];
unsigned int unk; unsigned int unk;
unsigned int items; unsigned int items;
unsigned int unk2; unsigned int unk2;
unsigned char maxlen[2]; unsigned char maxlen[2];
unsigned char padding[202]; unsigned char padding[202];
/* struct cfs_direntry_item _items[items]; */ /* struct cfs_direntry_item _items[items]; */
}; };
struct cfs_direntry_item struct cfs_direntry_item
{ {
unsigned int inode_number; unsigned int inode_number;
unsigned short strlen; unsigned short strlen;
unsigned short bytesperchar; unsigned short bytesperchar;
char string[32]; char string[32];
}; };
static bool cfs_inited = false; static bool cfs_inited = false;
static unsigned long cfs_start; static unsigned long cfs_start;
static unsigned long *sectors; static unsigned long *sectors;
#define CFS_START ( ((hdr->partitions[1].start*hdr->sector_size) & ~0xFFFF) + 0x10000 ) #define CFS_START ( ((hdr->partitions[1].start*hdr->sector_size) & ~0xFFFF) + 0x10000 )
#define CFS_CLUSTER2CLUSTER(x) ( CFS_START+((x)-1)*64 ) #define CFS_CLUSTER2CLUSTER(x) ( CFS_START+((x)-1)*64 )
/* Limited version of UCS -> ASCII */ /* Limited version of UCS -> ASCII */
static char* ucs2letostring(unsigned char* s) static char* ucs2letostring(unsigned char* s)
{ {
static char res[256]; static char res[256];
int i; int i;
for(i=0; (s[i] == 0 && s[i+1] == 0); i++) for(i=0; (s[i] == 0 && s[i+1] == 0); i++)
res[i] = s[i*2]; res[i] = s[i*2];
return (char*)&res; return (char*)&res;
} }
static void cfs_init(void) static void cfs_init(void)
{ {
struct main_header *hdr; struct main_header *hdr;
struct cfs_header *cfs; struct cfs_header *cfs;
struct cfs_inode *root_inode, *vfat_inode, *inode; struct cfs_inode *root_inode, *vfat_inode, *inode;
struct cfs_direntry *root_direntry, *vfat_direntry; struct cfs_direntry *root_direntry, *vfat_direntry;
struct cfs_direntry_item *root_direntry_items, *vfat_direntry_items; 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 int i, j, k, vfat_inode_nr=0, vfat_inodes_nr[10], vfat_sector_count;
unsigned char sector[512]; unsigned char sector[512];
static unsigned int vfat_data[2][0x8000]; static unsigned int vfat_data[2][0x8000];
static unsigned char sector2[0x8000]; static unsigned char sector2[0x8000];
if(cfs_inited) if(cfs_inited)
return; return;
/* Read MBLK */ /* Read MBLK */
_ata_read_sectors(0, 1, &sector); _ata_read_sectors(0, 1, &sector);
hdr = (struct main_header*)&sector; hdr = (struct main_header*)&sector;
//printf("CFS is at 0x%x", CFS_START); //printf("CFS is at 0x%x", CFS_START);
/* Read CFS header */ /* Read CFS header */
_ata_read_sectors(CFS_START/512, 64, &sector2); _ata_read_sectors(CFS_START/512, 64, &sector2);
cfs = (struct cfs_header*)&sector2; cfs = (struct cfs_header*)&sector2;
//printf("First inode = %d", cfs->first_inode); //printf("First inode = %d", cfs->first_inode);
/* Read root inode */ /* Read root inode */
_ata_read_sectors(CFS_CLUSTER2CLUSTER(cfs->first_inode), 64, &sector2); _ata_read_sectors(CFS_CLUSTER2CLUSTER(cfs->first_inode), 64, &sector2);
root_inode = (struct cfs_inode*)&sector2; root_inode = (struct cfs_inode*)&sector2;
/* Read root inode's first sector */ /* Read root inode's first sector */
_ata_read_sectors(CFS_CLUSTER2CLUSTER(root_inode->first_class_chain[0]), 64, &sector2); _ata_read_sectors(CFS_CLUSTER2CLUSTER(root_inode->first_class_chain[0]), 64, &sector2);
root_direntry = (struct cfs_direntry*)&sector2; root_direntry = (struct cfs_direntry*)&sector2;
root_direntry_items = (struct cfs_direntry_item*)(&sector2+sizeof(struct cfs_direntry)); root_direntry_items = (struct cfs_direntry_item*)(&sector2+sizeof(struct cfs_direntry));
/* Search VFAT inode */ /* Search VFAT inode */
for(i=0; i < root_direntry->items; i++) 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); //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) if(strcmp(ucs2letostring(&root_direntry_items[i].string[0]), "VFAT") == 0)
vfat_inode_nr = root_direntry_items[i].inode_number; vfat_inode_nr = root_direntry_items[i].inode_number;
} }
/* Read VFAT inode */ /* Read VFAT inode */
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode_nr), 64, &sector2); _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode_nr), 64, &sector2);
vfat_inode = (struct cfs_inode*)&sector2; vfat_inode = (struct cfs_inode*)&sector2;
/* Read VFAT inode's first sector */ /* Read VFAT inode's first sector */
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode->first_class_chain[0]), 64, &sector2); _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode->first_class_chain[0]), 64, &sector2);
vfat_direntry = (struct cfs_direntry*)&sector2; vfat_direntry = (struct cfs_direntry*)&sector2;
vfat_direntry_items = (struct cfs_direntry_item*)(&sector2+sizeof(struct cfs_direntry)); vfat_direntry_items = (struct cfs_direntry_item*)(&sector2+sizeof(struct cfs_direntry));
/* Search for VFAT's subinodes */ /* Search for VFAT's subinodes */
for(i=0; i < vfat_direntry->items; i++) 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); //printf(" * [%s] at 0x%x\n", ucs2letostring(&vfat_direntry_items[i].string[0]), vfat_direntry_items[i].inode_number);
if(i > 0) if(i > 0)
vfat_inodes_nr[i-1] = vfat_direntry_items[i].inode_number; vfat_inodes_nr[i-1] = vfat_direntry_items[i].inode_number;
} }
/* Determine size of VFAT file */ /* Determine size of VFAT file */
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, &sector); _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, &sector);
inode = (struct cfs_inode*)&sector; inode = (struct cfs_inode*)&sector;
sectors = (unsigned long*)buffer_alloc(VFAT_SECTOR_SIZE(inode->filesize)); sectors = (unsigned long*)buffer_alloc(VFAT_SECTOR_SIZE(inode->filesize));
//printf("VFAT file size: 0x%x", inode->filesize); //printf("VFAT file size: 0x%x", inode->filesize);
/* Clear data sectors */ /* Clear data sectors */
memset(&sectors, 0, VFAT_SECTOR_SIZE(inode->filesize)*sizeof(unsigned long)); memset(&sectors, 0, VFAT_SECTOR_SIZE(inode->filesize)*sizeof(unsigned long));
/* Read all data sectors' addresses in memory */ /* Read all data sectors' addresses in memory */
vfat_sector_count = 0; vfat_sector_count = 0;
for(i=0; vfat_inodes_nr[i] != 0; i++) for(i=0; vfat_inodes_nr[i] != 0; i++)
{ {
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[i]), 1, &sector); _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[i]), 1, &sector);
inode = (struct cfs_inode*)&sector; inode = (struct cfs_inode*)&sector;
/* Read second & third class chain */ /* 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_first_cluster), 64, &vfat_data[0]);
_ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_second_cluster), 64, &vfat_data[1]); _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_second_cluster), 64, &vfat_data[1]);
/* First class chain */ /* First class chain */
for(j=0; j<12; j++) for(j=0; j<12; j++)
{ {
if( (inode->first_class_chain[j] & 0xFFFF) != 0xFFFF && if( (inode->first_class_chain[j] & 0xFFFF) != 0xFFFF &&
inode->first_class_chain[j] != 0 inode->first_class_chain[j] != 0
) )
sectors[vfat_sector_count++] = inode->first_class_chain[j]; sectors[vfat_sector_count++] = inode->first_class_chain[j];
} }
/* Second class chain */ /* Second class chain */
for(j=0; j<0x8000/4; j++) for(j=0; j<0x8000/4; j++)
{ {
if( (vfat_data[0][j] & 0xFFFF) != 0xFFFF && if( (vfat_data[0][j] & 0xFFFF) != 0xFFFF &&
vfat_data[0][j] != 0 vfat_data[0][j] != 0
) )
sectors[vfat_sector_count++] = vfat_data[0][j]; sectors[vfat_sector_count++] = vfat_data[0][j];
} }
/* Third class chain */ /* Third class chain */
for(j=0; j<0x8000/4; j++) for(j=0; j<0x8000/4; j++)
{ {
if( (vfat_data[1][j] & 0xFFFF) != 0xFFFF && if( (vfat_data[1][j] & 0xFFFF) != 0xFFFF &&
vfat_data[1][j] != 0 vfat_data[1][j] != 0
) )
{ {
memset(&vfat_data[0], 0, 0x8000*sizeof(unsigned int)); memset(&vfat_data[0], 0, 0x8000*sizeof(unsigned int));
/* Read third class subchain(s) */ /* Read third class subchain(s) */
_ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_data[1][j]), 64, &vfat_data[0]); _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_data[1][j]), 64, &vfat_data[0]);
for(k=0; k<0x8000/4; k++) for(k=0; k<0x8000/4; k++)
{ {
if( (vfat_data[0][k] & 0xFFFF) != 0xFFFF && if( (vfat_data[0][k] & 0xFFFF) != 0xFFFF &&
vfat_data[0][k] != 0 vfat_data[0][k] != 0
) )
sectors[vfat_sector_count++] = vfat_data[0][k]; sectors[vfat_sector_count++] = vfat_data[0][k];
} }
} }
} }
} }
//printf("Sector count: %d 0x%x", vfat_sector_count, vfat_sector_count); //printf("Sector count: %d 0x%x", vfat_sector_count, vfat_sector_count);
cfs_inited = true; cfs_inited = true;
} }
static inline unsigned long map_sector(unsigned long sector) static inline unsigned long map_sector(unsigned long sector)
{ {
/* /*
* Sector mapping: start of CFS + FAT_SECTOR2CFS_SECTOR(sector) + missing part * Sector mapping: start of CFS + FAT_SECTOR2CFS_SECTOR(sector) + missing part
* FAT works with sectors of 0x200 bytes, CFS with sectors of 0x8000 bytes. * FAT works with sectors of 0x200 bytes, CFS with sectors of 0x8000 bytes.
*/ */
return cfs_start+sectors[sector/64]*64+sector%64; return cfs_start+sectors[sector/64]*64+sector%64;
} }
int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf)
{ {
if(!cfs_inited) if(!cfs_inited)
cfs_init(); cfs_init();
/* Check if count is lesser than or equal to 1 native CFS sector */ /* Check if count is lesser than or equal to 1 native CFS sector */
if(count <= 64) if(count <= 64)
return _ata_read_sectors(IF_MV2(drive,) map_sector(start), count, buf); return _ata_read_sectors(IF_MV2(drive,) map_sector(start), count, buf);
else else
{ {
int i, ret; int i, ret;
unsigned char* dest = (unsigned char*)buf; unsigned char* dest = (unsigned char*)buf;
/* Read sectors in parts of 0x8000 */ /* Read sectors in parts of 0x8000 */
for(i=0; i<count; i+=64) 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); ret = _ata_read_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest);
if(ret != 0) if(ret != 0)
return ret; return ret;
dest += (count-i >= 64 ? 0x8000 : (count-i)*512); dest += (count-i >= 64 ? 0x8000 : (count-i)*512);
} }
return ret; return ret;
} }
} }
int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf)
{ {
if(!cfs_inited) if(!cfs_inited)
cfs_init(); cfs_init();
/* Check if count is lesser than or equal to 1 native CFS sector */ /* Check if count is lesser than or equal to 1 native CFS sector */
if(count <= 64) if(count <= 64)
return _ata_write_sectors(IF_MV2(drive,) map_sector(start), count, buf); return _ata_write_sectors(IF_MV2(drive,) map_sector(start), count, buf);
else else
{ {
int i, ret; int i, ret;
unsigned char* dest = (unsigned char*)buf; unsigned char* dest = (unsigned char*)buf;
/* Read sectors in parts of 0x8000 */ /* Read sectors in parts of 0x8000 */
for(i=0; i<count; i+=64) 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); ret = _ata_write_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest);
if(ret != 0) if(ret != 0)
return ret; return ret;
dest += (count-i >= 64 ? 0x8000 : (count-i)*512); dest += (count-i >= 64 ? 0x8000 : (count-i)*512);
} }
return ret; return ret;
} }
} }
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
MiniFileSystem parsing code MiniFileSystem parsing code
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
struct minifs_file struct minifs_file
{ {
char name[0x10]; char name[0x10];
unsigned int unk; unsigned int unk;
unsigned long size; unsigned long size;
unsigned int chain1; unsigned int chain1;
unsigned int chain2; unsigned int chain2;
}; };
struct minifs_chain struct minifs_chain
{ {
unsigned int unknown; unsigned int unknown;
unsigned short chain[0x27FE]; unsigned short chain[0x27FE];
unsigned int unknown2; unsigned int unknown2;
unsigned long length; unsigned long length;
}; };
#define DIR_BITMAP_START 0x0143 #define DIR_BITMAP_START 0x0143
#define DIR_START 0x0144 #define DIR_START 0x0144
#define DATASPACE_BITMAP_START 0x0145 #define DATASPACE_BITMAP_START 0x0145
#define DATASPACE_START 0x0146 #define DATASPACE_START 0x0146
#define CLUSTER_CHAIN_SIZE 0x5008 #define CLUSTER_CHAIN_SIZE 0x5008
#define CLUSTER_CHAIN_HEAD 0x0000 #define CLUSTER_CHAIN_HEAD 0x0000
#define CLUSTER_CHAIN_BITMAP 0x0001 #define CLUSTER_CHAIN_BITMAP 0x0001
#define CLUSTER_CHAIN_CHAIN 0x0002 #define CLUSTER_CHAIN_CHAIN 0x0002
int load_minifs_file(char* filename, unsigned char* location) int load_minifs_file(char* filename, unsigned char* location)
{ {
struct main_header *hdr; struct main_header *hdr;
static struct minifs_file files[128]; static struct minifs_file files[128];
struct minifs_chain *chain; struct minifs_chain *chain;
unsigned int i; unsigned int i;
int found = -1; int found = -1;
unsigned char sector[512]; unsigned char sector[512];
static unsigned char chain_data[42*512]; /* stack overflow if not static */ static unsigned char chain_data[42*512]; /* stack overflow if not static */
/* Read MBLK */ /* Read MBLK */
_ata_read_sectors(0, 1, &sector); _ata_read_sectors(0, 1, &sector);
hdr = (struct main_header*)&sector; hdr = (struct main_header*)&sector;
/* Read directory listing */ /* Read directory listing */
#define CLUSTER2SECTOR(x) ( (hdr->partitions[0].start + (x)*8) ) #define CLUSTER2SECTOR(x) ( (hdr->partitions[0].start + (x)*8) )
_ata_read_sectors(CLUSTER2SECTOR(DIR_START), 8, &files); _ata_read_sectors(CLUSTER2SECTOR(DIR_START), 8, &files);
for(i=0; i<127; i++) for(i=0; i<127; i++)
{ {
if(strcmp(files[i].name, filename) == 0) if(strcmp(files[i].name, filename) == 0)
found = i; found = i;
} }
if(found == -1) if(found == -1)
return -1; return -1;
#define GET_CHAIN(x) ( CLUSTER2SECTOR(CLUSTER_CHAIN_CHAIN)*512 + (x)*CLUSTER_CHAIN_SIZE ) #define GET_CHAIN(x) ( CLUSTER2SECTOR(CLUSTER_CHAIN_CHAIN)*512 + (x)*CLUSTER_CHAIN_SIZE )
#define FILE2SECTOR(x) ( CLUSTER2SECTOR(DATASPACE_START + (x)) ) #define FILE2SECTOR(x) ( CLUSTER2SECTOR(DATASPACE_START + (x)) )
/* Read chain list */ /* Read chain list */
_ata_read_sectors(GET_CHAIN(files[found].chain1)/512, 41, &chain_data[0]); _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]; chain = (struct minifs_chain*)&chain_data[GET_CHAIN(files[found].chain1)%512];
/* Copy data */ /* Copy data */
for(i=0; i<chain->length; i++) for(i=0; i<chain->length; i++)
{ {
_ata_read_sectors(FILE2SECTOR(chain->chain[i]), 8, location); _ata_read_sectors(FILE2SECTOR(chain->chain[i]), 8, location);
location += 0x1000; location += 0x1000;
} }
return files[found].size; return files[found].size;
} }

View file

@ -1,130 +1,130 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id$ * $Id$
* *
* Copyright (C) 2008 by Maurus Cuelenaere * Copyright (C) 2008 by Maurus Cuelenaere
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "config.h" #include "config.h"
#include "kernel.h" #include "kernel.h"
#include "thread.h" #include "thread.h"
#include "system.h" #include "system.h"
#include "dma-target.h" #include "dma-target.h"
#include "dm320.h" #include "dm320.h"
#include "ata-target.h" #include "ata-target.h"
#include <stdbool.h> #include <stdbool.h>
#define CS1_START 0x50000000 #define CS1_START 0x50000000
#define CS2_START 0x60000000 #define CS2_START 0x60000000
#define SDRAM_START 0x00900000 #define SDRAM_START 0x00900000
#define FLASH_START 0x00100000 #define FLASH_START 0x00100000
#define CF_START 0x40000000 #define CF_START 0x40000000
#define SSFDC_START 0x48000000 #define SSFDC_START 0x48000000
static struct wakeup transfer_completion_signal; static struct wakeup transfer_completion_signal;
static bool dma_in_progress = false; static bool dma_in_progress = false;
void MTC0(void) void MTC0(void)
{ {
IO_INTC_IRQ1 = INTR_IRQ1_MTC0; IO_INTC_IRQ1 = INTR_IRQ1_MTC0;
wakeup_signal(&transfer_completion_signal); wakeup_signal(&transfer_completion_signal);
dma_in_progress = false; dma_in_progress = false;
} }
void dma_start(const void* addr, size_t size) void dma_start(const void* addr, size_t size)
{ {
/* Compatibility with Gigabeat S in dma_start.c */ /* Compatibility with Gigabeat S in dma_start.c */
(void) addr; (void) addr;
(void) size; (void) size;
} }
#define ATA_DEST (ATA_IOBASE-CS1_START) #define ATA_DEST (ATA_IOBASE-CS1_START)
void dma_ata_read(unsigned char* buf, int shortcount) void dma_ata_read(unsigned char* buf, int shortcount)
{ {
if(dma_in_progress) if(dma_in_progress)
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
while((unsigned long)buf & 0x1F) while((unsigned long)buf & 0x1F)
{ {
unsigned short tmp; unsigned short tmp;
tmp = ATA_DATA; tmp = ATA_DATA;
*buf++ = tmp & 0xFF; *buf++ = tmp & 0xFF;
*buf++ = tmp >> 8; *buf++ = tmp >> 8;
shortcount--; shortcount--;
} }
if (!shortcount) if (!shortcount)
return; return;
IO_SDRAM_SDDMASEL = 0x0820; /* 32-byte burst mode transfer */ IO_SDRAM_SDDMASEL = 0x0820; /* 32-byte burst mode transfer */
IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */ IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */
IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & 0x7FFF; /* Set variable address */ IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & 0x7FFF; /* Set variable address */
IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF; IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF;
IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */ IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */
IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF; IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF;
IO_EMIF_DMASIZE = shortcount/2; /* 16-bits *2 = 1 word */ IO_EMIF_DMASIZE = shortcount/2; /* 16-bits *2 = 1 word */
IO_EMIF_DMACTL = 3; /* Select MTC->AHB and start transfer */ IO_EMIF_DMACTL = 3; /* Select MTC->AHB and start transfer */
dma_in_progress = true; dma_in_progress = true;
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
if(shortcount % 2) if(shortcount % 2)
{ {
unsigned short tmp; unsigned short tmp;
tmp = ATA_DATA; tmp = ATA_DATA;
*buf++ = tmp & 0xFF; *buf++ = tmp & 0xFF;
*buf++ = tmp >> 8; *buf++ = tmp >> 8;
} }
} }
void dma_ata_write(unsigned char* buf, int wordcount) void dma_ata_write(unsigned char* buf, int wordcount)
{ {
if(dma_in_progress) if(dma_in_progress)
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
while((unsigned long)buf & 0x1F) while((unsigned long)buf & 0x1F)
{ {
unsigned short tmp; unsigned short tmp;
tmp = (unsigned short) *buf++; tmp = (unsigned short) *buf++;
tmp |= (unsigned short) *buf++ << 8; tmp |= (unsigned short) *buf++ << 8;
SET_16BITREG(ATA_DATA, tmp); SET_16BITREG(ATA_DATA, tmp);
wordcount--; wordcount--;
} }
if (!wordcount) if (!wordcount)
return; return;
IO_SDRAM_SDDMASEL = 0x0830; /* 32-byte burst mode transfer */ IO_SDRAM_SDDMASEL = 0x0830; /* 32-byte burst mode transfer */
IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */ IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */
IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & ~(1 << 15); /* Set variable address */ IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & ~(1 << 15); /* Set variable address */
IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF; IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF;
IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */ IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */
IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF; IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF;
IO_EMIF_DMASIZE = (wordcount+1)/2; IO_EMIF_DMASIZE = (wordcount+1)/2;
IO_EMIF_DMACTL = 1; /* Select AHB->MTC and start transfer */ IO_EMIF_DMACTL = 1; /* Select AHB->MTC and start transfer */
dma_in_progress = true; dma_in_progress = true;
wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK);
} }
void dma_init(void) void dma_init(void)
{ {
IO_INTC_EINT1 |= INTR_EINT1_MTC0; /* enable MTC interrupt */ IO_INTC_EINT1 |= INTR_EINT1_MTC0; /* enable MTC interrupt */
wakeup_init(&transfer_completion_signal); wakeup_init(&transfer_completion_signal);
dma_in_progress = false; dma_in_progress = false;
} }

View file

@ -1,30 +1,30 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id$ * $Id$
* *
* Copyright (C) 2008 by Maurus Cuelenaere * Copyright (C) 2008 by Maurus Cuelenaere
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#ifndef DMA_TARGET_H #ifndef DMA_TARGET_H
#define 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_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_read(unsigned char* buf, int wordcount);
void dma_ata_write(unsigned char* buf, int wordcount); void dma_ata_write(unsigned char* buf, int wordcount);
void dma_init(void); void dma_init(void);
#endif #endif

View file

@ -1,117 +1,117 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id$ * $Id$
* *
* Copyright (C) 2007 by Karl Kurbjun * Copyright (C) 2007 by Karl Kurbjun
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "system.h" #include "system.h"
#include "kernel.h" #include "kernel.h"
#include "logf.h" #include "logf.h"
#include "audio.h" #include "audio.h"
#include "sound.h" #include "sound.h"
#include "file.h" #include "file.h"
#include "dm320.h" #include "dm320.h"
#include "audiohw.h" #include "audiohw.h"
#include "dsp-target.h" #include "dsp-target.h"
void pcm_play_dma_init(void) void pcm_play_dma_init(void)
{ {
IO_CLK_O1DIV = 3; IO_CLK_O1DIV = 3;
/* Set GIO25 to CLKOUT1A */ /* Set GIO25 to CLKOUT1A */
IO_GIO_FSEL2 |= 3; IO_GIO_FSEL2 |= 3;
sleep(5); sleep(5);
audiohw_init(); audiohw_init();
audiohw_set_frequency(1); audiohw_set_frequency(1);
/* init DSP */ /* init DSP */
dsp_init(); dsp_init();
} }
void pcm_postinit(void) void pcm_postinit(void)
{ {
audiohw_postinit(); audiohw_postinit();
/* wake DSP */ /* wake DSP */
dsp_wake(); dsp_wake();
} }
/* set frequency used by the audio hardware */ /* set frequency used by the audio hardware */
void pcm_set_frequency(unsigned int frequency) void pcm_set_frequency(unsigned int frequency)
{ {
int index; int index;
switch(frequency) switch(frequency)
{ {
case SAMPR_11: case SAMPR_11:
case SAMPR_22: case SAMPR_22:
index = 0; index = 0;
break; break;
default: default:
case SAMPR_44: case SAMPR_44:
index = 1; index = 1;
break; break;
case SAMPR_88: case SAMPR_88:
index = 2; index = 2;
break; break;
} }
audiohw_set_frequency(index); audiohw_set_frequency(index);
} /* pcm_set_frequency */ } /* pcm_set_frequency */
const void * pcm_play_dma_get_peak_buffer(int *count) const void * pcm_play_dma_get_peak_buffer(int *count)
{ {
(void) count; (void) count;
return 0; return 0;
} }
void pcm_apply_settings(void) void pcm_apply_settings(void)
{ {
} }
void pcm_play_dma_start(const void *addr, size_t size) void pcm_play_dma_start(const void *addr, size_t size)
{ {
(void)addr; (void)addr;
(void)size; (void)size;
DEBUGF("pcm_play_dma_start(0x%x, %d)", addr, size); DEBUGF("pcm_play_dma_start(0x%x, %d)", addr, size);
} }
void pcm_play_dma_stop(void) void pcm_play_dma_stop(void)
{ {
} }
void pcm_play_lock(void) void pcm_play_lock(void)
{ {
} }
void pcm_play_unlock(void) void pcm_play_unlock(void)
{ {
} }
void pcm_play_dma_pause(bool pause) void pcm_play_dma_pause(bool pause)
{ {
(void) pause; (void) pause;
} }
size_t pcm_get_bytes_waiting(void) size_t pcm_get_bytes_waiting(void)
{ {
return 0; return 0;
} }

View file

@ -1,70 +1,70 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id: power-mr500.c 15599 2007-11-12 18:49:53Z amiconn $ * $Id: power-mr500.c 15599 2007-11-12 18:49:53Z amiconn $
* *
* Copyright (C) 2007 by Karl Kurbjun * Copyright (C) 2007 by Karl Kurbjun
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "config.h" #include "config.h"
#include "cpu.h" #include "cpu.h"
#include <stdbool.h> #include <stdbool.h>
#include "kernel.h" #include "kernel.h"
#include "system.h" #include "system.h"
#include "power.h" #include "power.h"
#include "backlight.h" #include "backlight.h"
#include "backlight-target.h" #include "backlight-target.h"
#ifndef SIMULATOR #ifndef SIMULATOR
void power_init(void) void power_init(void)
{ {
/* Initialize IDE power pin */ /* Initialize IDE power pin */
/* set ATA power on and output */ /* set ATA power on and output */
/* Charger detect */ /* Charger detect */
} }
bool charger_inserted(void) bool charger_inserted(void)
{ {
return false; return false;
} }
/* Returns true if the unit is charging the batteries. */ /* Returns true if the unit is charging the batteries. */
bool charging_state(void) { bool charging_state(void) {
return false; return false;
} }
void power_off(void) void power_off(void)
{ {
} }
#else /* SIMULATOR */ #else /* SIMULATOR */
bool charger_inserted(void) bool charger_inserted(void)
{ {
return false; return false;
} }
void charger_enable(bool on) void charger_enable(bool on)
{ {
(void)on; (void)on;
} }
void power_off(void) void power_off(void)
{ {
} }
#endif /* SIMULATOR */ #endif /* SIMULATOR */

View file

@ -1,59 +1,59 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id$ * $Id$
* *
* Copyright (C) 2007 by Karl Kurbjun * Copyright (C) 2007 by Karl Kurbjun
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "config.h" #include "config.h"
#include "adc.h" #include "adc.h"
#include "powermgmt.h" #include "powermgmt.h"
#include "kernel.h" #include "kernel.h"
/* THIS CONTAINS CURRENTLY DUMMY CODE! */ /* THIS CONTAINS CURRENTLY DUMMY CODE! */
unsigned short current_voltage = 3910; unsigned short current_voltage = 3910;
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
{ {
0 0
}; };
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
{ {
0 0
}; };
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
{ {
{ 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320 }, { 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320 },
}; };
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
const unsigned short percent_to_volt_charge[11] = const unsigned short percent_to_volt_charge[11] =
{ {
100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320, 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320,
}; };
void read_battery_inputs(void) void read_battery_inputs(void)
{ {
} }
/* Returns battery voltage from ADC [millivolts] */ /* Returns battery voltage from ADC [millivolts] */
unsigned int battery_adc_voltage(void) unsigned int battery_adc_voltage(void)
{ {
return current_voltage; return current_voltage;
} }

View file

@ -1,81 +1,81 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id$ * $Id$
* *
* Copyright (C) 2008 by Maurus Cuelenaere * Copyright (C) 2008 by Maurus Cuelenaere
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#ifndef USB_TARGET_H #ifndef USB_TARGET_H
#define USB_TARGET_H #define USB_TARGET_H
#include "dm320.h" #include "dm320.h"
/* General purpose memory region #2 */ /* General purpose memory region #2 */
#define ISP1583_IOBASE 0x60FFC000 #define ISP1583_IOBASE 0x60FFC000
#define ISP1583_H_OVERRIDE #define ISP1583_H_OVERRIDE
#define ISP1583_INIT_ADDRESS (*((volatile unsigned char*)(ISP1583_IOBASE+0x0))) //char #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_MODE (*((volatile unsigned short*)(ISP1583_IOBASE+0xC*2)))
#define ISP1583_INIT_INTCONF (*((volatile unsigned char*)(ISP1583_IOBASE+0x10*2))) //char #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_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_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_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) ) #define ISP1583_INIT_INTEN_READ (unsigned long)( (ISP1583_INIT_INTEN_A & 0xFFFF) | ((ISP1583_INIT_INTEN_B & 0xFFFF) << 16) )
/* Data flow registers */ /* Data flow registers */
#define ISP1583_DFLOW_EPINDEX (*((volatile unsigned char*)(ISP1583_IOBASE+0xC2*2))) //char #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_CTRLFUN (*((volatile unsigned char*)(ISP1583_IOBASE+0x28*2))) //char
#define ISP1583_DFLOW_DATA (*((volatile unsigned short*)(ISP1583_IOBASE+0x20*2))) #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_BUFLEN (*((volatile unsigned short*)(ISP1583_IOBASE+0x1C*2)))
#define ISP1583_DFLOW_BUFSTAT (*((volatile unsigned char*)(ISP1583_IOBASE+0x1E*2))) //char #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_MAXPKSZ (*((volatile unsigned short*)(ISP1583_IOBASE+0x04*2)))
#define ISP1583_DFLOW_EPTYPE (*((volatile unsigned short*)(ISP1583_IOBASE+0x08*2))) #define ISP1583_DFLOW_EPTYPE (*((volatile unsigned short*)(ISP1583_IOBASE+0x08*2)))
/* DMA registers */ /* DMA registers */
#define ISP1583_DMA_ENDPOINT (*((volatile unsigned char*)(ISP1583_IOBASE+0x58*2))) #define ISP1583_DMA_ENDPOINT (*((volatile unsigned char*)(ISP1583_IOBASE+0x58*2)))
/* General registers */ /* General registers */
#define ISP1583_GEN_INT_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2))) #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_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_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_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_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_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_FRAMEN0 (*((volatile unsigned short*)(ISP1583_IOBASE+0x74*2)))
#define ISP1583_GEN_SCRATCH (*((volatile unsigned short*)(ISP1583_IOBASE+0x78*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_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C*2)))
#define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84*2))) //char #define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84*2))) //char
#define EN_INT_CPU_TARGET IO_INTC_EINT1 |= INTR_EINT1_EXT7 #define EN_INT_CPU_TARGET IO_INTC_EINT1 |= INTR_EINT1_EXT7
#define DIS_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 0
//#define INT_CONF_TARGET 2 //#define INT_CONF_TARGET 2
#define set_int_value(a,b,value) a = value & 0xFFFF; \ #define set_int_value(a,b,value) a = value & 0xFFFF; \
b = value >> 16; b = value >> 16;
#define ZVM_SPECIFIC asm volatile( \ #define ZVM_SPECIFIC asm volatile( \
"LDR R12, =0x50FFC000\n" \ "LDR R12, =0x50FFC000\n" \
"LDRH R12, [R12]\n" \ "LDRH R12, [R12]\n" \
: : : "r12") : : : "r12")
//#define ZVM_SPECIFIC //#define ZVM_SPECIFIC
#define USE_IRAM #define USE_IRAM
#include <stdbool.h> #include <stdbool.h>
int usb_detect(void); int usb_detect(void);
void usb_init_device(void); void usb_init_device(void);
bool usb_drv_connected(void); bool usb_drv_connected(void);
#endif #endif