From c97a1aed74fc54176e0de66fc2b6bbe0767e8de6 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 24 May 2009 21:53:29 +0000 Subject: Also strip trailing whitespaces in C and Objective-C source files. (Seems I forgot that we got those too :-P) svn-id: r40872 --- backends/platform/ds/arm9/source/fat/io_efa2.c | 28 +++---- backends/platform/ds/arm9/source/fat/io_fcsr.c | 16 ++-- .../platform/ds/arm9/source/fat/io_m3_common.c | 10 +-- backends/platform/ds/arm9/source/fat/io_m3cf.c | 54 ++++++------ backends/platform/ds/arm9/source/fat/io_m3sd.c | 4 +- backends/platform/ds/arm9/source/fat/io_mmcf.c | 26 +++--- backends/platform/ds/arm9/source/fat/io_mpcf.c | 52 ++++++------ backends/platform/ds/arm9/source/fat/io_njsd.c | 76 ++++++++--------- backends/platform/ds/arm9/source/fat/io_nmmc.c | 58 ++++++------- backends/platform/ds/arm9/source/fat/io_sccf.c | 2 +- backends/platform/ds/arm9/source/fat/io_scsd.c | 8 +- .../platform/ds/arm9/source/fat/io_sd_common.c | 58 ++++++------- backends/platform/iphone/iphone_keyboard.m | 6 +- backends/platform/iphone/iphone_main.m | 6 +- backends/platform/iphone/iphone_video.m | 96 +++++++++++----------- backends/platform/ps2/cd.c | 8 +- backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c | 4 +- backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c | 6 +- backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c | 2 +- backends/platform/ps2/iop/rpckbd/src/ps2kbd.c | 68 +++++++-------- backends/platform/ps2/rpckbd.c | 2 +- 21 files changed, 295 insertions(+), 295 deletions(-) diff --git a/backends/platform/ds/arm9/source/fat/io_efa2.c b/backends/platform/ds/arm9/source/fat/io_efa2.c index f3aa65cfcb..468361969e 100644 --- a/backends/platform/ds/arm9/source/fat/io_efa2.c +++ b/backends/platform/ds/arm9/source/fat/io_efa2.c @@ -47,7 +47,7 @@ See gba_nds_fat.txt for help and license details. // ID of Samsung K9K1G NAND flash chip #define EFA2_NAND_ID 0xEC79A5C0 -// first sector of udisk +// first sector of udisk #define EFA2_UDSK_START 0x40 // @@ -101,7 +101,7 @@ void efa2_nand_lock(void) { // // Set NAND Flash chip enable and write protection bits ? -// +// // val | ~CE | ~WP | // -----+-----+-----+ // 0 | 0 | 0 | @@ -125,7 +125,7 @@ inline void efa2_nand_reset(void) { // // Read out NAND ID information, could be used for card detection -// +// // | EFA2 1GBit | // ------------------+------------+ // maker code | 0xEC | @@ -166,7 +166,7 @@ EFA2_ClearStatus Reads and checks NAND status information bool return OUT: true if NAND is idle -----------------------------------------------------------------*/ -bool EFA2_ClearStatus (void) +bool EFA2_ClearStatus (void) { // tbd: currently there is no write support, so always return // true, there is no possibility for pending operations @@ -178,7 +178,7 @@ EFA2_IsInserted Checks to see if the NAND chip used by the EFA2 is present bool return OUT: true if the correct NAND chip is found -----------------------------------------------------------------*/ -bool EFA2_IsInserted (void) +bool EFA2_IsInserted (void) { EFA2_ClearStatus(); return (efa2_nand_id() == EFA2_NAND_ID); @@ -223,7 +223,7 @@ bool EFA2_ReadSectors (u32 sector, u8 numSecs, void* buffer) efa2_nand_reset(); // set NAND to READ1 operation mode and transfer page address - REG_EFA2_NAND_CMD = 0x00; // write READ1 command + REG_EFA2_NAND_CMD = 0x00; // write READ1 command REG_EFA2_NAND_WR = 0x00; // write address [7:0] REG_EFA2_NAND_WR = (page ) & 0xff; // write address [15:8] REG_EFA2_NAND_WR = (page >> 8 ) & 0xff; // write address[23:16] @@ -280,7 +280,7 @@ bool EFA2_WriteSectors (u32 sector, u8 numSecs, void* buffer) EFA2_Shutdown unload the EFA2 interface -----------------------------------------------------------------*/ -bool EFA2_Shutdown(void) +bool EFA2_Shutdown(void) { return EFA2_ClearStatus(); } @@ -368,7 +368,7 @@ See gba_nds_fat.txt for help and license details. // ID of Samsung K9K1G NAND flash chip #define EFA2_NAND_ID 0xEC79A5C0 -// first sector of udisk +// first sector of udisk #define EFA2_UDSK_START 0x40 // @@ -422,7 +422,7 @@ void efa2_nand_lock(void) { // // Set NAND Flash chip enable and write protection bits ? -// +// // val | ~CE | ~WP | // -----+-----+-----+ // 0 | 0 | 0 | @@ -446,7 +446,7 @@ inline void efa2_nand_reset(void) { // // Read out NAND ID information, could be used for card detection -// +// // | EFA2 1GBit | // ------------------+------------+ // maker code | 0xEC | @@ -487,7 +487,7 @@ EFA2_ClearStatus Reads and checks NAND status information bool return OUT: true if NAND is idle -----------------------------------------------------------------*/ -bool EFA2_ClearStatus (void) +bool EFA2_ClearStatus (void) { // tbd: currently there is no write support, so always return // true, there is no possibility for pending operations @@ -499,7 +499,7 @@ EFA2_IsInserted Checks to see if the NAND chip used by the EFA2 is present bool return OUT: true if the correct NAND chip is found -----------------------------------------------------------------*/ -bool EFA2_IsInserted (void) +bool EFA2_IsInserted (void) { EFA2_ClearStatus(); return (efa2_nand_id() == EFA2_NAND_ID); @@ -544,7 +544,7 @@ bool EFA2_ReadSectors (u32 sector, u8 numSecs, void* buffer) efa2_nand_reset(); // set NAND to READ1 operation mode and transfer page address - REG_EFA2_NAND_CMD = 0x00; // write READ1 command + REG_EFA2_NAND_CMD = 0x00; // write READ1 command REG_EFA2_NAND_WR = 0x00; // write address [7:0] REG_EFA2_NAND_WR = (page ) & 0xff; // write address [15:8] REG_EFA2_NAND_WR = (page >> 8 ) & 0xff; // write address[23:16] @@ -601,7 +601,7 @@ bool EFA2_WriteSectors (u32 sector, u8 numSecs, void* buffer) EFA2_Shutdown unload the EFA2 interface -----------------------------------------------------------------*/ -bool EFA2_Shutdown(void) +bool EFA2_Shutdown(void) { return EFA2_ClearStatus(); } diff --git a/backends/platform/ds/arm9/source/fat/io_fcsr.c b/backends/platform/ds/arm9/source/fat/io_fcsr.c index d576dfbb0f..7a67a6b1b0 100644 --- a/backends/platform/ds/arm9/source/fat/io_fcsr.c +++ b/backends/platform/ds/arm9/source/fat/io_fcsr.c @@ -4,7 +4,7 @@ compact_flash.c By chishm (Michael Chisholm) - Hardware Routines for using a GBA Flash Cart and SRAM as a + Hardware Routines for using a GBA Flash Cart and SRAM as a block device. This software is completely free. No warranty is provided. @@ -57,7 +57,7 @@ FCSR_IsInserted Is a GBA Flash Cart with a valid file system inserted? bool return OUT: true if a GBA FC card is inserted -----------------------------------------------------------------*/ -bool FCSR_IsInserted (void) +bool FCSR_IsInserted (void) { bool flagFoundFileSys = false; @@ -85,7 +85,7 @@ FCSR_ClearStatus Finish any pending operations bool return OUT: always true for GBA FC -----------------------------------------------------------------*/ -bool FCSR_ClearStatus (void) +bool FCSR_ClearStatus (void) { return true; } @@ -101,7 +101,7 @@ void* buffer OUT: pointer to 512 byte buffer to store data in bool return OUT: true if successful -----------------------------------------------------------------*/ bool FCSR_ReadSectors (u32 sector, u8 numSecs, void* buffer) -{ +{ int i; bool flagSramSector = false; int numSectors = (numSecs > 0 ? numSecs : 256); @@ -208,14 +208,14 @@ bool FCSR_WriteSectors (u32 sector, u8 numSecs, void* buffer) FCSR_Shutdown unload the Flash Cart interface -----------------------------------------------------------------*/ -bool FCSR_Shutdown(void) +bool FCSR_Shutdown(void) { int i; if (FCSR_ClearStatus() == false) return false; FCSR_FileSysPointer = 0; - + for (i=0; i < 4; i++) { FCSR_SramSectorPointer[i] = 0; @@ -262,11 +262,11 @@ bool FCSR_StartUp(void) // Get SRAM sector regions from header block for (i = 0; i < 4; i++) { - FCSR_SramSectorStart[i] = fileSysPointer[i+4]; + FCSR_SramSectorStart[i] = fileSysPointer[i+4]; SramRegionSize[i] = fileSysPointer[i+8]; FCSR_SramSectorEnd[i] = FCSR_SramSectorStart[i] + SramRegionSize[i]; } - + // Calculate SRAM region pointers FCSR_SramSectorPointer[0] = (u8*)(SRAM_START + 4); for (i = 1; i < 4; i++) diff --git a/backends/platform/ds/arm9/source/fat/io_m3_common.c b/backends/platform/ds/arm9/source/fat/io_m3_common.c index ab2c143327..9c8280c808 100644 --- a/backends/platform/ds/arm9/source/fat/io_m3_common.c +++ b/backends/platform/ds/arm9/source/fat/io_m3_common.c @@ -1,13 +1,13 @@ /* - io_m3_common.c + io_m3_common.c Routines common to all version of the M3 - + Some code based on M3 SD drivers supplied by M3Adapter. Some code written by SaTa may have been unknowingly used. Copyright (c) 2006 Michael "Chishm" Chisholm - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -47,7 +47,7 @@ void _M3_changeMode (u32 mode) { _M3_readHalfword (0x08000000 + (mode << 1)); _M3_readHalfword (0x0800080e); _M3_readHalfword (0x08000000); - + if ((mode & 0x0f) != 4) { _M3_readHalfword (0x09000000); } else { @@ -56,5 +56,5 @@ void _M3_changeMode (u32 mode) { _M3_readHalfword (0x08000188); _M3_readHalfword (0x08000188); } -} +} diff --git a/backends/platform/ds/arm9/source/fat/io_m3cf.c b/backends/platform/ds/arm9/source/fat/io_m3cf.c index 910f01097e..968d83ae33 100644 --- a/backends/platform/ds/arm9/source/fat/io_m3cf.c +++ b/backends/platform/ds/arm9/source/fat/io_m3cf.c @@ -73,7 +73,7 @@ M3CF_IsInserted Is a compact flash card inserted? bool return OUT: true if a CF card is inserted -----------------------------------------------------------------*/ -bool M3CF_IsInserted (void) +bool M3CF_IsInserted (void) { // Change register, then check if value did change M3_REG_STS = CF_STS_INSERTED; @@ -86,17 +86,17 @@ M3CF_ClearStatus Tries to make the CF card go back to idle mode bool return OUT: true if a CF card is idle -----------------------------------------------------------------*/ -bool M3CF_ClearStatus (void) +bool M3CF_ClearStatus (void) { int i; - + // Wait until CF card is finished previous commands i=0; while ((M3_REG_CMD & CF_STS_BUSY) && (i < CARD_TIMEOUT)) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(M3_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -128,7 +128,7 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer) u8 *buff_u8 = (u8*)buffer; int temp; #endif - + #if defined _CF_USE_DMA && defined NDS && defined ARM9 DC_FlushRange( buffer, j * BYTE_PER_READ); #endif @@ -139,7 +139,7 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(M3_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -148,20 +148,20 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Set number of sectors to read - M3_REG_SEC = numSecs; - + M3_REG_SEC = numSecs; + // Set read sector M3_REG_LBA1 = sector & 0xFF; // 1st byte of sector number M3_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number M3_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number M3_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number - + // Set command to read M3_REG_CMD = CF_CMD_READ; - - + + while (j--) { // Wait until card is ready for reading @@ -172,7 +172,7 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Read data #ifdef _CF_USE_DMA #ifdef NDS @@ -194,12 +194,12 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *buff++ = *M3_DATA; + *buff++ = *M3_DATA; } #else i=256; while(i--) - *buff++ = *M3_DATA; + *buff++ = *M3_DATA; #endif } #if defined _CF_USE_DMA && defined NDS @@ -230,7 +230,7 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer) u8 *buff_u8 = (u8*)buffer; int temp; #endif - + #if defined _CF_USE_DMA && defined NDS && defined ARM9 DC_FlushRange( buffer, j * BYTE_PER_READ); #endif @@ -241,7 +241,7 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(M3_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -250,19 +250,19 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Set number of sectors to write - M3_REG_SEC = numSecs; - + M3_REG_SEC = numSecs; + // Set write sector M3_REG_LBA1 = sector & 0xFF; // 1st byte of sector number M3_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number M3_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number M3_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number - + // Set command to write M3_REG_CMD = CF_CMD_WRITE; - + while (j--) { // Wait until card is ready for writing @@ -273,7 +273,7 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Write data #ifdef _CF_USE_DMA #ifdef NDS @@ -295,19 +295,19 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *M3_DATA = *buff++; + *M3_DATA = *buff++; } #else i=256; while(i--) - *M3_DATA = *buff++; + *M3_DATA = *buff++; #endif } #if defined _CF_USE_DMA && defined NDS // Wait for end of transfer before returning while(DMA3_CR & DMA_BUSY); #endif - + return true; } @@ -317,7 +317,7 @@ M3_Unlock Returns true if M3 was unlocked, false if failed Added by MightyMax -----------------------------------------------------------------*/ -bool M3_Unlock(void) +bool M3_Unlock(void) { // run unlock sequence volatile unsigned short tmp ; diff --git a/backends/platform/ds/arm9/source/fat/io_m3sd.c b/backends/platform/ds/arm9/source/fat/io_m3sd.c index 914b83e06e..2bbda37a5a 100644 --- a/backends/platform/ds/arm9/source/fat/io_m3sd.c +++ b/backends/platform/ds/arm9/source/fat/io_m3sd.c @@ -218,7 +218,7 @@ void M3SD_writesector(u16 * p,u32 sectorn) } } while ((verify > 0) && (tries < 16)); - + free(data); free(check); } // */ @@ -356,7 +356,7 @@ bool M3SD_Shutdown(void) bool M3SD_StartUp(void) { vu16* waitCr = (vu16*)0x4000204; - + *waitCr |= 0x6000; // *(vu16*)0x4000204=0x6000; // Try unlocking 3 times, because occationally it fails to detect the reader. diff --git a/backends/platform/ds/arm9/source/fat/io_mmcf.c b/backends/platform/ds/arm9/source/fat/io_mmcf.c index 3034afe311..5ccb3122e4 100644 --- a/backends/platform/ds/arm9/source/fat/io_mmcf.c +++ b/backends/platform/ds/arm9/source/fat/io_mmcf.c @@ -74,14 +74,14 @@ static bool cf_block_ready(void) do { while (!(CF_RD_STATUS & 0x40)); - } while (CF_RD_STATUS & 0x80); + } while (CF_RD_STATUS & 0x80); */ do { i++; - while ( (!(CF_RD_STATUS & 0x40)) && (i < CARD_TIMEOUT) ) i++; - } while ( (CF_RD_STATUS & 0x80) && (i < CARD_TIMEOUT) ); + while ( (!(CF_RD_STATUS & 0x40)) && (i < CARD_TIMEOUT) ) i++; + } while ( (CF_RD_STATUS & 0x80) && (i < CARD_TIMEOUT) ); if (i >= CARD_TIMEOUT) { return false; @@ -110,7 +110,7 @@ MMCF_IsInserted Is a compact flash card inserted? bool return OUT: true if a CF card is inserted -----------------------------------------------------------------*/ -bool MMCF_IsInserted (void) +bool MMCF_IsInserted (void) { if ( !cf_set_features(0xAA) ) return false; @@ -123,7 +123,7 @@ MMCF_ClearStatus Tries to make the CF card go back to idle mode bool return OUT: true if a CF card is idle -----------------------------------------------------------------*/ -bool MMCF_ClearStatus (void) +bool MMCF_ClearStatus (void) { return true; } @@ -185,7 +185,7 @@ bool MMCF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *buff++ = *MP_DATA; + *buff++ = *MP_DATA; } #else i=256; @@ -222,15 +222,15 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) u8 *buff_u8 = (u8*)buffer; int temp; #endif - + #if defined _CF_USE_DMA && defined NDS && defined ARM9 DC_FlushRange( buffer, j * BYTE_PER_READ); #endif - if (numSecs > 1) + if (numSecs > 1) { int r = 0; - + for (r = 0; r < numSecs; r++) { MMCF_WriteSectors(sector + r, 1, ((unsigned char *) (buffer)) + 512); @@ -270,12 +270,12 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *MP_DATA = *buff++; + *MP_DATA = *buff++; } #else i=256; while(i--) - *MP_DATA = *buff++; + *MP_DATA = *buff++; #endif } @@ -283,7 +283,7 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) #if defined _CF_USE_DMA && defined NDS // Wait for end of transfer before returning while(DMA3_CR & DMA_BUSY); -#endif +#endif //#define _CF_VERIFY @@ -312,7 +312,7 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) MMCF_Shutdown unload the GBAMP CF interface -----------------------------------------------------------------*/ -bool MMCF_Shutdown(void) +bool MMCF_Shutdown(void) { return MMCF_ClearStatus() ; } diff --git a/backends/platform/ds/arm9/source/fat/io_mpcf.c b/backends/platform/ds/arm9/source/fat/io_mpcf.c index a12b6e8e1e..6b56e29291 100644 --- a/backends/platform/ds/arm9/source/fat/io_mpcf.c +++ b/backends/platform/ds/arm9/source/fat/io_mpcf.c @@ -73,7 +73,7 @@ MPCF_IsInserted Is a compact flash card inserted? bool return OUT: true if a CF card is inserted -----------------------------------------------------------------*/ -bool MPCF_IsInserted (void) +bool MPCF_IsInserted (void) { // Change register, then check if value did change MP_REG_STS = CF_STS_INSERTED; @@ -86,17 +86,17 @@ MPCF_ClearStatus Tries to make the CF card go back to idle mode bool return OUT: true if a CF card is idle -----------------------------------------------------------------*/ -bool MPCF_ClearStatus (void) +bool MPCF_ClearStatus (void) { int i; - + // Wait until CF card is finished previous commands i=0; while ((MP_REG_CMD & CF_STS_BUSY) && (i < CARD_TIMEOUT)) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(MP_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -139,7 +139,7 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(MP_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -148,20 +148,20 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Set number of sectors to read - MP_REG_SEC = numSecs; - + MP_REG_SEC = numSecs; + // Set read sector MP_REG_LBA1 = sector & 0xFF; // 1st byte of sector number MP_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number MP_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number MP_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number - + // Set command to read MP_REG_CMD = CF_CMD_READ; - - + + while (j--) { // Wait until card is ready for reading @@ -172,7 +172,7 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Read data #ifdef _CF_USE_DMA #ifdef NDS @@ -194,12 +194,12 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *buff++ = *MP_DATA; + *buff++ = *MP_DATA; } #else i=256; while(i--) - *buff++ = *MP_DATA; + *buff++ = *MP_DATA; #endif } #if (defined _CF_USE_DMA) && (defined NDS) @@ -229,7 +229,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) u8 *buff_u8 = (u8*)buffer; int temp; #endif - + #if defined _CF_USE_DMA && defined NDS && defined ARM9 DC_FlushRange( buffer, j * BYTE_PER_READ); #endif @@ -240,7 +240,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(MP_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -249,19 +249,19 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Set number of sectors to write - MP_REG_SEC = numSecs; - + MP_REG_SEC = numSecs; + // Set write sector MP_REG_LBA1 = sector & 0xFF; // 1st byte of sector number MP_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number MP_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number MP_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number - + // Set command to write MP_REG_CMD = CF_CMD_WRITE; - + while (j--) { // Wait until card is ready for writing @@ -272,7 +272,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Write data #ifdef _CF_USE_DMA #ifdef NDS @@ -294,19 +294,19 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *MP_DATA = *buff++; + *MP_DATA = *buff++; } #else i=256; while(i--) - *MP_DATA = *buff++; + *MP_DATA = *buff++; #endif } #if defined _CF_USE_DMA && defined NDS // Wait for end of transfer before returning while(DMA3_CR & DMA_BUSY); #endif - + return true; } @@ -314,7 +314,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) MPCF_Shutdown unload the GBAMP CF interface -----------------------------------------------------------------*/ -bool MPCF_Shutdown(void) +bool MPCF_Shutdown(void) { return MPCF_ClearStatus() ; } diff --git a/backends/platform/ds/arm9/source/fat/io_njsd.c b/backends/platform/ds/arm9/source/fat/io_njsd.c index fbb223d560..b9cb52aa00 100644 --- a/backends/platform/ds/arm9/source/fat/io_njsd.c +++ b/backends/platform/ds/arm9/source/fat/io_njsd.c @@ -3,11 +3,11 @@ Hardware Routines for reading an SD card using a NinjaDS SD adapter. - + Original code supplied by NinjaMod - + Copyright (c) 2006 Michael "Chishm" Chisholm - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -28,7 +28,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + 2006-08-05 - Chishm * First release */ @@ -84,7 +84,7 @@ static u32 _NJSD_relativeCardAddress = 0; static inline bool _NJSD_waitIRQ(void) { /*#ifdef _NJSD_SYNC int i = IRQ_TIMEOUT; - while (!(REG_IF & 0x100000) && --i); + while (!(REG_IF & 0x100000) && --i); REG_IF = 0x100000; if (i <= 0) { return false; @@ -96,7 +96,7 @@ static inline bool _NJSD_waitIRQ(void) { //if (!(REG_IME & 1)) //{ // irq's disabled... - while (!(REG_IF & 0x100000) && (!(_NJSD_irqFlag)) && --i); + while (!(REG_IF & 0x100000) && (!(_NJSD_irqFlag)) && --i); _NJSD_irqFlag = 0; REG_IF = 0x100000; if (i <= 0) { @@ -106,7 +106,7 @@ static inline bool _NJSD_waitIRQ(void) { } //} else { // irq's enabled - // while (!(_NJSD_irqFlag) && --i); + // while (!(_NJSD_irqFlag) && --i); // _NJSD_irqFlag = 0; // REG_IF = 0x100000; // if (i <= 0) { @@ -118,8 +118,8 @@ static inline bool _NJSD_waitIRQ(void) { //#endif } -static inline void _NJSD_writeCardCommand - (u8 cmd0, u8 cmd1, u8 cmd2, u8 cmd3, u8 cmd4, u8 cmd5, u8 cmd6, u8 cmd7) +static inline void _NJSD_writeCardCommand + (u8 cmd0, u8 cmd1, u8 cmd2, u8 cmd3, u8 cmd4, u8 cmd5, u8 cmd6, u8 cmd7) { CARD_COMMAND[0] = cmd0; CARD_COMMAND[1] = cmd1; @@ -142,7 +142,7 @@ static bool _NJSD_reset (void) { if (i <= 0) { return false; } - + return true; } @@ -179,7 +179,7 @@ static bool _NJSD_sendCMDR (int speed, u8 *rsp_buf, int type, u8 cmd, u32 param) REG_IME = 0; #endif - REG_IE &= ~0x100000; + REG_IE &= ~0x100000; REG_IF = 0x100000; CARD_CR1H = CARD_CR1_ENABLE; @@ -191,7 +191,7 @@ static bool _NJSD_sendCMDR (int speed, u8 *rsp_buf, int type, u8 cmd, u32 param) } else { CARD_COMMAND[0] = 0xF0 | (speed << 2) | 0 | (1 << 1); } - + CARD_COMMAND[1] = (type & 0x40) | ((( type >> 2) & 7) << 3); CARD_COMMAND[2] = 0x40 | cmd; CARD_COMMAND[3] = (param>>24) & 0xFF; @@ -301,7 +301,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) { } - REG_IE &= ~0x100000; + REG_IE &= ~0x100000; REG_IF = 0x100000; CARD_CR1H = CARD_CR1_ENABLE; @@ -334,7 +334,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) { i++; } } while (CARD_CR2 & CARD_BUSY); - + i = WRITE_TIMEOUT; responseBuffer[3] = 0; do { @@ -352,7 +352,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) { #ifdef _NJSD_SYNC REG_IME = old_REG_IME; #endif - + return true; } @@ -365,12 +365,12 @@ static bool _NJSD_sendCLK (int speed, int count) { REG_IME = 0; #endif - REG_IE &= ~0x100000; + REG_IE &= ~0x100000; REG_IF = 0x100000; //CARD_CR1H = CARD_CR1_ENABLE; // | CARD_CR1_IRQ; _NJSD_writeCardCommand (0xE0 | ((speed & 3) << 2), 0, (count - 1), 0, 0, 0, 0, 0); - + CARD_CR2 = _NJSD_cardFlags; i = COMMAND_TIMEOUT; while ((CARD_CR2 & CARD_BUSY) && --i); @@ -404,7 +404,7 @@ static bool _NJSD_sendCMDN (int speed, u8 cmd, u32 param) { REG_IME = 0; #endif - REG_IE &= ~0x100000; + REG_IE &= ~0x100000; REG_IF = 0x100000; CARD_CR1H = CARD_CR1_ENABLE; // | CARD_CR1_IRQ; @@ -438,22 +438,22 @@ static bool _NJSD_sendCMDN (int speed, u8 cmd, u32 param) { static bool _NJSD_cardInit (void) { u8 responseBuffer[17]; int i; - + // If the commands succeed the first time, assume they'll always succeed if (! _NJSD_sendCLK (SD_CLK_200KHz, 256) ) return false; if (! _NJSD_sendCMDN (SD_CLK_200KHz, GO_IDLE_STATE, 0) ) return false; _NJSD_sendCLK (SD_CLK_200KHz, 8); - + _NJSD_sendCLK (SD_CLK_200KHz, 256); _NJSD_sendCMDN (SD_CLK_200KHz, GO_IDLE_STATE, 0); _NJSD_sendCLK (SD_CLK_200KHz, 8); - + for (i = 0; i < MAX_STARTUP_TRIES ; i++) { _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, APP_CMD, 0); - if ( + if ( _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SD_APP_OP_COND, SD_OCR_VALUE) && ((responseBuffer[1] & 0x80) != 0)) - { + { // Card is ready to receive commands now break; } @@ -461,10 +461,10 @@ static bool _NJSD_cardInit (void) { if (i >= MAX_STARTUP_TRIES) { return false; } - + // The card's name, as assigned by the manufacturer _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_136, ALL_SEND_CID, 0); - + // Get a new address for (i = 0; i < MAX_STARTUP_TRIES ; i++) { _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SEND_RELATIVE_ADDR, 0); @@ -479,17 +479,17 @@ static bool _NJSD_cardInit (void) { // Some cards won't go to higher speeds unless they think you checked their capabilities _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_136, SEND_CSD, _NJSD_relativeCardAddress); - + // Only this card should respond to all future commands _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SELECT_CARD, _NJSD_relativeCardAddress); - + // Set a 4 bit data bus _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, APP_CMD, _NJSD_relativeCardAddress); _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SET_BUS_WIDTH, 2); // 4-bit mode. // Use 512 byte blocks _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SET_BLOCKLEN, 512); // 512 byte blocks - + return true; } @@ -521,7 +521,7 @@ bool _NJSD_startup(void) { return false; } return true; -} +} bool _NJSD_writeSectors (u32 sector, u32 numSectors, const void* buffer) { @@ -531,7 +531,7 @@ bool _NJSD_writeSectors (u32 sector, u32 numSectors, const void* buffer) { while (numSectors--) { _SD_CRC16 ( data, BYTES_PER_READ, crc); - + if (! _NJSD_writeSector (data, crc, offset)) { return false; } @@ -549,7 +549,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { #ifdef _NJSD_SYNC u32 old_REG_IME; #endif - + u8* tbuf = (u8*)buffer; if (numSectors == 0) { @@ -573,7 +573,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { if (!_NJSD_waitIRQ ()) { #ifdef _NJSD_SYNC REG_IME = old_REG_IME; -#endif +#endif return false; } } @@ -586,10 +586,10 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { if (!_NJSD_waitIRQ ()) { #ifdef _NJSD_SYNC REG_IME = old_REG_IME; -#endif +#endif return false; } - + if (((int)buffer & 0x03) != 0){ cardPolledTransfer (0xA1406000, tmp, BYTES_PER_READ, (u8*)_NJSD_read_cmd); memcpy (tbuf + (numSectors - 1) * BYTES_PER_READ, tmp, BYTES_PER_READ); @@ -618,7 +618,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { #ifdef _NJSD_SYNC u32 old_REG_IME; #endif - + u8* tbuf = (u8*)buffer; if (numSectors == 0) { @@ -637,7 +637,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { if (!_NJSD_waitIRQ ()) { #ifdef _NJSD_SYNC REG_IME = old_REG_IME; -#endif +#endif return false; } } @@ -645,10 +645,10 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { if (!_NJSD_waitIRQ ()) { #ifdef _NJSD_SYNC REG_IME = old_REG_IME; -#endif +#endif return false; } - + cardPolledTransfer (0xA1406000, (u32*)(tbuf + (numSectors - 1) * BYTES_PER_READ), BYTES_PER_READ, (u8*)_NJSD_read_cmd); } else { _NJSD_sendCMDR (_NJSD_speed, NULL, SD_RSP_STREAM, READ_SINGLE_BLOCK, sector * BYTES_PER_READ); diff --git a/backends/platform/ds/arm9/source/fat/io_nmmc.c b/backends/platform/ds/arm9/source/fat/io_nmmc.c index a29c26e43a..261096a27b 100644 --- a/backends/platform/ds/arm9/source/fat/io_nmmc.c +++ b/backends/platform/ds/arm9/source/fat/io_nmmc.c @@ -13,10 +13,10 @@ project at chishm@hotmail.com See gba_nds_fat.txt for help and license details. - + 2006-02-09 - www.neoflash.com: * First stable release - + 2006-02-13 - Chishm * Added ReadMK2Config function * Added read config test to init function so no unnecessary card commands are sent @@ -87,7 +87,7 @@ void Neo_WriteMK2Config(u8 config) { Neo_EnableEEPROM(false); } -u8 Neo_ReadMK2Config(void) +u8 Neo_ReadMK2Config(void) { u8 config; Neo_EnableEEPROM(true); @@ -104,7 +104,7 @@ u8 Neo_ReadMK2Config(void) u8 selectMMC_command [8] = {0xFF, 0x00, 0x6A, 0xDF, 0x37, 0x59, 0x33, 0xA3}; -void Neo_SelectMMC (u8 dataByte) +void Neo_SelectMMC (u8 dataByte) { selectMMC_command[1] = dataByte; // Set enable / disable byte cardWriteCommand (selectMMC_command); // Send "5. Use the EEPROM CS to access the MK2 MMC/SD card" @@ -154,12 +154,12 @@ bool Neo_CheckMMCResponse( u8 response, u8 mask ) { bool Neo_InitMMC() { Neo_MK2GameMode(); Neo_WriteMK2Config( MK2_CONFIG_ZIP_RAM_CLOSE | MK2_CONFIG_GAME_FLASH_CLOSE); - + // Make sure the configuration was accepted if (Neo_ReadMK2Config() != (MK2_CONFIG_ZIP_RAM_CLOSE | MK2_CONFIG_GAME_FLASH_CLOSE)) { return false; // If not, then it wasn't initialised properly } - + return true; } @@ -167,7 +167,7 @@ bool Neo_InitMMC() { bool NMMC_IsInserted(void) { int i; - + Neo_EnableMMC( true ); // Open SPI port to MMC card Neo_SendMMCCommand(MMC_SEND_CSD, 0); if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured @@ -183,13 +183,13 @@ bool NMMC_IsInserted(void) { for (i = 0; i < 28; i++) { Neo_SPI(0xff); } - + return true; } bool NMMC_ClearStatus (void) { u32 i; - + Neo_EnableMMC( true ); // Open SPI port to MMC card for (i = 0; i < 10; i++) { Neo_SPI(0xFF); // Send 10 0xFF bytes to MMC card @@ -224,14 +224,14 @@ bool NMMC_StartUp(void) { return false; } Neo_EnableMMC( true ); // Open SPI port to MMC card - + // Set block length Neo_SendMMCCommand(MMC_SET_BLOCKLEN, BYTE_PER_READ ); if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured Neo_EnableMMC( false ); return false; } - + // Check if we can use a higher SPI frequency Neo_SendMMCCommand(MMC_SEND_CSD, 0); if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured @@ -252,77 +252,77 @@ bool NMMC_StartUp(void) { if ((transSpeed & 0xf0) >= 0x30) { spi_freq = 0; } - + Neo_EnableMMC( false ); return true; -} +} -bool NMMC_WriteSectors (u32 sector, u8 numSecs, void* buffer) +bool NMMC_WriteSectors (u32 sector, u8 numSecs, void* buffer) { u32 i; u8 *p=buffer; - + int totalSecs = (numSecs == 0) ? 256 : numSecs; sector *= BYTE_PER_READ; - + Neo_EnableMMC( true ); // Open SPI port to MMC card Neo_SendMMCCommand( 25, sector ); if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured Neo_EnableMMC( false ); return false; } - + while (totalSecs--) { Neo_SPI( 0xFC ); // Send Start Block token for( i = 0; i < BYTE_PER_READ; i++ ) // Send a block of data Neo_SPI( *p++ ); Neo_SPI( 0xFF ); // Send fake CRC16 Neo_SPI( 0xFF ); // Send fake CRC16 - + if( ( Neo_SPI( 0xFF ) & 0x0F ) != 0x05 ) { // Make sure the block was accepted Neo_EnableMMC( false ); return false; } while( Neo_SPI( 0xFF ) == 0x00 ); // Wait for the block to be written } - + // Stop transmission block Neo_SPI( 0xFD ); // Send Stop Transmission Block token for( i = 0; i < BYTE_PER_READ; i++ ) // Send a block of fake data Neo_SPI( 0xFF ); Neo_SPI( 0xFF ); // Send fake CRC16 Neo_SPI( 0xFF ); // Send fake CRC16 - + Neo_SPI (0xFF); // Send 8 clocks while( Neo_SPI( 0xFF ) == 0x00 ); // Wait for the busy signal to clear - - for ( i = 0; i < 0x10; i++) { + + for ( i = 0; i < 0x10; i++) { Neo_SPI (0xFF); // Send clocks for the MMC card to finish what it's doing } - + Neo_EnableMMC( false ); // Close SPI port to MMC card return true; } -bool NMMC_ReadSectors (u32 sector, u8 numSecs, void* buffer) +bool NMMC_ReadSectors (u32 sector, u8 numSecs, void* buffer) { u32 i; u8 *p=buffer; - + int totalSecs = (numSecs == 0) ? 256 : numSecs; sector *= BYTE_PER_READ; - + Neo_EnableMMC( true ); // Open SPI port to MMC card - + while (totalSecs--) { Neo_SendMMCCommand(MMC_READ_BLOCK, sector ); if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured Neo_EnableMMC( false ); return false; } - + if( Neo_CheckMMCResponse( 0xFE, 0xFF ) == false ) { // Check for Start Block token Neo_EnableMMC( false ); return false; @@ -333,7 +333,7 @@ bool NMMC_ReadSectors (u32 sector, u8 numSecs, void* buffer) Neo_SPI( 0xFF ); // Ignore CRC16 sector += BYTE_PER_READ; } - + Neo_EnableMMC( false ); // Close SPI port to MMC card return true; } diff --git a/backends/platform/ds/arm9/source/fat/io_sccf.c b/backends/platform/ds/arm9/source/fat/io_sccf.c index 0c77f4673c..bda628fdaa 100644 --- a/backends/platform/ds/arm9/source/fat/io_sccf.c +++ b/backends/platform/ds/arm9/source/fat/io_sccf.c @@ -57,7 +57,7 @@ bool SCCF_Unlock(void) temp = (~temp & 0xFF); return (CF_REG_LBA1 == temp); #undef CF_REG_LBA1 -} +} bool SCCF_Shutdown(void) { return MPCF_ClearStatus() ; diff --git a/backends/platform/ds/arm9/source/fat/io_scsd.c b/backends/platform/ds/arm9/source/fat/io_scsd.c index 9359fefb6d..0a6ab5a528 100644 --- a/backends/platform/ds/arm9/source/fat/io_scsd.c +++ b/backends/platform/ds/arm9/source/fat/io_scsd.c @@ -1,8 +1,8 @@ /* io_scsd.c by SaTa. based on io_sccf.c - - + + */ /* @@ -43,7 +43,7 @@ extern void InitSCMode(void); // CF extern void ReadSector(u16 *buff,u32 sector,u8 ReadNumber); extern void WriteSector(u16 *buff,u32 sector,u8 writeNumber); extern bool MemoryCard_IsInserted(void); // CF‚ƈႤ -// +// /*----------------------------------------------------------------- SCSD_Unlock @@ -55,7 +55,7 @@ bool SCSD_Unlock(void) { InitSCMode(); return MemoryCard_IsInserted(); -} +} bool SCSD_Shutdown(void) { return MPCF_ClearStatus() ; diff --git a/backends/platform/ds/arm9/source/fat/io_sd_common.c b/backends/platform/ds/arm9/source/fat/io_sd_common.c index 0a38e6277c..ade9df0d80 100644 --- a/backends/platform/ds/arm9/source/fat/io_sd_common.c +++ b/backends/platform/ds/arm9/source/fat/io_sd_common.c @@ -5,10 +5,10 @@ Common SD card routines - SD routines partially based on sd.s by Romman + SD routines partially based on sd.s by Romman Copyright (c) 2006 Michael "Chishm" Chisholm - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + 2006-08-07 - Chishm * Moved the SD initialization to a common function * Increased timeouts for slower cards @@ -61,10 +61,10 @@ u8 _SD_CRC7(u8* data, int cnt) { } crc = (crc << 1) | 1; return(crc); -} +} /* -Calculates the CRC16 for a sector of data. Calculates it +Calculates the CRC16 for a sector of data. Calculates it as 4 separate lots, merged into one buffer. This is used for 4 SD data lines, not for 1 data line alone. */ @@ -79,53 +79,53 @@ void _SD_CRC16 (u8* buff, int buffLength, u8* crc16buff) { b = 0; // r4 c = 0; // r5 d = 0; // r6 - + buffLength = buffLength * 8; - - + + do { if (bitPattern & 0x80) dataByte = *buff++; - + a = a << 1; if ( a & 0x10000) a ^= crcConst; if (dataByte & (bitPattern >> 24)) a ^= crcConst; - + b = b << 1; if (b & 0x10000) b ^= crcConst; if (dataByte & (bitPattern >> 25)) b ^= crcConst; - + c = c << 1; if (c & 0x10000) c ^= crcConst; if (dataByte & (bitPattern >> 26)) c ^= crcConst; - + d = d << 1; if (d & 0x10000) d ^= crcConst; if (dataByte & (bitPattern >> 27)) d ^= crcConst; - + bitPattern = (bitPattern >> 4) | (bitPattern << 28); } while (buffLength-=4); - + count = 16; // r8 - + do { bitPattern = bitPattern << 4; if (a & 0x8000) bitPattern |= 8; if (b & 0x8000) bitPattern |= 4; if (c & 0x8000) bitPattern |= 2; if (d & 0x8000) bitPattern |= 1; - + a = a << 1; b = b << 1; c = c << 1; d = d << 1; - + count--; - + if (!(count & 0x01)) { *crc16buff++ = (u8)(bitPattern & 0xff); } } while (count != 0); - + return; } @@ -136,20 +136,20 @@ cmd_17byte_response: a pointer to a function that sends the SD card a command an use4bitBus: initialise card to use a 4 bit data bus when communicating with the card RCA: a pointer to the location to store the card's Relative Card Address, preshifted up by 16 bits. */ -bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, +bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, _SD_FN_CMD_17BYTE_RESPONSE cmd_17byte_response, bool use4bitBus, u32 *RCA) { u8 responseBuffer[17] = {0}; int i; - + for (i = 0; i < MAX_STARTUP_TRIES ; i++) { cmd_6byte_response (responseBuffer, APP_CMD, 0); - if ( + if ( cmd_6byte_response (responseBuffer, SD_APP_OP_COND, SD_OCR_VALUE) && ((responseBuffer[1] & 0x80) != 0)) - { + { // Card is ready to receive commands now break; } @@ -157,10 +157,10 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, if (i >= MAX_STARTUP_TRIES) { return false; } - + // The card's name, as assigned by the manufacturer cmd_17byte_response (responseBuffer, ALL_SEND_CID, 0); - + // Get a new address for (i = 0; i < MAX_STARTUP_TRIES ; i++) { cmd_6byte_response (responseBuffer, SEND_RELATIVE_ADDR, 0); @@ -175,10 +175,10 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, // Some cards won't go to higher speeds unless they think you checked their capabilities cmd_17byte_response (responseBuffer, SEND_CSD, *RCA); - + // Only this card should respond to all future commands cmd_6byte_response (responseBuffer, SELECT_CARD, *RCA); - + if (use4bitBus) { // Set a 4 bit data bus cmd_6byte_response (responseBuffer, APP_CMD, *RCA); @@ -187,7 +187,7 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, // Use 512 byte blocks cmd_6byte_response (responseBuffer, SET_BLOCKLEN, 512); // 512 byte blocks - + // Wait until card is ready for data i = 0; do { @@ -196,7 +196,7 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, } i++; } while (!cmd_6byte_response (responseBuffer, SEND_STATUS, *RCA) && ((responseBuffer[3] & 0x1f) != ((SD_STATE_TRAN << 1) | READY_FOR_DATA))); - + return true; } diff --git a/backends/platform/iphone/iphone_keyboard.m b/backends/platform/iphone/iphone_keyboard.m index a5052ac077..ba19773a34 100644 --- a/backends/platform/iphone/iphone_keyboard.m +++ b/backends/platform/iphone/iphone_keyboard.m @@ -45,11 +45,11 @@ - (id)initWithKeyboard:(SoftKeyboard*)keyboard; { self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)]; softKeyboard = keyboard; - + [[self textInputTraits] setAutocorrectionType:1]; [[self textInputTraits] setAutocapitalizationType:0]; [[self textInputTraits] setEnablesReturnKeyAutomatically:NO]; - + return self; } @@ -67,7 +67,7 @@ } [softKeyboard handleKeyPress:[character characterAtIndex:0]]; - + return NO; } diff --git a/backends/platform/iphone/iphone_main.m b/backends/platform/iphone/iphone_main.m index 1cda168cd0..d8992de5bb 100644 --- a/backends/platform/iphone/iphone_main.m +++ b/backends/platform/iphone/iphone_main.m @@ -48,7 +48,7 @@ int main(int argc, char** argv) { gArgc = argc; gArgv = argv; - NSAutoreleasePool *autoreleasePool = [ + NSAutoreleasePool *autoreleasePool = [ [ NSAutoreleasePool alloc ] init ]; @@ -99,7 +99,7 @@ int main(int argc, char** argv) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:@"UIDeviceOrientationDidChangeNotification" object:nil]; - + [NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil]; } @@ -111,7 +111,7 @@ int main(int argc, char** argv) { - (void)applicationResume:(struct __GSEvent *)event { [self removeApplicationBadge]; [_view applicationResume]; - + // Workaround, need to "hide" and unhide the statusbar to properly remove it, // since the Springboard has put it back without apparently flagging our application. [self setStatusBarHidden:YES animated:YES]; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 690e2339ae..0392172aa2 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -48,13 +48,13 @@ void iPhone_updateScreen() { void iPhone_updateScreenRect(unsigned short* screen, int x1, int y1, int x2, int y2) { [_lock lock]; - + int y; for (y = y1; y < y2; ++y) { memcpy(&_textureBuffer[(y * _textureWidth + x1 )* 2], &screen[y * _width + x1], (x2 - x1) * 2); } - [_lock unlock]; + [_lock unlock]; } @@ -104,13 +104,13 @@ bool getLocalMouseCoords(CGPoint *point) { uint getSizeNextPOT(uint size) { if ((size & (size - 1)) || !size) { int log = 0; - + while (size >>= 1) ++log; - + size = (2 << log); } - + return size; } @@ -129,7 +129,7 @@ uint getSizeNextPOT(uint size) { _screenLayer = nil; sharedInstance = self; - + _lock = [NSLock new]; _keyboardView = nil; _context = nil; @@ -144,7 +144,7 @@ uint getSizeNextPOT(uint size) { if (_keyboardView != nil) { [_keyboardView dealloc]; } - + if (_screenTexture) free(_textureBuffer); } @@ -188,7 +188,7 @@ uint getSizeNextPOT(uint size) { texWidth, texHeight, 0.0f, texHeight }; - + glVertexPointer(2, GL_FLOAT, 0, vertices); glTexCoordPointer(2, GL_FLOAT, 0, texCoords); @@ -201,7 +201,7 @@ uint getSizeNextPOT(uint size) { glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); - [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; + [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; } @@ -212,55 +212,55 @@ uint getSizeNextPOT(uint size) { UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _textureWidth, _textureHeight); - + if (_context == nil) { orientation = UIDeviceOrientationLandscapeRight; CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer; - + eaglLayer.opaque = YES; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; - + _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; if (!_context || [EAGLContext setCurrentContext:_context]) { glGenFramebuffersOES(1, &_viewFramebuffer); glGenRenderbuffersOES(1, &_viewRenderbuffer); - + glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id)self.layer]; glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); - + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_backingWidth); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_backingHeight); - + if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); return; } - + glViewport(0, 0, _backingWidth, _backingHeight); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - + glEnable(GL_TEXTURE_2D); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); } } glMatrixMode(GL_PROJECTION); glLoadIdentity(); - + if (orientation == UIDeviceOrientationLandscapeRight) { glRotatef(-90, 0, 0, 1); } else if (orientation == UIDeviceOrientationLandscapeLeft) { - glRotatef(90, 0, 0, 1); + glRotatef(90, 0, 0, 1); } else { glRotatef(180, 0, 0, 1); } - + glOrthof(0, _backingWidth, 0, _backingHeight, 0, 1); - + if (_screenTexture > 0) { glDeleteTextures(1, &_screenTexture); } @@ -268,7 +268,7 @@ uint getSizeNextPOT(uint size) { glGenTextures(1, &_screenTexture); glBindTexture(GL_TEXTURE_2D, _screenTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - + if (_textureBuffer) { free(_textureBuffer); } @@ -276,7 +276,7 @@ uint getSizeNextPOT(uint size) { int textureSize = _textureWidth * _textureHeight * 2; _textureBuffer = (char*)malloc(textureSize); memset(_textureBuffer, 0, textureSize); - + glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); // The color buffer is triple-buffered, so we clear it multiple times right away to avid doing any glClears later. @@ -285,7 +285,7 @@ uint getSizeNextPOT(uint size) { glClear(GL_COLOR_BUFFER_BIT); [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; } - + if (_keyboardView != nil) { [_keyboardView removeFromSuperview]; [[_keyboardView inputView] removeFromSuperview]; @@ -327,7 +327,7 @@ uint getSizeNextPOT(uint size) { _keyboardView = [[SoftKeyboard alloc] initWithFrame:keyFrame]; [_keyboardView setInputDelegate:self]; } - + [self addSubview:[_keyboardView inputView]]; [self addSubview: _keyboardView]; [[_keyboardView inputView] becomeFirstResponder]; @@ -370,7 +370,7 @@ uint getSizeNextPOT(uint size) { - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; - + switch ([allTouches count]) { case 1: { @@ -378,7 +378,7 @@ uint getSizeNextPOT(uint size) { CGPoint point = [touch locationInView:self]; if (!getLocalMouseCoords(&point)) return; - + [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseDown], @"type", @@ -386,16 +386,16 @@ uint getSizeNextPOT(uint size) { [NSNumber numberWithFloat:point.y], @"y", nil ] - ]; + ]; break; - } + } case 2: { UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; CGPoint point = [touch locationInView:self]; if (!getLocalMouseCoords(&point)) return; - + [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseSecondDown], @"type", @@ -403,16 +403,16 @@ uint getSizeNextPOT(uint size) { [NSNumber numberWithFloat:point.y], @"y", nil ] - ]; + ]; break; - } + } } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; - + switch ([allTouches count]) { case 1: { @@ -420,7 +420,7 @@ uint getSizeNextPOT(uint size) { CGPoint point = [touch locationInView:self]; if (!getLocalMouseCoords(&point)) return; - + [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseDragged], @"type", @@ -428,16 +428,16 @@ uint getSizeNextPOT(uint size) { [NSNumber numberWithFloat:point.y], @"y", nil ] - ]; + ]; break; - } + } case 2: { UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; CGPoint point = [touch locationInView:self]; if (!getLocalMouseCoords(&point)) return; - + [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseSecondDragged], @"type", @@ -445,16 +445,16 @@ uint getSizeNextPOT(uint size) { [NSNumber numberWithFloat:point.y], @"y", nil ] - ]; + ]; break; - } + } } } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; - + switch ([allTouches count]) { case 1: { @@ -462,7 +462,7 @@ uint getSizeNextPOT(uint size) { CGPoint point = [touch locationInView:self]; if (!getLocalMouseCoords(&point)) return; - + [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseUp], @"type", @@ -470,16 +470,16 @@ uint getSizeNextPOT(uint size) { [NSNumber numberWithFloat:point.y], @"y", nil ] - ]; + ]; break; - } + } case 2: { UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; CGPoint point = [touch locationInView:self]; if (!getLocalMouseCoords(&point)) return; - + [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseSecondUp], @"type", @@ -487,15 +487,15 @@ uint getSizeNextPOT(uint size) { [NSNumber numberWithFloat:point.y], @"y", nil ] - ]; + ]; break; - } + } } } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - + } - (void)handleKeyPress:(unichar)c { diff --git a/backends/platform/ps2/cd.c b/backends/platform/ps2/cd.c index 5694d9a960..cd44b3d034 100644 --- a/backends/platform/ps2/cd.c +++ b/backends/platform/ps2/cd.c @@ -29,7 +29,7 @@ int cdvdInit(int mode) u8 *pkt; cdvdCd.server = NULL; - + do { if ((ret = SifBindRpc(&cdvdCd, CDVD_INIT_BIND_RPC, 0)) < 0) { return -1; @@ -40,14 +40,14 @@ int cdvdInit(int mode) } while(!cdvdCd.server); - pkt = sendBuffer; + pkt = sendBuffer; PUSHDATA( int, pkt, mode, i); pkt += i; len += i; if ((ret = SifCallRpc(&cdvdCd, 0, 0, sendBuffer, len, NULL, 0, 0, 0)) < 0) return -1; - + cdvdInitialised = 1; - + return 0; } diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c b/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c index e5eb76fdc8..b423b44a1d 100644 --- a/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c +++ b/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c @@ -76,7 +76,7 @@ int cacheEnterDir(ISODirectoryRecord *dir) { cacheName = cachedDir + strlen(cachedDir); memcpy(cacheName, dir->name, dir->len_fi); cacheName[dir->len_fi] = '/'; - cacheName[dir->len_fi + 1] = '\0'; + cacheName[dir->len_fi + 1] = '\0'; return cdReadSectors(cachedDirLba, 1, cacheBuf, &rmode); } @@ -144,7 +144,7 @@ ISODirectoryRecord *findPath(const char *path) { initRootCache(); return (ISODirectoryRecord *)cacheBuf; } - + do { tok = strchr(path, '/'); if (tok) diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c b/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c index f4d512a6e4..a64b2f2f3b 100644 --- a/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c +++ b/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c @@ -162,7 +162,7 @@ int cd_read(iop_file_t *handle, void *dest, int length) { doCopy = 0x800 - readPos; if (doCopy > bytesLeft) doCopy = bytesLeft; - + memcpy(destPos, fd->buf + readPos, doCopy); readPos += doCopy; readLba += readPos >> 11; @@ -180,7 +180,7 @@ int cd_read(iop_file_t *handle, void *dest, int length) { bytesLeft &= 0x7FF; } } - return destPos - (uint8*)dest; + return destPos - (uint8*)dest; } int cd_close(iop_file_t *handle) { @@ -204,7 +204,7 @@ int cd_dopen(iop_file_t *handle, const char *path) { return -ENOENT; fdSlot = allocDioHandle(); - + if (fdSlot < 0) return -ENFILE; diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c b/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c index c46d452d2c..a9bfd636c7 100644 --- a/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c +++ b/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c @@ -48,7 +48,7 @@ int initRpc(void) { thread.attr = 0; tid = CreateThread(&thread); - if (tid >= 0) + if (tid >= 0) StartThread(tid, 0); else { printf("Unable to start RPC Thread!\n"); diff --git a/backends/platform/ps2/iop/rpckbd/src/ps2kbd.c b/backends/platform/ps2/iop/rpckbd/src/ps2kbd.c index f87a47f0cb..bb7de8ff2b 100644 --- a/backends/platform/ps2/iop/rpckbd/src/ps2kbd.c +++ b/backends/platform/ps2/iop/rpckbd/src/ps2kbd.c @@ -137,7 +137,7 @@ int ps2kbd_probe(int devId) //printf("PS2Kbd_probe devId %d\n", devId); dev = UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); /* Get device descriptor */ - if(!dev) + if(!dev) { printf("ERROR: Couldn't get device descriptor\n"); return 0; @@ -164,7 +164,7 @@ int ps2kbd_probe(int devId) printf("ERROR: No interfaces available\n"); return 0; } - + intf = (UsbInterfaceDescriptor *) ((char *) conf + conf->bLength); /* Get first interface */ /* printf("Interface Length %d Endpoints %d Class %d Sub %d Proto %d\n", intf->bLength, */ /* intf->bNumEndpoints, intf->bInterfaceClass, intf->bInterfaceSubClass, */ @@ -182,7 +182,7 @@ int ps2kbd_probe(int devId) endp = (UsbEndpointDescriptor *) ((char *) endp + endp->bLength); /* Go to the data endpoint */ //printf("Endpoint 1 Addr %d, Attr %d, MaxPacket %d\n", endp->bEndpointAddress, endp->bmAttributes, endp->wMaxPacketSizeLB); - + if(((endp->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) || ((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_IN)) { @@ -210,7 +210,7 @@ int ps2kbd_connect(int devId) //printf("PS2Kbd_connect devId %d\n", devId); dev = UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); /* Get device descriptor */ - if(!dev) + if(!dev) { printf("ERROR: Couldn't get device descriptor\n"); return 1; @@ -222,7 +222,7 @@ int ps2kbd_connect(int devId) printf("ERROR: Couldn't get configuration descriptor\n"); return 1; } - + intf = (UsbInterfaceDescriptor *) ((char *) conf + conf->bLength); /* Get first interface */ endp = (UsbEndpointDescriptor *) ((char *) intf + intf->bLength); endp = (UsbEndpointDescriptor *) ((char *) endp + endp->bLength); /* Go to the data endpoint */ @@ -311,7 +311,7 @@ typedef struct _string_descriptor { u8 buf[200]; char *desc; -} string_descriptor; +} string_descriptor; void ps2kbd_getstring_set(int resultCode, int bytes, void *arg) @@ -334,7 +334,7 @@ void ps2kbd_getstring_set(int resultCode, int bytes, void *arg) } printf("%s: %s\n", strBuf->desc, string); } - + FreeSysMemory(arg); } @@ -343,7 +343,7 @@ void usb_getstring(int endp, int index, char *desc) { u8 *data; string_descriptor *str; - int ret; + int ret; data = (u8 *) AllocSysMemory(0, sizeof(string_descriptor), NULL); str = (string_descriptor *) data; @@ -351,7 +351,7 @@ void usb_getstring(int endp, int index, char *desc) if(data != NULL) { str->desc = desc; - ret = UsbControlTransfer(endp, 0x80, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) | index, + ret = UsbControlTransfer(endp, 0x80, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) | index, 0, sizeof(string_descriptor) - 4, data, ps2kbd_getstring_set, data); if(ret != USB_RC_OK) { @@ -380,7 +380,7 @@ void ps2kbd_config_set(int resultCode, int bytes, void *arg) if(dev != NULL) { int ret; - + ret = UsbControlTransfer(dev->configEndp, 0x21, USB_REQ_SET_IDLE, 0, dev->interfaceNo, 0, NULL, ps2kbd_idlemode_set, arg); } } @@ -397,12 +397,12 @@ void ps2kbd_idlemode_set(int resultCode, int bytes, void *arg) printf("PS2KBD: Idlemode set error res %d, bytes %d, arg %p\n", resultCode, bytes, arg); return; } - + dev = (kbd_dev *) arg; if(dev != NULL) { int ret; - + ret = UsbInterruptTransfer(dev->dataEndp, &dev->data, dev->packetSize, ps2kbd_data_recv, arg); } } @@ -474,7 +474,7 @@ void ps2kbd_getkeys(u8 keyMods, u8 ledStatus, const u8 *keys, kbd_dev *dev) { tempPos = lineStartP; } - + for(loopKey = 0; loopKey < PS2KBD_MAXKEYS; loopKey++) { u8 currKey = keys[loopKey]; @@ -581,7 +581,7 @@ void ps2kbd_getkeys(u8 keyMods, u8 ledStatus, const u8 *keys, kbd_dev *dev) } } - if(byteCount > 0) + if(byteCount > 0) { iop_sys_clock_t t; /* Set alarm to do repeat rate */ @@ -619,11 +619,11 @@ void ps2kbd_getkeys_raw(u8 newKeyMods, u8 oldKeyMods, u8 *new, const u8 *old) { tempPos = lineStartP; } - + for(loopKey = 0; loopKey < 8; loopKey++) { int currMod = (1 << loopKey); - if(keyMods & currMod) + if(keyMods & currMod) { if(lineEndP == (tempPos - 2)) { @@ -708,7 +708,7 @@ void ps2kbd_data_recv(int resultCode, int bytes, void *arg) printf("PS2KEYBOARD: Data Recv set res %d, bytes %d, arg %p\n", resultCode, bytes, arg); return; } - + //printf("PS2KBD: Data Recv set res %d, bytes %d, arg %p\n", resultCode, bytes, arg); dev = (kbd_dev *) arg; @@ -717,7 +717,7 @@ void ps2kbd_data_recv(int resultCode, int bytes, void *arg) printf("PS2KBD: dev == NULL\n"); return; } - + /* printf("PS2KBD Modifiers %02X, Keys ", dev->data.mod_keys); */ /* for(loop = 0; loop < PS2KBD_MAXKEYS; loop++) */ /* { */ @@ -737,7 +737,7 @@ void ps2kbd_data_recv(int resultCode, int bytes, void *arg) break; } } - + if(!phantom) /* If not in a phantom state */ { u8 uniqueKeys[PS2KBD_MAXKEYS]; @@ -763,23 +763,23 @@ void ps2kbd_data_recv(int resultCode, int bytes, void *arg) /* printf("%02X ", missingKeys[loopKey]); */ /* } */ /* printf("\n"); */ - + if(kbd_readmode == PS2KBD_READMODE_NORMAL) { u8 ledStatus; ledStatus = dev->ledStatus; //printf("ledStatus %02X\n", ledStatus); - + for(loopKey = 0; loopKey < PS2KBD_MAXKEYS; loopKey++) /* Process key codes */ { switch(uniqueKeys[loopKey]) { - case USB_KEYB_NUMLOCK : + case USB_KEYB_NUMLOCK : ledStatus ^= PS2KBD_LED_NUMLOCK; uniqueKeys[loopKey] = 0; break; - case USB_KEYB_CAPSLOCK : + case USB_KEYB_CAPSLOCK : ledStatus ^= PS2KBD_LED_CAPSLOCK; uniqueKeys[loopKey] = 0; break; @@ -789,16 +789,16 @@ void ps2kbd_data_recv(int resultCode, int bytes, void *arg) break; } } - + if(ledStatus != dev->ledStatus) { dev->ledStatus = ledStatus & PS2KBD_LED_MASK; //printf("LEDS %02X\n", dev->ledStatus); /* Call Set LEDS */ - UsbControlTransfer(dev->configEndp, 0x21, USB_REQ_SET_REPORT, 0x200, + UsbControlTransfer(dev->configEndp, 0x21, USB_REQ_SET_REPORT, 0x200, dev->interfaceNo, 1, &dev->ledStatus, ps2kbd_led_set, arg); } - + WaitSema(lineSema); /* Make sure no other thread is going to manipulate the buffer */ ps2kbd_getkeys(dev->data.mod_keys, dev->ledStatus, uniqueKeys, dev); /* read in remaining keys */ SignalSema(lineSema); @@ -812,7 +812,7 @@ void ps2kbd_data_recv(int resultCode, int bytes, void *arg) memcpy(&dev->oldData, &dev->data, sizeof(kbd_data_recv)); } - + ret = UsbInterruptTransfer(dev->dataEndp, &dev->data, dev->packetSize, ps2kbd_data_recv, arg); } @@ -824,14 +824,14 @@ void flushbuffer() lineStartP = 0; lineEndP = 0; memset(lineBuffer, 0, lineSize); - + DeleteSema(bufferSema); s.initial = 0; s.max = lineSize; s.option = 0; s.attr = 0; bufferSema = CreateSema(&s); /* Create a sema to maintain status of readable data */ - + if(bufferSema <= 0) { printf("Error creating buffer sema\n"); @@ -843,7 +843,7 @@ void ps2kbd_rpc_setreadmode(u32 readmode) { int devLoop; - if(readmode == kbd_readmode) return; + if(readmode == kbd_readmode) return; if((readmode == PS2KBD_READMODE_NORMAL) || (readmode == PS2KBD_READMODE_RAW)) { @@ -1006,7 +1006,7 @@ void repeat_thread(void *arg) if(lineEndP != (tempPos - 2)) { lineBuffer[lineEndP++] = devices[devLoop]->repeatkeys[0]; - lineEndP %= lineSize; + lineEndP %= lineSize; lineBuffer[lineEndP++] = devices[devLoop]->repeatkeys[1]; lineEndP %= lineSize; SignalSema(bufferSema); @@ -1018,7 +1018,7 @@ void repeat_thread(void *arg) if(lineEndP != (tempPos - 1)) { lineBuffer[lineEndP++] = devices[devLoop]->repeatkeys[0]; - lineEndP %= lineSize; + lineEndP %= lineSize; SignalSema(bufferSema); } } @@ -1051,7 +1051,7 @@ int init_repeatthread() StartThread(repeat_tid, 0); return 0; } - else + else { return 1; } @@ -1171,7 +1171,7 @@ int ps2kbd_init() { lineEndP = 0; lineSize = PS2KBD_DEFLINELEN; memset(lineBuffer, 0, PS2KBD_DEFLINELEN); - + memset(devices, 0, sizeof(kbd_dev *) * PS2KBD_MAXDEV); dev_count = 0; kbd_readmode = PS2KBD_READMODE_NORMAL; diff --git a/backends/platform/ps2/rpckbd.c b/backends/platform/ps2/rpckbd.c index 8291df681a..0d37e4cfcb 100644 --- a/backends/platform/ps2/rpckbd.c +++ b/backends/platform/ps2/rpckbd.c @@ -58,7 +58,7 @@ int PS2KbdRead(char *key) int res; if ((!kbdInitialized) || (curr_readmode != PS2KBD_READMODE_NORMAL)) return -1; - + if (PollSema(kbdRpcSema) >= 0) { // last rpc call completed res = (rpcKey != 0); -- cgit v1.2.3