From b7cf0602fd08f6a367d42f0b6adadb8322b3d35d Mon Sep 17 00:00:00 2001 From: Alan Korr Date: Sun, 21 Apr 2002 12:21:14 +0000 Subject: removing all that stuff permanently. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@159 a1c6a512-1295-4272-9138-f99709370657 --- firmware/test/fat/config.h | 26 --- firmware/test/fat/defines.h | 24 -- firmware/test/fat/fat-bpb_sector.h | 211 ----------------- firmware/test/fat/fat-fsi_sector.c | 105 --------- firmware/test/fat/fat-fsi_sector.h | 80 ------- firmware/test/fat/fat-mbr_sector.c | 65 ------ firmware/test/fat/fat-mbr_sector.h | 69 ------ firmware/test/fat/fat-partition.h | 161 ------------- firmware/test/fat/fat-volume.c | 355 ---------------------------- firmware/test/fat/fat.h | 27 --- firmware/test/fat/functions.h | 26 --- firmware/test/fat/inlines.h | 27 --- firmware/test/fat/makefile | 24 -- firmware/test/fat/return_values.h | 31 --- firmware/test/fat/types.h | 43 ---- firmware/test/makefile-rules | 118 ---------- firmware/test/makefile-vars | 79 ------- firmware/test/memory/config.h | 27 --- firmware/test/memory/defines.h | 39 ---- firmware/test/memory/functions.h | 94 -------- firmware/test/memory/inlines.h | 26 --- firmware/test/memory/makefile | 23 -- firmware/test/memory/memory-block.c | 76 ------ firmware/test/memory/memory-block.txt | 0 firmware/test/memory/memory-misc.c | 48 ---- firmware/test/memory/memory-misc.txt | 0 firmware/test/memory/memory-page.c | 408 -------------------------------- firmware/test/memory/memory-page.h | 59 ----- firmware/test/memory/memory-page.txt | 74 ------ firmware/test/memory/memory-slab.c | 409 --------------------------------- firmware/test/memory/memory-slab.h | 62 ----- firmware/test/memory/memory-slab.txt | 0 firmware/test/memory/memory.h | 27 --- firmware/test/memory/return_values.h | 31 --- firmware/test/memory/test.l | 23 -- firmware/test/memory/test.y | 180 --------------- firmware/test/memory/types.h | 32 --- firmware/test/template/config.h | 26 --- firmware/test/template/defines.h | 24 -- firmware/test/template/functions.h | 26 --- firmware/test/template/inlines.h | 26 --- firmware/test/template/makefile | 23 -- firmware/test/template/return_values.h | 24 -- firmware/test/template/template.h | 27 --- firmware/test/template/types.h | 24 -- 45 files changed, 3309 deletions(-) delete mode 100644 firmware/test/fat/config.h delete mode 100644 firmware/test/fat/defines.h delete mode 100644 firmware/test/fat/fat-bpb_sector.h delete mode 100644 firmware/test/fat/fat-fsi_sector.c delete mode 100644 firmware/test/fat/fat-fsi_sector.h delete mode 100644 firmware/test/fat/fat-mbr_sector.c delete mode 100644 firmware/test/fat/fat-mbr_sector.h delete mode 100644 firmware/test/fat/fat-partition.h delete mode 100644 firmware/test/fat/fat-volume.c delete mode 100644 firmware/test/fat/fat.h delete mode 100644 firmware/test/fat/functions.h delete mode 100644 firmware/test/fat/inlines.h delete mode 100644 firmware/test/fat/makefile delete mode 100644 firmware/test/fat/return_values.h delete mode 100644 firmware/test/fat/types.h delete mode 100644 firmware/test/makefile-rules delete mode 100644 firmware/test/makefile-vars delete mode 100644 firmware/test/memory/config.h delete mode 100644 firmware/test/memory/defines.h delete mode 100644 firmware/test/memory/functions.h delete mode 100644 firmware/test/memory/inlines.h delete mode 100644 firmware/test/memory/makefile delete mode 100644 firmware/test/memory/memory-block.c delete mode 100644 firmware/test/memory/memory-block.txt delete mode 100644 firmware/test/memory/memory-misc.c delete mode 100644 firmware/test/memory/memory-misc.txt delete mode 100644 firmware/test/memory/memory-page.c delete mode 100644 firmware/test/memory/memory-page.h delete mode 100644 firmware/test/memory/memory-page.txt delete mode 100644 firmware/test/memory/memory-slab.c delete mode 100644 firmware/test/memory/memory-slab.h delete mode 100644 firmware/test/memory/memory-slab.txt delete mode 100644 firmware/test/memory/memory.h delete mode 100644 firmware/test/memory/return_values.h delete mode 100644 firmware/test/memory/test.l delete mode 100644 firmware/test/memory/test.y delete mode 100644 firmware/test/memory/types.h delete mode 100644 firmware/test/template/config.h delete mode 100644 firmware/test/template/defines.h delete mode 100644 firmware/test/template/functions.h delete mode 100644 firmware/test/template/inlines.h delete mode 100644 firmware/test/template/makefile delete mode 100644 firmware/test/template/return_values.h delete mode 100644 firmware/test/template/template.h delete mode 100644 firmware/test/template/types.h diff --git a/firmware/test/fat/config.h b/firmware/test/fat/config.h deleted file mode 100644 index 19777df743..0000000000 --- a/firmware/test/fat/config.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_H__ -# error "This header file must be included ONLY from fat.h." -#endif -#ifndef __LIBRARY_FAT_CONFIG_H__ -# define __LIBRARY_FAT_CONFIG_H__ -# define PACKAGE_NAME "fat" -# define PACKAGE_VERSION "0.0.0" -#endif \ No newline at end of file diff --git a/firmware/test/fat/defines.h b/firmware/test/fat/defines.h deleted file mode 100644 index c1b824b61c..0000000000 --- a/firmware/test/fat/defines.h +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_H__ -# error "This header file must be included ONLY from fat.h." -#endif -#ifndef __LIBRARY_FAT_DEFINES_H__ -# define __LIBRARY_FAT_DEFINES_H__ -#endif \ No newline at end of file diff --git a/firmware/test/fat/fat-bpb_sector.h b/firmware/test/fat/fat-bpb_sector.h deleted file mode 100644 index 247f53115c..0000000000 --- a/firmware/test/fat/fat-bpb_sector.h +++ /dev/null @@ -1,211 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_BPB_SECTOR_H__ -#define __LIBRARY_FAT_BPB_SECTOR_H__ - -// [Alan]: -// I would like to draw your attention about the fact that SH1 -// cannot use misaligned address access so you must be very cautious -// with structures stored in FAT32 partition because they come from -// PC world where misaligned address accesses are usual and not -// problematic. To avoid such a trouble, I decide to use special -// structures where fields are moved in such a way they can be -// accessed by SH1. It is possible thanks to the callback mechanism -// I use for reading or writing from/to an ATA device in ata.h/c. -// So don't be puzzled if those structures seem odd compared -// with the usual ones from PC world. I use this mechanism for structures -// 'partition_info', 'mbr_sector' and 'fsi_sector' for instance, but -// not for structure 'bpb_sector' which is too much complex to handle -// that way, I think. -// By the way, SH1 is big endian, not little endian as PC is. - -/////////////////////////////////////////////////////////////////////////////////// -// BPB SECTOR : -/////////////// -// -// - -struct __fat_bpb_sector /* Bios Parameters Block Sector */ - { - // jmp_boot has two valid ways to look like in a FAT BPB. - // Either EBXX90 or E9XXXX. - // Not used by Rockbox. - unsigned char - jmp_boot[3]; - - // Creator system of the fat-drive. - // Usually looks like "MSWIN4.x". - char - oem_name[8]; - - // It should be 512 if you don't want any trouble - // with Rockbox firmware. - unsigned char - bytes_per_sector[2]; - - // Must be a power of two. - unsigned char - sectors_per_cluster[1]; - - // Number of reserved sectors in the reserved region of the volume - // starting at the first sector of the volume. - // Usually 32 for FAT32. - unsigned char - reserved_sectors[2]; - - // Number of FAT structures. - // This value should always be 2. - unsigned char - number_of_fats[1]; - - // For FAT32, this field must be set to zero. - // Not used by Rockbox. - unsigned char - number_of_root_entries[2]; - - // Must be zero for FAT32, since the real value - // can be found in total_sectors. - // Not used by Rockbox. - unsigned char - total_sectors_16[2]; - - // Not used by Rockbox. - unsigned char - media[1]; - - // In FAT32 this must be zero. - // Not used by Rockbox. - unsigned char - sectors_per_fat_16[2]; - - // Sectors per track used on this media. - // Not used by Rockbox. - unsigned char - sectors_per_track[2]; - - // Number of heads used on this media. - // Not used by Rockbox. - unsigned char - number_of_heads[2]; - - // Number of hidden sectors. - // Not used by Rockbox. - unsigned char - hidden_sectors[4]; - - // Number of total sectors. - // For FAT32 volumes, this must be specified. - unsigned char - total_sectors[4]; - - // Here follows FAT12/16 or FAT32 specific data. */ - - // This is the number of sectors for one FAT. - unsigned char - sectors_per_fat[4]; - - // Extended FAT32 flags follow. - unsigned char - flags[2]; - // bits 15-8: reserved - // mirroring, bit 7: - // 0 -> FAT is mirrored at runtime into all FATs. - // 1 -> only the one specified in the following field - // is active. - // Rockbox always sets it. - // bits 7-4 : reserved - // active_fat, bits 3-0: - // this specifies the "active" FAT mentioned previously. - - // This specifies the file system version. - // High byte is major number, low byte is minor. - // The current version is 0.0. - unsigned char - filesystem_version[2]; - - // This is set to the cluster number of the first cluster - // of the root directory. Usually 2, but not required. - unsigned char - root_cluster[4]; - - // This specifies the sector number of the 'FSINFO' structure - // in the reserved area. - unsigned char - filesystem_info[2]; - - // If zero, this specifies where the backup of bpb - // can be found. - // Usually 6. - // No value other than 6 is recommended by Microsoft. - unsigned char - backup_bpb[2]; - - // The following area should always be set to zero - // when the volume is initialised. - unsigned char - zeros[12]; - - // Drive number for BIOS. - // Not used by Rockbox. - unsigned char - drive_number[0]; - - // Reserved for Windows NT. - // Should always be set to 0. - unsigned char - reserved_for_nt[0]; - - // Extended boot signature. - // If this is 0x29, the following three fields are present. - unsigned char - boot_signature[0]; - - // Volume serial number. - unsigned char - volume_id[4]; - - // Volume label. - // This field must be updated when the volume label - // in the root directory is updated. - char - volume_label[11]; - - // One of the strings "FAT12", "FAT16" or "FAT32". - // This can not be used to determine the type of the FAT, - // but it should be updated when creating file systems. - char - filesystem_type[8]; - - char - reserved[420]; - - long - signature; - }; - -static inline int __fat_get_bpb_sector (unsigned long partition_start,unsigned long lba,struct __fat_bpb_sector *bpb_sector) - { return ata_read_sectors (partition_start + lba,1,bpb_sector,0); } - -static inline int __fat_put_bpb_sector (unsigned long partition_start,unsigned long lba,struct __fat_bpb_sector *bpb_sector) - { return FAT_RETURN_SUCCESS && ata_write_sectors (partition_start + lba,1,bpb_sector,0); } - -// -/////////////////////////////////////////////////////////////////////////////////// - -#endif \ No newline at end of file diff --git a/firmware/test/fat/fat-fsi_sector.c b/firmware/test/fat/fat-fsi_sector.c deleted file mode 100644 index 54863dc2a4..0000000000 --- a/firmware/test/fat/fat-fsi_sector.c +++ /dev/null @@ -1,105 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include -#include "fat-fsi_sector.h" - -// [Alan]: -// I would like to draw your attention about the fact that SH1 -// cannot use misaligned address access so you must be very cautious -// with structures stored in FAT32 partition because they come from -// PC world where misaligned address accesses are usual and not -// problematic. To avoid such a trouble, I decide to use special -// structures where fields are moved in such a way they can be -// accessed by SH1. It is possible thanks to the callback mechanism -// I use for reading or writing from/to an ATA device in ata.h/c. -// So don't be puzzled if those structures seem odd compared -// with the usual ones from PC world. I use this mechanism for structures -// 'partition_info', 'mbr_sector' and 'fsi_sector' for instance, but -// not for structure 'bpb_sector' which is too much complex to handle -// that way, I think. -// By the way, SH1 is big endian, not little endian as PC is. - -/////////////////////////////////////////////////////////////////////////////////// -// FSI SECTOR : -/////////////// -// -// - -int __fat_get_fsi_sector_callback (struct __fat_fsi_sector *fsi_sector) - { - short *data = fsi_sector->data,*end; - union { unsigned long si[2]; unsigned short hi[4]; unsigned char qi[8]; } words; - for (end = fsi_sector->end0; data < end; ++data) - *data = ata_get_word (0); -#ifdef __little__ - words.hi[0] = ata_get_word (0); - words.hi[1] = ata_get_word (0); - words.hi[2] = ata_get_word (0); - words.hi[3] = ata_get_word (0); -#else - words.hi[1] = ata_get_word (0); - words.hi[0] = ata_get_word (0); - words.hi[3] = ata_get_word (0); - words.hi[2] = ata_get_word (0); -#endif - for (end = fsi_sector->end1; data < end; ++data) - *data = ata_get_word (0); -#ifdef __little__ - fsi_sector->left_free_clusters = words.si[0]; - fsi_sector->next_free_cluster = words.si[1]; -#else - fsi_sector->left_free_clusters = swawSI (words.si[0]); - fsi_sector->next_free_cluster = swawSI (words.si[1]); -#endif - return ATA_RETURN_SUCCESS; - } - -int __fat_put_fsi_sector_callback (struct __fat_fsi_sector *fsi_sector) - { - short *data = fsi_sector->data,*end; - union { unsigned long si[2]; unsigned short hi[4]; unsigned char qi[8]; } words; -#ifdef __little__ - words.si[0] = swawSI (fsi_sector->left_free_clusters); - words.si[1] = swawSI (fsi_sector->next_free_cluster); -#else - words.si[0] = swawSI (fsi_sector->left_free_clusters); - words.si[1] = swawSI (fsi_sector->next_free_cluster); -#endif - for (end = fsi_sector->end0; data < end;) - ata_put_word (*data++); -#ifdef __little__ - ata_put_word (words.hi[0],0); - ata_put_word (words.hi[1],0); - ata_put_word (words.hi[2],0); - ata_put_word (words.hi[3],0); -#else - ata_put_word (words.hi[1],0); - ata_put_word (words.hi[0],0); - ata_put_word (words.hi[3],0); - ata_put_word (words.hi[2],0); -#endif - for (end = fsi_sector->end1; data < end;) - ata_put_word (*data++); - return ATA_RETURN_SUCCESS; - } - -// -/////////////////////////////////////////////////////////////////////////////////// - -#endif \ No newline at end of file diff --git a/firmware/test/fat/fat-fsi_sector.h b/firmware/test/fat/fat-fsi_sector.h deleted file mode 100644 index c329148bfa..0000000000 --- a/firmware/test/fat/fat-fsi_sector.h +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_FSI_SECTOR_H__ -#define __LIBRARY_FAT_FSI_SECTOR_H__ - -// [Alan]: -// I would like to draw your attention about the fact that SH1 -// cannot use misaligned address access so you must be very cautious -// with structures stored in FAT32 partition because they come from -// PC world where misaligned address accesses are usual and not -// problematic. To avoid such a trouble, I decide to use special -// structures where fields are moved in such a way they can be -// accessed by SH1. It is possible thanks to the callback mechanism -// I use for reading or writing from/to an ATA device in ata.h/c. -// So don't be puzzled if those structures seem odd compared -// with the usual ones from PC world. I use this mechanism for structures -// 'partition_info', 'mbr_sector' and 'fsi_sector' for instance, but -// not for structure 'bpb_sector' which is too much complex to handle -// that way, I think. -// By the way, SH1 is big endian, not little endian as PC is. - -/////////////////////////////////////////////////////////////////////////////////// -// FSI SECTOR : -/////////////// -// -// - -struct __fat_fsi_sector /* File System Info Sector */ - { - unsigned long - left_free_clusters; - unsigned long - next_free_cluster; - short - data[0]; - long /* 0x61415252 - aARR */ - fsi_signature0; - char - reserved0[480]; - long /* 0x41617272 - Aarr */ - fsi_signature1; - short - end0[0]; - char - reserved1[12]; - long /* 0x000055AA */ - signature; - short - end1[0]; - }; - -int __fat_get_fsi_sector_callback (struct __fat_fsi_sector *fsi_sector); -int __fat_put_fsi_sector_callback (struct __fat_fsi_sector *fsi_sector); - -static inline int __fat_get_fsi_sector (unsigned long partition_start,unsigned long lba,struct __fat_fsi_sector *fsi_sector) - { return ata_read_sectors (partition_start + lba,1,fsi_sector,(int(*)(void *))get_fsi_sector_callback); } - -static inline int __fat_put_fsi_sector (unsigned long partition_start,unsigned long lba,struct __fat_fsi_sector *fsi_sector) - { return ata_write_sectors (partition_start + lba,1,fsi_sector,(int(*)(void *))put_fsi_sector_callback); } - -// -/////////////////////////////////////////////////////////////////////////////////// - -#endif \ No newline at end of file diff --git a/firmware/test/fat/fat-mbr_sector.c b/firmware/test/fat/fat-mbr_sector.c deleted file mode 100644 index f6b510cea5..0000000000 --- a/firmware/test/fat/fat-mbr_sector.c +++ /dev/null @@ -1,65 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include -#include "fat-mbr_sector.h" - -// [Alan]: -// I would like to draw your attention about the fact that SH1 -// cannot use misaligned address access so you must be very cautious -// with structures stored in FAT32 partition because they come from -// PC world where misaligned address accesses are usual and not -// problematic. To avoid such a trouble, I decide to use special -// structures where fields are moved in such a way they can be -// accessed by SH1. It is possible thanks to the callback mechanism -// I use for reading or writing from/to an ATA device in ata.h/c. -// So don't be puzzled if those structures seem odd compared -// with the usual ones from PC world. I use this mechanism for structures -// 'partition_info', 'mbr_sector' and 'fsi_sector' for instance, but -// not for structure 'bpb_sector' which is too much complex to handle -// that way, I think. -// By the way, SH1 is big endian, not little endian as PC is. - -/////////////////////////////////////////////////////////////////////////////////// -// MBR SECTOR : -/////////////// -// -// - -int __fat_get_mbr_sector_callback (struct __fat_mbr_sector *mbr_sector) - { - short *data = mbr_sector->data,*end; - for (end = mbr_sector->end; data < end; ++data) - *data = ata_get_word (0); - __fat_get_partition_table (mbr_sector->partition_table); - mbr_sector->signature = HI(ATAR_DATA); - return FAT_RETURN_SUCCESS; - } - -int __fat_put_mbr_sector_callback (struct __fat_mbr_sector *mbr_sector) - { - short const *data = mbr_sector->data,*end; - for (end = mbr_sector->end; data < end;) - HI(ATAR_DATA) = *data++; - __fat_put_partition_table (mbr_sector->partition_table); - ata_put_word (mbr_sector->signature,0); - return FAT_RETURN_SUCCESS; - } - -// -/////////////////////////////////////////////////////////////////////////////////// diff --git a/firmware/test/fat/fat-mbr_sector.h b/firmware/test/fat/fat-mbr_sector.h deleted file mode 100644 index 11f131e440..0000000000 --- a/firmware/test/fat/fat-mbr_sector.h +++ /dev/null @@ -1,69 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_MBR_SECTOR_H__ -#define __LIBRARY_FAT_MBR_SECTOR_H__ -#include "fat-partition.h" - -// [Alan]: -// I would like to draw your attention about the fact that SH1 -// cannot use misaligned address access so you must be very cautious -// with structures stored in FAT32 partition because they come from -// PC world where misaligned address accesses are usual and not -// problematic. To avoid such a trouble, I decide to use special -// structures where fields are moved in such a way they can be -// accessed by SH1. It is possible thanks to the callback mechanism -// I use for reading or writing from/to an ATA device in ata.h/c. -// So don't be puzzled if those structures seem odd compared -// with the usual ones from PC world. I use this mechanism for structures -// 'partition_info', 'mbr_sector' and 'fsi_sector' for instance, but -// not for structure 'bpb_sector' which is too much complex to handle -// that way, I think. -// By the way, SH1 is big endian, not little endian as PC is. - -/////////////////////////////////////////////////////////////////////////////////// -// MBR SECTOR : -/////////////// -// -// - -struct __fat_mbr_sector /* Master Boot Record Sector */ - { - struct - __fat_partition_info partition_table[4]; - short - data[0x1BE/2]; - short - end[0]; - short - signature; - }; - -int __fat_get_mbr_sector_callback (struct __fat_mbr_sector *mbr_sector); -int __fat_put_mbr_sector_callback (struct __fat_mbr_sector *mbr_sector); - -static inline int __fat_get_mbr_sector (struct mbr_sector *__fat_mbr_sector) - { return ata_read_sectors (0,1,mbr_sector,(int(*)(void *))__fat_get_mbr_sector_callback); } - -static inline int __fat_put_mbr_sector (struct mbr_sector *__fat_mbr_sector) - { return ata_write_sectors (0,1,mbr_sector,(int(*)(void *))__fat_put_mbr_sector_callback); } - -// -/////////////////////////////////////////////////////////////////////////////////// - -#endif \ No newline at end of file diff --git a/firmware/test/fat/fat-partition.h b/firmware/test/fat/fat-partition.h deleted file mode 100644 index 1b0e363efb..0000000000 --- a/firmware/test/fat/fat-partition.h +++ /dev/null @@ -1,161 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_PARTITION_H__ -#define __LIBRARY_FAT_PARTITION_H__ -#include - -// [Alan]: -// I would like to draw your attention about the fact that SH1 -// cannot use misaligned address access so you must be very cautious -// with structures stored in FAT32 partition because they come from -// PC world where misaligned address accesses are usual and not -// problematic. To avoid such a trouble, I decide to use special -// structures where fields are moved in such a way they can be -// accessed by SH1. It is possible thanks to the callback mechanism -// I use for reading or writing from/to an ATA device in ata.h/c. -// So don't be puzzled if those structures seem odd compared -// with the usual ones from PC world. I use this mechanism for structures -// 'partition_info', 'mbr_sector' and 'fsi_sector' for instance, but -// not for structure 'bpb_sector' which is too much complex to handle -// that way, I think. -// By the way, SH1 is big endian, not little endian as PC is. - -/////////////////////////////////////////////////////////////////////////////////// -// PARTITION INFO : -/////////////////// -// -// - -struct __fat_partition_info - { - // Absolute start sector in this partition : - // start = start_cylinder * heads * sectors + start_head * sectors + start_sector - 1 - unsigned long - start; - - // Number of sectors in this partition : - // sectors = end_cylinder * heads * sectors + end_head * sectors + end_sector - start_sector - unsigned long - sectors; - - // File system type. - // Must be a FAT32 file system type (0x0B or 0x0C) - // for Rockbox. - char - filesystem_type; - - // Is this partition bootable ? - // Not used by Rockbox. - char - bootable; - - // Not used by Rockbox. - unsigned char - start_head; - - // Not used by Rockbox. - unsigned char - start_cylinder; - - // Not used by Rockbox. - unsigned char - start_sector; - - // Not used by Rockbox. - unsigned char - end_head; - - // Not used by Rockbox. - unsigned char - end_cylinder; - - // Not used by Rockbox. - unsigned char - end_sector; - }; - - -// load partition info into memory -static inline void __fat_get_partition_info (struct partition_info *__fat_partition_info) - { - // - union { unsigned long si[4]; unsigned short hi[8]; unsigned char qi[16]; } words; - short *data = words.hi,*end; - for (end = data + 8; data < end; ++data) - *data = HI(ATAR_DATA); - partition_info->start = swawSI(words.si[2]); - partition_info->sectors = swawSI(words.si[3]); - partition_info->bootable = words.qi[1]; - partition_info->filesystem_type = words.qi[5]; - partition_info->start_head = words.qi[0]; - partition_info->start_cylinder = words.qi[3]; - partition_info->start_sector = words.qi[2]; - partition_info->end_head = words.qi[4]; - partition_info->end_cylinder = words.qi[7]; - partition_info->end_sector = words.qi[6]; - } - -// store partition info into harddisk -static inline void __fat_put_partition_info (struct partition_info *__fat_partition_info) - { - union { unsigned long si[4]; short hi[8]; unsigned char qi[16]; } words; - short *data = words.hi,*end; - words.si[2] = swawSI(partition_info->start); - words.si[3] = swawSI(partition_info->sectors); - words.qi[1] = partition_info->bootable; - words.qi[5] = partition_info->filesystem_type; - words.qi[0] = partition_info->start_head; - words.qi[3] = partition_info->start_cylinder; - words.qi[2] = partition_info->start_sector; - words.qi[4] = partition_info->end_head; - words.qi[7] = partition_info->end_cylinder; - words.qi[6] = partition_info->end_sector; - for (end = data + 8; data < end;) - HI(ATAR_DATA) = *data++; - } - -// -/////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////// -// PARTITION TABLE : -//////////////////// -// -// - -// load the partition table from a mbr sector -static inline void __fat_get_partition_table (struct partition_info table[4]) - { - struct partition_info *last; - for (last = table + 4; table < last;) - __fat_get_partition_info (table++); - } - -// store the partition table into a mbr sector -static inline void __fat_put_partition_table (struct partition_info const table[4]) - { - struct partition_info const *last; - for (last = table + 4; table < last;) - __fat_put_partition_info (table++); - } - -// -/////////////////////////////////////////////////////////////////////////////////// - -#endif \ No newline at end of file diff --git a/firmware/test/fat/fat-volume.c b/firmware/test/fat/fat-volume.c deleted file mode 100644 index dada78c4e6..0000000000 --- a/firmware/test/fat/fat-volume.c +++ /dev/null @@ -1,355 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#define __LIBRARY_FAT_VOLUME_C__ - -#include -#include "fat-mbr_sector.h" -#include "fat-bpb_sector.h" -#include "fat-fsi_sector.h" - -/////////////////////////////////////////////////////////////////////////////////// -// FAT VOLUME : -/////////////// -// -// - -// check fsi sector integrity -static int __fat_check_fsi_sector (struct fat_volume *volume,struct __fat_fsi_sector *fsi_sector,unsigned long lba) - { - int error; - if (!lba) - // no FSI sector - { - volume->next_free_cluster = 2; - return FAT_RETURN_SUCCESS; - } - if ((error = __fat_get_fsi_sector (volume->partition_start,lba,fsi_sector)) > 0) - { - if ((fsi_sector->signature != 0x0000AA55) || - (fsi_sector->fsi_signature0 != 0x52524161) || - (fsi_sector->fsi_signature1 != 0x72726141)) - { - return FAT_RETURN_BAD_FSI; - } - if (fsi_sector->left_free_clusters == -1) - fsi_sector->next_free_cluster = 2; - else if (fsi_sector->next_free_cluster >= volume->sectors_per_fat) - return FAT_RETURN_BAD_FSI; - volume->next_free_cluster = fsi_sector->next_free_cluster; - fsi_sector->left_free_clusters = -1; - fsi_sector->next_free_cluster = 2; - error = __fat_put_fsi_sector (volume->partition_start,lba,fsi_sector))); - } - return error; - } - -static inline int bit_in_range (int value,int min,int max) - { - for (;min < max; min <<= 1) - if (value == min) - return 1; - return 0; - } - -// check bpb sector integrity -static int __fat_check_bpb_sector (struct fat_volume *volume,struct __fat_bpb_sector *bpb_sector,struct __fat_fsi_sector *fsi_sector) - { - long unsigned bpb_lba = 0,fsi_lba; - long unsigned sectors_per_cluster,sectors_per_fat,sectors,reserved_sectors,total_sectors; - long unsigned first_cluster_of_root,first_sector_of_fat,first_sector_of_data; - long unsigned clusters_per_fat,bytes_per_sector; - int error,backup; - for (backup = 0; !backup ; backup = 1) - { - if ((error = __fat_get_bpb_sector (volume->partition_start,bpb_lba,bpb_sector)) > 0) - { - bytes_per_sector = peekHI (bpb_sector->bytes_per_sector ); - sectors_per_cluster = peekQI (bpb_sector->sectors_per_cluster); - sectors_per_fat = peekSI (bpb_sector->sectors_per_fat ); - sectors = peekQI (bpb_sector->number_of_fats ) * sectors_per_fat; - reserved_sectors = peekHI (bpb_sector->reserved_sectors ); - total_sectors = peekSI (bpb_sector->total_sectors ); - first_cluster_of_root = peekSI (bpb_sector->root_cluster ); - first_sector_of_fat = reserved_sectors + volume->partition_start; - first_sector_of_data = first_sector_of_fat + sectors; - clusters_per_fat = (total_sectors - first_sector_of_data) / sectors_per_cluster; - - if (!bpb_lba) - { - bpb_lba = peekHI(bpb_sector->backup_bpb); - if (bpb_lba == -1) - bpb_lba = 0; - } - - if ((bpb_lba >= reserved_sectors) || - (bpb_sector->signature != 0x000055AA) || - (clusters_per_fat < 65525) || - (bytes_per_sector != 512) || - (!bit_in_range (sectors_per_cluster,1,128)) || - (bytes_per_sector * sectors_per_cluster >= 32 KB) || - (peekHI (bpb_sector->total_sectors_16)) || - (peekHI (bpb_sector->sectors_per_fat_16)) || - (peekHI (bpb_sector->number_of_root_entries)) || - ((bpb_sector->media[0] != 0xF0) && (bpb_sector->media[0] < 0xF8))) - { - error = FAT_RETURN_BAD_BPB; - if (bpb_lba) // try with backup BPB sector ? - continue; - return error; - } - if ((signed char)bpb_sector->flags[0] >= 0) - { - bpb_sector->flags[0] = 0x80; - if (!backup && (error = __fat_put_bpb_sector (volume->partition_start,0,bpb_sector)) <= 0) - return error; - if ((error = __fat_put_bpb_sector (volume->partition_start,bpb_lba,bpb_sector)) <= 0) - return error; - } - - volume->sectors_per_cluster = sectors_per_cluster; - volume->sectors_per_fat = sectors_per_fat; - volume->first_cluster_of_root = first_cluster_of_root; - volume->first_sector_of_fat = first_sector_of_fat; - volume->first_sector_of_data = first_sector_of_data; - volume->clusters_per_fat = clusters_per_fat; - - fsi_lba = ((long)peekHI(bpb_sector->filesystem_info)); - if (fsi_lba == -1) - fsi_lba = 0; - else if (fsi_lba >= reserved_sectors) - { - error = FAT_RETURN_BAD_FSI; - if (bpb_lba) // try with backup BPB sector ? - continue; - return error; - } - - if (((error = __fat_check_fsi_sector (volume,fsi_sector,fsi_lba + (backup ? 0 : bpb_lba))) <= 0) && bpb_lba) - continue; - - if (backup) - { - error = __fat_put_bpb_sector (volume,0,bpb_sector)) <= 0); - if (!error) - error = __fat_put_fsi_sector (volume,fsi_lba,fsi_sector)) <= 0); - } - - break; - } - } - return error; - } - -static inline int __fat_compare_volume_name (char const *name,struct fat_volume *volume) - { - return !name ? -1 : strncpy (name,volume->name,11); - } - -static struct fat_volume *__fat_splay_volume (struct fat_volume *root,char const *name) - { - struct fat_volume *down; - struct fat_volume *less; - struct fat_volume *more; - struct fat_volume *head[2]; - ((struct fat_volume *)head)->less = - ((struct fat_volume *)head)->more = 0; - less = - more = head; - while (1) - { - int sign = __fat_compare_volume_name (name,root); - if (sign < 0) - { - if ((down = root->less)) - { - sign = __fat_compare_volume_name (name,down); - if (sign < 0) - { - root->less = down->more; - down->more = root; - root = down; - if (!root->less) - break; - } - more->less = root; - more = root; - root = root->less; - continue; - } - break; - } - if (0 < sign) - { - if ((down = root->more)) - { - sign = __fat_compare_volume_name (name,down); - if (0 < sign) - { - root->more = down->less; - down->less = root; - root = down; - if (!root->more) - break; - } - less->more = root; - less = root; - root = root->more; - continue; - } - } - break; - } - less->more = root->less; - more->less = root->more; - root->less = ((struct fat_volume *)head)->more; - root->more = ((struct fat_volume *)head)->less; - return root; - } - -static inline struct fat_volume *__fat_insert_volume (struct fat_volume *root,struct fat_volume *node) - { - if (!root) - { - node->less = - node->more = 0; - } - else if (node < (root = __fat_splay_volume (root,node->name))) - { - node->less = root->less; - node->more = root; - root->less = 0; - } - else if - { - node->less = root; - node->more = root->more; - node->more = 0; - } - return node; - } - -#if 0 -static inline struct fat_volume *__fat_remove_volume (struct fat_volume *root,struct memory_free_page *node) - { - root = __fat_splay_volume (root,node->name); - if (root->less) - { - node = __fat_splay_volume (root->less,node->name); - node->more = root->more; - } - else - node = root->more; - return node; - } -#endif - -static inline struct fat_volume *__fat_lookup_volume (struct fat_volume *root,char const *name) - { - return __fat_splay_volume (root,0); - } - -static struct fat_volume *__fat_first_volume (struct fat_volume *root) - { - struct fat_volume *down; - struct fat_volume *less; - struct fat_volume *more; - struct fat_volume *head[2]; - ((struct fat_volume *)head)->less = - ((struct fat_volume *)head)->more = 0; - less = - more = &head; - if (root) - while (1) - { - if ((down = root->less)) - { - root->less = down->more; - down->more = root; - root = down; - if (!root->less) - break; - more->less = root; - more = root; - root = root->less; - continue; - } - break; - } - less->more = root->less; - more->less = root->more; - root->less = ((struct fat_volume *)head)->more; - root->more = ((struct fat_volume *)head)->less; - return root; - } - -static inline struct fat_volume *__fat_scan_volume (struct fat_volume *root,int next) - { - return __fat_first_volume (next ? root->more : root,0); - } - -static int __fat_build_volume_tree (struct fat_volume *root) - { - struct fat_volume *volume; - int number = 4; - struct __fat_partition_info *partition_info; - struct __fat_mbr_sector mbr_sector; - struct __fat_bpb_sector bpb_sector; - struct __fat_fsi_sector fsi_sector; - if (__fat_get_mbr_sector (&mbr_sector) <= 0) - return 0; - partition_info = mbr_sector.partition_table; - for (;number-- > 0; ++partition_info) - { - switch (partition_info->filesystem_type) - { - case 0x05: // extended partition - handle it as well - { - if (!__fat_build_volume_list (list)) - return 0; - break; - } - case 0x0B: // FAT32 partitions - case 0x0C: - { - if (!(volume = memory_allocate_page (0))) - return 0; - volume->next = 0; - volume->partition_start = partition_info->start; - volume->partition_sectors = partition_info->sectors; - if (__fat_check_bpb_sector (volume,&mbr_sector,&fsi_sector) > 0) - { - dump_volume (volume); - *root = volume; - list = &volume->next; - break; - } - else - memory_release_page (volume,0); - } - } - } - return 1; - } - -static struct fat_volume *__fat_volume_root; - -void fat_setup (void) - { - //build_volume_list (&root); - } diff --git a/firmware/test/fat/fat.h b/firmware/test/fat/fat.h deleted file mode 100644 index e840f3f862..0000000000 --- a/firmware/test/fat/fat.h +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_H__ -# define __LIBRARY_FAT_H__ -# include -# include -# include -# include -# include -# include -#endif diff --git a/firmware/test/fat/functions.h b/firmware/test/fat/functions.h deleted file mode 100644 index 5e8ff24149..0000000000 --- a/firmware/test/fat/functions.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_H__ -# error "This header file must be included ONLY from fat.h." -#endif -# ifndef __LIBRARY_FAT_FUNCTIONS_H__ -# define __LIBRARY_FAT_FUNCTIONS_H__ -# ifdef TEST -# endif -#endif diff --git a/firmware/test/fat/inlines.h b/firmware/test/fat/inlines.h deleted file mode 100644 index eb776e9792..0000000000 --- a/firmware/test/fat/inlines.h +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_H__ -# error "This header file must be included ONLY from fat.h." -#endif -# ifndef __LIBRARY_FAT_INLINES_H__ -#define __LIBRARY_FAT_INLINES_H__ - - - -#endif \ No newline at end of file diff --git a/firmware/test/fat/makefile b/firmware/test/fat/makefile deleted file mode 100644 index 1cd259b52f..0000000000 --- a/firmware/test/fat/makefile +++ /dev/null @@ -1,24 +0,0 @@ -############################################################################## -## __________ __ ___. -## Open \______ \ ____ ____ | | _\_ |__ _______ ___ -## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -## \/ \/ \/ \/ \/ -## $Id: -## -## Copyright (C) 2002 by Alan Korr -## -## All files in this archive are subject to the GNU General Public License. -## See the file COPYING in the source tree root for full license agreement. -## -## This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY -## KIND, either express or implied. -## -############################################################################## -ARCH = test -PACKAGE = fat -VERSION = 0.0.0 --include ../makefile-vars --include ../makefile-rules - diff --git a/firmware/test/fat/return_values.h b/firmware/test/fat/return_values.h deleted file mode 100644 index 67747ffc36..0000000000 --- a/firmware/test/fat/return_values.h +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_H__ -# error "This header file must be included ONLY from fat.h." -#endif -#ifndef __LIBRARY_FAT_RETURN_VALUES_H__ -# define __LIBRARY_FAT_RETURN_VALUES_H__ - -enum - { - FAT_RETURN_SUCCESS = 1, - FAT_RETURN_FAILURE = 0 - }; - -#endif \ No newline at end of file diff --git a/firmware/test/fat/types.h b/firmware/test/fat/types.h deleted file mode 100644 index d83de9e2c1..0000000000 --- a/firmware/test/fat/types.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_FAT_H__ -# error "This header file must be included ONLY from fat.h." -#endif -#ifndef __LIBRARY_FAT_TYPES_H__ -# define __LIBRARY_FAT_TYPES_H__ - -// [Alan]: -// I would like to draw your attention about the fact that SH1 -// cannot use misaligned address access so you must be very cautious -// with structures stored in FAT32 partition because they come from -// PC world where misaligned address accesses are usual and not -// problematic. To avoid such a trouble, I decide to use special -// structures where fields are moved in such a way they can be -// accessed by SH1. It is possible thanks to the callback mechanism -// I use for reading or writing from/to an ATA device in ata.h/c. -// So don't be puzzled if those structures seem odd compared -// with the usual ones from PC world. I use this mechanism for structures -// 'partition_info', 'mbr_sector' and 'fsi_sector' for instance, but -// not for structure 'bpb_sector' which is too much complex to handle -// that way, I think. -// By the way, SH1 is big endian, not little endian as PC is. - - - -#endif \ No newline at end of file diff --git a/firmware/test/makefile-rules b/firmware/test/makefile-rules deleted file mode 100644 index 320d05a6c2..0000000000 --- a/firmware/test/makefile-rules +++ /dev/null @@ -1,118 +0,0 @@ -############################################################################# -## __________ __ ___. -## Open \______ \ ____ ____ | | _\_ |__ _______ ___ -## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -## \/ \/ \/ \/ \/ -## Copyright Alan Korr, 2002. All rights reserved. -## -## Permission to use, copy, modify, and distribute this software for any -## purpose is hereby granted without fee, provided that this copyright and -## permissions notice appear in all copies and derivatives, and that no -## charge may be made for the software and its documentation except to cover -## cost of distribution. -## -## This software is provided "as is" without express or implied warranty. -############################################################################# - -####################################################################### -## PLEASE CONSIDER THERE IS NOTHING TO CHANGE IN THE FOLLOWING LINES -## SINCE THERE ARE COMMON FOR ALL LIBRARY -## - -.SUFFIXES : .o .c .s - -%.o: %.c - @echo "Compiling" $<... - @$(CC) -o $(@) $(CFLAGS) $(INCLUDES) -c $< - @$(CC) -M $< $(CFLAGS) $(INCLUDES) > $(*F).d - -%.o: %.s - @echo "Assembling" $<... - @$(CC) -o $(@) $(CFLAGS) $(INCLUDES) -c $< - @$(CC) -M $< $(CFLAGS) $(INCLUDES) > $(*F).d - -.PHONY: splash all clean backup restore dist install - -all: splash $(LIBRARY) test - -splash: - @echo "<<< " $(PACKAGE) "-" $(VERSION) ">>>" - -#################################################### -# LIBRAY PART : - -$(LIBRARY): $(OBJECTS) - @echo "Creating library" $(LIBRARY)... - @$(AR) cru $(@) $(OBJECTS) - @$(RL) $(@) - -#################################################### -# TEST PART : - -test: test.tab.o test.lex.o $(LIBRARY) - @echo "Creating executable" $@... - @$(CC) -g -o $(@) $(INCLUDES) $(+) -lfl -lreadline - -test.tab.o: test.tab.c - @echo "Compiling" $<... - @$(CC) $(INCLUDES) $(DEFINES) -g -o $(@) -O3 -fomit-frame-pointer -c test.tab.c - -test.lex.o: test.lex.c - @echo "Compiling" $<... - @$(CC) $(INCLUDES) $(DEFINES) -g -o $(@) -O3 -fomit-frame-pointer -c test.lex.c - -test.tab.h: test.tab.c - -test.lex.c: test.l test.tab.h - @echo "Flex:" $< - @flex -otest.lex.c test.l - -test.tab.c: test.y - @echo "Bison:" $< - @bison -d test.y - - -#################################################### -# MISCELLANOUS PART : - -clean: - @rm -f $(LIBRARY) - @rm -f $(OBJECTS) test.lex.o test.tab.o - @rm -f $(DEPENDENCIES) - @rm -f *~ test test.exe - @rm -f test.tab.h test.tab.c test.lex.c - @rm -f core - -backup: - @mkdir -p ./backup - @cp -f makefile ./backup - @cp -f test.l ./backup - @cp -f test.y ./backup - @cp -f $(SOURCES:.c=.txt) ./backup - @for header in $(HEADERS) ; do cp -f $$header ./backup ; done - @for source in $(SOURCES) ; do cp -f $$source ./backup ; done - -restore: - @cp -f ./backup/makefile . - @cp -f ./backup/test.l . - @cp -f ./backup/test.y . - @cp -f ./backup/$(SOURCES:.c=.txt) - @for header in $(HEADERS) ; do cp -f ./backup/$$header . ; done - @for source in $(SOURCES) ; do cp -f ./backup/$$source . ; done - -dist: backup - @mv backup $(PACKAGE) - @tar czvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)/* - @rm -f $(PACKAGE)/* - @rmdir $(PACKAGE) - -install: all - @mkdir -p $(PREFIX)/libraries - @cp $(LIBRARY) $(PREFIX)/libraries - @mkdir -p $(PREFIX)/headers/$(PACKAGE) - @for header in $(HEADERS) ; do cp $$header $(PREFIX)/headers/$(PACKAGE) ; done - --include $(DEPENDENCIES) - diff --git a/firmware/test/makefile-vars b/firmware/test/makefile-vars deleted file mode 100644 index 719f01dd98..0000000000 --- a/firmware/test/makefile-vars +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################# -## __________ __ ___. -## Open \______ \ ____ ____ | | _\_ |__ _______ ___ -## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -## \/ \/ \/ \/ \/ -## Copyright Alan Korr, 2002. All rights reserved. -## -## Permission to use, copy, modify, and distribute this software for any -## purpose is hereby granted without fee, provided that this copyright and -## permissions notice appear in all copies and derivatives, and that no -## charge may be made for the software and its documentation except to cover -## cost of distribution. -## -## This software is provided "as is" without express or implied warranty. -############################################################################# - -####################################################################### -## PLEASE CONSIDER THERE IS NOTHING TO CHANGE IN THE FOLLOWING LINES -## SINCE THERE ARE COMMON FOR ALL LIBRARY -## - -ARCH=test - -CC = gcc -AS = as -LD = ld -AR = ar -RL = ranlib -OC = objcopy -GZ = gzip -f - -PREFIX = ~/rockbox/$(ARCH) -DEFINES = -DTEST - -CFLAGS = -g -#CFLAGS += -save-temps -CFLAGS += -Wall \ - -W \ - -Wshadow \ - -Wpointer-arith \ - -Waggregate-return \ - -Wstrict-prototypes \ - -Wredundant-decls \ - -Winline \ - -Wmissing-prototypes \ - -Werror \ - -Wsign-compare \ - -Wmissing-declarations \ - -Wmissing-noreturns \ - -Wnested-externs -CFLAGS += -pipe -O3 -CFLAGS += -fomit-frame-pointer \ - -fschedule-insns -CFLAGS += $(EXTRA_CFLAGS) -CFLAGS += $(DEFINES) - -INCLUDES = -I.. \ - -I. \ - -I$(PREFIX)/headers - -LIBRARY = lib$(PACKAGE).a - -HEADERS = $(PACKAGE).h \ - config.h \ - defines.h \ - types.h \ - return_values.h \ - inlines.h \ - functions.h - -SOURCES = $(wildcard $(PACKAGE)-*.c) - -OBJECTS = $(SOURCES:.c=.o) - -DEPENDENCIES = $(SOURCES:.c=.d) - -HEADER_PATH = $(PREFIX)/headers/$(PACKAGE)/. diff --git a/firmware/test/memory/config.h b/firmware/test/memory/config.h deleted file mode 100644 index aba52b5599..0000000000 --- a/firmware/test/memory/config.h +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -#ifndef __LIBRARY_MEMORY_CONFIG_H__ -# define __LIBRARY_MEMORY_CONFIG_H__ -# define PACKAGE_NAME "memory" -# define PACKAGE_VERSION "0.1.1" -# define MEMORY_PAGE_USE_SPLAY_TREE 1 -#endif diff --git a/firmware/test/memory/defines.h b/firmware/test/memory/defines.h deleted file mode 100644 index 804731cea3..0000000000 --- a/firmware/test/memory/defines.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -#ifndef __LIBRARY_MEMORY_DEFINES_H__ -# define __LIBRARY_MEMORY_DEFINES_H__ -# ifndef MEMORY_PAGE_MINIMAL_ORDER -# define MEMORY_PAGE_MINIMAL_ORDER (9) /* 512 bytes */ -# endif -# ifndef MEMORY_PAGE_MAXIMAL_ORDER -# define MEMORY_PAGE_MAXIMAL_ORDER (21) /* 2 Mbytes */ -# endif -# ifndef MEMORY_PAGE_MINIMAL_SIZE -# define MEMORY_PAGE_MINIMAL_SIZE (1 << MEMORY_PAGE_MINIMAL_ORDER) -# endif -# ifndef MEMORY_PAGE_MAXIMAL_SIZE -# define MEMORY_PAGE_MAXIMAL_SIZE (1 << MEMORY_PAGE_MAXIMAL_ORDER) -# endif -# define MEMORY_TOTAL_PAGES (MEMORY_PAGE_MAXIMAL_SIZE / MEMORY_PAGE_MINIMAL_SIZE) -# define MEMORY_TOTAL_BYTES (MEMORY_PAGE_MAXIMAL_SIZE) -# define MEMORY_TOTAL_ORDERS (1 + MEMORY_PAGE_MAXIMAL_ORDER - MEMORY_PAGE_MINIMAL_ORDER) -#endif diff --git a/firmware/test/memory/functions.h b/firmware/test/memory/functions.h deleted file mode 100644 index c856a934cf..0000000000 --- a/firmware/test/memory/functions.h +++ /dev/null @@ -1,94 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -# ifndef __LIBRARY_MEMORY_FUNCTIONS_H__ -# define __LIBRARY_MEMORY_FUNCTIONS_H__ - -///////////////////////////////////////////////////////////////////// -// MEMORY : -/////////// - -extern void memory_copy (void *target,void const *source,unsigned int count); -extern void memory_set (void *target,int byte,unsigned int count); - -///////////////////////////////////////////////////////////////////// -// MEMORY PAGE : -//////////////// -// -// - memory_allocate_page : allocate a page -// - memory_release_page : release a page -// - -extern int memory_release_page (void *address); -extern void *memory_allocate_page (int order); -extern void memory_setup (void); - -// -///////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////////////////////////////// -// MEMORY SLAB : -//////////////// -// -// - memory_grow_cache : allocate a new slab for a cache -// - memory_shrink_cache : release free slabs from a cache -// - memory_create_cache : create a new cache of size-fixed blocks -// - memory_destroy_cache : destroy the cache and release all the slabs -// - memory_cache_allocate : allocate a block from the cache -// - memory_cache_release : release a block in the cache -// - -extern struct memory_slab *memory_grow_cache (struct memory_cache *cache); -extern int memory_shrink_cache (struct memory_cache *cache,int all); -extern struct memory_cache *memory_create_cache (unsigned int size,int align,int flags); -extern int memory_destroy_cache (struct memory_cache *cache); -extern void *memory_cache_allocate (struct memory_cache *cache); -extern int memory_cache_release (struct memory_cache *cache,void *address); - -// -///////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// MEMORY BLOCK : -///////////////// -// -// - memory_allocate_small_block : allocate a small block (no page) -// - memory_release_small_block : release a small block (no page) -// - memory_allocate_block : allocate a block (or a page) -// - memory_release_block : release a block (or a page) -// - -extern void *memory_allocate_small_block (int order); -extern int memory_release_small_block (int order,void *address); -extern void *memory_allocate_block (unsigned int size); -extern int memory_release_block (void *address); - -// -///////////////////////////////////////////////////////////////////// - - - -# ifdef TEST -void memory_spy_page (void *address); -void memory_dump (int order); -void memory_check (int order); -# endif -#endif diff --git a/firmware/test/memory/inlines.h b/firmware/test/memory/inlines.h deleted file mode 100644 index 003c611153..0000000000 --- a/firmware/test/memory/inlines.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -# ifndef __LIBRARY_MEMORY_INLINES_H__ -#define __LIBRARY_MEMORY_INLINES_H__ - - -#endif diff --git a/firmware/test/memory/makefile b/firmware/test/memory/makefile deleted file mode 100644 index 2878500e45..0000000000 --- a/firmware/test/memory/makefile +++ /dev/null @@ -1,23 +0,0 @@ -############################################################################# -## __________ __ ___. -## Open \______ \ ____ ____ | | _\_ |__ _______ ___ -## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -## \/ \/ \/ \/ \/ -## Copyright Alan Korr, 2002. All rights reserved. -## -## Permission to use, copy, modify, and distribute this software for any -## purpose is hereby granted without fee, provided that this copyright and -## permissions notice appear in all copies and derivatives, and that no -## charge may be made for the software and its documentation except to cover -## cost of distribution. -## -## This software is provided "as is" without express or implied warranty. -############################################################################# -ARCH = test -PACKAGE = memory -VERSION = 0.1.1 --include ../makefile-vars --include ../makefile-rules - diff --git a/firmware/test/memory/memory-block.c b/firmware/test/memory/memory-block.c deleted file mode 100644 index c5cf3ce9f8..0000000000 --- a/firmware/test/memory/memory-block.c +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#if 0 -#include -#include "memory-page.h" -#include "memory-slab.h" - -static struct memory_cache *__memory_free_block_cache[MEMORY_PAGE_MINIMAL_ORDER - 2]; - -/////////////////////////////////////////////////////////////////////////////// -// MEMORY BLOCK : -///////////////// -// -// - memory_allocate_block : allocate a power-of-2-sized block (or a page) -// - memory_release_block : release a power-of-2-sized block (or a page) -// - -static inline void *__memory_allocate_block (int order) - { - struct memory_cache *cache = __memory_free_block_cache[order - 2]; - do - { - if (cache) - return memory_cache_allocate (cache); - } - while ((__memory_free_block_cache[order] = cache = memory_create_cache (size,0,0))); - return MEMORY_RETURN_FAILURE; - } - -void *memory_allocate_block (int order) - { - if (order < 2) - order = 2; - if (order < MEMORY_PAGE_MINIMAL_ORDER) - return __memory_allocate_block (order); - if (order < MEMORY_PAGE_MAXIMAL_ORDER) - return memory_allocate_page (order); - return MEMORY_RETURN_FAILURE; - } - -static inline int __memory_release_block (int order,void *address) - { - struct memory_cache *cache = __memory_free_block_cache[order - 2]; - if (cache) - return memory_cache_release (cache,address); - return MEMORY_RETURN_FAILURE; - } - -int memory_release_block (int order,void *address) - { - if (order < 2) - order = 2; - if (order < MEMORY_PAGE_MINIMAL_ORDER) - return __memory_release_block (order); - if (order < MEMORY_PAGE_MAXIMAL_ORDER) - return memory_release_page (address); - return MEMORY_RETURN_FAILURE; - } - -#endif diff --git a/firmware/test/memory/memory-block.txt b/firmware/test/memory/memory-block.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/firmware/test/memory/memory-misc.c b/firmware/test/memory/memory-misc.c deleted file mode 100644 index 765600765b..0000000000 --- a/firmware/test/memory/memory-misc.c +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include -#include "memory-page.h" -#if 0 -#include "memory-slab.h" -#endif - -/* NOT VERY OPTIMIZED AT ALL BUT WE WILL DO IT WHEN PRIORITY COMES */ -void memory_copy (void *target,void const *source,unsigned int count) - { - while (count--) - *((char *)target)++ = *((char const *)source)++; - } - -/* NOT VERY OPTIMIZED AT ALL BUT WE WILL DO IT WHEN PRIORITY COMES */ -void memory_set (void *target,int byte,unsigned int count) - { - while (count--) - *((char *)target)++ = (char)byte; - } - -void memory_setup (void) - { -#if 1 - memory_set (__memory_free_page,0,MEMORY_TOTAL_BYTES); - memory_set (__memory_free_page_bin,0,MEMORY_TOTAL_ORDERS *sizeof (struct memory_free_page *)); - memory_set (__memory_free_page_order + 1,0,MEMORY_TOTAL_PAGES); -#endif - __memory_free_page_order[0] = MEMORY_TOTAL_ORDERS - 1; - __memory_free_page_bin[MEMORY_TOTAL_ORDERS - 1] = __memory_free_page; - } diff --git a/firmware/test/memory/memory-misc.txt b/firmware/test/memory/memory-misc.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/firmware/test/memory/memory-page.c b/firmware/test/memory/memory-page.c deleted file mode 100644 index 1327cf57c9..0000000000 --- a/firmware/test/memory/memory-page.c +++ /dev/null @@ -1,408 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include -#include "memory-page.h" -#if 0 -#include "memory-slab.h" -#endif - -#ifdef TEST - -// IA32 has no problem with shift operation -static inline unsigned int __memory_get_size (int order) - { - return (MEMORY_PAGE_MINIMAL_SIZE << order); - } - -// Arghhhh ! I cannot align 'free_page' on 512-byte boundary (max is 16-byte for Cygwin) -static inline struct memory_free_page *__memory_get_neighbour (struct memory_free_page *node,unsigned int size) - { - return ((struct memory_free_page *)((unsigned)__memory_free_page + (((unsigned)node - (unsigned)__memory_free_page) ^ size))); - } - -#else - -// SH1 has very poor shift instructions (only <<1,>>1,<<2,>>2,<<8,>>8,<<16 and >>16). -// so we should use a lookup table to speedup. -static inline unsigned int __memory_get_size (int order) - { - static unsigned short size [MEMORY_TOTAL_ORDERS] = - { - 1<less)) - { - if (node < down) - { - root->less = down->more; - down->more = root; - root = down; - if (!root->less) - break; - } - more->less = root; - more = root; - root = root->less; - continue; - } - break; - } - if (root < node) - { - if ((down = root->more)) - { - if (root < node) - { - root->more = down->less; - down->less = root; - root = down; - if (!root->more) - break; - } - less->more = root; - less = root; - root = root->more; - continue; - } - } - break; - } - less->more = root->less; - more->less = root->more; - root->less = head.more; - root->more = head.less; - return root; - } - -static inline void __memory_insert_page (int order,struct memory_free_page *node) - { - struct memory_free_page *root = __memory_free_page_bin[order]; - if (!root) - { - node->less = - node->more = 0; - } - else if (node < (root = __memory_splay_page (root,node))) - { - node->less = root->less; - node->more = root; - root->less = 0; - } - else if (node > root) - { - node->less = root; - node->more = root->more; - node->more = 0; - } - __memory_free_page_bin[order] = node; - __memory_set_order (node,order); - return; - } - -static inline struct memory_free_page *__memory_pop_page (int order,int want) - { - struct memory_free_page *root = __memory_free_page_bin[order]; - if (root) - { - root = __memory_splay_page (root,__memory_free_page); - __memory_free_page_bin[order] = root->more; - __memory_set_order (root,~want); - } - return root; - } - -static inline void __memory_remove_page (int order,struct memory_free_page *node) - { - struct memory_free_page *root = __memory_free_page_bin[order]; - root = __memory_splay_page (root,node); - if (root->less) - { - node = __memory_splay_page (root->less,node); - node->more = root->more; - } - else - node = root->more; - __memory_free_page_bin[order] = node; - } - -#else - -static inline void __memory_insert_page (int order,struct memory_free_page *node) - { - struct memory_free_page *head = __memory_free_page_bin[order]; - node->less = 0; - node->more = head; - if (head) - head->less = node; - __memory_free_page_bin[order] = node; - __memory_set_order (node,order); - } - -static inline struct memory_free_page *pop_page (int order,int want) - { - struct memory_free_page *node = __memory_free_page_bin[order]; - if (node) - { - __memory_free_page_bin[order] = node->more; - if (node->more) - node->more->less = 0; - __memory_set_order (node,~want); - } - return node; - } - -static inline void __memory_remove_page (int order,struct memory_free_page *node) - { - if (node->less) - node->less->more = node->more; - else - __memory_free_page_bin[order] = node->more; - if (node->more) - node->more->less = node->less; - } - -#endif - -static inline void __memory_push_page (int order,struct memory_free_page *node) - { - node->less = 0; - node->more = 0; - __memory_free_page_bin[order] = node; - __memory_set_order (node,order); - } - -static struct memory_free_page *__memory_allocate_page (unsigned int size,int order) - { - struct memory_free_page *node; - int min = order; - while ((unsigned)order <= (MEMORY_TOTAL_ORDERS - 1)) - // order is valid ? - { - if (!(node = __memory_pop_page (order,min))) - // no free page of this order ? - { - ++order; size <<= 1; - continue; - } - while (order > min) - // split our larger page in smaller pages - { - --order; size >>= 1; - __memory_push_page (order,(struct memory_free_page *)((unsigned int)node + size)); - } - return node; - } - return MEMORY_RETURN_FAILURE; - } - -static inline void __memory_release_page (struct memory_free_page *node,unsigned int size,int order) - { - struct memory_free_page *neighbour; - while ((order <= (MEMORY_TOTAL_ORDERS - 1)) && - ((neighbour = __memory_get_neighbour (node,size)), - (__memory_get_order (neighbour) == order))) - // merge our released page with its contiguous page into a larger page - { - __memory_remove_page (order,neighbour); - ++order; size <<= 1; - if (neighbour < node) - node = neighbour; - } - __memory_insert_page (order,node); - } - - -/*****************************************************************************/ -/* PUBLIC FUNCTIONS */ -/*****************************************************************************/ - -void *memory_allocate_page (int order) - { - if (order < 0) - return MEMORY_RETURN_FAILURE; - return __memory_allocate_page (__memory_get_size (order),order); - } - -// release a page : -// when called, 'address' MUST be a valid address pointing -// to &dram[i], where i ranges from 0 to MEMORY_TOTAL_PAGES - 1. -// FAILURE if block is already freed. -int memory_release_page (void *address) - { - struct memory_free_page *node = (struct memory_free_page *)address; - int order = ~__memory_get_order (node); - if (order < 0) - return MEMORY_RETURN_FAILURE; - __memory_release_page (node,__memory_get_size (order),order); - return MEMORY_RETURN_SUCCESS; - } - - -#ifdef TEST -# include -# include -# if MEMORY_PAGE_USE_SPLAY_TREE - -void __memory_dump_splay_node (struct memory_free_page *node,int level) - { - if (!node) - return; - __memory_dump_splay_node (node->less,level+1); - printf ("\n%*s[%d-%d]",level,"",(node - __memory_free_page),(node - __memory_free_page) + (1 << __memory_get_order (node)) - 1); - __memory_dump_splay_node (node->more,level+1); - } - -void __memory_dump_splay_tree (struct memory_free_page *root) - { - __memory_dump_splay_node (root,2); fflush (stdout); - } - -# endif - -void __memory_spy_page (void *address) - { - struct memory_free_page *node = (struct memory_free_page *)address; - int order,used; - if (node) - { - order = __memory_get_order (node); - used = order < 0; - if (used) - order = ~order; - printf("\n(%s,%2d,%7d)",(used ? "used" : "free"),order,__memory_get_size (order)); - } - } - -void __memory_dump (int order) - { - struct memory_free_page *node = __memory_free_page_bin[order]; - printf("\n(%s,%2d,%7d)",node ? "free" : "none",order,__memory_get_size (order)); -# if MEMORY_PAGE_USE_SPLAY_TREE - __memory_dump_splay_tree (node); -# else - while (node) - { - printf("[%d-%d]",(node - __memory_free_page),(node - __memory_free_page) + (1<more; - } -# endif - - } - -void __memory_check (int order) - { - struct memory_free_page *node[4096],*swap; - unsigned int i = 0,j = 0; - while (i <= 12) - __memory_dump (i++); - i = 0; - printf ("\nallocating...\n"); - while (order >= 0) - { - j = order; - while ((swap = memory_allocate_page (j))) - { - node[i++] = swap; - printf("[%d-%d]",(swap - __memory_free_page),(swap - __memory_free_page) + ((1 << j)-1)); - for (j += (rand () & 15); j > (unsigned int)order; j -= order); - } - --order; - } - node[i] = 0; - while (j <= 12) - __memory_dump (j++); - j = 0; - printf ("\nreleasing..."); - --i; - while (i > 0) - { - unsigned int k = 0; -# if 0 - printf ("\n"); -# endif - swap = node[k++]; -# if 0 - while (swap) - { - printf("[%d-%d]",(swap - __memory_free_page),(swap - __memory_free_page) + ((1 << ~__memory_get_order (swap))-1)); - swap = node[k++]; - } -# endif - for (j += 1 + (rand () & 15); j >= i; j -= i); - swap = node[j]; - node[j] = node[i]; - memory_release_page (swap); - node[i] = 0; - --i; - } - memory_release_page (node[0]); - i = 0; - while (i <= 12) - __memory_dump (i++); - printf("\n\n%s !",(__memory_get_order (__memory_free_page) == 12) ? "SUCCESS" : "FAILURE"); - } - -#endif diff --git a/firmware/test/memory/memory-page.h b/firmware/test/memory/memory-page.h deleted file mode 100644 index ab360447d7..0000000000 --- a/firmware/test/memory/memory-page.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_PAGE_H__ -#define __LIBRARY_MEMORY_PAGE_H__ - -struct memory_free_page - { - struct memory_free_page - *less,*more; - char - reserved[MEMORY_PAGE_MINIMAL_SIZE - 2*sizeof (struct memory_free_page *)]; - }; - -#define LESS -1 -#define MORE +1 - -#ifdef TEST - -struct memory_free_page __memory_free_page[MEMORY_TOTAL_PAGES]; - -#else - -extern struct memory_free_page __memory_free_page[MEMORY_TOTAL_PAGES] asm("dram"); - -#endif - -char __memory_free_page_order[MEMORY_TOTAL_PAGES]; -struct memory_free_page *__memory_free_page_bin[MEMORY_TOTAL_ORDERS]; - -#ifdef TEST -# if MEMORY_PAGE_USE_SPLAY_TREE - -void __memory_dump_splay_node (struct memory_free_page *node,int level); -void __memory_dump_splay_tree (struct memory_free_page *root); - -# endif - -void __memory_spy_page (void *address); -void __memory_dump (int order); -void __memory_check (int order); - -#endif -#endif \ No newline at end of file diff --git a/firmware/test/memory/memory-page.txt b/firmware/test/memory/memory-page.txt deleted file mode 100644 index 03811f9bde..0000000000 --- a/firmware/test/memory/memory-page.txt +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -Best-fit via binning represent the main ideas of the algorithm. - -The memory-page allocator uses an array which contains the power-of-two -orders of each free or used pages to retrieve their sizes. - -Available pages are maintained in bins, grouped by size. Depending on -its size, a free page is stored in the bin corresponding to the correct -size range (bins are detailed further): 512 B, 1 KB, 2 KB, 4 KB, 8 KB, -16 KB, 32 KB, 64 KB, 128 KB, 256 KB, 512 KB, 1 MB or 2 MB. - -Searches for available pages are processed in smallest-first, best-fit -order. - -Two implementations to chain same-sized pages are provided: -* using doubly linked stack (unordered list) as bin, pages are left - unsorted within bins, so that the best-fit strategy should only be - approximate. -* using splay tree (ordered list) as bin, pages are instead sorted - by address within bins. - -Using splay trees is slower than using doubly linked stacks but affords us -to allocate contiguous pages when possible : since doubly linked stack is -not ordered, it cannot warrant a contiguous allocation of pages. However, -there is no evidence that using splay trees really helps unfragmenting -much more than using doubly linked stack. - -All procedures maintain the invariant that no free page physically -borders another one (two bordering unused pages are always coalesced -into one larger page). - -* Alignment of pages: power-of-two, the same as their sizes. -* Minimum overhead per allocated pages: no overhead. -* Minimum allocated size: minimal page size, i.e, 512 bytes. -* Maximum allocated size: maximal page size, i.e, 2 megabytes. - --- ALGORITHMS ----------------------------------------------------------------- - -Unoptimized and recursive algorithm to allocate an N-sized page : - -* If there is no pages in the bin of N-sized pages, try to allocate - a (2xN)-sized page and split it into two N-sized pages and free - both if they are not N-sized pages or just free one and keep - the other to mark it used if they are N-sized pages. - -Unoptimized and recursive algorithm to release an N-sized page : - -* If there is a "contiguous" page, merge it with our N-sized page and - try to release it as a (2xN)-sized page. Otherwise mark it free. - -Notes: -* Two pages are "contiguous" if they are also N-aligned and mergeable - as a 2xN-aligned page. -* The address of a "contiguous" page is quickly given by : - - address("contiguous" page) = (address(page) ^ size(page)) diff --git a/firmware/test/memory/memory-slab.c b/firmware/test/memory/memory-slab.c deleted file mode 100644 index 35ab96f787..0000000000 --- a/firmware/test/memory/memory-slab.c +++ /dev/null @@ -1,409 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#if 0 -#include -#include "memory-page.h" -#include "memory-slab.h" - -/////////////////////////////////////////////////////////////////////////////// -// MEMORY SLAB : -//////////////// -// -// - -static inline struct memory_slab *__memory_push_slab (struct memory_slab *head,struct memory_slab *node) - { - node->less = head; - if (head) - { - node->more = head->more; - head->more = node; - } - else - node->more = 0; - return node; - } - -static inline struct memory_slab *__memory_pop_slab (struct memory_slab *head,struct memory_slab *node) - { - if (head) - head->more = node->more; - return node->more; - } - -static inline struct memory_slab *__memory_move_slab (struct memory_slab **from,struct memory_slab **to) - { - struct memory_slab *head = *from; - *from = (*from)->more; - if (*from) - (*from)->less = head->less; - head->less = 0; - head->more = (*to); - if (*to) - (*to)->prev = head; - *to = head; - return head; - } - -// -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// MEMORY CACHE : -///////////////// -// -// - -static struct memory_cache *cache_tree; - -static inline int __memory_get_order (unsigned size) - { - int order = 0; - size = (size + sizeof(struct memory_free_block) - 1) & - sizeof(struct memory_free_block); - while (size > 0) - { - ++order; size <<= 1; - } - return order; - } - -static inline struct memory_slab *__memory_get_slab (struct memory_cache *cache,void *address) - { -#ifdef TEST - return (struct memory_slab *)((((unsigned)address + cache->page_size) & -cache->page_size) - sizeof (struct memory_slab)); -#else - return (struct memory_slab *)((free_page + (((unsigned)address - free_page + cache->page_size) & -cache->page_size) - sizeof (struct memory_slab))); -#endif - } - -static struct memory_cache *__memory_splay_cache (struct memory_cache *root,unsigned int left) - { - struct memory_cache *down; - struct memory_cache *less; - struct memory_cache *more; - struct memory_cache head; - head.less = - head.more = 0; - less = - more = &head; - while (1) - { - if (left < root->left) - { - if ((down = root->less)) - { - if (left < down->left) - { - root->less = down->more; - down->more = root; - root = down; - if (!root->less) - break; - } - more->less = root; - more = root; - root = root->less; - continue; - } - break; - } - if (root->left < left) - { - if ((down = root->more)) - { - if (root->left < left) - { - root->more = down->less; - down->less = root; - root = down; - if (!root->more) - break; - } - less->more = root; - less = root; - root = root->more; - continue; - } - } - break; - } - less->more = root->less; - more->less = root->more; - root->less = head.more; - root->more = head.less; - return root; - } - -static inline struct memory_cache *__memory_insert_cache (struct memory_cache *root,struct memory_cache *node) - { - node->less = - node->more = - node->same = 0; - if (root) - { - if (node->left == ((root = __memory_splay_cache (root,node))->left)) - { - node->less = root.less; - node->more = root.more; - node->same = root; - root->less = node; - } - else if (node < root) - { - node->less = root->less; - node->more = root; - root->less = 0; - } - else - { - node->less = root; - node->more = root->more; - node->more = 0; - } - } - return node; - } - -static inline struct memory_cache *__memory_remove_cache (struct memory_cache *root,struct memory_cache *node) - { - if (root) - { - root = __memory_splay_cache (root,node); - if (root != node) - { - node->less->same = node->same; - if (node->same) - node->same->less = node->less; - return root; - } - if (root->less) - { - node = __memory_splay_page (root->less,node); - node->more = root->more; - } - else - node = root->more; - } - return root; - } - -static inline struct memory_cache *__memory_move_cache (struct memory_cache *root,struct memory_cache *node,int delta) - { - if ((root = __memory_remove_cache (root,node))) - { - node->left += delta; - root = __memory_insert_cache (root,node); - } - return root; - } - -// -///////////////////// -// PUBLIC FUNCTIONS : -///////////////////// -// -// - memory_grow_cache : allocate a new slab for a cache -// - memory_shrink_cache : release free slabs from a cache -// - memory_create_cache : create a new cache of size-fixed blocks -// - memory_destroy_cache : destroy the cache and release all the slabs -// - memory_cache_allocate : allocate a block from the cache -// - memory_cache_release : release a block in the cache -// - -struct memory_slab *memory_grow_cache (struct memory_cache *cache) - { - struct memory_slab *slab; - unsigned int page; - if (cache) - { - page = (unsigned int)memory_allocate_page (cache->page_order); - if (page) - { - struct memory_free_block *block,**link; - slab = (struct memory_slab *)(page + cache->page_size - sizeof (struct memory_slab)); - slab->free = 0; - slab->left = 0; - link = &slab->free; - for ((unsigned int)block = page; - (unsigned int)block + cache->size < (unsigned int)slab; - (unsigned int)block += cache->size) - { - *link = block; - link = &block->link; - ++slab->free; - } - *link = 0; - cache->blocks_per_slab = slab->free; - cache->reap = __memory_push_slab (cache->reap,slab); - cache_tree = __memory_move_cache (cache_tree,cache,+1); - return slab; - } - } - return MEMORY_RETURN_FAILURE; - } - -static int __memory_shrink_cache (struct memory_cache *cache,int all,int move) - { - struct memory_slab *slab; - unsigned int slabs = 0; - if (cache) - { - while ((slab = cache->reap)) - { - ++slabs; - cache->reap = __memory_pop_slab (cache->reap,slab); - memory_release_page ((void *)slab); - if (all) - continue; - if (move) - cache_tree = __memory_move_cache (cache_tree,cache,-slabs); - return MEMORY_RETURN_SUCCESS; - } - } - return MEMORY_RETURN_FAILURE; - } - -int memory_shrink_cache (struct memory_cache *cache,int all) - { - return __memory_shrink_cache (cache,all,1 /* move cache in cache_tree */); - } - -struct memory_cache *memory_create_cache (unsigned int size,int align,int flags) - { - struct memory_cache *cache; - unsigned int waste = 0,blocks_per_page; - int page_order; - unsigned int page_size; - unsigned int original_size = size; - - // Align size on 'align' bytes ('align' should equal 1< 4) ? ((size + align - 1) & -align) : ((size + sizeof (int) - 1) & -sizeof (int)); - if (!(cache = memory_cache_allocate (&cache_cache)) - return MEMORY_RETURN_FAILURE; - - cache->flags = - cache->left = 0; - - cache->used = - cache->free = - cache->reap = 0; - - cache->original_size = original_size; - cache->size = size; - - page_size = 0; - page_order = MEMORY_PAGE_MINIMAL_SIZE;; - - // Trying to determine what is the best number of pages per slab - for (;; ++order,(page_size <<= 1)) - { - if (page_order >= MEMORY_MAXIMUM_PAGE_ORDER_PER_SLAB) - { - memory_cache_release (&cache_cache,cache); - return MEMORY_RETURN_FAILURE; - } - - waste = page_size; - waste -= sizeof (struct memory_slab); - - blocks_per_slab = waste / size; - waste -= block_per_slab * size; - - if (blocks_per_slab < MEMORY_MINIMUM_BLOCKS_PER_SLAB) - { - ++page_order; page_size <<= 1; - continue; - } - - // below 3% of lost space is correct - if ((waste << 16) / page_size) < 1967) - break; - ++page_order; page_size <<= 1; - } - - cache->page_size = page_size; - cache->page_order = page_order; - - cache_tree = __memory_insert_cache (cache_tree,cache); - - return cache; - } - -int memory_destroy_cache (struct memory_cache *cache) - { - /* FIX ME : this function shouldn't be called if there are still used blocks */ - if (cache && !cache->free && !cache->used) - { - cache_tree = __memory_remove_cache (cache_tree,cache); - if (__memory_shrink_cache (cache,1 /* release all free slabs */,0 /* don't move in cache_tree */)) - return memory_cache_release (&cache_cache,cache); - } - return MEMORY_RETURN_FAILURE; - } - -void *memory_cache_allocate (struct memory_cache *cache) - { - if (cache) - { - do - { - struct memory_slab *slab; - if ((slab = cache->free)) - { - if (slab->left > 0) - { -ok: struct memory_free_block *block = slab->free; - slab->free = block->link; - if (--slab->left == 0) - __memory_move_slab (&cache->free,&cache->used); - return block; - } - } - if (cache->reap) - { - slab = __memory_move_slab (&cache->reap,&cache->free); - cache_tree = __memory_move_cache (cache_tree,cache,-1); - goto ok; - } - } - while (__memory_grow_cache (cache)); - } - return MEMORY_RETURN_FAILURE; - } - -int memory_cache_release (struct memory_cache *cache,void *address) - { - struct memory_slab *slab = __memory_get_slab (cache,address); - ((struct memory_free_block *)address)->link = slab->free; - slab->free = (struct memory_free_block *)address; - if (slab->left++ == 0) - __memory_move_slab (&cache->used,&cache->free); - else if (slab->left == cache->blocks_per_slab) - { - __memory_move_slab (&cache->free,&cache->reap); - cache_tree = __memory_move_cache (cache_tree,cache,+1); - } - return MEMORY_RETURN_SUCCESS; - } - -// -/////////////////////////////////////////////////////////////////////////////// - -#endif diff --git a/firmware/test/memory/memory-slab.h b/firmware/test/memory/memory-slab.h deleted file mode 100644 index f58897c3ec..0000000000 --- a/firmware/test/memory/memory-slab.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_SLAB_H__ -#define __LIBRARY_MEMORY_SLAB_H__ - -struct memory_free_block - { - struct memory_free_block - *link; - }; - -struct memory_slab - { - struct memory_slab - *less,*more; - unsigned int // left == number of free blocks left - left; - struct memory_free_block - *free; - }; - -struct memory_cache - { - struct memory_cache - *less,*more,*same; - unsigned int - left; // number of free slabs - struct memory_slab - *used; - struct memory_slab - *free; - struct memory_slab - *reap; - unsigned int - size,original_size; - unsigned int - page_size; - unsigned int - blocks_per_slab; - int - page_order; - unsigned int - flags; - }; - -#endif diff --git a/firmware/test/memory/memory-slab.txt b/firmware/test/memory/memory-slab.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/firmware/test/memory/memory.h b/firmware/test/memory/memory.h deleted file mode 100644 index fde6ac3ad1..0000000000 --- a/firmware/test/memory/memory.h +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# define __LIBRARY_MEMORY_H__ -# include -# include -# include -# include -# include -# include -#endif diff --git a/firmware/test/memory/return_values.h b/firmware/test/memory/return_values.h deleted file mode 100644 index fe3cf8f88d..0000000000 --- a/firmware/test/memory/return_values.h +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -# ifndef __LIBRARY_MEMORY_RETURN_VALUES_H__ -#define __LIBRARY_MEMORY_RETURN_VALUES_H__ - -enum - { - MEMORY_RETURN_SUCCESS = 1, - MEMORY_RETURN_FAILURE = 0 - }; - -#endif diff --git a/firmware/test/memory/test.l b/firmware/test/memory/test.l deleted file mode 100644 index 7b938e9330..0000000000 --- a/firmware/test/memory/test.l +++ /dev/null @@ -1,23 +0,0 @@ -%{ -#include "test.tab.h" -#define YY_INPUT(buf,result,max_size) \ - result = read_input (buf,max_size); -%} - -%s GETNUMBER - -%% - -[0-9]+ { yylval = atoi(yytext); return NUMBER;} - -"a"|"allocate" { BEGIN GETNUMBER; return ALLOCATE; } -"r"|"release" { BEGIN GETNUMBER; return RELEASE; } -"s"|"spy" { BEGIN GETNUMBER; return SPY; } -"c"|"check" { BEGIN GETNUMBER; return CHECK; } -"i"|"init" { return INIT; } -"d"|"dump" { return DUMP; } -"q"|"quit" { return QUIT; } -[ \t] ; -\n|. { BEGIN 0; return yytext[0]; } -%% - diff --git a/firmware/test/memory/test.y b/firmware/test/memory/test.y deleted file mode 100644 index b3b39acc26..0000000000 --- a/firmware/test/memory/test.y +++ /dev/null @@ -1,180 +0,0 @@ -%{ -#include "memory.h" -#include "memory-page.h" -#include -#include -#include -void allocate (int); -void release (int); -void spy (int); -void dump (void); -void prompt (void); -%} - -%token NUMBER -%token ALLOCATE -%token RELEASE -%token DUMP -%token SPY -%token CHECK -%token INIT -%token QUIT - -%left '+' '-' -%left '*' '/' -%nonassoc UMINUS - -%% -commands - : command ';' - { } - | commands command ';' - { } - | error ';' - { yyerrok; } - ; - -command - : allocate - | release - | spy - | check - | INIT - { memory_setup (); } - | DUMP - { dump (); } - | QUIT - { return 0; } - ; - -allocate - : ALLOCATE expression - { allocate (yylval); } - ; - -release - : RELEASE expression - { release (yylval); } - ; - -spy - : SPY expression - { spy (yylval); } - ; - -check - : CHECK expression - { __memory_check (yylval); } - ; - -expression - : expression '+' expression - { $$ = $1 + $3; } - | expression '-' expression - { $$ = $1 - $3; } - | expression '*' expression - { $$ = $1 * $3; } - | expression '/' expression - { - if($3 == 0) - yyerror("divide by zero"); - else - $$ = $1 / $3; - } - | '-' expression %prec UMINUS - { - $$ = -$2; - } - | '(' expression ')' - { - $$ = $2; - } - | NUMBER - { - $$ = $1; - } - ; - -%% - -#include -#include - -int yyerror(char *s) - { - fprintf(stderr,"\nBad command"); - return 1; - } - -void prompt (void) - { - printf("\n>"); fflush (stdout); - } - -void allocate (int order) - { - void *address; - printf("\nallocating a page of %d bytes...",512< 21) - printf (" bad order !"); - else if ((address = memory_allocate_page (order))) - printf (" page #%d allocated !",((char *)address - (char *)__memory_free_page) >> 9); - else - printf (" cannot allocate a page !"); - } - -void release (int page) - { - void *address = (void *)((char *)__memory_free_page + (page << 9)); - printf("\nreleasing page #%d...",page); - if ((unsigned)page >= (2*1024*1024/512)) - printf (" bad page number !"); - else if (memory_release_page (address)) - printf (" page #%d released !",page); - else - printf (" cannot release this page !"); - } - -void spy (int page) - { - void *address = (void *)((char *)__memory_free_page + (page << 9)); - printf("\nspying page #%d...",page); - if ((unsigned)page >= (2*1024*1024/512)) - printf (" bad page number !"); - else - __memory_spy_page (address); - } - -void dump (void) - { - int order; - printf("\ndumping free pages list..."); - for (order = 0; order < 13; ++order) - __memory_dump (order); - } - -int main () - { - yyparse(); - return 0; - } - -int read_input (char *buffer,int max) - { - char *line = 0; - while (1) - { - line = readline ("\n>"); - if (!line) - break; - if (*line) - add_history(line); - strncpy (buffer,line,max); - strcat (buffer,";"); - free (line); - return strlen (buffer); - } - buffer[0] = ';'; - return 1; - } - diff --git a/firmware/test/memory/types.h b/firmware/test/memory/types.h deleted file mode 100644 index 4d2be940b5..0000000000 --- a/firmware/test/memory/types.h +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -#ifndef __LIBRARY_MEMORY_TYPES_H__ -# define __LIBRARY_MEMORY_TYPES_H__ - -struct memory_free_page; -struct memory_free_block; -struct memory_slab; -struct memory_cache; - - - -#endif diff --git a/firmware/test/template/config.h b/firmware/test/template/config.h deleted file mode 100644 index 978d447e8b..0000000000 --- a/firmware/test/template/config.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_TEMPLATE_H__ -# error "This header file must be included ONLY from template.h." -#endif -#ifndef __LIBRARY_TEMPLATE_CONFIG_H__ -# define __LIBRARY_TEMPLATE_CONFIG_H__ -# define PACKAGE_NAME "template" -# define PACKAGE_VERSION "0.0.0" -#endif \ No newline at end of file diff --git a/firmware/test/template/defines.h b/firmware/test/template/defines.h deleted file mode 100644 index 04da65bf23..0000000000 --- a/firmware/test/template/defines.h +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_TEMPLATE_H__ -# error "This header file must be included ONLY from template.h." -#endif -#ifndef __LIBRARY_TEMPLATE_DEFINES_H__ -# define __LIBRARY_TEMPLATE_DEFINES_H__ -#endif \ No newline at end of file diff --git a/firmware/test/template/functions.h b/firmware/test/template/functions.h deleted file mode 100644 index 9bb748265f..0000000000 --- a/firmware/test/template/functions.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_TEMPLATE_H__ -# error "This header file must be included ONLY from template.h." -#endif -# ifndef __LIBRARY_TEMPLATE_FUNCTIONS_H__ -# define __LIBRARY_TEMPLATE_FUNCTIONS_H__ -# ifdef TEST -# endif -#endif diff --git a/firmware/test/template/inlines.h b/firmware/test/template/inlines.h deleted file mode 100644 index 9fd804dc6b..0000000000 --- a/firmware/test/template/inlines.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_TEMPLATE_H__ -# error "This header file must be included ONLY from template.h." -#endif -# ifndef __LIBRARY_TEMPLATE_INLINES_H__ -#define __LIBRARY_TEMPLATE_INLINES_H__ - - -#endif \ No newline at end of file diff --git a/firmware/test/template/makefile b/firmware/test/template/makefile deleted file mode 100644 index 76bf4e30df..0000000000 --- a/firmware/test/template/makefile +++ /dev/null @@ -1,23 +0,0 @@ -############################################################################# -## __________ __ ___. -## Open \______ \ ____ ____ | | _\_ |__ _______ ___ -## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -## \/ \/ \/ \/ \/ -## Copyright Alan Korr, 2002. All rights reserved. -## -## Permission to use, copy, modify, and distribute this software for any -## purpose is hereby granted without fee, provided that this copyright and -## permissions notice appear in all copies and derivatives, and that no -## charge may be made for the software and its documentation except to cover -## cost of distribution. -## -## This software is provided "as is" without express or implied warranty. -############################################################################# -ARCH = test -PACKAGE = template -VERSION = 0.0.0 --include ../makefile-vars --include ../makefile-rules - diff --git a/firmware/test/template/return_values.h b/firmware/test/template/return_values.h deleted file mode 100644 index b91db7fffc..0000000000 --- a/firmware/test/template/return_values.h +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_TEMPLATE_H__ -# error "This header file must be included ONLY from template.h." -#endif -#ifndef __LIBRARY_TEMPLATE_RETURN_VALUES_H__ -# define __LIBRARY_TEMPLATE_RETURN_VALUES_H__ -#endif \ No newline at end of file diff --git a/firmware/test/template/template.h b/firmware/test/template/template.h deleted file mode 100644 index 89a31a9ded..0000000000 --- a/firmware/test/template/template.h +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_TEMPLATE_H__ -# define __LIBRARY_TEMPLATE_H__ -# include