- Corrected whitespace formatting with Astyle tool.

git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@132 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
Frank Voorburg 2016-03-01 14:24:23 +00:00
parent efbab9c73d
commit 90b766c778
173 changed files with 41206 additions and 38694 deletions

20
Doc/astyle.bat Normal file
View File

@ -0,0 +1,20 @@
@echo off
rem Configuration file for Astyle. Can be downloaded from: https://sourceforge.net/projects/astyle/?source=typ_redirect
rem Example usage: C:\Work\software\OpenBLT\Target\Source>..\..\Doc\astyle.bat *.c *.h
set ASTYLE_BIN="C:\AStyle\bin"
set ASTYLE_CODESTYLE_PARAMS=--mode=c --style=allman --indent=spaces=2 --indent-switches --pad-header --unpad-paren --lineend=windows --add-brackets --align-pointer=name
set ASTYLE_EXECUTION_PARAMS=--suffix=none --formatted --ignore-exclude-errors-x --recursive
echo.
echo ------------------ prepare astyle ---------------------------------------------
echo.
%ASTYLE_BIN%\AStyle.exe --version
echo style params: %ASTYLE_CODESTYLE_PARAMS%
echo exec params : %ASTYLE_EXECUTION_PARAMS%
echo user params : %*
echo target dir : %CD%
echo.
echo ------------------ astyle execution -------------------------------------------
echo.
%ASTYLE_BIN%\AStyle.exe %ASTYLE_CODESTYLE_PARAMS% %ASTYLE_EXECUTION_PARAMS% %*
echo.
echo ------------------ astyle done ------------------------------------------------

View File

@ -92,7 +92,7 @@ typedef struct
typedef struct
{
blt_addr base_addr; /**< Base address for the flash operation.*/
blt_int8u data[FLASH_WRITE_BLOCK_SIZE] __attribute__ ((aligned (4))); /**< Data array. */
blt_int8u data[FLASH_WRITE_BLOCK_SIZE] __attribute__((aligned(4))); /**< Data array. */
} tFlashBlockInfo;
@ -188,7 +188,7 @@ static const tFlashSector flashLayout[] =
* harvested, ideally until there is enough to program an entire flash block,
* before the flash device is actually operated on.
*/
static tFlashBlockInfo blockInfo;
static tFlashBlockInfo blockInfo;
/** \brief Local variable with information about the flash boot block.
* \details The first block of the user program holds the vector table, which on the
@ -241,8 +241,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
blt_addr base_addr;
/* make sure the addresses are within the flash device */
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -277,7 +277,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
first_sector = FlashGetSector(addr);
last_sector = FlashGetSector(addr+len-1);
/* check them */
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -319,27 +319,27 @@ blt_bool FlashWriteChecksum(void)
* bootblock is not part of the reprogramming this time and therefore no
* new checksum needs to be written
*/
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
return BLT_TRUE;
}
}
/* compute the checksum. note that the user program's vectors are not yet written
* to flash but are present in the bootblock data structure at this point.
*/
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x1C]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x1C]));
signature_checksum = ~signature_checksum; /* one's complement */
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+0x14, sizeof(blt_addr),
(blt_int8u*)&signature_checksum);
(blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -354,14 +354,14 @@ blt_bool FlashVerifyChecksum(void)
blt_int32u signature_checksum = 0;
/* verify the checksum based on how it was written by CpuWriteChecksum() */
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x1C));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x1C));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
@ -652,8 +652,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
{
return BLT_FALSE;
}
if ( (first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
if ((first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
{
return BLT_FALSE;
}
@ -716,9 +716,9 @@ static blt_int8u FlashGetSector(blt_addr address)
/* keep the watchdog happy */
CopService();
/* is the address in this sector? */
if ( (address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)) )
if ((address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)))
{
/* return the sector number */
return flashLayout[sectorIdx].sector_num;

View File

@ -92,7 +92,7 @@ typedef struct
typedef struct
{
blt_addr base_addr; /**< Base address for the flash operation.*/
blt_int8u data[FLASH_WRITE_BLOCK_SIZE] __attribute__ ((aligned (4))); /**< Data array. */
blt_int8u data[FLASH_WRITE_BLOCK_SIZE] __attribute__((aligned(4))); /**< Data array. */
} tFlashBlockInfo;
@ -188,7 +188,7 @@ static const tFlashSector flashLayout[] =
* harvested, ideally until there is enough to program an entire flash block,
* before the flash device is actually operated on.
*/
static tFlashBlockInfo blockInfo;
static tFlashBlockInfo blockInfo;
/** \brief Local variable with information about the flash boot block.
* \details The first block of the user program holds the vector table, which on the
@ -241,8 +241,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
blt_addr base_addr;
/* make sure the addresses are within the flash device */
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -277,7 +277,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
first_sector = FlashGetSector(addr);
last_sector = FlashGetSector(addr+len-1);
/* check them */
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -319,27 +319,27 @@ blt_bool FlashWriteChecksum(void)
* bootblock is not part of the reprogramming this time and therefore no
* new checksum needs to be written
*/
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
return BLT_TRUE;
}
}
/* compute the checksum. note that the user program's vectors are not yet written
* to flash but are present in the bootblock data structure at this point.
*/
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x1C]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x1C]));
signature_checksum = ~signature_checksum; /* one's complement */
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+0x14, sizeof(blt_addr),
(blt_int8u*)&signature_checksum);
(blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -354,14 +354,14 @@ blt_bool FlashVerifyChecksum(void)
blt_int32u signature_checksum = 0;
/* verify the checksum based on how it was written by CpuWriteChecksum() */
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x1C));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x1C));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
@ -652,8 +652,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
{
return BLT_FALSE;
}
if ( (first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
if ((first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
{
return BLT_FALSE;
}
@ -716,9 +716,9 @@ static blt_int8u FlashGetSector(blt_addr address)
/* keep the watchdog happy */
CopService();
/* is the address in this sector? */
if ( (address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)) )
if ((address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)))
{
/* return the sector number */
return flashLayout[sectorIdx].sector_num;

View File

@ -41,9 +41,9 @@
/****************************************************************************************
* Function prototypes
****************************************************************************************/
void __attribute__ ((interrupt("FIQ"))) FIQ_ISR(void);
void __attribute__ ((interrupt("IRQ"))) IRQ_ISR(void);
void __attribute__ ((interrupt("UNDEF"))) UNDEF_ISR(void);
void __attribute__((interrupt("FIQ"))) FIQ_ISR(void);
void __attribute__((interrupt("IRQ"))) IRQ_ISR(void);
void __attribute__((interrupt("UNDEF"))) UNDEF_ISR(void);
/************************************************************************************//**

View File

@ -111,26 +111,27 @@ typedef struct t_can_bus_timing
* a sample point between 68..78%.
*/
static const tCanBusTiming canTiming[] =
{ /* TQ | TSEG1 | TSEG2 | SP */
/* ------------------------- */
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
{ 6, 3 }, /* 10 | 6 | 3 | 70% */
{ 7, 3 }, /* 11 | 7 | 3 | 73% */
{ 8, 3 }, /* 12 | 8 | 3 | 75% */
{ 9, 3 }, /* 13 | 9 | 3 | 77% */
{ 9, 4 }, /* 14 | 9 | 4 | 71% */
{ 10, 4 }, /* 15 | 10 | 4 | 73% */
{ 11, 4 }, /* 16 | 11 | 4 | 75% */
{ 12, 4 }, /* 17 | 12 | 4 | 76% */
{ 12, 5 }, /* 18 | 12 | 5 | 72% */
{ 13, 5 }, /* 19 | 13 | 5 | 74% */
{ 14, 5 }, /* 20 | 14 | 5 | 75% */
{ 15, 5 }, /* 21 | 15 | 5 | 76% */
{ 15, 6 }, /* 22 | 15 | 6 | 73% */
{ 16, 6 }, /* 23 | 16 | 6 | 74% */
{ 16, 7 }, /* 24 | 16 | 7 | 71% */
{ 16, 8 } /* 25 | 16 | 8 | 68% */
{
/* TQ | TSEG1 | TSEG2 | SP */
/* ------------------------- */
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
{ 6, 3 }, /* 10 | 6 | 3 | 70% */
{ 7, 3 }, /* 11 | 7 | 3 | 73% */
{ 8, 3 }, /* 12 | 8 | 3 | 75% */
{ 9, 3 }, /* 13 | 9 | 3 | 77% */
{ 9, 4 }, /* 14 | 9 | 4 | 71% */
{ 10, 4 }, /* 15 | 10 | 4 | 73% */
{ 11, 4 }, /* 16 | 11 | 4 | 75% */
{ 12, 4 }, /* 17 | 12 | 4 | 76% */
{ 12, 5 }, /* 18 | 12 | 5 | 72% */
{ 13, 5 }, /* 19 | 13 | 5 | 74% */
{ 14, 5 }, /* 20 | 14 | 5 | 75% */
{ 15, 5 }, /* 21 | 15 | 5 | 76% */
{ 15, 6 }, /* 22 | 15 | 6 | 73% */
{ 16, 6 }, /* 23 | 16 | 6 | 74% */
{ 16, 7 }, /* 24 | 16 | 7 | 71% */
{ 16, 8 } /* 25 | 16 | 8 | 68% */
};
@ -157,7 +158,7 @@ static blt_bool CanGetSpeedConfig(blt_int16u baud, blt_int32u *btr)
prescaler = BOOT_CPU_SYSTEM_SPEED_KHZ/(baud*(canTiming[cnt].tseg1+canTiming[cnt].tseg2+1));
/* make sure the prescaler is valid */
if ( (prescaler > 0) && (prescaler <= 1024) )
if ((prescaler > 0) && (prescaler <= 1024))
{
/* store the prescaler and bustiming register value */
*btr = prescaler - 1;

View File

@ -85,18 +85,18 @@ void CpuStartUserProgram(void)
/* not a valid user program so it cannot be started */
return;
}
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
/* invoke callback */
if (CpuUserProgramStartHook() == BLT_FALSE)
{
/* callback requests the user program to not be started */
return;
}
#endif
#if (BOOT_COM_ENABLE > 0)
#endif
#if (BOOT_COM_ENABLE > 0)
/* release the communication interface */
ComFree();
#endif
#endif
/* reset the timer */
TimerReset();
/* copy the user program's interrupt vector table to RAM */
@ -107,7 +107,7 @@ void CpuStartUserProgram(void)
MEMMAP = 0x02;
/* set the address where the bootloader needs to jump to */
pProgResetHandler = (void*)CPU_RAM_VECTORS_START_ADDR;
pProgResetHandler = (void *)CPU_RAM_VECTORS_START_ADDR;
/* start the user program by activating its reset interrupt service routine */
pProgResetHandler();
@ -131,7 +131,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
to = (blt_int8u *)dest;
/* copy all bytes from source address to destination address */
while(len-- > 0)
while (len-- > 0)
{
/* store byte value from source to destination */
*to++ = *from++;

View File

@ -120,12 +120,12 @@ void UartInit(void)
*/
/* check that baudrate register value is not 0 */
ASSERT_CT((((BOOT_CPU_SYSTEM_SPEED_KHZ*1000/16)+((BOOT_COM_UART_BAUDRATE+1)/2))/ \
BOOT_COM_UART_BAUDRATE) > 0);
BOOT_COM_UART_BAUDRATE) > 0);
/* check that baudrate register value is not greater than max 16-bit unsigned value */
ASSERT_CT((((BOOT_CPU_SYSTEM_SPEED_KHZ*1000/16)+((BOOT_COM_UART_BAUDRATE+1)/2))/ \
BOOT_COM_UART_BAUDRATE) <= 65535);
BOOT_COM_UART_BAUDRATE) <= 65535);
baud_reg_value = (((BOOT_CPU_SYSTEM_SPEED_KHZ*1000/16)+ \
((BOOT_COM_UART_BAUDRATE+1)/2))/BOOT_COM_UART_BAUDRATE);
((BOOT_COM_UART_BAUDRATE+1)/2))/BOOT_COM_UART_BAUDRATE);
/* write the calculated baudrate selector value to the registers */
U0DLL = (blt_int8u)baud_reg_value;
U0DLM = (blt_int8u)(baud_reg_value >> 8);
@ -242,7 +242,7 @@ blt_bool UartReceivePacket(blt_int8u *data)
static blt_bool UartReceiveByte(blt_int8u *data)
{
/* check if a new byte was received by means of the RDR-bit */
if((U0LSR & UART_RDR) != 0)
if ((U0LSR & UART_RDR) != 0)
{
/* store the received byte */
data[0] = U0RBR;
@ -271,7 +271,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
/* write byte to transmit holding register */
U0THR = data;
/* wait for tx holding register to be empty */
while((U0LSR & UART_THRE) == 0)
while ((U0LSR & UART_THRE) == 0)
{
/* keep the watchdog happy */
CopService();

View File

@ -70,13 +70,13 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
blt_int32u ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/** \brief Interrupt vector table. */
__attribute__ ((section(".vectors")))
__attribute__((section(".vectors")))
const tIsrFunc _vectors[] =
{
{ .ptr = (blt_int32u)&__stack_end__ }, /* the initial stack pointer */
{ .ptr = (blt_int32u) &__stack_end__ }, /* the initial stack pointer */
reset_handler, /* the reset handler */
UnusedISR, /* NMI Handler */
UnusedISR, /* Hard Fault Handler */

View File

@ -70,7 +70,7 @@ void reset_handler(void)
__asm(" cpsid i");
/* copy the data segment initializers from flash to SRAM */
pSrc = &_etext;
for(pDest = &_data; pDest < &_edata; )
for (pDest = &_data; pDest < &_edata;)
{
*pDest++ = *pSrc++;
}

View File

@ -64,13 +64,13 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
blt_int32u ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/** \brief Interrupt vector table. */
__attribute__ ((section(".isr_vector")))
__attribute__((section(".isr_vector")))
const tIsrFunc _vectab[] =
{
{ .ptr = (blt_int32u)&_estack }, /* the initial stack pointer */
{ .ptr = (blt_int32u) &_estack }, /* the initial stack pointer */
{ reset_handler }, /* the reset handler */
{ UnusedISR }, /* NMI Handler */
{ UnusedISR }, /* Hard Fault Handler */

View File

@ -40,7 +40,7 @@
/****************************************************************************************
* External functions
****************************************************************************************/
extern void reset_handler( void );
extern void reset_handler(void);
/****************************************************************************************
@ -51,7 +51,7 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
void *ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/************************************************************************************//**
@ -75,7 +75,7 @@ void UnusedISR(void)
/** \brief Interrupt vector table. */
__root const tIsrFunc __vector_table[] @ ".intvec" =
{
{ .ptr = __sfe( "CSTACK" ) }, /* the initial stack pointer */
{ .ptr = __sfe("CSTACK") }, /* the initial stack pointer */
{ &reset_handler }, /* the reset handler */
{ UnusedISR }, /* NMI Handler */
{ UnusedISR }, /* Hard Fault Handler */

View File

@ -83,18 +83,18 @@ void CpuStartUserProgram(void)
/* not a valid user program so it cannot be started */
return;
}
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
/* invoke callback */
if (CpuUserProgramStartHook() == BLT_FALSE)
{
/* callback requests the user program to not be started */
return;
}
#endif
#if (BOOT_COM_ENABLE > 0)
#endif
#if (BOOT_COM_ENABLE > 0)
/* release the communication interface */
ComFree();
#endif
#endif
/* reset the timer */
TimerReset();
/* remap user program's vector table */
@ -103,7 +103,7 @@ void CpuStartUserProgram(void)
* the 2nd entry in the user program's vector table. this address points to the
* user program's reset handler.
*/
pProgResetHandler = (void(*)(void))(*((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));
pProgResetHandler = (void(*)(void))(*((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR));
/* start the user program by activating its reset interrupt service routine */
pProgResetHandler();
} /*** end of CpuStartUserProgram ***/
@ -126,7 +126,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
to = (blt_int8u *)dest;
/* copy all bytes from source address to destination address */
while(len-- > 0)
while (len-- > 0)
{
/* store byte value from source to destination */
*to++ = *from++;

View File

@ -219,8 +219,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
blt_addr base_addr;
/* make sure the addresses are within the flash device */
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -255,7 +255,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
first_sector = FlashGetSector(addr);
last_sector = FlashGetSector(addr+len-1);
/* check them */
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -301,27 +301,27 @@ blt_bool FlashWriteChecksum(void)
* bootblock is not part of the reprogramming this time and therefore no
* new checksum needs to be written
*/
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
return BLT_TRUE;
}
}
/* compute the checksum. note that the user program's vectors are not yet written
* to flash but are present in the bootblock data structure at this point.
*/
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x14]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x14]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
signature_checksum = ~signature_checksum; /* one's complement */
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -336,14 +336,14 @@ blt_bool FlashVerifyChecksum(void)
blt_int32u signature_checksum = 0;
/* verify the checksum based on how it was written by CpuWriteChecksum() */
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{
@ -579,7 +579,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int32u)); word_cnt++)
{
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int32u));
prog_data = *(volatile blt_int32u*)(&block->data[word_cnt * sizeof(blt_int32u)]);
prog_data = *(volatile blt_int32u *)(&block->data[word_cnt * sizeof(blt_int32u)]);
/* keep the watchdog happy */
CopService();
/* program a word */
@ -589,7 +589,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
break;
}
/* verify that the written data is actually there */
if (*(volatile blt_int32u*)prog_addr != prog_data)
if (*(volatile blt_int32u *)prog_addr != prog_data)
{
result = BLT_FALSE;
break;
@ -608,14 +608,14 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
****************************************************************************************/
static blt_int32u FlashCalcPageSize(void)
{
blt_int8u family = *(blt_int8u*)0x0FE081FE;
blt_int8u family = *(blt_int8u *)0x0FE081FE;
if ( ( family == 71 ) || ( family == 73 ) )
if ((family == 71) || (family == 73))
{
/* Gecko and Tiny, 'G' or 'I' */
return 512;
}
else if ( family == 72 )
else if (family == 72)
{
/* Giant, 'H' */
return 4096;
@ -648,8 +648,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
{
return BLT_FALSE;
}
if ( (first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
if ((first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
{
return BLT_FALSE;
}
@ -693,9 +693,9 @@ static blt_int8u FlashGetSector(blt_addr address)
/* keep the watchdog happy */
CopService();
/* is the address in this sector? */
if ( (address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)) )
if ((address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)))
{
/* return the sector number */
return flashLayout[sectorIdx].sector_num;

View File

@ -233,7 +233,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
/* write byte to transmit holding register */
LEUART_Tx(LEUART1, data);
/* wait for tx holding register to be empty */
while((LEUART1->STATUS & LEUART_STATUS_TXBL) == 0)
while ((LEUART1->STATUS & LEUART_STATUS_TXBL) == 0)
{
/* keep the watchdog happy */
CopService();

View File

@ -70,13 +70,13 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
blt_int32u ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/** \brief Interrupt vector table. */
__attribute__ ((section(".vectors")))
__attribute__((section(".vectors")))
const tIsrFunc _vectors[] =
{
{ .ptr = (blt_int32u)&__stack_end__ }, /* the initial stack pointer */
{ .ptr = (blt_int32u) &__stack_end__ }, /* the initial stack pointer */
reset_handler, /* the reset handler */
UnusedISR, /* NMI Handler */
UnusedISR, /* Hard Fault Handler */

View File

@ -69,7 +69,7 @@ void reset_handler(void)
__asm(" cpsid i");
/* copy the data segment initializers from flash to SRAM */
pSrc = &_etext;
for(pDest = &_data; pDest < &_edata; )
for (pDest = &_data; pDest < &_edata;)
{
*pDest++ = *pSrc++;
}

View File

@ -64,13 +64,13 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
blt_int32u ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/** \brief Interrupt vector table. */
__attribute__ ((section(".isr_vector")))
__attribute__((section(".isr_vector")))
const tIsrFunc _vectab[] =
{
{ .ptr = (blt_int32u)&_estack }, /* the initial stack pointer */
{ .ptr = (blt_int32u) &_estack }, /* the initial stack pointer */
{ reset_handler }, /* the reset handler */
{ UnusedISR }, /* NMI Handler */
{ UnusedISR }, /* Hard Fault Handler */

View File

@ -40,7 +40,7 @@
/****************************************************************************************
* External functions
****************************************************************************************/
extern void reset_handler( void );
extern void reset_handler(void);
/****************************************************************************************
@ -51,7 +51,7 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
void *ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/************************************************************************************//**
@ -75,7 +75,7 @@ void UnusedISR(void)
/** \brief Interrupt vector table. */
__root const tIsrFunc __vector_table[] @ ".intvec" =
{
{ .ptr = __sfe( "CSTACK" ) }, /* the initial stack pointer */
{ .ptr = __sfe("CSTACK") }, /* the initial stack pointer */
{ &reset_handler }, /* the reset handler */
{ UnusedISR }, /* NMI Handler */
{ UnusedISR }, /* Hard Fault Handler */

View File

@ -91,7 +91,7 @@ static blt_int8u CanSetBittiming(void)
{
samplepoint = ((1+bitClkParms.uSyncPropPhase1Seg) * 100) / (1+bitClkParms.uSyncPropPhase1Seg+bitClkParms.uPhase2Seg);
/* check that sample points is within the preferred range */
if ( (samplepoint >= 65) && (samplepoint <= 75) )
if ((samplepoint >= 65) && (samplepoint <= 75))
{
/* does a prescaler exist to get the exact baudrate with these bittiming
* settings?
@ -104,7 +104,7 @@ static blt_int8u CanSetBittiming(void)
*/
if (bitClkParms.uPhase2Seg < 4)
{
bitClkParms.uSJW = bitClkParms.uPhase2Seg;
bitClkParms.uSJW = bitClkParms.uPhase2Seg;
}
/* calculate the actual prescaler value */
bitClkParms.uQuantumPrescaler = ((BOOT_CPU_XTAL_SPEED_KHZ*1000)/BOOT_COM_CAN_BAUDRATE)/(1+bitClkParms.uSyncPropPhase1Seg+bitClkParms.uPhase2Seg);

View File

@ -83,18 +83,18 @@ void CpuStartUserProgram(void)
/* not a valid user program so it cannot be started */
return;
}
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
/* invoke callback */
if (CpuUserProgramStartHook() == BLT_FALSE)
{
/* callback requests the user program to not be started */
return;
}
#endif
#if (BOOT_COM_ENABLE > 0)
#endif
#if (BOOT_COM_ENABLE > 0)
/* release the communication interface */
ComFree();
#endif
#endif
/* reset the timer */
TimerReset();
/* remap user program's vector table */
@ -103,7 +103,7 @@ void CpuStartUserProgram(void)
* the 2nd entry in the user program's vector table. this address points to the
* user program's reset handler.
*/
pProgResetHandler = (void(*)(void))(*((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));
pProgResetHandler = (void(*)(void))(*((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR));
/* start the user program by activating its reset interrupt service routine */
pProgResetHandler();
} /*** end of CpuStartUserProgram ***/
@ -126,7 +126,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
to = (blt_int8u *)dest;
/* copy all bytes from source address to destination address */
while(len-- > 0)
while (len-- > 0)
{
/* store byte value from source to destination */
*to++ = *from++;

View File

@ -220,8 +220,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
blt_addr base_addr;
/* make sure the addresses are within the flash device */
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -256,7 +256,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
first_sector = FlashGetSector(addr);
last_sector = FlashGetSector(addr+len-1);
/* check them */
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -302,27 +302,27 @@ blt_bool FlashWriteChecksum(void)
* bootblock is not part of the reprogramming this time and therefore no
* new checksum needs to be written
*/
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
return BLT_TRUE;
}
}
/* compute the checksum. note that the user program's vectors are not yet written
* to flash but are present in the bootblock data structure at this point.
*/
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x14]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x14]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
signature_checksum = ~signature_checksum; /* one's complement */
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -337,14 +337,14 @@ blt_bool FlashVerifyChecksum(void)
blt_int32u signature_checksum = 0;
/* verify the checksum based on how it was written by CpuWriteChecksum() */
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{
@ -576,7 +576,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int32u)); word_cnt++)
{
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int32u));
prog_data = *(volatile blt_int32u*)(&block->data[word_cnt * sizeof(blt_int32u)]);
prog_data = *(volatile blt_int32u *)(&block->data[word_cnt * sizeof(blt_int32u)]);
/* keep the watchdog happy */
CopService();
/* program the word to flash */
@ -586,7 +586,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
break;
}
/* verify that the written data is actually there */
if (*(volatile blt_int32u*)prog_addr != prog_data)
if (*(volatile blt_int32u *)prog_addr != prog_data)
{
result = BLT_FALSE;
break;
@ -616,8 +616,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
{
return BLT_FALSE;
}
if ( (first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
if ((first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
{
return BLT_FALSE;
}
@ -658,9 +658,9 @@ static blt_int8u FlashGetSector(blt_addr address)
/* keep the watchdog happy */
CopService();
/* is the address in this sector? */
if ( (address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)) )
if ((address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)))
{
/* return the sector number */
return flashLayout[sectorIdx].sector_num;

View File

@ -76,7 +76,7 @@ void UartInit(void)
/* configure the UART0 baudrate and communication parameters */
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), BOOT_COM_UART_BAUDRATE,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
UART_CONFIG_PAR_NONE));
} /*** end of UartInit ***/
@ -190,7 +190,7 @@ static blt_bool UartReceiveByte(blt_int8u *data)
/* try to read a newly received byte */
result = UARTCharGetNonBlocking(UART0_BASE);
/* check if a new byte was received */
if(result != -1)
if (result != -1)
{
/* store the received byte */
data[0] = (blt_int8u)result;
@ -217,7 +217,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
return BLT_FALSE;
}
/* wait for tx holding register to be empty */
while(UARTSpaceAvail(UART0_BASE) == false)
while (UARTSpaceAvail(UART0_BASE) == false)
{
/* keep the watchdog happy */
CopService();

View File

@ -70,13 +70,13 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
blt_int32u ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/** \brief Interrupt vector table. */
__attribute__ ((section(".vectors")))
__attribute__((section(".vectors")))
const tIsrFunc _vectors[] =
{
{ .ptr = (blt_int32u)&__stack_end__ }, /* the initial stack pointer */
{ .ptr = (blt_int32u) &__stack_end__ }, /* the initial stack pointer */
reset_handler, /* the reset handler */
UnusedISR, /* NMI Handler */
UnusedISR, /* Hard Fault Handler */

View File

@ -69,7 +69,7 @@ void reset_handler(void)
__asm(" cpsid i");
/* copy the data segment initializers from flash to SRAM */
pSrc = &_etext;
for(pDest = &_data; pDest < &_edata; )
for (pDest = &_data; pDest < &_edata;)
{
*pDest++ = *pSrc++;
}

View File

@ -64,13 +64,13 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
blt_int32u ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/** \brief Interrupt vector table. */
__attribute__ ((section(".isr_vector")))
__attribute__((section(".isr_vector")))
const tIsrFunc _vectab[] =
{
{ .ptr = (blt_int32u)&_estack }, /* the initial stack pointer */
{ .ptr = (blt_int32u) &_estack }, /* the initial stack pointer */
{ reset_handler }, /* the reset handler */
{ UnusedISR }, /* NMI Handler */
{ UnusedISR }, /* Hard Fault Handler */

View File

@ -40,7 +40,7 @@
/****************************************************************************************
* External functions
****************************************************************************************/
extern void reset_handler( void );
extern void reset_handler(void);
/****************************************************************************************
@ -51,7 +51,7 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
void *ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/************************************************************************************//**
@ -75,7 +75,7 @@ void UnusedISR(void)
/** \brief Interrupt vector table. */
__root const tIsrFunc __vector_table[] @ ".intvec" =
{
{ .ptr = __sfe( "CSTACK" ) }, /* the initial stack pointer */
{ .ptr = __sfe("CSTACK") }, /* the initial stack pointer */
{ &reset_handler }, /* the reset handler */
{ UnusedISR }, /* NMI Handler */
{ UnusedISR }, /* Hard Fault Handler */

View File

@ -147,26 +147,27 @@ typedef struct t_can_bus_timing
* a sample point between 68..78%.
*/
static const tCanBusTiming canTiming[] =
{ /* TQ | TSEG1 | TSEG2 | SP */
/* ------------------------- */
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
{ 6, 3 }, /* 10 | 6 | 3 | 70% */
{ 7, 3 }, /* 11 | 7 | 3 | 73% */
{ 8, 3 }, /* 12 | 8 | 3 | 75% */
{ 9, 3 }, /* 13 | 9 | 3 | 77% */
{ 9, 4 }, /* 14 | 9 | 4 | 71% */
{ 10, 4 }, /* 15 | 10 | 4 | 73% */
{ 11, 4 }, /* 16 | 11 | 4 | 75% */
{ 12, 4 }, /* 17 | 12 | 4 | 76% */
{ 12, 5 }, /* 18 | 12 | 5 | 72% */
{ 13, 5 }, /* 19 | 13 | 5 | 74% */
{ 14, 5 }, /* 20 | 14 | 5 | 75% */
{ 15, 5 }, /* 21 | 15 | 5 | 76% */
{ 15, 6 }, /* 22 | 15 | 6 | 73% */
{ 16, 6 }, /* 23 | 16 | 6 | 74% */
{ 16, 7 }, /* 24 | 16 | 7 | 71% */
{ 16, 8 } /* 25 | 16 | 8 | 68% */
{
/* TQ | TSEG1 | TSEG2 | SP */
/* ------------------------- */
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
{ 6, 3 }, /* 10 | 6 | 3 | 70% */
{ 7, 3 }, /* 11 | 7 | 3 | 73% */
{ 8, 3 }, /* 12 | 8 | 3 | 75% */
{ 9, 3 }, /* 13 | 9 | 3 | 77% */
{ 9, 4 }, /* 14 | 9 | 4 | 71% */
{ 10, 4 }, /* 15 | 10 | 4 | 73% */
{ 11, 4 }, /* 16 | 11 | 4 | 75% */
{ 12, 4 }, /* 17 | 12 | 4 | 76% */
{ 12, 5 }, /* 18 | 12 | 5 | 72% */
{ 13, 5 }, /* 19 | 13 | 5 | 74% */
{ 14, 5 }, /* 20 | 14 | 5 | 75% */
{ 15, 5 }, /* 21 | 15 | 5 | 76% */
{ 15, 6 }, /* 22 | 15 | 6 | 73% */
{ 16, 6 }, /* 23 | 16 | 6 | 74% */
{ 16, 7 }, /* 24 | 16 | 7 | 71% */
{ 16, 8 } /* 25 | 16 | 8 | 68% */
};
@ -195,7 +196,7 @@ static blt_bool CanGetSpeedConfig(blt_int16u baud, blt_int16u *prescaler,
*prescaler = (BOOT_CPU_SYSTEM_SPEED_KHZ/2)/(baud*(canTiming[cnt].tseg1+canTiming[cnt].tseg2+1));
/* make sure the prescaler is valid */
if ( (*prescaler > 0) && (*prescaler <= 1024) )
if ((*prescaler > 0) && (*prescaler <= 1024))
{
/* store the bustiming configuration */
*tseg1 = canTiming[cnt].tseg1;

View File

@ -83,18 +83,18 @@ void CpuStartUserProgram(void)
/* not a valid user program so it cannot be started */
return;
}
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
/* invoke callback */
if (CpuUserProgramStartHook() == BLT_FALSE)
{
/* callback requests the user program to not be started */
return;
}
#endif
#if (BOOT_COM_ENABLE > 0)
#endif
#if (BOOT_COM_ENABLE > 0)
/* release the communication interface */
ComFree();
#endif
#endif
/* reset the timer */
TimerReset();
/* remap user program's vector table */
@ -103,7 +103,7 @@ void CpuStartUserProgram(void)
* the 2nd entry in the user program's vector table. this address points to the
* user program's reset handler.
*/
pProgResetHandler = (void(*)(void))(*((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));
pProgResetHandler = (void(*)(void))(*((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR));
/* start the user program by activating its reset interrupt service routine */
pProgResetHandler();
} /*** end of CpuStartUserProgram ***/
@ -126,7 +126,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
to = (blt_int8u *)dest;
/* copy all bytes from source address to destination address */
while(len-- > 0)
while (len-- > 0)
{
/* store byte value from source to destination */
*to++ = *from++;

View File

@ -250,8 +250,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
blt_addr base_addr;
/* make sure the addresses are within the flash device */
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -286,7 +286,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
first_sector = FlashGetSector(addr);
last_sector = FlashGetSector(addr+len-1);
/* check them */
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -332,27 +332,27 @@ blt_bool FlashWriteChecksum(void)
* bootblock is not part of the reprogramming this time and therefore no
* new checksum needs to be written
*/
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
return BLT_TRUE;
}
}
/* compute the checksum. note that the user program's vectors are not yet written
* to flash but are present in the bootblock data structure at this point.
*/
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x14]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x14]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
signature_checksum = ~signature_checksum; /* one's complement */
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -367,14 +367,14 @@ blt_bool FlashVerifyChecksum(void)
blt_int32u signature_checksum = 0;
/* verify the checksum based on how it was written by CpuWriteChecksum() */
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{
@ -618,9 +618,9 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int32u)); word_cnt++)
{
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int32u));
prog_data = *(volatile blt_int32u*)(&block->data[word_cnt * sizeof(blt_int32u)]);
prog_data = *(volatile blt_int32u *)(&block->data[word_cnt * sizeof(blt_int32u)]);
/* program the first half word */
*(volatile blt_int16u*)prog_addr = (blt_int16u)prog_data;
*(volatile blt_int16u *)prog_addr = (blt_int16u)prog_data;
/* wait for the program operation to complete */
while ((FLASH->SR & FLASH_BSY_BIT) == FLASH_BSY_BIT)
{
@ -628,7 +628,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
CopService();
}
/* program the second half word */
*(volatile blt_int16u*)(prog_addr+2) = (blt_int16u)(prog_data >> 16);
*(volatile blt_int16u *)(prog_addr+2) = (blt_int16u)(prog_data >> 16);
/* wait for the program operation to complete */
while ((FLASH->SR & FLASH_BSY_BIT) == FLASH_BSY_BIT)
{
@ -636,7 +636,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
CopService();
}
/* verify that the written data is actually there */
if (*(volatile blt_int32u*)prog_addr != prog_data)
if (*(volatile blt_int32u *)prog_addr != prog_data)
{
result = BLT_FALSE;
break;
@ -670,8 +670,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
{
return BLT_FALSE;
}
if ( (first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
if ((first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
{
return BLT_FALSE;
}
@ -761,9 +761,9 @@ static blt_int8u FlashGetSector(blt_addr address)
/* keep the watchdog happy */
CopService();
/* is the address in this sector? */
if ( (address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)) )
if ((address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)))
{
/* return the sector number */
return flashLayout[sectorIdx].sector_num;

View File

@ -236,7 +236,7 @@ blt_bool UartReceivePacket(blt_int8u *data)
static blt_bool UartReceiveByte(blt_int8u *data)
{
/* check if a new byte was received by means of the RDR-bit */
if((UARTx->SR & UART_BIT_RXNE) != 0)
if ((UARTx->SR & UART_BIT_RXNE) != 0)
{
/* store the received byte */
data[0] = UARTx->DR;
@ -265,7 +265,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
/* write byte to transmit holding register */
UARTx->DR = data;
/* wait for tx holding register to be empty */
while((UARTx->SR & UART_BIT_TXE) == 0)
while ((UARTx->SR & UART_BIT_TXE) == 0)
{
/* keep the watchdog happy */
CopService();

View File

@ -123,8 +123,8 @@ void UsbInit(void)
fifoPipeBulkIN.handle = UsbFifoMgrCreate(fifoPipeBulkIN.data, FIFO_PIPE_SIZE);
fifoPipeBulkOUT.handle = UsbFifoMgrCreate(fifoPipeBulkOUT.data, FIFO_PIPE_SIZE);
/* validate fifo handles */
ASSERT_RT( (fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE) );
ASSERT_RT((fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE));
/* initialize the low level USB driver */
USB_Init();
} /*** end of UsbInit ***/
@ -383,13 +383,13 @@ void UsbReceivePipeBulkOUT(void)
** \return none.
**
****************************************************************************************/
static void IntToUnicode (blt_int32u value , blt_int8u *pbuf , blt_int8u len)
static void IntToUnicode(blt_int32u value , blt_int8u *pbuf , blt_int8u len)
{
blt_int8u idx = 0;
for( idx = 0 ; idx < len ; idx ++)
for (idx = 0 ; idx < len ; idx ++)
{
if( ((value >> 28)) < 0xA )
if (((value >> 28)) < 0xA)
{
pbuf[ 2* idx] = (value >> 28) + '0';
}
@ -414,9 +414,9 @@ void UsbGetSerialNum(void)
{
blt_int32u Device_Serial0, Device_Serial1, Device_Serial2;
Device_Serial0 = *(volatile blt_int32u*)(0x1FFFF7E8);
Device_Serial1 = *(volatile blt_int32u*)(0x1FFFF7EC);
Device_Serial2 = *(volatile blt_int32u*)(0x1FFFF7F0);
Device_Serial0 = *(volatile blt_int32u *)(0x1FFFF7E8);
Device_Serial1 = *(volatile blt_int32u *)(0x1FFFF7EC);
Device_Serial2 = *(volatile blt_int32u *)(0x1FFFF7F0);
Device_Serial0 += Device_Serial2;
@ -488,7 +488,7 @@ static blt_int8u UsbFifoMgrCreate(blt_int8u *buffer, blt_int8u length)
pbc->writeptr = buffer;
pbc->entries = 0;
pbc->startptr = buffer;
pbc->endptr = (blt_int8u*)(buffer + length - 1);
pbc->endptr = (blt_int8u *)(buffer + length - 1);
/* return the handle to the successfully created fifo control */
return pbc->handle;

View File

@ -70,13 +70,13 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
blt_int32u ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/** \brief Interrupt vector table. */
__attribute__ ((section(".vectors")))
__attribute__((section(".vectors")))
const tIsrFunc _vectors[] =
{
{ .ptr = (blt_int32u)&__stack_end__ }, /* the initial stack pointer */
{ .ptr = (blt_int32u) &__stack_end__ }, /* the initial stack pointer */
reset_handler, /* the reset handler */
UnusedISR, /* NMI Handler */
UnusedISR, /* Hard Fault Handler */

View File

@ -69,7 +69,7 @@ void reset_handler(void)
__asm(" cpsid i");
/* copy the data segment initializers from flash to SRAM */
pSrc = &_etext;
for(pDest = &_data; pDest < &_edata; )
for (pDest = &_data; pDest < &_edata;)
{
*pDest++ = *pSrc++;
}

View File

@ -64,13 +64,13 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
blt_int32u ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/** \brief Interrupt vector table. */
__attribute__ ((section(".isr_vector")))
__attribute__((section(".isr_vector")))
const tIsrFunc _vectab[] =
{
{ .ptr = (blt_int32u)&_estack }, /* the initial stack pointer */
{ .ptr = (blt_int32u) &_estack }, /* the initial stack pointer */
{ reset_handler }, /* the reset handler */
{ UnusedISR }, /* NMI Handler */
{ UnusedISR }, /* Hard Fault Handler */

View File

@ -40,7 +40,7 @@
/****************************************************************************************
* External functions
****************************************************************************************/
extern void reset_handler( void );
extern void reset_handler(void);
/****************************************************************************************
@ -51,7 +51,7 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
void *ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/************************************************************************************//**
@ -75,7 +75,7 @@ void UnusedISR(void)
/** \brief Interrupt vector table. */
__root const tIsrFunc __vector_table[] @ ".intvec" =
{
{ .ptr = __sfe( "CSTACK" ) }, /* the initial stack pointer */
{ .ptr = __sfe("CSTACK") }, /* the initial stack pointer */
{ &reset_handler }, /* the reset handler */
{ UnusedISR }, /* NMI Handler */
{ UnusedISR }, /* Hard Fault Handler */

View File

@ -156,26 +156,27 @@ typedef struct t_can_bus_timing
* a sample point between 68..78%.
*/
static const tCanBusTiming canTiming[] =
{ /* TQ | TSEG1 | TSEG2 | SP */
/* ------------------------- */
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
{ 6, 3 }, /* 10 | 6 | 3 | 70% */
{ 7, 3 }, /* 11 | 7 | 3 | 73% */
{ 8, 3 }, /* 12 | 8 | 3 | 75% */
{ 9, 3 }, /* 13 | 9 | 3 | 77% */
{ 9, 4 }, /* 14 | 9 | 4 | 71% */
{ 10, 4 }, /* 15 | 10 | 4 | 73% */
{ 11, 4 }, /* 16 | 11 | 4 | 75% */
{ 12, 4 }, /* 17 | 12 | 4 | 76% */
{ 12, 5 }, /* 18 | 12 | 5 | 72% */
{ 13, 5 }, /* 19 | 13 | 5 | 74% */
{ 14, 5 }, /* 20 | 14 | 5 | 75% */
{ 15, 5 }, /* 21 | 15 | 5 | 76% */
{ 15, 6 }, /* 22 | 15 | 6 | 73% */
{ 16, 6 }, /* 23 | 16 | 6 | 74% */
{ 16, 7 }, /* 24 | 16 | 7 | 71% */
{ 16, 8 } /* 25 | 16 | 8 | 68% */
{
/* TQ | TSEG1 | TSEG2 | SP */
/* ------------------------- */
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
{ 6, 3 }, /* 10 | 6 | 3 | 70% */
{ 7, 3 }, /* 11 | 7 | 3 | 73% */
{ 8, 3 }, /* 12 | 8 | 3 | 75% */
{ 9, 3 }, /* 13 | 9 | 3 | 77% */
{ 9, 4 }, /* 14 | 9 | 4 | 71% */
{ 10, 4 }, /* 15 | 10 | 4 | 73% */
{ 11, 4 }, /* 16 | 11 | 4 | 75% */
{ 12, 4 }, /* 17 | 12 | 4 | 76% */
{ 12, 5 }, /* 18 | 12 | 5 | 72% */
{ 13, 5 }, /* 19 | 13 | 5 | 74% */
{ 14, 5 }, /* 20 | 14 | 5 | 75% */
{ 15, 5 }, /* 21 | 15 | 5 | 76% */
{ 15, 6 }, /* 22 | 15 | 6 | 73% */
{ 16, 6 }, /* 23 | 16 | 6 | 74% */
{ 16, 7 }, /* 24 | 16 | 7 | 71% */
{ 16, 8 } /* 25 | 16 | 8 | 68% */
};
@ -204,7 +205,7 @@ static blt_bool CanGetSpeedConfig(blt_int16u baud, blt_int16u *prescaler,
*prescaler = (BOOT_CPU_SYSTEM_SPEED_KHZ/4)/(baud*(canTiming[cnt].tseg1+canTiming[cnt].tseg2+1));
/* make sure the prescaler is valid */
if ( (*prescaler > 0) && (*prescaler <= 1024) )
if ((*prescaler > 0) && (*prescaler <= 1024))
{
/* store the bustiming configuration */
*tseg1 = canTiming[cnt].tseg1;

View File

@ -83,18 +83,18 @@ void CpuStartUserProgram(void)
/* not a valid user program so it cannot be started */
return;
}
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
/* invoke callback */
if (CpuUserProgramStartHook() == BLT_FALSE)
{
/* callback requests the user program to not be started */
return;
}
#endif
#if (BOOT_COM_ENABLE > 0)
#endif
#if (BOOT_COM_ENABLE > 0)
/* release the communication interface */
ComFree();
#endif
#endif
/* reset the timer */
TimerReset();
/* remap user program's vector table */
@ -103,7 +103,7 @@ void CpuStartUserProgram(void)
* the 2nd entry in the user program's vector table. this address points to the
* user program's reset handler.
*/
pProgResetHandler = (void(*)(void))(*((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));
pProgResetHandler = (void(*)(void))(*((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR));
/* start the user program by activating its reset interrupt service routine */
pProgResetHandler();
} /*** end of CpuStartUserProgram ***/
@ -126,7 +126,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
to = (blt_int8u *)dest;
/* copy all bytes from source address to destination address */
while(len-- > 0)
while (len-- > 0)
{
/* store byte value from source to destination */
*to++ = *from++;

View File

@ -235,8 +235,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
blt_addr base_addr;
/* make sure the addresses are within the flash device */
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -271,7 +271,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
first_sector = FlashGetSector(addr);
last_sector = FlashGetSector(addr+len-1);
/* check them */
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -317,27 +317,27 @@ blt_bool FlashWriteChecksum(void)
* bootblock is not part of the reprogramming this time and therefore no
* new checksum needs to be written
*/
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
return BLT_TRUE;
}
}
/* compute the checksum. note that the user program's vectors are not yet written
* to flash but are present in the bootblock data structure at this point.
*/
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x14]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x14]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
signature_checksum = ~signature_checksum; /* one's complement */
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -352,14 +352,14 @@ blt_bool FlashVerifyChecksum(void)
blt_int32u signature_checksum = 0;
/* verify the checksum based on how it was written by CpuWriteChecksum() */
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{
@ -604,7 +604,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int32u)); word_cnt++)
{
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int32u));
prog_data = *(volatile blt_int32u*)(&block->data[word_cnt * sizeof(blt_int32u)]);
prog_data = *(volatile blt_int32u *)(&block->data[word_cnt * sizeof(blt_int32u)]);
/* keep the watchdog happy */
CopService();
/* program the word */
@ -614,7 +614,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
break;
}
/* verify that the written data is actually there */
if (*(volatile blt_int32u*)prog_addr != prog_data)
if (*(volatile blt_int32u *)prog_addr != prog_data)
{
result = BLT_FALSE;
break;
@ -643,8 +643,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
{
return BLT_FALSE;
}
if ( (first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
if ((first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
{
return BLT_FALSE;
}
@ -698,9 +698,9 @@ static blt_int8u FlashGetSector(blt_addr address)
/* keep the watchdog happy */
CopService();
/* is the address in this sector? */
if ( (address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)) )
if ((address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)))
{
/* return the sector number */
return flashLayout[sectorIdx].sector_num;

View File

@ -122,8 +122,8 @@ void UsbInit(void)
fifoPipeBulkIN.handle = UsbFifoMgrCreate(fifoPipeBulkIN.data, FIFO_PIPE_SIZE);
fifoPipeBulkOUT.handle = UsbFifoMgrCreate(fifoPipeBulkOUT.data, FIFO_PIPE_SIZE);
/* validate fifo handles */
ASSERT_RT( (fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE) );
ASSERT_RT((fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE));
/* initialize the low level USB driver */
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_bulk_cb, &USR_cb);
} /*** end of UsbInit ***/
@ -187,7 +187,7 @@ blt_bool UsbReceivePacket(blt_int8u *data)
static blt_bool xcpCtoRxInProgress = BLT_FALSE;
/* poll USB interrupt flags to process USB related events */
USBD_OTG_ISR_Handler (&USB_OTG_dev);
USBD_OTG_ISR_Handler(&USB_OTG_dev);
/* start of cto packet received? */
if (xcpCtoRxInProgress == BLT_FALSE)
@ -394,7 +394,7 @@ static blt_int8u UsbFifoMgrCreate(blt_int8u *buffer, blt_int8u length)
pbc->writeptr = buffer;
pbc->entries = 0;
pbc->startptr = buffer;
pbc->endptr = (blt_int8u*)(buffer + length - 1);
pbc->endptr = (blt_int8u *)(buffer + length - 1);
/* return the handle to the successfully created fifo control */
return pbc->handle;

View File

@ -40,7 +40,7 @@
/****************************************************************************************
* External functions
****************************************************************************************/
extern void reset_handler( void );
extern void reset_handler(void);
/****************************************************************************************
@ -51,7 +51,7 @@ typedef union
{
void (*func)(void); /**< for ISR function pointers */
void *ptr; /**< for stack pointer entry */
}tIsrFunc;
} tIsrFunc;
/************************************************************************************//**
@ -75,7 +75,7 @@ void UnusedISR(void)
/** \brief Interrupt vector table. */
__root const tIsrFunc __vector_table[] @ ".intvec" =
{
{ .ptr = __sfe( "CSTACK" ) }, /* the initial stack pointer */
{ .ptr = __sfe("CSTACK") }, /* the initial stack pointer */
{ &reset_handler }, /* the reset handler */
{ UnusedISR }, /* NMI Handler */
{ UnusedISR }, /* Hard Fault Handler */

View File

@ -83,18 +83,18 @@ void CpuStartUserProgram(void)
/* not a valid user program so it cannot be started */
return;
}
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
/* invoke callback */
if (CpuUserProgramStartHook() == BLT_FALSE)
{
/* callback requests the user program to not be started */
return;
}
#endif
#if (BOOT_COM_ENABLE > 0)
#endif
#if (BOOT_COM_ENABLE > 0)
/* release the communication interface */
ComFree();
#endif
#endif
/* reset the timer */
TimerReset();
/* remap user program's vector table */
@ -103,7 +103,7 @@ void CpuStartUserProgram(void)
* the 2nd entry in the user program's vector table. this address points to the
* user program's reset handler.
*/
pProgResetHandler = (void(*)(void))(*((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));
pProgResetHandler = (void(*)(void))(*((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR));
/* start the user program by activating its reset interrupt service routine */
pProgResetHandler();
} /*** end of CpuStartUserProgram ***/
@ -126,7 +126,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
to = (blt_int8u *)dest;
/* copy all bytes from source address to destination address */
while(len-- > 0)
while (len-- > 0)
{
/* store byte value from source to destination */
*to++ = *from++;

View File

@ -222,8 +222,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
blt_addr base_addr;
/* make sure the addresses are within the flash device */
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -258,7 +258,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
first_sector = FlashGetSector(addr);
last_sector = FlashGetSector(addr+len-1);
/* check them */
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -304,27 +304,27 @@ blt_bool FlashWriteChecksum(void)
* bootblock is not part of the reprogramming this time and therefore no
* new checksum needs to be written
*/
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
return BLT_TRUE;
}
}
/* compute the checksum. note that the user program's vectors are not yet written
* to flash but are present in the bootblock data structure at this point.
*/
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x14]));
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x14]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
signature_checksum = ~signature_checksum; /* one's complement */
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -339,14 +339,14 @@ blt_bool FlashVerifyChecksum(void)
blt_int32u signature_checksum = 0;
/* verify the checksum based on how it was written by CpuWriteChecksum() */
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{
@ -579,7 +579,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int32u)); word_cnt++)
{
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int32u));
prog_data = *(volatile blt_int32u*)(&block->data[word_cnt * sizeof(blt_int32u)]);
prog_data = *(volatile blt_int32u *)(&block->data[word_cnt * sizeof(blt_int32u)]);
/* keep the watchdog happy */
CopService();
/* program the word to flash */
@ -589,7 +589,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
break;
}
/* verify that the written data is actually there */
if (*(volatile blt_int32u*)prog_addr != prog_data)
if (*(volatile blt_int32u *)prog_addr != prog_data)
{
result = BLT_FALSE;
break;
@ -619,8 +619,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
{
return BLT_FALSE;
}
if ( (first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
if ((first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
{
return BLT_FALSE;
}
@ -662,9 +662,9 @@ static blt_int8u FlashGetSector(blt_addr address)
/* keep the watchdog happy */
CopService();
/* is the address in this sector? */
if ( (address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)) )
if ((address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)))
{
/* return the sector number */
return flashLayout[sectorIdx].sector_num;

View File

@ -78,7 +78,7 @@ void UartInit(void)
/* configure the UART0 baudrate and communication parameters */
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), BOOT_COM_UART_BAUDRATE,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
UART_CONFIG_PAR_NONE));
} /*** end of UartInit ***/
@ -192,7 +192,7 @@ static blt_bool UartReceiveByte(blt_int8u *data)
/* try to read a newly received byte */
result = UARTCharGetNonBlocking(UART0_BASE);
/* check if a new byte was received */
if(result != -1)
if (result != -1)
{
/* store the received byte */
data[0] = (blt_int8u)result;
@ -219,7 +219,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
return BLT_FALSE;
}
/* wait for tx holding register to be empty */
while(UARTSpaceAvail(UART0_BASE) == false)
while (UARTSpaceAvail(UART0_BASE) == false)
{
/* keep the watchdog happy */
CopService();

View File

@ -129,8 +129,8 @@ void UsbInit(void)
fifoPipeBulkIN.handle = UsbFifoMgrCreate(fifoPipeBulkIN.data, FIFO_PIPE_SIZE);
fifoPipeBulkOUT.handle = UsbFifoMgrCreate(fifoPipeBulkOUT.data, FIFO_PIPE_SIZE);
/* validate fifo handles */
ASSERT_RT( (fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE) );
ASSERT_RT((fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE));
/* initialize the transmit and receive buffers */
USBBufferInit(&g_sTxBuffer);
USBBufferInit(&g_sRxBuffer);
@ -377,7 +377,7 @@ static void UsbReceivePipeBulkOUT(blt_int8u *data, blt_int32u len)
****************************************************************************************/
uint32_t UsbBulkTxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData)
{
if(ui32Event == USB_EVENT_TX_COMPLETE)
if (ui32Event == USB_EVENT_TX_COMPLETE)
{
/* check if more data is waiting to be transmitted */
UsbTransmitPipeBulkIN();
@ -399,7 +399,7 @@ uint32_t UsbBulkTxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgVa
uint32_t UsbBulkRxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData)
{
/* which event are we being sent? */
switch(ui32Event)
switch (ui32Event)
{
/* we are connected to a host and communication is now possible */
case USB_EVENT_CONNECTED:
@ -504,7 +504,7 @@ static blt_int8u UsbFifoMgrCreate(blt_int8u *buffer, blt_int8u length)
pbc->writeptr = buffer;
pbc->entries = 0;
pbc->startptr = buffer;
pbc->endptr = (blt_int8u*)(buffer + length - 1);
pbc->endptr = (blt_int8u *)(buffer + length - 1);
/* return the handle to the successfully created fifo control */
return pbc->handle;

View File

@ -17,7 +17,7 @@ Note: C++ destructors of global objects are NOT yet supported in the HIWARE Obje
/*#define __BANKED_COPY_DOWN : allow to allocate .copy in flash area */
#if defined(__BANKED_COPY_DOWN) && (!defined(__HCS12X__) || !defined(__ELF_OBJECT_FILE_FORMAT__))
#error /* the __BANKED_COPY_DOWN switch is only supported for the HCS12X with ELF */
/* (and not for the HC12, HCS12 or for the HIWARE object file format) */
/* (and not for the HC12, HCS12 or for the HIWARE object file format) */
#endif
#include "hidef.h"
@ -71,8 +71,8 @@ __EXTERN_C void main(void); /* prototype of main function */
#pragma DATA_SEG __NEAR_SEG STARTUP_DATA /* _startupData can be accessed using 16 bit accesses. */
/* This is needed because it contains the stack top, and without stack, far data cannot be accessed */
struct _tagStartup _startupData; /* read-only: */
/* _startupData is allocated in ROM and */
/* initialized by the linker */
/* _startupData is allocated in ROM and */
/* initialized by the linker */
#pragma DATA_SEG DEFAULT
#endif /* __ONLY_INIT_SP */
@ -86,8 +86,8 @@ struct _tagStartup _startupData; /* read-only: */
/*lint -esym(752,_SET_PAGE) , symbol '_SET_PAGE' is referenced in HLI */
__EXTERN_C void _SET_PAGE(void); /* the inline assembler needs a prototype */
/* this is a runtime routine with a special */
/* calling convention, do not use it in c code! */
/* this is a runtime routine with a special */
/* calling convention, do not use it in c code! */
#else
/*lint -e451 default.sgm contains a conditionally compiled CODE_SEG pragma */
#include "default.sgm"
@ -127,198 +127,300 @@ static void __far Init(void)
#else
static void Init(void)
#endif
{
/* purpose: 1) zero out RAM-areas where data is allocated */
/* 2) copy initialization data from ROM to RAM */
/* 3) call global constructors in C++ */
/* called from: _Startup, LibInits */
asm {
ZeroOut:
{
/* purpose: 1) zero out RAM-areas where data is allocated */
/* 2) copy initialization data from ROM to RAM */
/* 3) call global constructors in C++ */
/* called from: _Startup, LibInits */
asm
{
ZeroOut:
#if defined(__HIWARE_OBJECT_FILE_FORMAT__) && defined(__LARGE__)
LDX _startupData.pZeroOut:1 ; in the large memory model in the HIWARE format, pZeroOut is a 24 bit pointer
LDX _startupData.pZeroOut:1 ;
in the large memory model in the HIWARE format, pZeroOut is a 24 bit pointer
#else
LDX _startupData.pZeroOut ; *pZeroOut
LDX _startupData.pZeroOut ;
*pZeroOut
#endif
LDY _startupData.nofZeroOuts ; nofZeroOuts
BEQ CopyDown ; if nothing to zero out
LDY _startupData.nofZeroOuts ;
nofZeroOuts
BEQ CopyDown ;
if nothing to zero out
NextZeroOut: PSHY ; save nofZeroOuts
NextZeroOut: PSHY ;
save nofZeroOuts
#if defined(FAR_DATA)
LDAB 1,X+ ; load page of destination address
LDY 2,X+ ; load offset of destination address
LDAB 1,X+ ;
load page of destination address
LDY 2,X+ ;
load offset of destination address
#if defined(__HCS12X__)
STAB __GPAGE_ADR__
STAB __GPAGE_ADR__
#else /* defined(__HCS12X__) */
__PIC_JSR(_SET_PAGE) ; sets the page in the correct page register
__PIC_JSR(_SET_PAGE) ;
sets the page in the correct page register
#endif /* defined(__HCS12X__) */
#else /* FAR_DATA */
LDY 2,X+ ; start address and advance *pZeroOut (X = X+4)
LDY 2,X+ ;
start address and advance *pZeroOut(X = X+4)
#endif /* FAR_DATA */
#if defined(__HCS12X__) && defined(FAR_DATA)
PSHX
LDX 0,X ; byte count
PSHX
LDX 0,X ;
byte count
#if defined(__OPTIMIZE_FOR_SIZE__)
CLRA
NextWord: GSTAA 1,Y+ ; clear memory byte
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE X, NextWord ; dec byte count
CLRA
NextWord:
GSTAA 1,Y+ ;
clear memory byte
__FEED_COP_IN_HLI() ;
feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE X, NextWord ;
dec byte count
#else
LDD #0
LSRX
BEQ LoopClrW1 ; do we copy more than 1 byte?
NextWord: GSTD 2,Y+ ; clear memory word
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE X, NextWord ; dec word count
LDD #0
LSRX
BEQ LoopClrW1 ;
do we copy more than 1 byte?
NextWord: GSTD 2,Y+ ;
clear memory word
__FEED_COP_IN_HLI() ;
feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE X, NextWord ;
dec word count
LoopClrW1:
BCC LastClr ; handle last byte
GSTAA 1,Y+ ; handle last byte
BCC LastClr ;
handle last byte
GSTAA 1,Y+ ;
handle last byte
LastClr:
#endif
PULX
LEAX 2,X
PULX
LEAX 2,X
#elif defined(__OPTIMIZE_FOR_SIZE__) /* -os, default */
LDD 2,X+ ; byte count
NextWord: CLR 1,Y+ ; clear memory byte
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D, NextWord ; dec byte count
LDD 2,X+ ;
byte count
NextWord:
CLR 1,Y+ ;
clear memory byte
__FEED_COP_IN_HLI() ;
feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D, NextWord ;
dec byte count
#else /* __OPTIMIZE_FOR_TIME__ */
LDD 2,X+ ; byte count
LSRD ; /2 and save bit 0 in the carry
BEQ LoopClrW1 ; do we copy more than 1 byte?
PSHX
LDX #0
LoopClrW: STX 2,Y+ ; Word-Clear
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D, LoopClrW
PULX
LDD 2,X+ ;
byte count
LSRD ;
/2 and save bit 0 in the carry
BEQ LoopClrW1 ;
do we copy more than 1 byte?
PSHX
LDX #0
LoopClrW: STX 2,Y+ ;
Word-Clear
__FEED_COP_IN_HLI() ;
feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D, LoopClrW
PULX
LoopClrW1:
BCC LastClr ; handle last byte
CLR 1,Y+
BCC LastClr ;
handle last byte
CLR 1,Y+
LastClr:
#endif /* __OPTIMIZE_FOR_SIZE__/__OPTIMIZE_FOR_TIME__ */
PULY ; restore nofZeroOuts
DEY ; dec nofZeroOuts
BNE NextZeroOut
PULY ;
restore nofZeroOuts
DEY ;
dec nofZeroOuts
BNE NextZeroOut
CopyDown:
#if defined(__BANKED_COPY_DOWN)
LDAA _startupData.toCopyDownBeg:0 ; get PAGE address of .copy section
STAA __PPAGE_ADR__ ; set PPAGE address
LDX _startupData.toCopyDownBeg:1 ; load address of copy down desc.
LDAA _startupData.toCopyDownBeg:0 ;
get PAGE address of .copy section
STAA __PPAGE_ADR__ ;
set PPAGE address
LDX _startupData.toCopyDownBeg:1 ;
load address of copy down desc.
#elif defined(__ELF_OBJECT_FILE_FORMAT__)
LDX _startupData.toCopyDownBeg ; load address of copy down desc.
LDX _startupData.toCopyDownBeg ;
load address of copy down desc.
#else
LDX _startupData.toCopyDownBeg:2 ; load address of copy down desc.
LDX _startupData.toCopyDownBeg:2 ;
load address of copy down desc.
#endif
NextBlock:
LDD 2,X+ ; size of init-data -> D
BEQ funcInits ; end of copy down desc.
LDD 2,X+ ;
size of init-data -> D
BEQ funcInits ;
end of copy down desc.
#ifdef FAR_DATA
PSHD ; save counter
LDAB 1,X+ ; load destination page
LDY 2,X+ ; destination address
PSHD ;
save counter
LDAB 1,X+ ;
load destination page
LDY 2,X+ ;
destination address
#if defined(__HCS12X__)
STAB __GPAGE_ADR__
STAB __GPAGE_ADR__
#else /* __HCS12X__ */
__PIC_JSR(_SET_PAGE) ; sets the destinations page register
__PIC_JSR(_SET_PAGE) ;
sets the destinations page register
#endif /* __HCS12X__ */
PULD ; restore counter
PULD ;
restore counter
#else /* FAR_DATA */
LDY 2,X+ ; load destination address
LDY 2,X+ ;
load destination address
#endif /* FAR_DATA */
#if defined(__HCS12X__) && defined(FAR_DATA)
#if defined(__OPTIMIZE_FOR_SIZE__) /* -os, default */
Copy: PSHA
LDAA 1,X+
GSTAA 1,Y+ ; move a byte from ROM to the data area
PULA
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D,Copy ; copy-byte loop
Copy:
PSHA
LDAA 1,X+
GSTAA 1,Y+ ;
move a byte from ROM to the data area
PULA
__FEED_COP_IN_HLI() ;
feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D,Copy ;
copy-byte loop
#else
LSRD ; /2 and save bit 0 in the carry
BEQ Copy1 ; do we copy more than 1 byte?
LSRD ;
/2 and save bit 0 in the carry
BEQ Copy1 ;
do we copy more than 1 byte?
Copy: PSHD
LDD 2,X+
GSTD 2,Y+ ; move a word from ROM to the data area
PULD
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D,Copy ; copy-word loop
Copy: PSHD
LDD 2,X+
GSTD 2,Y+ ;
move a word from ROM to the data area
PULD
__FEED_COP_IN_HLI() ;
feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D,Copy ;
copy-word loop
Copy1:
BCC NextBlock ; handle last byte?
LDAA 1,X+
GSTAA 1,Y+ ; move a byte from ROM to the data area
BCC NextBlock ;
handle last byte?
LDAA 1,X+
GSTAA 1,Y+ ;
move a byte from ROM to the data area
#endif
#elif defined(__OPTIMIZE_FOR_SIZE__) /* -os, default */
Copy: MOVB 1,X+,1,Y+ ; move a byte from ROM to the data area
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D,Copy ; copy-byte loop
Copy:
MOVB 1,X+,1,Y+ ;
move a byte from ROM to the data area
__FEED_COP_IN_HLI() ;
feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D,Copy ;
copy-byte loop
#else /* __OPTIMIZE_FOR_TIME__ */
LSRD ; /2 and save bit 0 in the carry
BEQ Copy1 ; do we copy more than 1 byte?
Copy: MOVW 2,X+,2,Y+ ; move a word from ROM to the data area
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D,Copy ; copy-word loop
LSRD ;
/2 and save bit 0 in the carry
BEQ Copy1 ;
do we copy more than 1 byte?
Copy: MOVW 2,X+,2,Y+ ;
move a word from ROM to the data area
__FEED_COP_IN_HLI() ;
feed the COP if necessary /*lint !e505 !e522 asm code */
DBNE D,Copy ;
copy-word loop
Copy1:
BCC NextBlock ; handle last byte?
MOVB 1,X+,1,Y+ ; copy the last byte
BCC NextBlock ;
handle last byte?
MOVB 1,X+,1,Y+ ;
copy the last byte
#endif /* __OPTIMIZE_FOR_SIZE__/__OPTIMIZE_FOR_TIME__ */
BRA NextBlock
funcInits: ; call of global construtors is only in c++ necessary
BRA NextBlock
funcInits:
;
call of global construtors is only in c++ necessary
#if defined(__cplusplus)
#if defined(__ELF_OBJECT_FILE_FORMAT__)
#if defined( __BANKED__) || defined(__LARGE__)
LDY _startupData.nofInitBodies; load number of cpp.
BEQ done ; if cppcount == 0, goto done
LDX _startupData.initBodies ; load address of first module to initialize
LDY _startupData.nofInitBodies;
load number of cpp.
BEQ done ;
if cppcount == 0, goto done
LDX _startupData.initBodies ;
load address of first module to initialize
nextInit:
LEAX 3,X ; increment to next init
PSHX ; save address of next function to initialize
PSHY ; save cpp counter
CALL [-3,X] ; use double indirect call to load the page register also
PULY ; restore cpp counter
PULX ; restore actual address
DEY ; decrement cpp counter
BNE nextInit
LEAX 3,X ;
increment to next init
PSHX ;
save address of next function to initialize
PSHY ;
save cpp counter
CALL [-3,X] ;
use double indirect call to load the page register also
PULY ;
restore cpp counter
PULX ;
restore actual address
DEY ;
decrement cpp counter
BNE nextInit
#else /* defined( __BANKED__) || defined(__LARGE__) */
LDD _startupData.nofInitBodies; load number of cpp.
BEQ done ; if cppcount == 0, goto done
LDX _startupData.initBodies ; load address of first module to initialize
LDD _startupData.nofInitBodies;
load number of cpp.
BEQ done ;
if cppcount == 0, goto done
LDX _startupData.initBodies ;
load address of first module to initialize
nextInit:
LDY 2,X+ ; load address of first module to initialize
PSHD
PSHX ; save actual address
JSR 0,Y ; call initialization function
PULX ; restore actual address
PULD ; restore cpp counter
DBNE D, nextInit
LDY 2,X+ ;
load address of first module to initialize
PSHD
PSHX ;
save actual address
JSR 0,Y ;
call initialization function
PULX ;
restore actual address
PULD ;
restore cpp counter
DBNE D, nextInit
#endif /* defined( __BANKED__) || defined(__LARGE__) */
#else /* __ELF_OBJECT_FILE_FORMAT__ */
LDX _startupData.mInits ; load address of first module to initialize
LDX _startupData.mInits ;
load address of first module to initialize
#if defined( __BANKED__) || defined(__LARGE__)
nextInit: LDY 3,X+ ; load address of initialization function
BEQ done ; stop when address == 0
; in common environments the offset of a function is never 0, so this test could be avoided
nextInit:
LDY 3,X+ ;
load address of initialization function
BEQ done ;
stop when address == 0
;
in common environments the offset of a function is never 0, so this test could be avoided
#ifdef __InitFunctionsMayHaveOffset0__
BRCLR -1,X, done, 0xff ; stop when address == 0
BRCLR -1,X, done, 0xff ;
stop when address == 0
#endif /* __InitFunctionsMayHaveOffset0__ */
PSHX ; save address of next function to initialize
CALL [-3,X] ; use double indirect call to load the page register also
PSHX ;
save address of next function to initialize
CALL [-3,X] ;
use double indirect call to load the page register also
#else /* defined( __BANKED__) || defined(__LARGE__) */
nextInit:
LDY 2,X+ ; load address of first module to initialize
BEQ done ; stop when address of function == 0
PSHX ; save actual address
JSR 0,Y ; call initialization function
LDY 2,X+ ;
load address of first module to initialize
BEQ done ;
stop when address of function == 0
PSHX ;
save actual address
JSR 0,Y ;
call initialization function
#endif /* defined( __BANKED__) || defined(__LARGE__) */
PULX ; restore actual address
BRA nextInit
PULX ;
restore actual address
BRA nextInit
#endif /* __ELF_OBJECT_FILE_FORMAT__ */
done:
#endif /* __cplusplus */
}
}
}
#endif /* __ONLY_INIT_SP */
@ -330,38 +432,57 @@ static void __far Fini(void)
static void Fini(void)
#endif
{
/* purpose: 1) call global destructors in C++ */
asm {
/* purpose: 1) call global destructors in C++ */
asm
{
#if defined( __BANKED__) || defined(__LARGE__)
LDY _startupData.nofFiniBodies; load number of cpp.
BEQ done ; if cppcount == 0, goto done
LDX _startupData.finiBodies ; load address of first module to finalize
nextInit2:
LEAX 3,X ; increment to next init
PSHX ; save address of next function to finalize
PSHY ; save cpp counter
CALL [-3,X] ; use double indirect call to load the page register also
PULY ; restore cpp counter
PULX ; restore actual address
DEY ; decrement cpp counter
BNE nextInit2
LDY _startupData.nofFiniBodies;
load number of cpp.
BEQ done ;
if cppcount == 0, goto done
LDX _startupData.finiBodies ;
load address of first module to finalize
nextInit2:
LEAX 3,X ;
increment to next init
PSHX ;
save address of next function to finalize
PSHY ;
save cpp counter
CALL [-3,X] ;
use double indirect call to load the page register also
PULY ;
restore cpp counter
PULX ;
restore actual address
DEY ;
decrement cpp counter
BNE nextInit2
#else /* defined( __BANKED__) || defined(__LARGE__) */
LDD _startupData.nofFiniBodies; load number of cpp.
BEQ done ; if cppcount == 0, goto done
LDX _startupData.finiBodies ; load address of first module to finalize
nextInit2:
LDY 2,X+ ; load address of first module to finalize
PSHD
PSHX ; save actual address
JSR 0,Y ; call finalize function
PULX ; restore actual address
PULD ; restore cpp counter
DBNE D, nextInit2
LDD _startupData.nofFiniBodies;
load number of cpp.
BEQ done ;
if cppcount == 0, goto done
LDX _startupData.finiBodies ;
load address of first module to finalize
nextInit2:
LDY 2,X+ ;
load address of first module to finalize
PSHD
PSHX ;
save actual address
JSR 0,Y ;
call finalize function
PULX ;
restore actual address
PULD ;
restore cpp counter
DBNE D, nextInit2
#endif /* defined(__BANKED__) || defined(__LARGE__) */
done:;
}
}
}
#endif
@ -390,35 +511,37 @@ done:;
/* the reset vector must be set so that the application has a defined entry point */
#if defined(__SET_RESET_VECTOR__)
__EXTERN_C void __interrupt 0 _Startup(void) {
__EXTERN_C void __interrupt 0 _Startup(void)
{
#else
__EXTERN_C void _Startup(void) {
__EXTERN_C void _Startup(void)
{
#endif
/* purpose: 1) initialize the stack
2) initialize the RAM, copy down init data etc (Init)
3) call main;
parameters: NONE
called from: _PRESTART-code generated by the Linker
or directly referenced by the reset vector */
/* purpose: 1) initialize the stack
2) initialize the RAM, copy down init data etc (Init)
3) call main;
parameters: NONE
called from: _PRESTART-code generated by the Linker
or directly referenced by the reset vector */
/* initialize the stack pointer */
/*lint -e{960} , MISRA 14.3 REQ, macro INIT_SP_FROM_STARTUP_DESC() expands to HLI code */
/*lint -e{522} , MISRA 14.2 REQ, macro INIT_SP_FROM_STARTUP_DESC() expands to HLI code */
/* With OpenBLT this function is not directly called at reset, but called by a custom
* reset handler. For this to work, the stackpointer must be initialized before this
* function is called, otherwise the RTS instruction won't know where to go.
*/
/*INIT_SP_FROM_STARTUP_DESC();*/ /* HLI macro definition in hidef.h */
/* initialize the stack pointer */
/*lint -e{960} , MISRA 14.3 REQ, macro INIT_SP_FROM_STARTUP_DESC() expands to HLI code */
/*lint -e{522} , MISRA 14.2 REQ, macro INIT_SP_FROM_STARTUP_DESC() expands to HLI code */
/* With OpenBLT this function is not directly called at reset, but called by a custom
* reset handler. For this to work, the stackpointer must be initialized before this
* function is called, otherwise the RTS instruction won't know where to go.
*/
/*INIT_SP_FROM_STARTUP_DESC();*/ /* HLI macro definition in hidef.h */
/* Here user defined code could be inserted, the stack could be used */
/* Here user defined code could be inserted, the stack could be used */
#if defined(_DO_DISABLE_COP_)
_DISABLE_COP();
_DISABLE_COP();
#endif
/* Example : Set up WinDef Register to allow Paging */
/* Example : Set up WinDef Register to allow Paging */
#ifdef HC812A4 /* HC12 A4 derivative needs WINDEF to configure which pages are available */
#if (__ENABLE_EPAGE__ != 0 || __ENABLE_DPAGE__ != 0 || __ENABLE_PPAGE__ != 0)
WINDEF= __ENABLE_EPAGE__ | __ENABLE_DPAGE__ | __ENABLE_PPAGE__;
WINDEF= __ENABLE_EPAGE__ | __ENABLE_DPAGE__ | __ENABLE_PPAGE__;
#endif
#endif
@ -453,19 +576,19 @@ __EXTERN_C void _Startup(void) {
#endif
#ifndef __ONLY_INIT_SP
/*lint -e{522} , MISRA 14.2 REQ, function Init() contains HLI only */
Init(); /* zero out, copy down, call constructors */
/*lint -e{522} , MISRA 14.2 REQ, function Init() contains HLI only */
Init(); /* zero out, copy down, call constructors */
#endif
/* Here user defined code could be inserted, all global variables are initilized */
/* Here user defined code could be inserted, all global variables are initilized */
#if defined(_DO_ENABLE_COP_)
_ENABLE_COP(1);
_ENABLE_COP(1);
#endif
/* OpenBLT modifcation: do not call main. instead do this in the reset handler found in
* vectors.c
*/
/* main(); */
/* OpenBLT modifcation: do not call main. instead do this in the reset handler found in
* vectors.c
*/
/* main(); */
}

View File

@ -107,7 +107,7 @@ void Vector0_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (0 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (0 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -132,7 +132,7 @@ void Vector1_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (1 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (1 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -157,7 +157,7 @@ void Vector2_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (2 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (2 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -182,7 +182,7 @@ void Vector3_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (3 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (3 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -207,7 +207,7 @@ void Vector4_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (4 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (4 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -232,7 +232,7 @@ void Vector5_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (5 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (5 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -257,7 +257,7 @@ void Vector6_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (6 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (6 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -282,7 +282,7 @@ void Vector7_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (7 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (7 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -307,7 +307,7 @@ void Vector8_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (8 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (8 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -332,7 +332,7 @@ void Vector9_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (9 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (9 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -357,7 +357,7 @@ void Vector10_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (10 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (10 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -382,7 +382,7 @@ void Vector11_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (11 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (11 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -407,7 +407,7 @@ void Vector12_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (12 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (12 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -432,7 +432,7 @@ void Vector13_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (13 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (13 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -457,7 +457,7 @@ void Vector14_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (14 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (14 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -482,7 +482,7 @@ void Vector15_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (15 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (15 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -507,7 +507,7 @@ void Vector16_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (16 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (16 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -532,7 +532,7 @@ void Vector17_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (17 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (17 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -557,7 +557,7 @@ void Vector18_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (18 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (18 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -582,7 +582,7 @@ void Vector19_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (19 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (19 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -607,7 +607,7 @@ void Vector20_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (20 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (20 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -632,7 +632,7 @@ void Vector21_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (21 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (21 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -657,7 +657,7 @@ void Vector22_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (22 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (22 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -682,7 +682,7 @@ void Vector23_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (23 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (23 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -707,7 +707,7 @@ void Vector24_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (24 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (24 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -732,7 +732,7 @@ void Vector25_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (25 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (25 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -757,7 +757,7 @@ void Vector26_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (26 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (26 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -782,7 +782,7 @@ void Vector27_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (27 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (27 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -807,7 +807,7 @@ void Vector28_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (28 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (28 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -832,7 +832,7 @@ void Vector29_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (29 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (29 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -857,7 +857,7 @@ void Vector30_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (30 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (30 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -882,7 +882,7 @@ void Vector31_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (31 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (31 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -908,7 +908,7 @@ void Vector32_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (32 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (32 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -933,7 +933,7 @@ void Vector33_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (33 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (33 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -958,7 +958,7 @@ void Vector34_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (34 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (34 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -983,7 +983,7 @@ void Vector35_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (35 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (35 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1008,7 +1008,7 @@ void Vector36_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (36 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (36 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1033,7 +1033,7 @@ void Vector37_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (37 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (37 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1058,7 +1058,7 @@ void Vector38_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (38 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (38 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1083,7 +1083,7 @@ void Vector39_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (39 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (39 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1108,7 +1108,7 @@ void Vector40_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (40 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (40 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1133,7 +1133,7 @@ void Vector41_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (41 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (41 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1158,7 +1158,7 @@ void Vector42_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (42 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (42 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1183,7 +1183,7 @@ void Vector43_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (43 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (43 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1208,7 +1208,7 @@ void Vector44_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (44 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (44 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1233,7 +1233,7 @@ void Vector45_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (45 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (45 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1258,7 +1258,7 @@ void Vector46_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (46 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (46 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1283,7 +1283,7 @@ void Vector47_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (47 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (47 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1308,7 +1308,7 @@ void Vector48_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (48 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (48 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1333,7 +1333,7 @@ void Vector49_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (49 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (49 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1358,7 +1358,7 @@ void Vector50_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (50 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (50 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1383,7 +1383,7 @@ void Vector51_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (51 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (51 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1408,7 +1408,7 @@ void Vector52_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (52 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (52 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1433,7 +1433,7 @@ void Vector53_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (53 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (53 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1458,7 +1458,7 @@ void Vector54_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (54 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (54 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1483,7 +1483,7 @@ void Vector55_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (55 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (55 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1508,7 +1508,7 @@ void Vector56_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (56 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (56 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1533,7 +1533,7 @@ void Vector57_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (57 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (57 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1558,7 +1558,7 @@ void Vector58_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (58 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (58 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1583,7 +1583,7 @@ void Vector59_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (59 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (59 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1608,7 +1608,7 @@ void Vector60_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (60 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (60 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1633,7 +1633,7 @@ void Vector61_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (61 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (61 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.
@ -1658,7 +1658,7 @@ void Vector62_handler(void)
asm
{
/* Load the address of the user program's ISR into X. */
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (62 * 2))
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (62 * 2))
/* Jump there. It is important to use the JMP instruction here as opposed to other
* branch instruction, because the JMP instruction does not modify the stack by
* saving a return address for example.

View File

@ -187,26 +187,27 @@ static blt_bool CanGetSpeedConfig(blt_int16u baud, blt_int8u *btr0, blt_int8u *b
* with a sample point between 68..78%.
*/
static const tCanBusTiming canTiming[] =
{ /* TQ | TSEG1 | TSEG2 | SP */
/* ------------------------- */
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
{ 6, 3 }, /* 10 | 6 | 3 | 70% */
{ 7, 3 }, /* 11 | 7 | 3 | 73% */
{ 8, 3 }, /* 12 | 8 | 3 | 75% */
{ 9, 3 }, /* 13 | 9 | 3 | 77% */
{ 9, 4 }, /* 14 | 9 | 4 | 71% */
{ 10, 4 }, /* 15 | 10 | 4 | 73% */
{ 11, 4 }, /* 16 | 11 | 4 | 75% */
{ 12, 4 }, /* 17 | 12 | 4 | 76% */
{ 12, 5 }, /* 18 | 12 | 5 | 72% */
{ 13, 5 }, /* 19 | 13 | 5 | 74% */
{ 14, 5 }, /* 20 | 14 | 5 | 75% */
{ 15, 5 }, /* 21 | 15 | 5 | 76% */
{ 15, 6 }, /* 22 | 15 | 6 | 73% */
{ 16, 6 }, /* 23 | 16 | 6 | 74% */
{ 16, 7 }, /* 24 | 16 | 7 | 71% */
{ 16, 8 } /* 25 | 16 | 8 | 68% */
{
/* TQ | TSEG1 | TSEG2 | SP */
/* ------------------------- */
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
{ 6, 3 }, /* 10 | 6 | 3 | 70% */
{ 7, 3 }, /* 11 | 7 | 3 | 73% */
{ 8, 3 }, /* 12 | 8 | 3 | 75% */
{ 9, 3 }, /* 13 | 9 | 3 | 77% */
{ 9, 4 }, /* 14 | 9 | 4 | 71% */
{ 10, 4 }, /* 15 | 10 | 4 | 73% */
{ 11, 4 }, /* 16 | 11 | 4 | 75% */
{ 12, 4 }, /* 17 | 12 | 4 | 76% */
{ 12, 5 }, /* 18 | 12 | 5 | 72% */
{ 13, 5 }, /* 19 | 13 | 5 | 74% */
{ 14, 5 }, /* 20 | 14 | 5 | 75% */
{ 15, 5 }, /* 21 | 15 | 5 | 76% */
{ 15, 6 }, /* 22 | 15 | 6 | 73% */
{ 16, 6 }, /* 23 | 16 | 6 | 74% */
{ 16, 7 }, /* 24 | 16 | 7 | 71% */
{ 16, 8 } /* 25 | 16 | 8 | 68% */
};
@ -370,13 +371,13 @@ blt_bool CanReceivePacket(blt_int8u *data)
if ((CAN->rxSlot.idr[1] & IDE_BIT) == 0)
{
/* 11-bit id */
rxMsgId = (*(blt_int16u*)(&CAN->rxSlot.idr[0])) >> 5;
rxMsgId = (*(blt_int16u *)(&CAN->rxSlot.idr[0])) >> 5;
}
else
{
/* 29-bit id */
rxMsgId = (blt_int32u)(((*(blt_int32u*)(&CAN->rxSlot.idr[0])) & 0x0007ffff) >> 1) |
(blt_int32u)(((*(blt_int32u*)(&CAN->rxSlot.idr[0])) & 0xffe00000) >> 3);
rxMsgId = (blt_int32u)(((*(blt_int32u *)(&CAN->rxSlot.idr[0])) & 0x0007ffff) >> 1) |
(blt_int32u)(((*(blt_int32u *)(&CAN->rxSlot.idr[0])) & 0xffe00000) >> 3);
}
/* is this the packet identifier? */
if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID)
@ -421,7 +422,7 @@ static blt_bool CanGetSpeedConfig(blt_int16u baud, blt_int8u *btr0, blt_int8u *b
prescaler = (blt_int8u)(BOOT_CPU_XTAL_SPEED_KHZ/(baud*(canTiming[cnt].tseg1+canTiming[cnt].tseg2+1)));
/* make sure the prescaler is valid */
if ( (prescaler > 0) && (prescaler <= 64) )
if ((prescaler > 0) && (prescaler <= 64))
{
/* store the MSCAN bustiming register values */
*btr0 = prescaler - 1;

View File

@ -78,25 +78,25 @@ void CpuStartUserProgram(void)
/* not a valid user program so it cannot be started */
return;
}
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
/* invoke callback */
if (CpuUserProgramStartHook() == BLT_FALSE)
{
/* callback requests the user program to not be started */
return;
}
#endif
#if (BOOT_COM_ENABLE > 0)
#endif
#if (BOOT_COM_ENABLE > 0)
/* release the communication interface */
ComFree();
#endif
#endif
/* reset the timer */
TimerReset();
/* set the address where the bootloader needs to jump to. this is the address of
* the last entry in the user program's vector table. this address points to the
* user program's reset handler.
*/
pProgResetHandler = (void(*)(void))(*((blt_int16u*)CPU_USER_PROGRAM_STARTADDR_PTR));
pProgResetHandler = (void(*)(void))(*((blt_int16u *)CPU_USER_PROGRAM_STARTADDR_PTR));
/* start the user program by activating its reset interrupt service routine */
pProgResetHandler();
} /*** end of CpuStartUserProgram ***/
@ -119,7 +119,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
to = (blt_int8u *)dest;
/* copy all bytes from source address to destination address */
while(len-- > 0)
while (len-- > 0)
{
/* store byte value from source to destination */
*to++ = *from++;

View File

@ -139,7 +139,7 @@ typedef volatile struct
} tFlashRegs;
/** \brief Pointer type to flash command execution function. */
typedef void (*pFlashExeCmdFct) (void);
typedef void (*pFlashExeCmdFct)(void);
/****************************************************************************************
@ -358,7 +358,7 @@ void FlashInit(void)
clockFreq = BOOT_CPU_XTAL_SPEED_KHZ / (prescaler * (1 + cnt));
/* is this a valid setting? */
if ( (clockFreq > 150) && (clockFreq < 200) )
if ((clockFreq > 150) && (clockFreq < 200))
{
/* configure the setting while taking into account the prescaler */
if (prescaler == 8)
@ -397,7 +397,7 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
blt_addr last_block_base_addr;
/* make sure the addresses are within the flash device */
if ( (addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS) )
if ((addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS))
{
return BLT_FALSE;
}
@ -441,7 +441,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
erase_base_addr = (addr/FLASH_ERASE_BLOCK_SIZE)*FLASH_ERASE_BLOCK_SIZE;
/* make sure the addresses are within the flash device */
if ( (erase_base_addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS) )
if ((erase_base_addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS))
{
return BLT_FALSE;
}
@ -450,7 +450,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
total_erase_len = len + (addr - erase_base_addr);
/* determine the number of blocks to erase */
nr_of_erase_blocks = (blt_int16u) (total_erase_len / FLASH_ERASE_BLOCK_SIZE);
nr_of_erase_blocks = (blt_int16u)(total_erase_len / FLASH_ERASE_BLOCK_SIZE);
if ((total_erase_len % FLASH_ERASE_BLOCK_SIZE) > 0)
{
nr_of_erase_blocks++;
@ -535,7 +535,7 @@ blt_bool FlashWriteChecksum(void)
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \
FLASH_VECTOR_TABLE_CS_OFFSET;
return FlashWrite(checksum_address, sizeof(signature_checksum),
(blt_int8u*)&signature_checksum);
(blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -567,7 +567,7 @@ blt_bool FlashVerifyChecksum(void)
}
/* add the 16-bit checksum value */
signature_checksum += (((blt_int16u)FlashGetLinearAddrByte(checksum_addr_lin) << 8) +
FlashGetLinearAddrByte(checksum_addr_lin + 1));
FlashGetLinearAddrByte(checksum_addr_lin + 1));
/* sum should add up to an unsigned 16-bit value of 0 */
if (signature_checksum == 0)
{
@ -826,7 +826,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int16u)); word_cnt++)
{
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int16u));
prog_data = *(volatile blt_int16u*)(&block->data[word_cnt * sizeof(blt_int16u)]);
prog_data = *(volatile blt_int16u *)(&block->data[word_cnt * sizeof(blt_int16u)]);
/* keep the watchdog happy */
CopService();
/* program the word to flash */
@ -873,7 +873,7 @@ static blt_int8u FlashGetLinearAddrByte(blt_addr addr)
FLASH_PPAGE_REG = FlashGetPhysPage(addr);
/* read the byte value from the page address */
result = *((blt_int8u*)FlashGetPhysAddr(addr));
result = *((blt_int8u *)FlashGetPhysAddr(addr));
/* restore originally selected page */
FLASH_PPAGE_REG = oldPage;
@ -930,7 +930,7 @@ static void FlashExecuteCommand(void)
}
/* init the function pointer */
pExecCommandFct = (pFlashExeCmdFct) ((void *)flashExecCmdRam);
pExecCommandFct = (pFlashExeCmdFct)((void *)flashExecCmdRam);
/* call the command execution function */
pExecCommandFct();
} /*** end of FlashExecuteCommand ***/
@ -973,7 +973,7 @@ static blt_bool FlashOperate(blt_int8u cmd, blt_addr addr, blt_int16u data)
if ((FLASH->fstat & CBEIF_BIT) == CBEIF_BIT)
{
/* write data value to the physical address to operate on */
*((blt_int16u*)FlashGetPhysAddr(addr)) = data;
*((blt_int16u *)FlashGetPhysAddr(addr)) = data;
/* write the command */
FLASH->fcmd = cmd;
/* launch the actual command */

View File

@ -146,7 +146,7 @@ typedef volatile struct
} tFlashRegs;
/** \brief Pointer type to flash command execution function. */
typedef void (*pFlashExeCmdFct) (void);
typedef void (*pFlashExeCmdFct)(void);
/** \brief Mapping table for finding the corect flash clock divider prescaler. */
typedef struct
@ -378,8 +378,8 @@ void FlashInit(void)
/* try to find correct flash clock divider setting using the lookup table */
for (cnt=0; cnt<(sizeof(flashFDIVlookup)/sizeof(flashFDIVlookup[0])); cnt++)
{
if ( (BOOT_CPU_SYSTEM_SPEED_KHZ > flashFDIVlookup[cnt].sysclock_min) &&
(BOOT_CPU_SYSTEM_SPEED_KHZ <= flashFDIVlookup[cnt].sysclock_max) )
if ((BOOT_CPU_SYSTEM_SPEED_KHZ > flashFDIVlookup[cnt].sysclock_min) &&
(BOOT_CPU_SYSTEM_SPEED_KHZ <= flashFDIVlookup[cnt].sysclock_max))
{
/* matching configuration found in the lookup table so store it */
fdiv_bits = flashFDIVlookup[cnt].prescaler;
@ -392,7 +392,7 @@ void FlashInit(void)
ASSERT_RT(fdiv_bits != FLASH_FDIV_INVALID);
/* wait until all flash commands are finished */
while((FLASH->fstat & CCIF_BIT) == 0)
while ((FLASH->fstat & CCIF_BIT) == 0)
{
;
}
@ -429,7 +429,7 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
blt_addr last_block_base_addr;
/* make sure the addresses are within the flash device */
if ( (addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS) )
if ((addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS))
{
return BLT_FALSE;
}
@ -473,7 +473,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
erase_base_addr = (addr/FLASH_ERASE_BLOCK_SIZE)*FLASH_ERASE_BLOCK_SIZE;
/* make sure the addresses are within the flash device */
if ( (erase_base_addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS) )
if ((erase_base_addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS))
{
return BLT_FALSE;
}
@ -482,7 +482,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
total_erase_len = len + (addr - erase_base_addr);
/* determine the number of blocks to erase */
nr_of_erase_blocks = (blt_int16u) (total_erase_len / FLASH_ERASE_BLOCK_SIZE);
nr_of_erase_blocks = (blt_int16u)(total_erase_len / FLASH_ERASE_BLOCK_SIZE);
if ((total_erase_len % FLASH_ERASE_BLOCK_SIZE) > 0)
{
nr_of_erase_blocks++;
@ -568,7 +568,7 @@ blt_bool FlashWriteChecksum(void)
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \
FLASH_VECTOR_TABLE_CS_OFFSET;
return FlashWrite(checksum_address, sizeof(signature_checksum),
(blt_int8u*)&signature_checksum);
(blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -600,7 +600,7 @@ blt_bool FlashVerifyChecksum(void)
}
/* add the 16-bit checksum value */
signature_checksum += (((blt_int16u)FlashGetGlobalAddrByte(checksum_addr_glob) << 8) +
FlashGetGlobalAddrByte(checksum_addr_glob + 1));
FlashGetGlobalAddrByte(checksum_addr_glob + 1));
/* sum should add up to an unsigned 16-bit value of 0 */
if (signature_checksum == 0)
{
@ -896,7 +896,7 @@ static blt_int8u FlashGetGlobalAddrByte(blt_addr addr)
FLASH_PPAGE_REG = FlashGetPhysPage(addr);
/* read the byte value from the page address */
result = *((blt_int8u*)FlashGetPhysAddr(addr));
result = *((blt_int8u *)FlashGetPhysAddr(addr));
/* restore originally selected page */
FLASH_PPAGE_REG = oldPage;
@ -953,7 +953,7 @@ static void FlashExecuteCommand(void)
}
/* init the function pointer */
pExecCommandFct = (pFlashExeCmdFct) ((void *)flashExecCmdRam);
pExecCommandFct = (pFlashExeCmdFct)((void *)flashExecCmdRam);
/* call the command execution function */
pExecCommandFct();
} /*** end of FlashExecuteCommand ***/
@ -988,7 +988,7 @@ static blt_bool FlashOperate(blt_int8u cmd, blt_addr addr, blt_int16u params[],
}
/* clear possibly pending error flags from the previous command */
FLASH->fstat = (FPVIOL_BIT | ACCERR_BIT);
FLASH->fstat = (FPVIOL_BIT | ACCERR_BIT);
/* write the command and the address to operate on */
FLASH->fccobix = 0;

View File

@ -231,7 +231,7 @@ blt_bool UartReceivePacket(blt_int8u *data)
static blt_bool UartReceiveByte(blt_int8u *data)
{
/* check if a new byte was received by means of the RDRF-bit */
if((UART->scisr1 & RDRF_BIT) != 0)
if ((UART->scisr1 & RDRF_BIT) != 0)
{
/* store the received byte */
data[0] = UART->scidrl;
@ -260,7 +260,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
/* write byte to transmit holding register */
UART->scidrl = data;
/* wait for tx holding register to be empty */
while((UART->scisr1 & TDRE_BIT) == 0)
while ((UART->scisr1 & TDRE_BIT) == 0)
{
/* keep the watchdog happy */
CopService();

View File

@ -94,7 +94,7 @@ static void CpuWriteWDTCON0(blt_int32u value)
/* set HWPW1 = 1111b */
dummy |= 0x000000F0;
/* set HWPW0 = WDTDR */
if(WDT_CON1.bits.DR)
if (WDT_CON1.bits.DR)
{
dummy |= 0x00000008;
}
@ -103,7 +103,7 @@ static void CpuWriteWDTCON0(blt_int32u value)
dummy &= ~0x00000008;
}
/* set HWPW0 = WDTIR */
if(WDT_CON1.bits.IR)
if (WDT_CON1.bits.IR)
{
dummy |= 0x00000004;
}

View File

@ -74,25 +74,25 @@ void CpuStartUserProgram(void)
/* not a valid user program so it cannot be started */
return;
}
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
/* invoke callback */
if (CpuUserProgramStartHook() == BLT_FALSE)
{
/* callback requests the user program to not be started */
return;
}
#endif
#if (BOOT_COM_ENABLE > 0)
#endif
#if (BOOT_COM_ENABLE > 0)
/* release the communication interface */
ComFree();
#endif
#endif
/* reset the timer */
TimerReset();
/* set the address where the bootloader needs to jump to. the user program entry,
* typically called _start, is expected to be located at the start of the user program
* flash.
*/
pProgResetHandler = (void(*)(void))((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR);
pProgResetHandler = (void(*)(void))((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR);
/* start the user program by activating its reset interrupt service routine */
pProgResetHandler();
} /*** end of CpuStartUserProgram ***/
@ -115,7 +115,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
to = (blt_int8u *)dest;
/* copy all bytes from source address to destination address */
while(len-- > 0)
while (len-- > 0)
{
/* store byte value from source to destination */
*to++ = *from++;

View File

@ -243,8 +243,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
blt_addr base_addr;
/* make sure the addresses are within the flash device */
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -279,7 +279,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
first_sector = FlashGetSector(addr);
last_sector = FlashGetSector(addr+len-1);
/* check them */
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
{
return BLT_FALSE;
}
@ -328,23 +328,23 @@ blt_bool FlashWriteChecksum(void)
* bootblock is not part of the reprogramming this time and therefore no
* new checksum needs to be written
*/
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
if (bootBlockInfo.base_addr == FLASH_INVALID_ADDRESS)
{
return BLT_TRUE;
}
}
/* compute the checksum. note that the data in the checksum range is not yet written
* to flash but is present in the bootblock data structure at this point.
*/
for (wordIdx = 0; wordIdx < FLASH_CS_RANGE_TOTAL_WORDS; wordIdx++)
{
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[(wordIdx*4)+FLASH_CS_RANGE_START_OFFSET]));
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[(wordIdx*4)+FLASH_CS_RANGE_START_OFFSET]));
}
signature_checksum = ~signature_checksum; /* one's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_CS_OFFSET,
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -363,14 +363,14 @@ blt_bool FlashVerifyChecksum(void)
/* compute the checksum by reading it from flash */
for (wordIdx = 0; wordIdx < FLASH_CS_RANGE_TOTAL_WORDS; wordIdx++)
{
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start + (wordIdx*4) + FLASH_CS_RANGE_START_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start + (wordIdx*4) + FLASH_CS_RANGE_START_OFFSET));
}
signature_checksum = ~signature_checksum; /* one's complement */
/* read the checksum value from flash that was writtin by the bootloader at the end
* of the last firmware update
*/
signature_checksum_rom = *((blt_int32u*)(flashLayout[0].sector_start + FLASH_CS_OFFSET));
signature_checksum_rom = *((blt_int32u *)(flashLayout[0].sector_start + FLASH_CS_OFFSET));
/* verify that they are both the same */
if (signature_checksum == signature_checksum_rom)
{
@ -618,8 +618,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
{
return BLT_FALSE;
}
if ( (first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
if ((first_sector < flashLayout[0].sector_num) || \
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
{
return BLT_FALSE;
}
@ -659,9 +659,9 @@ static blt_int8u FlashGetSector(blt_addr address)
/* keep the watchdog happy */
CopService();
/* is the address in this sector? */
if ( (address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)) )
if ((address >= flashLayout[sectorIdx].sector_start) && \
(address < (flashLayout[sectorIdx].sector_start + \
flashLayout[sectorIdx].sector_size)))
{
/* return the sector number */
return flashLayout[sectorIdx].sector_num;
@ -756,21 +756,21 @@ static blt_bool FlashTricoreProgramPage(blt_addr start_addr, blt_int8u *data)
/* perform DSYNC */
CpuSetDSYNC();
/* wait until FSR.xFPAGE = '1' */
while(pflashFSR->bits.PFPAGE != 1)
{
while (pflashFSR->bits.PFPAGE != 1)
{
/* fail if FSR.SQER = '1' */
if (pflashFSR->bits.SQER == 1)
{
return BLT_FALSE;
}
if (pflashFSR->bits.SQER == 1)
{
return BLT_FALSE;
}
/* fail if FSR.PROER = '1' */
if (pflashFSR->bits.PROER == 1)
{
return BLT_FALSE;
}
if (pflashFSR->bits.PROER == 1)
{
return BLT_FALSE;
}
/* keep the watchdog happy */
CopService();
}
}
/* load FLASH_WRITE_BLOCK_SIZE bytes of program data into the assembly buffer */
dataPtr = (blt_int32u *)data;
for (idx = 0; idx <(FLASH_WRITE_BLOCK_SIZE/8u); idx++)
@ -790,49 +790,49 @@ static blt_bool FlashTricoreProgramPage(blt_addr start_addr, blt_int8u *data)
/* perform DSYNC */
CpuSetDSYNC();
/* wait until FSR.PROG = '1' */
while(pflashFSR->bits.PROG != 1)
{
while (pflashFSR->bits.PROG != 1)
{
/* fail if FSR.SQER = '1' */
if (pflashFSR->bits.SQER == 1)
{
return BLT_FALSE;
}
if (pflashFSR->bits.SQER == 1)
{
return BLT_FALSE;
}
/* fail if FSR.PROER = '1' */
if (pflashFSR->bits.PROER == 1)
{
return BLT_FALSE;
}
if (pflashFSR->bits.PROER == 1)
{
return BLT_FALSE;
}
/* keep the watchdog happy */
CopService();
}
}
/* wait until FSR.xBUSY = '0' */
while(pflashFSR->bits.PBUSY == 1)
{
while (pflashFSR->bits.PBUSY == 1)
{
/* check flag FSR.xFOPER for 1 as abort criterion to protect against hardware
* failures causing BUSY to stay '1'
*/
if (pflashFSR->bits.PFOPER == 1)
{
return BLT_FALSE;
}
if (pflashFSR->bits.PFOPER == 1)
{
return BLT_FALSE;
}
/* keep the watchdog happy */
CopService();
}
}
/* check FSR.VER flag */
if (pflashFSR->bits.VER != 0)
{
return BLT_FALSE;
}
if (pflashFSR->bits.VER != 0)
{
return BLT_FALSE;
}
/* fail if FSR.xFOPER = '1' */
if (pflashFSR->bits.PFOPER != 0)
{
return BLT_FALSE;
}
if (pflashFSR->bits.PFOPER != 0)
{
return BLT_FALSE;
}
/* evaluate FSR.xDBER */
if(pflashFSR->bits.PFDBER != 0)
{
return BLT_FALSE;
}
if (pflashFSR->bits.PFDBER != 0)
{
return BLT_FALSE;
}
/* use "clear status" command to clear flags */
FLASH_WRITE_TO_U32_PTR_BY_ADDR(baseAddr + 0x5554u, 0x000000F5u);
/* perform verification by checking the written values. do this on a byte-per-byte
@ -886,44 +886,44 @@ static blt_bool FlashTricoreEraseSector(blt_addr start_addr)
/* perform DSYNC */
CpuSetDSYNC();
/* wait until FSR.ERASE = '1' */
while(pflashFSR->bits.ERASE != 1)
{
while (pflashFSR->bits.ERASE != 1)
{
/* fail if FSR.SQER = '1' */
if (pflashFSR->bits.SQER == 1)
{
return BLT_FALSE;
}
if (pflashFSR->bits.SQER == 1)
{
return BLT_FALSE;
}
/* fail if FSR.PROER = '1' */
if (pflashFSR->bits.PROER == 1)
{
return BLT_FALSE;
}
if (pflashFSR->bits.PROER == 1)
{
return BLT_FALSE;
}
/* keep the watchdog happy */
CopService();
}
}
/* wait until FSR.xBUSY = '0' */
while(pflashFSR->bits.PBUSY == 1)
{
while (pflashFSR->bits.PBUSY == 1)
{
/* check flag FSR.xFOPER for 1 as abort criterion to protect against hardware
* failures causing BUSY to stay '1'
*/
if (pflashFSR->bits.PFOPER == 1)
{
return BLT_FALSE;
}
if (pflashFSR->bits.PFOPER == 1)
{
return BLT_FALSE;
}
/* keep the watchdog happy */
CopService();
}
}
/* check FSR.VER flag */
if (pflashFSR->bits.VER != 0)
{
return BLT_FALSE;
}
if (pflashFSR->bits.VER != 0)
{
return BLT_FALSE;
}
/* fail if FSR.xFOPER = '1' */
if (pflashFSR->bits.PFOPER != 0)
{
return BLT_FALSE;
}
if (pflashFSR->bits.PFOPER != 0)
{
return BLT_FALSE;
}
/* use "clear status" command to clear flags */
FLASH_WRITE_TO_U32_PTR_BY_ADDR(baseAddr + 0x5554u, 0x000000F5u);

View File

@ -44,23 +44,23 @@
****************************************************************************************/
typedef struct
{
blt_int32u reserved0[0x1]; /* 0x0 */
ASCn_PISEL_t PISEL; /* 0x4 */
ASCn_ID_t ID; /* 0x8 */
blt_int32u reserved3[0x1]; /* 0xc */
ASCn_CON_t CON; /* 0x10 */
ASCn_BG_t BG; /* 0x14 */
ASCn_FDV_t FDV; /* 0x18 */
blt_int32u reserved7[0x1]; /* 0x1c */
ASCn_TBUF_t TBUF; /* 0x20 */
ASCn_RBUF_t RBUF; /* 0x24 */
blt_int32u reserved10[0xa]; /* 0x28 */
ASCn_WHBCON_t WHBCON; /* 0x50 */
blt_int32u reserved12[0x27]; /* 0x54 */
ASCn_TSRC_t TSRC; /* 0xf0 */
ASCn_RSRC_t RSRC; /* 0xf4 */
ASCn_ESRC_t ESRC; /* 0xf8 */
ASCn_TBSRC_t TBSRC; /* 0xfc */
blt_int32u reserved0[0x1]; /* 0x0 */
ASCn_PISEL_t PISEL; /* 0x4 */
ASCn_ID_t ID; /* 0x8 */
blt_int32u reserved3[0x1]; /* 0xc */
ASCn_CON_t CON; /* 0x10 */
ASCn_BG_t BG; /* 0x14 */
ASCn_FDV_t FDV; /* 0x18 */
blt_int32u reserved7[0x1]; /* 0x1c */
ASCn_TBUF_t TBUF; /* 0x20 */
ASCn_RBUF_t RBUF; /* 0x24 */
blt_int32u reserved10[0xa]; /* 0x28 */
ASCn_WHBCON_t WHBCON; /* 0x50 */
blt_int32u reserved12[0x27]; /* 0x54 */
ASCn_TSRC_t TSRC; /* 0xf0 */
ASCn_RSRC_t RSRC; /* 0xf4 */
ASCn_ESRC_t ESRC; /* 0xf8 */
ASCn_TBSRC_t TBSRC; /* 0xfc */
} tUartRegs;
@ -104,33 +104,33 @@ void UartInit(void)
{
blt_int32u frequency, reload_value, fdv, dfreq;
/* Compute system frequency and reload value for ASC */
frequency = BOOT_CPU_SYSTEM_SPEED_KHZ * 1000;
/* Compute system frequency and reload value for ASC */
frequency = BOOT_CPU_SYSTEM_SPEED_KHZ * 1000;
/* reload_value = fdv/512 * freq/16/baudrate -1 ==>
/* reload_value = fdv/512 * freq/16/baudrate -1 ==>
* reload_value = (512*freq)/(baudrate * 512*16) - 1
* fdv = (reload_value + 1) * (baudrate*512*16/freq)
* reload_value = (frequency / 32) / baudrate - 1;
*/
reload_value = (frequency / ((blt_int32u)BOOT_COM_UART_BAUDRATE * 16)) - 1;
dfreq = frequency / (16*512);
fdv = (reload_value + 1) * (blt_int32u)BOOT_COM_UART_BAUDRATE / dfreq;
*/
reload_value = (frequency / ((blt_int32u)BOOT_COM_UART_BAUDRATE * 16)) - 1;
dfreq = frequency / (16*512);
fdv = (reload_value + 1) * (blt_int32u)BOOT_COM_UART_BAUDRATE / dfreq;
/* enable ASC module */
CpuEnterInitMode();
ASC0_CLC.bits.RMC = 1;
ASC0_CLC.bits.DISR = 0;
CpuLeaveInitMode();
/* enable ASC module */
CpuEnterInitMode();
ASC0_CLC.bits.RMC = 1;
ASC0_CLC.bits.DISR = 0;
CpuLeaveInitMode();
/* configure the ASC module for 8,n,1 */
UARTx->CON.reg = 0;
UARTx->BG.reg = reload_value;
UARTx->FDV.reg = fdv;
UARTx->BG.reg = reload_value;
UARTx->FDV.reg = fdv;
UARTx->CON.bits.M = 0x01;
UARTx->CON.bits.R = 1;
UARTx->CON.bits.REN = 1;
UARTx->CON.bits.FDE = 1;
UARTx->CON.bits.M = 0x01;
UARTx->CON.bits.R = 1;
UARTx->CON.bits.REN = 1;
UARTx->CON.bits.FDE = 1;
} /*** end of UartInit ***/
@ -270,7 +270,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
/* write byte to transmit buffer register */
UARTx->TBUF.reg = data;
/* wait for transmit buffer register to be empty */
while(UARTx->TBSRC.bits.SRR == 0)
while (UARTx->TBSRC.bits.SRR == 0)
{
CopService();
}

View File

@ -61,7 +61,7 @@ void AssertFailure(blt_char *file, blt_int32u line)
assert_failure_file = file;
assert_failure_line = line;
/* hang the software so that it requires a hard reset */
for(;;)
for (;;)
{
/* keep servicing the watchdog so that this one does not cause a reset */
CopService();

View File

@ -40,15 +40,15 @@
* for runtime assertions.
*/
#ifdef NDEBUG
#define ASSERT_CT(cond) ((void)0)
#define ASSERT_RT(cond) ((void)0)
#define ASSERT_CT(cond) ((void)0)
#define ASSERT_RT(cond) ((void)0)
#else
#define ASSERT_CONCAT_(a, b) a##b
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
/** \brief Macro for assertions that can be performed at compile time. */
#define ASSERT_CT(cond) enum { ASSERT_CONCAT(assert_error_on_line_, __LINE__) = 1/(!!(cond)) }
/** \brief Macro for assertions that can only be performed at run time. */
#define ASSERT_RT(cond) \
#define ASSERT_CONCAT_(a, b) a##b
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
/** \brief Macro for assertions that can be performed at compile time. */
#define ASSERT_CT(cond) enum { ASSERT_CONCAT(assert_error_on_line_, __LINE__) = 1/(!!(cond)) }
/** \brief Macro for assertions that can only be performed at run time. */
#define ASSERT_RT(cond) \
if (cond) \
{ ; } \
else \

View File

@ -41,25 +41,25 @@
* Macro definitions
****************************************************************************************/
#if (BOOT_BACKDOOR_HOOKS_ENABLE == 0)
#ifndef BACKDOOR_ENTRY_TIMEOUT_MS
/** \brief Sets the time in milliseconds that the backdoor is open, but allow an
* override for this time. note that this time should be at least 2.5 times
* as long as the time that is configured in Microboot's XCP settings for the
* connect command response. This is the last entry on XCP Timeouts tab. By
* default the connect command response is configured as 20ms by Microboot,
* except for TCP/IP where it is 300ms due to accomodate for worldwide
* network latency. The default value was chosen safely for compatibility
* reasons with all supported communication interfaces. It could be made
* shorter your bootloader. To change this value, simply add the macro
* BACKDOOR_ENTRY_TIMEOUT_MS to blt_conf.h with your desired backdoor open time
* in milliseconds.
*/
#if (BOOT_COM_NET_ENABLE == 1)
#define BACKDOOR_ENTRY_TIMEOUT_MS (750)
#else
#define BACKDOOR_ENTRY_TIMEOUT_MS (500)
#endif
#endif
#ifndef BACKDOOR_ENTRY_TIMEOUT_MS
/** \brief Sets the time in milliseconds that the backdoor is open, but allow an
* override for this time. note that this time should be at least 2.5 times
* as long as the time that is configured in Microboot's XCP settings for the
* connect command response. This is the last entry on XCP Timeouts tab. By
* default the connect command response is configured as 20ms by Microboot,
* except for TCP/IP where it is 300ms due to accomodate for worldwide
* network latency. The default value was chosen safely for compatibility
* reasons with all supported communication interfaces. It could be made
* shorter your bootloader. To change this value, simply add the macro
* BACKDOOR_ENTRY_TIMEOUT_MS to blt_conf.h with your desired backdoor open time
* in milliseconds.
*/
#if (BOOT_COM_NET_ENABLE == 1)
#define BACKDOOR_ENTRY_TIMEOUT_MS (750)
#else
#define BACKDOOR_ENTRY_TIMEOUT_MS (500)
#endif
#endif
#endif
/****************************************************************************************
@ -99,7 +99,7 @@ void BackDoorInit(void)
/* this function does not return if a valid user program is present */
CpuStartUserProgram();
}
#if (BOOT_FILE_SYS_ENABLE > 0)
#if (BOOT_FILE_SYS_ENABLE > 0)
else
{
/* the backdoor is open so we should check if a update from locally attached storage
@ -107,7 +107,7 @@ void BackDoorInit(void)
*/
FileHandleFirmwareUpdateRequest();
}
#endif
#endif
#else
/* open the backdoor after a reset */
backdoorOpen = BLT_TRUE;
@ -129,7 +129,7 @@ void BackDoorInit(void)
void BackDoorCheck(void)
{
#if (BOOT_BACKDOOR_HOOKS_ENABLE == 0)
#if (BOOT_COM_ENABLE > 0)
#if (BOOT_COM_ENABLE > 0)
/* check if a connection with the host was already established. in this case the
* backdoor stays open anyway, so no need to check if it needs to be closed.
*/
@ -137,8 +137,8 @@ void BackDoorCheck(void)
{
return;
}
#endif
#if (BOOT_FILE_SYS_ENABLE > 0)
#endif
#if (BOOT_FILE_SYS_ENABLE > 0)
/* check if the file module is busy, indicating that a firmware update through the
* locally attached storage is in progress. in this case the backdoor stays open
* anyway, so no need to check if it needs to be closed.
@ -147,7 +147,7 @@ void BackDoorCheck(void)
{
return;
}
#endif
#endif
/* when the backdoor is still open, check if it's time to close it */
if (backdoorOpen == BLT_TRUE)
@ -157,13 +157,13 @@ void BackDoorCheck(void)
{
/* close the backdoor */
backdoorOpen = BLT_FALSE;
#if (BOOT_FILE_SYS_ENABLE > 0)
#if (BOOT_FILE_SYS_ENABLE > 0)
/* during the timed backdoor no remote update request was detected. now do one
* last check to see if a firmware update from locally attached storage is
* pending.
*/
if (FileHandleFirmwareUpdateRequest() == BLT_FALSE)
#endif
#endif
{
/* no firmware update requests detected, so attempt to start the user program.
* this function does not return if a valid user program is present.

View File

@ -50,14 +50,14 @@ void BootInit(void)
TimerInit();
/* initialize the non-volatile memory driver */
NvmInit();
#if (BOOT_FILE_SYS_ENABLE > 0)
#if (BOOT_FILE_SYS_ENABLE > 0)
/* initialize the file system module */
FileInit();
#endif
#if (BOOT_COM_ENABLE > 0)
#endif
#if (BOOT_COM_ENABLE > 0)
/* initialize the communication module */
ComInit();
#endif
#endif
/* initialize the backdoor entry */
BackDoorInit();
} /*** end of BootInit ***/
@ -74,14 +74,14 @@ void BootTask(void)
CopService();
/* update the millisecond timer */
TimerUpdate();
#if (BOOT_FILE_SYS_ENABLE > 0)
#if (BOOT_FILE_SYS_ENABLE > 0)
/* call worker task for updating firmware from locally attached file storage */
FileTask();
#endif /* BOOT_FILE_SYS_ENABLE > 0 */
#if (BOOT_COM_ENABLE > 0)
#endif /* BOOT_FILE_SYS_ENABLE > 0 */
#if (BOOT_COM_ENABLE > 0)
/* process possibly pending communication data */
ComTask();
#endif
#endif
/* control the backdoor */
BackDoorCheck();
} /*** end of BootTask ***/

View File

@ -36,16 +36,16 @@
****************************************************************************************/
#include "boot.h" /* bootloader generic header */
#if (BOOT_COM_CAN_ENABLE > 0)
#include "can.h" /* can driver module */
#include "can.h" /* can driver module */
#endif
#if (BOOT_COM_UART_ENABLE > 0)
#include "uart.h" /* uart driver module */
#include "uart.h" /* uart driver module */
#endif
#if (BOOT_COM_USB_ENABLE > 0)
#include "usb.h" /* usb driver module */
#include "usb.h" /* usb driver module */
#endif
#if (BOOT_COM_NET_ENABLE > 0)
#include "net.h" /* tcp/ip driver module */
#include "net.h" /* tcp/ip driver module */
#endif

View File

@ -150,7 +150,7 @@ blt_bool FileIsIdle(void)
****************************************************************************************/
blt_bool FileHandleFirmwareUpdateRequest(void)
{
#if (BOOT_COM_ENABLE > 0)
#if (BOOT_COM_ENABLE > 0)
/* make sure that there is no connection with a remote host to prevent two firmware
* updates happening at the same time
*/
@ -158,7 +158,7 @@ blt_bool FileHandleFirmwareUpdateRequest(void)
{
return BLT_FALSE;
}
#endif
#endif
/* a new firmware update request can only be handled if not already busy with one */
if (firmwareUpdateState != FIRMWARE_UPDATE_STATE_IDLE)
{
@ -195,32 +195,32 @@ void FileTask(void)
/* ------------------------------- starting ---------------------------------------- */
else if (firmwareUpdateState == FIRMWARE_UPDATE_STATE_STARTING)
{
#if (BOOT_FILE_STARTED_HOOK_ENABLE > 0)
#if (BOOT_FILE_STARTED_HOOK_ENABLE > 0)
/* inform application about update started event via hook function */
FileFirmwareUpdateStartedHook();
#endif
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#endif
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("Firmware update request detected\n\r");
FileFirmwareUpdateLogHook("Opening firmware file for reading...");
#endif
#endif
/* attempt to obtain a file object for the firmware file */
if (f_open(&fatFsObjects.file, FileGetFirmwareFilenameHook(), FA_OPEN_EXISTING | FA_READ) != FR_OK)
{
/* can't open file */
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("ERROR\n\r");
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_OPEN_FIRMWARE_FILE);
#endif
#endif
/* nothing left to do now */
return;
}
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("OK\n\r");
FileFirmwareUpdateLogHook("Starting the programming sequence\n\r");
FileFirmwareUpdateLogHook("Parsing firmware file to obtain erase size...");
#endif
#endif
/* prepare data objects for the erasing state */
eraseInfo.start_address = 0;
eraseInfo.total_size = 0;
@ -235,12 +235,12 @@ void FileTask(void)
/* check if an error occurred */
if (f_error(&fatFsObjects.file) > 0)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("ERROR\n\r");
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_READ_FROM_FILE);
#endif
#endif
/* close the file */
f_close(&fatFsObjects.file);
/* cannot continue with firmware update so go back to idle state */
@ -254,12 +254,12 @@ void FileTask(void)
/* check parsing result */
if (parse_result == ERROR_SREC_INVALID_CHECKSUM)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("ERROR\n\r");
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
FileFirmwareUpdateErrorHook(FILE_ERROR_INVALID_CHECKSUM_IN_FILE);
#endif
#endif
/* close the file */
f_close(&fatFsObjects.file);
/* cannot continue with firmware update so go back to idle state */
@ -293,19 +293,19 @@ void FileTask(void)
/* rewind the file in preparation for the programming state */
if (f_lseek(&fatFsObjects.file, 0) != FR_OK)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("ERROR\n\r");
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
FileFirmwareUpdateErrorHook(FILE_ERROR_REWINDING_FILE_READ_POINTER);
#endif
#endif
/* close the file */
f_close(&fatFsObjects.file);
/* cannot continue with firmware update so go back to idle state */
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
return;
}
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("OK\n\r");
FileFirmwareUpdateLogHook("Erasing ");
/* convert size to string */
@ -319,25 +319,25 @@ void FileTask(void)
FileLibByteToHexString((blt_int8u)eraseInfo.start_address, &loggingStr[6]);
FileFirmwareUpdateLogHook(loggingStr);
FileFirmwareUpdateLogHook("...");
#endif
#endif
/* still here so we are ready to perform the memory erase operation */
if (NvmErase(eraseInfo.start_address, eraseInfo.total_size) == BLT_FALSE)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("ERROR\n\r");
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_ERASE_MEMORY);
#endif
#endif
/* close the file */
f_close(&fatFsObjects.file);
/* cannot continue with firmware update so go back to idle state */
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
return;
}
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("OK\n\r");
#endif
#endif
/* all okay, then go to programming state */
firmwareUpdateState = FIRMWARE_UPDATE_STATE_PROGRAMMING;
}
@ -350,12 +350,12 @@ void FileTask(void)
/* check if an error occurred */
if (f_error(&fatFsObjects.file) > 0)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("Reading line from file...ERROR\n\r");
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_READ_FROM_FILE);
#endif
#endif
/* close the file */
f_close(&fatFsObjects.file);
/* cannot continue with firmware update so go back to idle state */
@ -369,12 +369,12 @@ void FileTask(void)
/* check parsing result */
if (parse_result == ERROR_SREC_INVALID_CHECKSUM)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("Invalid checksum found...ERROR\n\r");
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
FileFirmwareUpdateErrorHook(FILE_ERROR_INVALID_CHECKSUM_IN_FILE);
#endif
#endif
/* close the file */
f_close(&fatFsObjects.file);
/* cannot continue with firmware update so go back to idle state */
@ -385,7 +385,7 @@ void FileTask(void)
/* only process parsing results if the line contained address/data info */
if (parse_result > 0)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("Programming ");
/* convert size to string */
FileLibLongToIntString(parse_result, loggingStr);
@ -398,62 +398,62 @@ void FileTask(void)
FileLibByteToHexString((blt_int8u)lineParseObject.address, &loggingStr[6]);
FileFirmwareUpdateLogHook(loggingStr);
FileFirmwareUpdateLogHook("...");
#endif
#endif
/* program the data */
if (NvmWrite(lineParseObject.address, parse_result, lineParseObject.data) == BLT_FALSE)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("ERROR\n\r");
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_PROGRAM_MEMORY);
#endif
#endif
/* close the file */
f_close(&fatFsObjects.file);
/* cannot continue with firmware update so go back to idle state */
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
return;
}
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("OK\n\r");
#endif
#endif
}
/* check if the end of the file was reached */
if (f_eof(&fatFsObjects.file) > 0)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("Writing program checksum...");
#endif
#endif
/* finish the programming by writing the checksum */
if (NvmDone() == BLT_FALSE)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("ERROR\n\r");
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_WRITE_CHECKSUM);
#endif
#endif
/* close the file */
f_close(&fatFsObjects.file);
/* cannot continue with firmware update so go back to idle state */
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
return;
}
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("OK\n\r");
FileFirmwareUpdateLogHook("Closing firmware file\n\r");
#endif
#endif
/* close the file */
f_close(&fatFsObjects.file);
#if (BOOT_FILE_LOGGING_ENABLE > 0)
#if (BOOT_FILE_LOGGING_ENABLE > 0)
FileFirmwareUpdateLogHook("Firmware update successfully completed\n\r");
#endif
#endif
/* all done so transistion back to idle mode */
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE > 0)
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE > 0)
/* inform application about update completed event via hook function */
FileFirmwareUpdateCompletedHook();
#endif
#endif
/* attempt to start the user program now that programming is done. note that
* a call to CpuReset() won't work correctly here, because if the same firmware
* file is still on the locally attached storage, it will just restart the
@ -474,7 +474,7 @@ void FileTask(void)
tSrecLineType FileSrecGetLineType(const blt_char *line)
{
/* check if the line starts with the 'S' character, followed by a digit */
if ( (toupper(line[0]) != 'S') || (isdigit(line[1]) == 0) )
if ((toupper(line[0]) != 'S') || (isdigit(line[1]) == 0))
{
/* not a valid S-Record line type */
return LINE_TYPE_UNSUPPORTED;
@ -784,7 +784,7 @@ static blt_int8u FileLibHexStringToByte(const blt_char *hexstring)
/* read out the character */
c = toupper(hexstring[counter]);
/* check that the character is 0..9 or A..F */
if ( (c < '0') || (c > 'F') || ( (c > '9') && (c < 'A') ) )
if ((c < '0') || (c > 'F') || ((c > '9') && (c < 'A')))
{
/* character not valid */
return 0;

View File

@ -91,15 +91,15 @@ static blt_int32u ARPTimerTimeOut;
void NetInit(void)
{
uip_ipaddr_t ipaddr;
#if (BOOT_COM_NET_IPADDR_HOOK_ENABLE > 0)
#if (BOOT_COM_NET_IPADDR_HOOK_ENABLE > 0)
blt_int8u ipAddrArray[4];
#endif
#if (BOOT_COM_NET_NETMASK_HOOK_ENABLE > 0)
#endif
#if (BOOT_COM_NET_NETMASK_HOOK_ENABLE > 0)
blt_int8u netMaskArray[4];
#endif
#if (BOOT_COM_NET_GATEWAY_HOOK_ENABLE > 0)
#endif
#if (BOOT_COM_NET_GATEWAY_HOOK_ENABLE > 0)
blt_int8u gatewayAddrArray[4];
#endif
#endif
/* initialize the network device */
netdev_init();
@ -109,31 +109,31 @@ void NetInit(void)
/* initialize the uIP TCP/IP stack. */
uip_init();
/* set the IP address */
#if (BOOT_COM_NET_IPADDR_HOOK_ENABLE > 0)
#if (BOOT_COM_NET_IPADDR_HOOK_ENABLE > 0)
NetIpAddressHook(ipAddrArray);
uip_ipaddr(ipaddr, ipAddrArray[0], ipAddrArray[1], ipAddrArray[2], ipAddrArray[3]);
#else
#else
uip_ipaddr(ipaddr, BOOT_COM_NET_IPADDR0, BOOT_COM_NET_IPADDR1, BOOT_COM_NET_IPADDR2,
BOOT_COM_NET_IPADDR3);
#endif
#endif
uip_sethostaddr(ipaddr);
/* set the network mask */
#if (BOOT_COM_NET_NETMASK_HOOK_ENABLE > 0)
#if (BOOT_COM_NET_NETMASK_HOOK_ENABLE > 0)
NetNetworkMaskHook(netMaskArray);
uip_ipaddr(ipaddr, netMaskArray[0], netMaskArray[1], netMaskArray[2], netMaskArray[3]);
#else
#else
uip_ipaddr(ipaddr, BOOT_COM_NET_NETMASK0, BOOT_COM_NET_NETMASK1, BOOT_COM_NET_NETMASK2,
BOOT_COM_NET_NETMASK3);
#endif
#endif
uip_setnetmask(ipaddr);
/* set the gateway address */
#if (BOOT_COM_NET_GATEWAY_HOOK_ENABLE > 0)
#if (BOOT_COM_NET_GATEWAY_HOOK_ENABLE > 0)
NetGatewayAddressHook(gatewayAddrArray);
uip_ipaddr(ipaddr, gatewayAddrArray[0], gatewayAddrArray[1], gatewayAddrArray[2], gatewayAddrArray[3]);
#else
#else
uip_ipaddr(ipaddr, BOOT_COM_NET_GATEWAY0, BOOT_COM_NET_GATEWAY1, BOOT_COM_NET_GATEWAY2,
BOOT_COM_NET_GATEWAY3);
#endif
#endif
uip_setdraddr(ipaddr);
/* start listening on the configured port for XCP transfers on TCP/IP */
uip_listen(HTONS(BOOT_COM_NET_PORT));
@ -158,7 +158,7 @@ void NetTransmitPacket(blt_int8u *data, blt_int8u len)
s = &(uip_conn->appstate);
/* add the dto counter first */
*(blt_int32u*)&(s->dto_data[0]) = s->dto_counter;
*(blt_int32u *)&(s->dto_data[0]) = s->dto_counter;
/* copy the actual XCP response */
for (cnt=0; cnt<len; cnt++)
{
@ -260,13 +260,13 @@ static void NetServerTask(void)
/* check for an RX packet and read it. */
packetLen = netdev_read();
if(packetLen > 0)
if (packetLen > 0)
{
/* set uip_len for uIP stack usage */
uip_len = (blt_int16u)packetLen;
/* process incoming IP packets here. */
if(NET_UIP_HEADER_BUF->type == htons(UIP_ETHTYPE_IP))
if (NET_UIP_HEADER_BUF->type == htons(UIP_ETHTYPE_IP))
{
uip_arp_ipin();
uip_input();
@ -274,7 +274,7 @@ static void NetServerTask(void)
* should be sent out on the network, the global variable
* uip_len is set to a value > 0.
*/
if(uip_len > 0)
if (uip_len > 0)
{
uip_arp_out();
netdev_send();
@ -282,7 +282,7 @@ static void NetServerTask(void)
}
}
/* process incoming ARP packets here. */
else if(NET_UIP_HEADER_BUF->type == htons(UIP_ETHTYPE_ARP))
else if (NET_UIP_HEADER_BUF->type == htons(UIP_ETHTYPE_ARP))
{
uip_arp_arpin();
@ -290,7 +290,7 @@ static void NetServerTask(void)
* should be sent out on the network, the global variable
* uip_len is set to a value > 0.
*/
if(uip_len > 0)
if (uip_len > 0)
{
netdev_send();
uip_len = 0;
@ -309,7 +309,7 @@ static void NetServerTask(void)
* should be sent out on the network, the global variable
* uip_len is set to a value > 0.
*/
if(uip_len > 0)
if (uip_len > 0)
{
uip_arp_out();
netdev_send();
@ -321,8 +321,8 @@ static void NetServerTask(void)
/* process ARP Timer here. */
if (TimerGet() >= ARPTimerTimeOut)
{
ARPTimerTimeOut += NET_UIP_ARP_TIMER_MS;
uip_arp_timer();
ARPTimerTimeOut += NET_UIP_ARP_TIMER_MS;
uip_arp_timer();
}
} /*** end of NetServerTask ***/
#endif /* BOOT_COM_NET_ENABLE > 0 */

View File

@ -111,61 +111,61 @@
#endif
#if (BOOT_COM_CAN_ENABLE > 0)
#ifndef BOOT_COM_CAN_BAUDRATE
#error "BOOT_COM_CAN_BAUDRATE is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_CAN_BAUDRATE
#error "BOOT_COM_CAN_BAUDRATE is missing in blt_conf.h"
#endif
#if (BOOT_COM_CAN_BAUDRATE <= 0)
#error "BOOT_COM_CAN_BAUDRATE must be > 0"
#endif
#if (BOOT_COM_CAN_BAUDRATE <= 0)
#error "BOOT_COM_CAN_BAUDRATE must be > 0"
#endif
#ifndef BOOT_COM_CAN_TX_MSG_ID
#error "BOOT_COM_CAN_TX_MSG_ID is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_CAN_TX_MSG_ID
#error "BOOT_COM_CAN_TX_MSG_ID is missing in blt_conf.h"
#endif
#if (BOOT_COM_CAN_TX_MSG_ID <= 0)
#error "BOOT_COM_CAN_TX_MSG_ID must be > 0"
#endif
#if (BOOT_COM_CAN_TX_MSG_ID <= 0)
#error "BOOT_COM_CAN_TX_MSG_ID must be > 0"
#endif
#ifndef BOOT_COM_CAN_TX_MAX_DATA
#error "BOOT_COM_CAN_TX_MAX_DATA is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_CAN_TX_MAX_DATA
#error "BOOT_COM_CAN_TX_MAX_DATA is missing in blt_conf.h"
#endif
#if (BOOT_COM_CAN_TX_MAX_DATA <= 0)
#error "BOOT_COM_CAN_TX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_CAN_TX_MAX_DATA <= 0)
#error "BOOT_COM_CAN_TX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_CAN_TX_MAX_DATA > 8)
#error "BOOT_COM_CAN_TX_MAX_DATA must be <= 8"
#endif
#if (BOOT_COM_CAN_TX_MAX_DATA > 8)
#error "BOOT_COM_CAN_TX_MAX_DATA must be <= 8"
#endif
#ifndef BOOT_COM_CAN_RX_MSG_ID
#error "BOOT_COM_CAN_RX_MSG_ID is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_CAN_RX_MSG_ID
#error "BOOT_COM_CAN_RX_MSG_ID is missing in blt_conf.h"
#endif
#if (BOOT_COM_CAN_RX_MSG_ID <= 0)
#error "BOOT_COM_CAN_RX_MSG_ID must be > 0"
#endif
#if (BOOT_COM_CAN_RX_MSG_ID <= 0)
#error "BOOT_COM_CAN_RX_MSG_ID must be > 0"
#endif
#ifndef BOOT_COM_CAN_RX_MAX_DATA
#error "BOOT_COM_CAN_RX_MAX_DATA is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_CAN_RX_MAX_DATA
#error "BOOT_COM_CAN_RX_MAX_DATA is missing in blt_conf.h"
#endif
#if (BOOT_COM_CAN_RX_MAX_DATA <= 0)
#error "BOOT_COM_CAN_RX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_CAN_RX_MAX_DATA <= 0)
#error "BOOT_COM_CAN_RX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_CAN_RX_MAX_DATA > 8)
#error "BOOT_COM_CAN_RX_MAX_DATA must be <= 8"
#endif
#if (BOOT_COM_CAN_RX_MAX_DATA > 8)
#error "BOOT_COM_CAN_RX_MAX_DATA must be <= 8"
#endif
#ifndef BOOT_COM_CAN_CHANNEL_INDEX
#error "BOOT_COM_CAN_CHANNEL_INDEX is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_CAN_CHANNEL_INDEX
#error "BOOT_COM_CAN_CHANNEL_INDEX is missing in blt_conf.h"
#endif
#if (BOOT_COM_CAN_CHANNEL_INDEX < 0)
#error "BOOT_COM_CAN_CHANNEL_INDEX must be >= 0"
#endif
#if (BOOT_COM_CAN_CHANNEL_INDEX < 0)
#error "BOOT_COM_CAN_CHANNEL_INDEX must be >= 0"
#endif
#endif /* BOOT_COM_CAN_ENABLE > 0 */
#ifndef BOOT_COM_UART_ENABLE
@ -173,45 +173,45 @@
#endif
#if (BOOT_COM_UART_ENABLE > 0)
#ifndef BOOT_COM_UART_BAUDRATE
#error "BOOT_COM_UART_BAUDRATE is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_UART_BAUDRATE
#error "BOOT_COM_UART_BAUDRATE is missing in blt_conf.h"
#endif
#if (BOOT_COM_UART_BAUDRATE <= 0)
#error "BOOT_COM_UART_BAUDRATE must be > 0"
#endif
#if (BOOT_COM_UART_BAUDRATE <= 0)
#error "BOOT_COM_UART_BAUDRATE must be > 0"
#endif
#ifndef BOOT_COM_UART_TX_MAX_DATA
#error "BOOT_COM_UART_TX_MAX_DATA is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_UART_TX_MAX_DATA
#error "BOOT_COM_UART_TX_MAX_DATA is missing in blt_conf.h"
#endif
#if (BOOT_COM_UART_TX_MAX_DATA <= 0)
#error "BOOT_COM_UART_TX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_UART_TX_MAX_DATA <= 0)
#error "BOOT_COM_UART_TX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_UART_TX_MAX_DATA > 255)
#error "BOOT_COM_UART_TX_MAX_DATA must be <= 255"
#endif
#if (BOOT_COM_UART_TX_MAX_DATA > 255)
#error "BOOT_COM_UART_TX_MAX_DATA must be <= 255"
#endif
#ifndef BOOT_COM_UART_RX_MAX_DATA
#error "BOOT_COM_UART_RX_MAX_DATA is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_UART_RX_MAX_DATA
#error "BOOT_COM_UART_RX_MAX_DATA is missing in blt_conf.h"
#endif
#if (BOOT_COM_UART_RX_MAX_DATA <= 0)
#error "BOOT_COM_UART_RX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_UART_RX_MAX_DATA <= 0)
#error "BOOT_COM_UART_RX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_UART_RX_MAX_DATA > 255)
#error "BOOT_COM_UART_RX_MAX_DATA must be <= 255"
#endif
#if (BOOT_COM_UART_RX_MAX_DATA > 255)
#error "BOOT_COM_UART_RX_MAX_DATA must be <= 255"
#endif
#ifndef BOOT_COM_UART_CHANNEL_INDEX
#error "BOOT_COM_UART_CHANNEL_INDEX is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_UART_CHANNEL_INDEX
#error "BOOT_COM_UART_CHANNEL_INDEX is missing in blt_conf.h"
#endif
#if (BOOT_COM_UART_CHANNEL_INDEX < 0)
#error "BOOT_COM_UART_CHANNEL_INDEX must be >= 0"
#endif
#if (BOOT_COM_UART_CHANNEL_INDEX < 0)
#error "BOOT_COM_UART_CHANNEL_INDEX must be >= 0"
#endif
#endif /* BOOT_COM_UART_ENABLE > 0 */
#ifndef BOOT_COM_USB_ENABLE
@ -219,21 +219,21 @@
#endif
#if (BOOT_COM_USB_ENABLE > 0)
#ifndef BOOT_COM_USB_TX_MAX_DATA
#error "BOOT_COM_USB_TX_MAX_DATA is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_USB_TX_MAX_DATA
#error "BOOT_COM_USB_TX_MAX_DATA is missing in blt_conf.h"
#endif
#if (BOOT_COM_USB_TX_MAX_DATA <= 0)
#error "BOOT_COM_USB_TX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_USB_TX_MAX_DATA <= 0)
#error "BOOT_COM_USB_TX_MAX_DATA must be > 0"
#endif
#ifndef BOOT_COM_USB_RX_MAX_DATA
#error "BOOT_COM_USB_RX_MAX_DATA is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_USB_RX_MAX_DATA
#error "BOOT_COM_USB_RX_MAX_DATA is missing in blt_conf.h"
#endif
#if (BOOT_COM_USB_RX_MAX_DATA <= 0)
#error "BOOT_COM_USB_RX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_USB_RX_MAX_DATA <= 0)
#error "BOOT_COM_USB_RX_MAX_DATA must be > 0"
#endif
#endif /* BOOT_COM_USB_ENABLE > 0 */
@ -243,137 +243,137 @@
#endif
#if (BOOT_COM_NET_ENABLE > 0)
#ifndef BOOT_COM_NET_TX_MAX_DATA
#error "BOOT_COM_NET_TX_MAX_DATA is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_TX_MAX_DATA
#error "BOOT_COM_NET_TX_MAX_DATA is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_TX_MAX_DATA <= 0)
#error "BOOT_COM_NET_TX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_NET_TX_MAX_DATA <= 0)
#error "BOOT_COM_NET_TX_MAX_DATA must be > 0"
#endif
#ifndef BOOT_COM_NET_RX_MAX_DATA
#error "BOOT_COM_NET_RX_MAX_DATA is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_RX_MAX_DATA
#error "BOOT_COM_NET_RX_MAX_DATA is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_RX_MAX_DATA <= 0)
#error "BOOT_COM_NET_RX_MAX_DATA must be > 0"
#endif
#if (BOOT_COM_NET_RX_MAX_DATA <= 0)
#error "BOOT_COM_NET_RX_MAX_DATA must be > 0"
#endif
#ifndef BOOT_COM_NET_IPADDR0
#error "BOOT_COM_NET_IPADDR0 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_IPADDR0
#error "BOOT_COM_NET_IPADDR0 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_IPADDR0 < 0)
#error "BOOT_COM_NET_IPADDR0 must be >= 0"
#endif
#if (BOOT_COM_NET_IPADDR0 < 0)
#error "BOOT_COM_NET_IPADDR0 must be >= 0"
#endif
#ifndef BOOT_COM_NET_IPADDR1
#error "BOOT_COM_NET_IPADDR1 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_IPADDR1
#error "BOOT_COM_NET_IPADDR1 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_IPADDR1 < 0)
#error "BOOT_COM_NET_IPADDR1 must be >= 0"
#endif
#if (BOOT_COM_NET_IPADDR1 < 0)
#error "BOOT_COM_NET_IPADDR1 must be >= 0"
#endif
#ifndef BOOT_COM_NET_IPADDR2
#error "BOOT_COM_NET_IPADDR2 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_IPADDR2
#error "BOOT_COM_NET_IPADDR2 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_IPADDR2 < 0)
#error "BOOT_COM_NET_IPADDR2 must be >= 0"
#endif
#if (BOOT_COM_NET_IPADDR2 < 0)
#error "BOOT_COM_NET_IPADDR2 must be >= 0"
#endif
#ifndef BOOT_COM_NET_IPADDR3
#error "BOOT_COM_NET_IPADDR3 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_IPADDR3
#error "BOOT_COM_NET_IPADDR3 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_IPADDR3 < 0)
#error "BOOT_COM_NET_IPADDR3 must be >= 0"
#endif
#if (BOOT_COM_NET_IPADDR3 < 0)
#error "BOOT_COM_NET_IPADDR3 must be >= 0"
#endif
#ifndef BOOT_COM_NET_NETMASK0
#error "BOOT_COM_NET_NETMASK0 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_NETMASK0
#error "BOOT_COM_NET_NETMASK0 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_NETMASK0 < 0)
#error "BOOT_COM_NET_NETMASK0 must be >= 0"
#endif
#if (BOOT_COM_NET_NETMASK0 < 0)
#error "BOOT_COM_NET_NETMASK0 must be >= 0"
#endif
#ifndef BOOT_COM_NET_NETMASK1
#error "BOOT_COM_NET_NETMASK1 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_NETMASK1
#error "BOOT_COM_NET_NETMASK1 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_NETMASK1 < 0)
#error "BOOT_COM_NET_NETMASK1 must be >= 0"
#endif
#if (BOOT_COM_NET_NETMASK1 < 0)
#error "BOOT_COM_NET_NETMASK1 must be >= 0"
#endif
#ifndef BOOT_COM_NET_NETMASK2
#error "BOOT_COM_NET_NETMASK2 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_NETMASK2
#error "BOOT_COM_NET_NETMASK2 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_NETMASK2 < 0)
#error "BOOT_COM_NET_NETMASK2 must be >= 0"
#endif
#if (BOOT_COM_NET_NETMASK2 < 0)
#error "BOOT_COM_NET_NETMASK2 must be >= 0"
#endif
#ifndef BOOT_COM_NET_NETMASK3
#error "BOOT_COM_NET_NETMASK3 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_NETMASK3
#error "BOOT_COM_NET_NETMASK3 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_NETMASK3 < 0)
#error "BOOT_COM_NET_NETMASK3 must be >= 0"
#endif
#if (BOOT_COM_NET_NETMASK3 < 0)
#error "BOOT_COM_NET_NETMASK3 must be >= 0"
#endif
#ifndef BOOT_COM_NET_GATEWAY0
#error "BOOT_COM_NET_GATEWAY0 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_GATEWAY0
#error "BOOT_COM_NET_GATEWAY0 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_GATEWAY0 < 0)
#error "BOOT_COM_NET_GATEWAY0 must be >= 0"
#endif
#if (BOOT_COM_NET_GATEWAY0 < 0)
#error "BOOT_COM_NET_GATEWAY0 must be >= 0"
#endif
#ifndef BOOT_COM_NET_GATEWAY1
#error "BOOT_COM_NET_GATEWAY1 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_GATEWAY1
#error "BOOT_COM_NET_GATEWAY1 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_GATEWAY1 < 0)
#error "BOOT_COM_NET_GATEWAY1 must be >= 0"
#endif
#if (BOOT_COM_NET_GATEWAY1 < 0)
#error "BOOT_COM_NET_GATEWAY1 must be >= 0"
#endif
#ifndef BOOT_COM_NET_GATEWAY2
#error "BOOT_COM_NET_GATEWAY2 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_GATEWAY2
#error "BOOT_COM_NET_GATEWAY2 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_GATEWAY2 < 0)
#error "BOOT_COM_NET_GATEWAY2 must be >= 0"
#endif
#if (BOOT_COM_NET_GATEWAY2 < 0)
#error "BOOT_COM_NET_GATEWAY2 must be >= 0"
#endif
#ifndef BOOT_COM_NET_GATEWAY3
#error "BOOT_COM_NET_GATEWAY3 is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_GATEWAY3
#error "BOOT_COM_NET_GATEWAY3 is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_GATEWAY3 < 0)
#error "BOOT_COM_NET_GATEWAY3 must be >= 0"
#endif
#if (BOOT_COM_NET_GATEWAY3 < 0)
#error "BOOT_COM_NET_GATEWAY3 must be >= 0"
#endif
#ifndef BOOT_COM_NET_PORT
#error "BOOT_COM_NET_PORT is missing in blt_conf.h"
#endif
#ifndef BOOT_COM_NET_PORT
#error "BOOT_COM_NET_PORT is missing in blt_conf.h"
#endif
#if (BOOT_COM_NET_PORT < 0)
#error "BOOT_COM_NET_PORT must be >= 0"
#endif
#if (BOOT_COM_NET_PORT < 0)
#error "BOOT_COM_NET_PORT must be >= 0"
#endif
#ifndef BOOT_COM_NET_IPADDR_HOOK_ENABLE
#define BOOT_COM_NET_IPADDR_HOOK_ENABLE (0)
#endif
#ifndef BOOT_COM_NET_IPADDR_HOOK_ENABLE
#define BOOT_COM_NET_IPADDR_HOOK_ENABLE (0)
#endif
#ifndef BOOT_COM_NET_NETMASK_HOOK_ENABLE
#define BOOT_COM_NET_NETMASK_HOOK_ENABLE (0)
#endif
#ifndef BOOT_COM_NET_NETMASK_HOOK_ENABLE
#define BOOT_COM_NET_NETMASK_HOOK_ENABLE (0)
#endif
#ifndef BOOT_COM_NET_GATEWAY_HOOK_ENABLE
#define BOOT_COM_NET_GATEWAY_HOOK_ENABLE (0)
#endif
#ifndef BOOT_COM_NET_GATEWAY_HOOK_ENABLE
#define BOOT_COM_NET_GATEWAY_HOOK_ENABLE (0)
#endif
#endif /* BOOT_COM_USB_ENABLE > 0 */
@ -386,37 +386,37 @@
#endif
#if (BOOT_FILE_SYS_ENABLE > 0)
#ifndef BOOT_FILE_LOGGING_ENABLE
#define BOOT_FILE_LOGGING_ENABLE (0)
#endif
#ifndef BOOT_FILE_LOGGING_ENABLE
#define BOOT_FILE_LOGGING_ENABLE (0)
#endif
#if (BOOT_FILE_LOGGING_ENABLE < 0) || (BOOT_FILE_LOGGING_ENABLE > 1)
#error "BOOT_FILE_LOGGING_ENABLE must be 0 or 1"
#endif
#if (BOOT_FILE_LOGGING_ENABLE < 0) || (BOOT_FILE_LOGGING_ENABLE > 1)
#error "BOOT_FILE_LOGGING_ENABLE must be 0 or 1"
#endif
#ifndef BOOT_FILE_ERROR_HOOK_ENABLE
#define BOOT_FILE_ERROR_HOOK_ENABLE (0)
#endif
#ifndef BOOT_FILE_ERROR_HOOK_ENABLE
#define BOOT_FILE_ERROR_HOOK_ENABLE (0)
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE < 0) || (BOOT_FILE_ERROR_HOOK_ENABLE > 1)
#error "BOOT_FILE_ERROR_HOOK_ENABLE must be 0 or 1"
#endif
#if (BOOT_FILE_ERROR_HOOK_ENABLE < 0) || (BOOT_FILE_ERROR_HOOK_ENABLE > 1)
#error "BOOT_FILE_ERROR_HOOK_ENABLE must be 0 or 1"
#endif
#ifndef BOOT_FILE_STARTED_HOOK_ENABLE
#define BOOT_FILE_STARTED_HOOK_ENABLE (0)
#endif
#ifndef BOOT_FILE_STARTED_HOOK_ENABLE
#define BOOT_FILE_STARTED_HOOK_ENABLE (0)
#endif
#if (BOOT_FILE_STARTED_HOOK_ENABLE < 0) || (BOOT_FILE_STARTED_HOOK_ENABLE > 1)
#error "BOOT_FILE_STARTED_HOOK_ENABLE must be 0 or 1"
#endif
#if (BOOT_FILE_STARTED_HOOK_ENABLE < 0) || (BOOT_FILE_STARTED_HOOK_ENABLE > 1)
#error "BOOT_FILE_STARTED_HOOK_ENABLE must be 0 or 1"
#endif
#ifndef BOOT_FILE_COMPLETED_HOOK_ENABLE
#define BOOT_FILE_COMPLETED_HOOK_ENABLE (0)
#endif
#ifndef BOOT_FILE_COMPLETED_HOOK_ENABLE
#define BOOT_FILE_COMPLETED_HOOK_ENABLE (0)
#endif
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE < 0) || (BOOT_FILE_COMPLETED_HOOK_ENABLE > 1)
#error "BOOT_FILE_COMPLETED_HOOK_ENABLE must be 0 or 1"
#endif
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE < 0) || (BOOT_FILE_COMPLETED_HOOK_ENABLE > 1)
#error "BOOT_FILE_COMPLETED_HOOK_ENABLE must be 0 or 1"
#endif
#endif /* BOOT_FILE_SYS_ENABLE > 0 */
#if (BOOT_COM_CAN_ENABLE == 1) || (BOOT_COM_UART_ENABLE == 1) || (BOOT_COM_NET_ENABLE == 1) || (BOOT_COM_USB_ENABLE == 1)

View File

@ -2,43 +2,49 @@
/ Open or create a file in append mode
/------------------------------------------------------------*/
FRESULT open_append (
FIL* fp, /* [OUT] File object to create */
const char* path /* [IN] File name to be opened */
FRESULT open_append(
FIL *fp, /* [OUT] File object to create */
const char *path /* [IN] File name to be opened */
)
{
FRESULT fr;
FRESULT fr;
/* Opens an existing file. If not exist, creates a new file. */
fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS);
if (fr == FR_OK) {
/* Seek to end of the file to append data */
fr = f_lseek(fp, f_size(fp));
if (fr != FR_OK)
f_close(fp);
/* Opens an existing file. If not exist, creates a new file. */
fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS);
if (fr == FR_OK)
{
/* Seek to end of the file to append data */
fr = f_lseek(fp, f_size(fp));
if (fr != FR_OK)
{
f_close(fp);
}
return fr;
}
return fr;
}
int main (void)
int main(void)
{
FRESULT fr;
FIL fil;
FRESULT fr;
FIL fil;
f_mount(0, &Fatfs);
f_mount(0, &Fatfs);
/* Open or create a log file and ready to append */
fr = open_append(&fil, "logfile.txt");
if (fr != FR_OK) return 1;
/* Open or create a log file and ready to append */
fr = open_append(&fil, "logfile.txt");
if (fr != FR_OK)
{
return 1;
}
/* Append a line */
f_printf(&fil, "%02u/%02u/%u, %2u:%02u\n", Mday, Mon, Year, Hour, Min);
/* Append a line */
f_printf(&fil, "%02u/%02u/%u, %2u:%02u\n", Mday, Mon, Year, Hour, Min);
/* Close the file */
f_close(&fil);
/* Close the file */
f_close(&fil);
return 0;
return 0;
}

View File

@ -4,63 +4,83 @@
/------------------------------------------------------------*/
FRESULT empty_directory (
char* path /* Working buffer filled with start directory */
FRESULT empty_directory(
char *path /* Working buffer filled with start directory */
)
{
UINT i, j;
FRESULT fr;
DIR dir;
FILINFO fno;
UINT i, j;
FRESULT fr;
DIR dir;
FILINFO fno;
#if _USE_LFN
fno.lfname = 0; /* Set null pointer because LFN is not needed */
fno.lfname = 0; /* Set null pointer because LFN is not needed */
#endif
fr = f_opendir(&dir, path);
if (fr == FR_OK) {
for (i = 0; path[i]; i++) ;
path[i++] = '/';
for (;;) {
fr = f_readdir(&dir, &fno);
if (fr != FR_OK || !fno.fname[0]) break;
if (fno.fname[0] == '.') continue;
j = 0;
do
path[i+j] = fno.fname[j];
while (fno.fname[j++]);
if (fno.fattrib & AM_DIR) {
fr = empty_directory(path);
if (fr != FR_OK) break;
}
fr = f_unlink(path);
if (fr != FR_OK) break;
fr = f_opendir(&dir, path);
if (fr == FR_OK)
{
for (i = 0; path[i]; i++) ;
path[i++] = '/';
for (;;)
{
fr = f_readdir(&dir, &fno);
if (fr != FR_OK || !fno.fname[0])
{
break;
}
if (fno.fname[0] == '.')
{
continue;
}
j = 0;
do
{
path[i+j] = fno.fname[j];
}
while (fno.fname[j++]);
if (fno.fattrib & AM_DIR)
{
fr = empty_directory(path);
if (fr != FR_OK)
{
break;
}
path[--i] = '\0';
}
fr = f_unlink(path);
if (fr != FR_OK)
{
break;
}
}
path[--i] = '\0';
}
return fr;
return fr;
}
int main (void)
int main(void)
{
FRESULT fr;
char buff[64]; /* Working buffer */
FRESULT fr;
char buff[64]; /* Working buffer */
f_mount(0, &Fatfs);
f_mount(0, &Fatfs);
strcpy(buff, "/"); /* Directory to be emptied */
fr = empty_directory(buff);
strcpy(buff, "/"); /* Directory to be emptied */
fr = empty_directory(buff);
if (fr) {
printf("Function failed. (%u)\n", fr);
return 1;
} else {
printf("All contents in the %s are successfully removed.\n", buff);
return 0;
}
if (fr)
{
printf("Function failed. (%u)\n", fr);
return 1;
}
else
{
printf("All contents in the %s are successfully removed.\n", buff);
return 0;
}
}

View File

@ -4,95 +4,133 @@
/* Declarations of FatFs internal functions accessible from applications.
/ This is intended to be used by disk checking/fixing or dirty hacks :-) */
DWORD clust2sect (FATFS *fs, DWORD clst);
DWORD get_fat (FATFS *fs, DWORD clst);
FRESULT put_fat (FATFS *fs, DWORD clst, DWORD val);
DWORD clust2sect(FATFS *fs, DWORD clst);
DWORD get_fat(FATFS *fs, DWORD clst);
FRESULT put_fat(FATFS *fs, DWORD clst, DWORD val);
DWORD allocate_contiguous_clusters ( /* Returns file start sector number */
FIL* fp, /* Pointer to the open file object */
DWORD len /* Number of bytes to allocate */
DWORD allocate_contiguous_clusters( /* Returns file start sector number */
FIL *fp, /* Pointer to the open file object */
DWORD len /* Number of bytes to allocate */
)
{
DWORD csz, tcl, ncl, ccl, cl;
DWORD csz, tcl, ncl, ccl, cl;
#if _FATFS != 82786 /* Check if R0.09b */
#error This function may not be compatible with this revision of FatFs module.
#endif
if (f_lseek(fp, 0) || !len) /* Check if the given parameters are valid */
return 0;
csz = 512UL * fp->fs->csize; /* Cluster size in unit of byte (assuming 512 bytes/sector) */
tcl = (len + csz - 1) / csz; /* Total number of clusters required */
len = tcl * csz; /* Round-up file size to the cluster boundary */
/* Check if the existing cluster chain is contiguous */
if (len == fp->fsize) {
ncl = 0; ccl = fp->sclust;
do {
cl = get_fat(fp->fs, ccl); /* Get the cluster status */
if (cl + 1 < 3) return 0; /* Hard error? */
if (cl != ccl + 1 &&; cl < fp->fs->n_fatent) break; /* Not contiguous? */
ccl = cl;
} while (++ncl < tcl);
if (ncl == tcl) /* Is the file contiguous? */
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
}
if (f_truncate(fp)) return 0; /* Remove the existing chain */
/* Find a free contiguous area */
ccl = cl = 2; ncl = 0;
do {
if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */
if (get_fat(fp->fs, cl)) { /* Encounterd a cluster in use */
do { /* Skip the block of used clusters */
cl++;
if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */
} while (get_fat(fp->fs, cl));
ccl = cl; ncl = 0;
}
cl++; ncl++;
} while (ncl < tcl);
/* Create a contiguous cluster chain */
fp->fs->last_clust = ccl - 1;
if (f_lseek(fp, len)) return 0;
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
}
int main (void)
{
FRESULT fr;
DRESULT dr;
FIL fil;
DWORD org;
f_mount(0, &Fatfs);
/* Open or create a file */
fr = f_open(&fil, "pagefile.dat", FA_READ | FA_WRITE | FA_OPEN_ALWAYS);
if (fr) return 1;
/* Check if the file is 64MB in size and occupies a contiguous area.
/ If not, a contiguous area is re-allocated to the file. */
org = allocate_contiguous_clusters(&fil, 0x4000000);
if (!org) {
printf("Function failed due to any error or insufficient contiguous area.\n");
f_close(&fil);
return 1;
}
/* Now you can read/write the file with disk functions bypassing the file system layer.
/ Note that 4th argument of the disk read/write function is BYTE, so that you may need
/ to bypass the disk functions for large number of multiple sector transfer. */
dr = disk_write(fil.fs->drv, Buff, org, 128); /* Write 64K bytes from top of the file */
...
f_close(&fil);
if (f_lseek(fp, 0) || !len) /* Check if the given parameters are valid */
{
return 0;
}
csz = 512UL * fp->fs->csize; /* Cluster size in unit of byte (assuming 512 bytes/sector) */
tcl = (len + csz - 1) / csz; /* Total number of clusters required */
len = tcl * csz; /* Round-up file size to the cluster boundary */
/* Check if the existing cluster chain is contiguous */
if (len == fp->fsize)
{
ncl = 0;
ccl = fp->sclust;
do
{
cl = get_fat(fp->fs, ccl); /* Get the cluster status */
if (cl + 1 < 3)
{
return 0; /* Hard error? */
}
if (cl != ccl + 1 &&; cl < fp->fs->n_fatent)
{
break; /* Not contiguous? */
}
ccl = cl;
}
while (++ncl < tcl);
if (ncl == tcl) /* Is the file contiguous? */
{
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
}
}
if (f_truncate(fp))
{
return 0; /* Remove the existing chain */
}
/* Find a free contiguous area */
ccl = cl = 2;
ncl = 0;
do
{
if (cl >= fp->fs->n_fatent)
{
return 0; /* No contiguous area is found. */
}
if (get_fat(fp->fs, cl)) /* Encounterd a cluster in use */
{
do /* Skip the block of used clusters */
{
cl++;
if (cl >= fp->fs->n_fatent)
{
return 0; /* No contiguous area is found. */
}
}
while (get_fat(fp->fs, cl));
ccl = cl;
ncl = 0;
}
cl++;
ncl++;
}
while (ncl < tcl);
/* Create a contiguous cluster chain */
fp->fs->last_clust = ccl - 1;
if (f_lseek(fp, len))
{
return 0;
}
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
}
int main(void)
{
FRESULT fr;
DRESULT dr;
FIL fil;
DWORD org;
f_mount(0, &Fatfs);
/* Open or create a file */
fr = f_open(&fil, "pagefile.dat", FA_READ | FA_WRITE | FA_OPEN_ALWAYS);
if (fr)
{
return 1;
}
/* Check if the file is 64MB in size and occupies a contiguous area.
/ If not, a contiguous area is re-allocated to the file. */
org = allocate_contiguous_clusters(&fil, 0x4000000);
if (!org)
{
printf("Function failed due to any error or insufficient contiguous area.\n");
f_close(&fil);
return 1;
}
/* Now you can read/write the file with disk functions bypassing the file system layer.
/ Note that 4th argument of the disk read/write function is BYTE, so that you may need
/ to bypass the disk functions for large number of multiple sector transfer. */
dr = disk_write(fil.fs->drv, Buff, org, 128); /* Write 64K bytes from top of the file */
...
f_close(&fil);
return 0;
}

View File

@ -19,12 +19,13 @@ extern "C" {
typedef BYTE DSTATUS;
/* Results of Disk Functions */
typedef enum {
RES_OK = 0, /* 0: Successful */
RES_ERROR, /* 1: R/W Error */
RES_WRPRT, /* 2: Write Protected */
RES_NOTRDY, /* 3: Not Ready */
RES_PARERR /* 4: Invalid Parameter */
typedef enum
{
RES_OK = 0, /* 0: Successful */
RES_ERROR, /* 1: R/W Error */
RES_WRPRT, /* 2: Write Protected */
RES_NOTRDY, /* 3: Not Ready */
RES_PARERR /* 4: Invalid Parameter */
} DRESULT;
@ -32,11 +33,11 @@ typedef enum {
/* Prototypes for disk control functions */
DSTATUS disk_initialize (BYTE pdrv);
DSTATUS disk_status (BYTE pdrv);
DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count);
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count);
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
DSTATUS disk_initialize(BYTE pdrv);
DSTATUS disk_status(BYTE pdrv);
DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, BYTE count);
DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, BYTE count);
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff);
/* Disk Status Bits (DSTATUS) */

File diff suppressed because it is too large Load Diff

View File

@ -33,9 +33,10 @@ extern "C" {
/* Definitions of volume management */
#if _MULTI_PARTITION /* Multiple partition configuration */
typedef struct {
BYTE pd; /* Physical drive number */
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
typedef struct
{
BYTE pd; /* Physical drive number */
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
} PARTITION;
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
@ -74,65 +75,67 @@ typedef char TCHAR;
/* File system object structure (FATFS) */
typedef struct {
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
BYTE drv; /* Physical drive number */
BYTE csize; /* Sectors per cluster (1,2,4...128) */
BYTE n_fats; /* Number of FAT copies (1,2) */
BYTE wflag; /* win[] dirty flag (1:must be written back) */
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
WORD id; /* File system mount ID */
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
typedef struct
{
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
BYTE drv; /* Physical drive number */
BYTE csize; /* Sectors per cluster (1,2,4...128) */
BYTE n_fats; /* Number of FAT copies (1,2) */
BYTE wflag; /* win[] dirty flag (1:must be written back) */
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
WORD id; /* File system mount ID */
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
#if _MAX_SS != 512
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
#endif
#if _FS_REENTRANT
_SYNC_t sobj; /* Identifier of sync object */
_SYNC_t sobj; /* Identifier of sync object */
#endif
#if !_FS_READONLY
DWORD last_clust; /* Last allocated cluster */
DWORD free_clust; /* Number of free clusters */
DWORD fsi_sector; /* fsinfo sector (FAT32) */
DWORD last_clust; /* Last allocated cluster */
DWORD free_clust; /* Number of free clusters */
DWORD fsi_sector; /* fsinfo sector (FAT32) */
#endif
#if _FS_RPATH
DWORD cdir; /* Current directory start cluster (0:root) */
DWORD cdir; /* Current directory start cluster (0:root) */
#endif
DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
DWORD fsize; /* Sectors per FAT */
DWORD volbase; /* Volume start sector */
DWORD fatbase; /* FAT start sector */
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
DWORD database; /* Data start sector */
DWORD winsect; /* Current sector appearing in the win[] */
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */
DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
DWORD fsize; /* Sectors per FAT */
DWORD volbase; /* Volume start sector */
DWORD fatbase; /* FAT start sector */
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
DWORD database; /* Data start sector */
DWORD winsect; /* Current sector appearing in the win[] */
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */
} FATFS;
/* File object structure (FIL) */
typedef struct {
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
WORD id; /* Owner file system mount ID (**do not change order**) */
BYTE flag; /* File status flags */
BYTE pad1;
DWORD fptr; /* File read/write pointer (0ed on file open) */
DWORD fsize; /* File size */
DWORD sclust; /* File data start cluster (0:no data cluster, always 0 when fsize is 0) */
DWORD clust; /* Current cluster of fpter */
DWORD dsect; /* Current data sector of fpter */
typedef struct
{
FATFS *fs; /* Pointer to the related file system object (**do not change order**) */
WORD id; /* Owner file system mount ID (**do not change order**) */
BYTE flag; /* File status flags */
BYTE pad1;
DWORD fptr; /* File read/write pointer (0ed on file open) */
DWORD fsize; /* File size */
DWORD sclust; /* File data start cluster (0:no data cluster, always 0 when fsize is 0) */
DWORD clust; /* Current cluster of fpter */
DWORD dsect; /* Current data sector of fpter */
#if !_FS_READONLY
DWORD dir_sect; /* Sector containing the directory entry */
BYTE* dir_ptr; /* Pointer to the directory entry in the window */
DWORD dir_sect; /* Sector containing the directory entry */
BYTE *dir_ptr; /* Pointer to the directory entry in the window */
#endif
#if _USE_FASTSEEK
DWORD* cltbl; /* Pointer to the cluster link map table (null on file open) */
DWORD *cltbl; /* Pointer to the cluster link map table (null on file open) */
#endif
#if _FS_LOCK
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
#endif
#if !_FS_TINY
BYTE buf[_MAX_SS]; /* File data read/write buffer */
BYTE buf[_MAX_SS]; /* File data read/write buffer */
#endif
} FIL;
@ -140,18 +143,19 @@ typedef struct {
/* Directory object structure (DIR) */
typedef struct {
FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */
WORD id; /* Owner file system mount ID (**do not change order**) */
WORD index; /* Current read/write index number */
DWORD sclust; /* Table start cluster (0:Root dir) */
DWORD clust; /* Current cluster */
DWORD sect; /* Current sector */
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
typedef struct
{
FATFS *fs; /* Pointer to the owner file system object (**do not change order**) */
WORD id; /* Owner file system mount ID (**do not change order**) */
WORD index; /* Current read/write index number */
DWORD sclust; /* Table start cluster (0:Root dir) */
DWORD clust; /* Current cluster */
DWORD sect; /* Current sector */
BYTE *dir; /* Pointer to the current SFN entry in the win[] */
BYTE *fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
#if _USE_LFN
WCHAR* lfn; /* Pointer to the LFN working buffer */
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
WCHAR *lfn; /* Pointer to the LFN working buffer */
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
#endif
} DIR;
@ -159,15 +163,16 @@ typedef struct {
/* File status structure (FILINFO) */
typedef struct {
DWORD fsize; /* File size */
WORD fdate; /* Last modified date */
WORD ftime; /* Last modified time */
BYTE fattrib; /* Attribute */
TCHAR fname[13]; /* Short file name (8.3 format) */
typedef struct
{
DWORD fsize; /* File size */
WORD fdate; /* Last modified date */
WORD ftime; /* Last modified time */
BYTE fattrib; /* Attribute */
TCHAR fname[13]; /* Short file name (8.3 format) */
#if _USE_LFN
TCHAR* lfname; /* Pointer to the LFN buffer */
UINT lfsize; /* Size of LFN buffer in TCHAR */
TCHAR *lfname; /* Pointer to the LFN buffer */
UINT lfsize; /* Size of LFN buffer in TCHAR */
#endif
} FILINFO;
@ -175,27 +180,28 @@ typedef struct {
/* File function return code (FRESULT) */
typedef enum {
FR_OK = 0, /* (0) Succeeded */
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR, /* (2) Assertion failed */
FR_NOT_READY, /* (3) The physical drive cannot work */
FR_NO_FILE, /* (4) Could not find the file */
FR_NO_PATH, /* (5) Could not find the path */
FR_INVALID_NAME, /* (6) The path name format is invalid */
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
FR_EXIST, /* (8) Access denied due to prohibited access */
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
FR_NOT_ENABLED, /* (12) The volume has no work area */
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
typedef enum
{
FR_OK = 0, /* (0) Succeeded */
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR, /* (2) Assertion failed */
FR_NOT_READY, /* (3) The physical drive cannot work */
FR_NO_FILE, /* (4) Could not find the file */
FR_NO_PATH, /* (5) Could not find the path */
FR_INVALID_NAME, /* (6) The path name format is invalid */
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
FR_EXIST, /* (8) Access denied due to prohibited access */
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
FR_NOT_ENABLED, /* (12) The volume has no work area */
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
} FRESULT;
@ -203,35 +209,35 @@ typedef enum {
/*--------------------------------------------------------------*/
/* FatFs module application interface */
FRESULT f_mount (BYTE vol, FATFS* fs); /* Mount/Unmount a logical drive */
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
FRESULT f_close (FIL* fp); /* Close an open file object */
FRESULT f_opendir (DIR* dj, const TCHAR* path); /* Open an existing directory */
FRESULT f_readdir (DIR* dj, FILINFO* fno); /* Read a directory item */
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
FRESULT f_truncate (FIL* fp); /* Truncate file */
FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
FRESULT f_mkdir (const TCHAR* path); /* Create a new directory */
FRESULT f_chmod (const TCHAR* path, BYTE value, BYTE mask); /* Change attribute of the file/dir */
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
FRESULT f_chdrive (BYTE drv); /* Change current drive */
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* sn); /* Get volume label */
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
FRESULT f_mkfs (BYTE vol, BYTE sfd, UINT au); /* Create a file system on the drive */
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
FRESULT f_mount(BYTE vol, FATFS *fs); /* Mount/Unmount a logical drive */
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode); /* Open or create a file */
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br); /* Read data from a file */
FRESULT f_lseek(FIL *fp, DWORD ofs); /* Move file pointer of a file object */
FRESULT f_close(FIL *fp); /* Close an open file object */
FRESULT f_opendir(DIR *dj, const TCHAR *path); /* Open an existing directory */
FRESULT f_readdir(DIR *dj, FILINFO *fno); /* Read a directory item */
FRESULT f_stat(const TCHAR *path, FILINFO *fno); /* Get file status */
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw); /* Write data to a file */
FRESULT f_getfree(const TCHAR *path, DWORD *nclst, FATFS **fatfs); /* Get number of free clusters on the drive */
FRESULT f_truncate(FIL *fp); /* Truncate file */
FRESULT f_sync(FIL *fp); /* Flush cached data of a writing file */
FRESULT f_unlink(const TCHAR *path); /* Delete an existing file or directory */
FRESULT f_mkdir(const TCHAR *path); /* Create a new directory */
FRESULT f_chmod(const TCHAR *path, BYTE value, BYTE mask); /* Change attribute of the file/dir */
FRESULT f_utime(const TCHAR *path, const FILINFO *fno); /* Change times-tamp of the file/dir */
FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new); /* Rename/Move a file or directory */
FRESULT f_chdrive(BYTE drv); /* Change current drive */
FRESULT f_chdir(const TCHAR *path); /* Change current directory */
FRESULT f_getcwd(TCHAR *buff, UINT len); /* Get current directory */
FRESULT f_getlabel(const TCHAR *path, TCHAR *label, DWORD *sn); /* Get volume label */
FRESULT f_setlabel(const TCHAR *label); /* Set volume label */
FRESULT f_forward(FIL *fp, UINT(*func)(const BYTE *,UINT), UINT btf, UINT *bf); /* Forward data to the stream */
FRESULT f_mkfs(BYTE vol, BYTE sfd, UINT au); /* Create a file system on the drive */
FRESULT f_fdisk(BYTE pdrv, const DWORD szt[], void *work); /* Divide a physical drive into some partitions */
int f_putc(TCHAR c, FIL *fp); /* Put a character to the file */
int f_puts(const TCHAR *str, FIL *cp); /* Put a string to the file */
int f_printf(FIL *fp, const TCHAR *str, ...); /* Put a formatted string to the file */
TCHAR *f_gets(TCHAR *buff, int len, FIL *fp); /* Get a string from the file */
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
@ -250,25 +256,25 @@ TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the fil
/* RTC function */
#if !_FS_READONLY
DWORD get_fattime (void);
DWORD get_fattime(void);
#endif
/* Unicode support functions */
#if _USE_LFN /* Unicode - OEM code conversion */
WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */
WCHAR ff_convert(WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
WCHAR ff_wtoupper(WCHAR chr); /* Unicode upper-case conversion */
#if _USE_LFN == 3 /* Memory functions */
void* ff_memalloc (UINT msize); /* Allocate memory block */
void ff_memfree (void* mblock); /* Free memory block */
void *ff_memalloc(UINT msize); /* Allocate memory block */
void ff_memfree(void *mblock); /* Free memory block */
#endif
#endif
/* Sync functions */
#if _FS_REENTRANT
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */
int ff_req_grant (_SYNC_t sobj); /* Lock sync object */
void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */
int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
int ff_cre_syncobj(BYTE vol, _SYNC_t *sobj); /* Create a sync object */
int ff_req_grant(_SYNC_t sobj); /* Lock sync object */
void ff_rel_grant(_SYNC_t sobj); /* Unlock sync object */
int ff_del_syncobj(_SYNC_t sobj); /* Delete a sync object */
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -31,463 +31,484 @@
#if _CODE_PAGE == 437
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP437(0x80-0xFF) to Unicode conversion table */
{
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 720
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */
0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000,
0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9,
0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627,
0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642,
0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A,
0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP720(0x80-0xFF) to Unicode conversion table */
{
0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000,
0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9,
0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627,
0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642,
0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A,
0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 737
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */
0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9,
0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8,
0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0,
0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD,
0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E,
0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP737(0x80-0xFF) to Unicode conversion table */
{
0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9,
0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8,
0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0,
0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD,
0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E,
0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 775
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */
0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107,
0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A,
0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4,
0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6,
0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118,
0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D,
0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B,
0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144,
0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019,
0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E,
0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP775(0x80-0xFF) to Unicode conversion table */
{
0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107,
0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A,
0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4,
0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6,
0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118,
0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D,
0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B,
0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144,
0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019,
0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E,
0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 850
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP850(0x80-0xFF) to Unicode conversion table */
{
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 852
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7,
0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106,
0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A,
0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E,
0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A,
0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE,
0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161,
0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4,
0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP852(0x80-0xFF) to Unicode conversion table */
{
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7,
0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106,
0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A,
0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E,
0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A,
0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE,
0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161,
0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4,
0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 855
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */
0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404,
0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,
0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C,
0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A,
0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414,
0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438,
0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E,
0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580,
0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443,
0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116,
0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D,
0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP855(0x80-0xFF) to Unicode conversion table */
{
0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404,
0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,
0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C,
0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A,
0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414,
0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438,
0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E,
0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580,
0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443,
0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116,
0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D,
0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 857
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F,
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE,
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000,
0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4,
0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP857(0x80-0xFF) to Unicode conversion table */
{
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F,
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE,
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000,
0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4,
0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 858
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP858(0x80-0xFF) to Unicode conversion table */
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
0x00A9, 0x2563, 0x2551, 0x2557, 0x2550, 0x00A2, 0x00A5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x20AC, 0x00CD, 0x00CE,
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00C6, 0x00CC, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP858(0x80-0xFF) to Unicode conversion table */
{
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
0x00A9, 0x2563, 0x2551, 0x2557, 0x2550, 0x00A2, 0x00A5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x20AC, 0x00CD, 0x00CE,
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00C6, 0x00CC, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 862
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP862(0x80-0xFF) to Unicode conversion table */
{
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 866
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0
const WCHAR Tbl[] = /* CP866(0x80-0xFF) to Unicode conversion table */
{
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0
};
#elif _CODE_PAGE == 874
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP874(0x80-0xFF) to Unicode conversion table */
0x20AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x2026, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07,
0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
0x0E38, 0x0E39, 0x0E3A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0E3F,
0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x0000, 0x0000, 0x0000, 0x0000
const WCHAR Tbl[] = /* CP874(0x80-0xFF) to Unicode conversion table */
{
0x20AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x2026, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07,
0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
0x0E38, 0x0E39, 0x0E3A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0E3F,
0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x0000, 0x0000, 0x0000, 0x0000
};
#elif _CODE_PAGE == 1250
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP1250(0x80-0xFF) to Unicode conversion table */
0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021,
0x0000, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x0000, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A,
0x00A0, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x017B,
0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C,
0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9
const WCHAR Tbl[] = /* CP1250(0x80-0xFF) to Unicode conversion table */
{
0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021,
0x0000, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x0000, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A,
0x00A0, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x017B,
0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C,
0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9
};
#elif _CODE_PAGE == 1251
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP1251(0x80-0xFF) to Unicode conversion table */
0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x0000, 0x2111, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457,
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F
const WCHAR Tbl[] = /* CP1251(0x80-0xFF) to Unicode conversion table */
{
0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x0000, 0x2111, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457,
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F
};
#elif _CODE_PAGE == 1252
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP1252(0x80-0xFF) to Unicode conversion table */
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x017D, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x0000, 0x017E, 0x0178,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
const WCHAR Tbl[] = /* CP1252(0x80-0xFF) to Unicode conversion table */
{
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x017D, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x0000, 0x017E, 0x0178,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
};
#elif _CODE_PAGE == 1253
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP1253(0x80-0xFF) to Unicode conversion table */
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x0000, 0x2030, 0x0000, 0x2039, 0x000C, 0x0000, 0x0000, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x0000, 0x2122, 0x0000, 0x203A, 0x0000, 0x0000, 0x0000, 0x0000,
0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x0000, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7,
0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F,
0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
0x03A0, 0x03A1, 0x0000, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7,
0x03A8, 0x03A9, 0x03AA, 0x03AD, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x0000
const WCHAR Tbl[] = /* CP1253(0x80-0xFF) to Unicode conversion table */
{
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x0000, 0x2030, 0x0000, 0x2039, 0x000C, 0x0000, 0x0000, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x0000, 0x2122, 0x0000, 0x203A, 0x0000, 0x0000, 0x0000, 0x0000,
0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x0000, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7,
0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F,
0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
0x03A0, 0x03A1, 0x0000, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7,
0x03A8, 0x03A9, 0x03AA, 0x03AD, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x0000
};
#elif _CODE_PAGE == 1254
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP1254(0x80-0xFF) to Unicode conversion table */
0x20AC, 0x0000, 0x210A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x0000, 0x0000, 0x0178,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
0x00D8, 0x00D9, 0x00DA, 0x00BD, 0x00DC, 0x0130, 0x015E, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF
const WCHAR Tbl[] = /* CP1254(0x80-0xFF) to Unicode conversion table */
{
0x20AC, 0x0000, 0x210A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x0000, 0x0000, 0x0178,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
0x00D8, 0x00D9, 0x00DA, 0x00BD, 0x00DC, 0x0130, 0x015E, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF
};
#elif _CODE_PAGE == 1255
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP1255(0x80-0xFF) to Unicode conversion table */
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0000, 0x2039, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x0000, 0x203A, 0x0000, 0x0000, 0x0000, 0x0000,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7,
0x05B8, 0x05B9, 0x0000, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF,
0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3,
0x05F4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
0x05E8, 0x05E9, 0x05EA, 0x0000, 0x0000, 0x200E, 0x200F, 0x0000
const WCHAR Tbl[] = /* CP1255(0x80-0xFF) to Unicode conversion table */
{
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0000, 0x2039, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x0000, 0x203A, 0x0000, 0x0000, 0x0000, 0x0000,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7,
0x05B8, 0x05B9, 0x0000, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF,
0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3,
0x05F4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
0x05E8, 0x05E9, 0x05EA, 0x0000, 0x0000, 0x200E, 0x200F, 0x0000
};
#elif _CODE_PAGE == 1256
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP1256(0x80-0xFF) to Unicode conversion table */
0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x06A9, 0x2122, 0x0691, 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA,
0x00A0, 0x060C, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x061F,
0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7,
0x0637, 0x0638, 0x0639, 0x063A, 0x0640, 0x0640, 0x0642, 0x0643,
0x00E0, 0x0644, 0x00E2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF,
0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7,
0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2
const WCHAR Tbl[] = /* CP1256(0x80-0xFF) to Unicode conversion table */
{
0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x06A9, 0x2122, 0x0691, 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA,
0x00A0, 0x060C, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x061F,
0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7,
0x0637, 0x0638, 0x0639, 0x063A, 0x0640, 0x0640, 0x0642, 0x0643,
0x00E0, 0x0644, 0x00E2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF,
0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7,
0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2
}
#elif _CODE_PAGE == 1257
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP1257(0x80-0xFF) to Unicode conversion table */
0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021,
0x0000, 0x2030, 0x0000, 0x2039, 0x0000, 0x00A8, 0x02C7, 0x00B8,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x0000, 0x2122, 0x0000, 0x203A, 0x0000, 0x00AF, 0x02DB, 0x0000,
0x00A0, 0x0000, 0x00A2, 0x00A3, 0x00A4, 0x0000, 0x00A6, 0x00A7,
0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6,
0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112,
0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B,
0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7,
0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF,
0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113,
0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C,
0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7,
0x0173, 0x014E, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9
const WCHAR Tbl[] = /* CP1257(0x80-0xFF) to Unicode conversion table */
{
0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021,
0x0000, 0x2030, 0x0000, 0x2039, 0x0000, 0x00A8, 0x02C7, 0x00B8,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x0000, 0x2122, 0x0000, 0x203A, 0x0000, 0x00AF, 0x02DB, 0x0000,
0x00A0, 0x0000, 0x00A2, 0x00A3, 0x00A4, 0x0000, 0x00A6, 0x00A7,
0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6,
0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112,
0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B,
0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7,
0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF,
0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113,
0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C,
0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7,
0x0173, 0x014E, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9
};
#elif _CODE_PAGE == 1258
#define _TBLDEF 1
static
const WCHAR Tbl[] = { /* CP1258(0x80-0xFF) to Unicode conversion table */
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0000, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x0000, 0x203A, 0x0153, 0x0000, 0x0000, 0x0178,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0300, 0x00CD, 0x00CE, 0x00CF,
0x0110, 0x00D1, 0x0309, 0x00D3, 0x00D4, 0x01A0, 0x00D6, 0x00D7,
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x01AF, 0x0303, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0301, 0x00ED, 0x00EE, 0x00EF,
0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF
const WCHAR Tbl[] = /* CP1258(0x80-0xFF) to Unicode conversion table */
{
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0000, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000,
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x0000, 0x203A, 0x0153, 0x0000, 0x0000, 0x0178,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0300, 0x00CD, 0x00CE, 0x00CF,
0x0110, 0x00D1, 0x0309, 0x00D3, 0x00D4, 0x01A0, 0x00D6, 0x00D7,
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x01AF, 0x0303, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0301, 0x00ED, 0x00EE, 0x00EF,
0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF
};
#endif
@ -498,43 +519,53 @@ const WCHAR Tbl[] = { /* CP1258(0x80-0xFF) to Unicode conversion table */
#endif
WCHAR ff_convert ( /* Converted character, Returns zero on error */
WCHAR chr, /* Character code to be converted */
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
WCHAR ff_convert( /* Converted character, Returns zero on error */
WCHAR chr, /* Character code to be converted */
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
)
{
WCHAR c;
WCHAR c;
if (chr < 0x80) { /* ASCII */
c = chr;
if (chr < 0x80) /* ASCII */
{
c = chr;
} else {
if (dir) { /* OEMCP to Unicode */
c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80];
}
else
{
if (dir) /* OEMCP to Unicode */
{
c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80];
} else { /* Unicode to OEMCP */
for (c = 0; c < 0x80; c++) {
if (chr == Tbl[c]) break;
}
c = (c + 0x80) & 0xFF;
}
}
}
else /* Unicode to OEMCP */
{
for (c = 0; c < 0x80; c++)
{
if (chr == Tbl[c])
{
break;
}
}
c = (c + 0x80) & 0xFF;
}
}
return c;
return c;
}
WCHAR ff_wtoupper ( /* Upper converted character */
WCHAR chr /* Input character */
WCHAR ff_wtoupper( /* Upper converted character */
WCHAR chr /* Input character */
)
{
static const WCHAR tbl_lower[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0xA1, 0x00A2, 0x00A3, 0x00A5, 0x00AC, 0x00AF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0x0FF, 0x101, 0x103, 0x105, 0x107, 0x109, 0x10B, 0x10D, 0x10F, 0x111, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129, 0x12B, 0x12D, 0x12F, 0x131, 0x133, 0x135, 0x137, 0x13A, 0x13C, 0x13E, 0x140, 0x142, 0x144, 0x146, 0x148, 0x14B, 0x14D, 0x14F, 0x151, 0x153, 0x155, 0x157, 0x159, 0x15B, 0x15D, 0x15F, 0x161, 0x163, 0x165, 0x167, 0x169, 0x16B, 0x16D, 0x16F, 0x171, 0x173, 0x175, 0x177, 0x17A, 0x17C, 0x17E, 0x192, 0x3B1, 0x3B2, 0x3B3, 0x3B4, 0x3B5, 0x3B6, 0x3B7, 0x3B8, 0x3B9, 0x3BA, 0x3BB, 0x3BC, 0x3BD, 0x3BE, 0x3BF, 0x3C0, 0x3C1, 0x3C3, 0x3C4, 0x3C5, 0x3C6, 0x3C7, 0x3C8, 0x3C9, 0x3CA, 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x43E, 0x43F, 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447, 0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457, 0x458, 0x459, 0x45A, 0x45B, 0x45C, 0x45E, 0x45F, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47, 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F, 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57, 0xFF58, 0xFF59, 0xFF5A, 0 };
static const WCHAR tbl_upper[] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x21, 0xFFE0, 0xFFE1, 0xFFE5, 0xFFE2, 0xFFE3, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0x178, 0x100, 0x102, 0x104, 0x106, 0x108, 0x10A, 0x10C, 0x10E, 0x110, 0x112, 0x114, 0x116, 0x118, 0x11A, 0x11C, 0x11E, 0x120, 0x122, 0x124, 0x126, 0x128, 0x12A, 0x12C, 0x12E, 0x130, 0x132, 0x134, 0x136, 0x139, 0x13B, 0x13D, 0x13F, 0x141, 0x143, 0x145, 0x147, 0x14A, 0x14C, 0x14E, 0x150, 0x152, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E, 0x160, 0x162, 0x164, 0x166, 0x168, 0x16A, 0x16C, 0x16E, 0x170, 0x172, 0x174, 0x176, 0x179, 0x17B, 0x17D, 0x191, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, 0x398, 0x399, 0x39A, 0x39B, 0x39C, 0x39D, 0x39E, 0x39F, 0x3A0, 0x3A1, 0x3A3, 0x3A4, 0x3A5, 0x3A6, 0x3A7, 0x3A8, 0x3A9, 0x3AA, 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, 0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E, 0x41F, 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, 0x428, 0x429, 0x42A, 0x42B, 0x42C, 0x42D, 0x42E, 0x42F, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407, 0x408, 0x409, 0x40A, 0x40B, 0x40C, 0x40E, 0x40F, 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0x216A, 0x216B, 0x216C, 0x216D, 0x216E, 0x216F, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27, 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F, 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37, 0xFF38, 0xFF39, 0xFF3A, 0 };
int i;
static const WCHAR tbl_lower[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0xA1, 0x00A2, 0x00A3, 0x00A5, 0x00AC, 0x00AF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0x0FF, 0x101, 0x103, 0x105, 0x107, 0x109, 0x10B, 0x10D, 0x10F, 0x111, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129, 0x12B, 0x12D, 0x12F, 0x131, 0x133, 0x135, 0x137, 0x13A, 0x13C, 0x13E, 0x140, 0x142, 0x144, 0x146, 0x148, 0x14B, 0x14D, 0x14F, 0x151, 0x153, 0x155, 0x157, 0x159, 0x15B, 0x15D, 0x15F, 0x161, 0x163, 0x165, 0x167, 0x169, 0x16B, 0x16D, 0x16F, 0x171, 0x173, 0x175, 0x177, 0x17A, 0x17C, 0x17E, 0x192, 0x3B1, 0x3B2, 0x3B3, 0x3B4, 0x3B5, 0x3B6, 0x3B7, 0x3B8, 0x3B9, 0x3BA, 0x3BB, 0x3BC, 0x3BD, 0x3BE, 0x3BF, 0x3C0, 0x3C1, 0x3C3, 0x3C4, 0x3C5, 0x3C6, 0x3C7, 0x3C8, 0x3C9, 0x3CA, 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x43E, 0x43F, 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447, 0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457, 0x458, 0x459, 0x45A, 0x45B, 0x45C, 0x45E, 0x45F, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47, 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F, 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57, 0xFF58, 0xFF59, 0xFF5A, 0 };
static const WCHAR tbl_upper[] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x21, 0xFFE0, 0xFFE1, 0xFFE5, 0xFFE2, 0xFFE3, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0x178, 0x100, 0x102, 0x104, 0x106, 0x108, 0x10A, 0x10C, 0x10E, 0x110, 0x112, 0x114, 0x116, 0x118, 0x11A, 0x11C, 0x11E, 0x120, 0x122, 0x124, 0x126, 0x128, 0x12A, 0x12C, 0x12E, 0x130, 0x132, 0x134, 0x136, 0x139, 0x13B, 0x13D, 0x13F, 0x141, 0x143, 0x145, 0x147, 0x14A, 0x14C, 0x14E, 0x150, 0x152, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E, 0x160, 0x162, 0x164, 0x166, 0x168, 0x16A, 0x16C, 0x16E, 0x170, 0x172, 0x174, 0x176, 0x179, 0x17B, 0x17D, 0x191, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, 0x398, 0x399, 0x39A, 0x39B, 0x39C, 0x39D, 0x39E, 0x39F, 0x3A0, 0x3A1, 0x3A3, 0x3A4, 0x3A5, 0x3A6, 0x3A7, 0x3A8, 0x3A9, 0x3AA, 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, 0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E, 0x41F, 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, 0x428, 0x429, 0x42A, 0x42B, 0x42C, 0x42D, 0x42E, 0x42F, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407, 0x408, 0x409, 0x40A, 0x40B, 0x40C, 0x40E, 0x40F, 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0x216A, 0x216B, 0x216C, 0x216D, 0x216E, 0x216F, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27, 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F, 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37, 0xFF38, 0xFF39, 0xFF3A, 0 };
int i;
for (i = 0; tbl_lower[i] && chr != tbl_lower[i]; i++) ;
for (i = 0; tbl_lower[i] && chr != tbl_lower[i]; i++) ;
return tbl_lower[i] ? tbl_upper[i] : chr;
return tbl_lower[i] ? tbl_upper[i] : chr;
}

View File

@ -18,17 +18,17 @@
/ returned, the f_mount function fails with FR_INT_ERR.
*/
int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create due to any error */
BYTE vol, /* Corresponding logical drive being processed */
_SYNC_t *sobj /* Pointer to return the created sync object */
int ff_cre_syncobj( /* 1:Function succeeded, 0:Could not create due to any error */
BYTE vol, /* Corresponding logical drive being processed */
_SYNC_t *sobj /* Pointer to return the created sync object */
)
{
int ret;
int ret;
// static _SYNC_t sem[_VOLUMES]; /* FreeRTOS */
*sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */
ret = (*sobj != INVALID_HANDLE_VALUE);
*sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */
ret = (*sobj != INVALID_HANDLE_VALUE);
// *sobj = SyncObjects[vol]; /* uITRON (give a static created sync object) */
// ret = 1; /* The initial value of the semaphore must be 1. */
@ -41,7 +41,7 @@ int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create due to any erro
// *sobj = sem[vol];
// ret = (*sobj != NULL);
return ret;
return ret;
}
@ -54,14 +54,14 @@ int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create due to any erro
/ returned, the f_mount function fails with FR_INT_ERR.
*/
int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any error */
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
int ff_del_syncobj( /* 1:Function succeeded, 0:Could not delete due to any error */
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
)
{
int ret;
int ret;
ret = CloseHandle(sobj); /* Win32 */
ret = CloseHandle(sobj); /* Win32 */
// ret = 1; /* uITRON (nothing to do) */
@ -70,7 +70,7 @@ int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any erro
// ret = 1; /* FreeRTOS (nothing to do) */
return ret;
return ret;
}
@ -82,13 +82,13 @@ int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any erro
/ When a FALSE is returned, the file function fails with FR_TIMEOUT.
*/
int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
_SYNC_t sobj /* Sync object to wait */
int ff_req_grant( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
_SYNC_t sobj /* Sync object to wait */
)
{
int ret;
int ret;
ret = (WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0); /* Win32 */
ret = (WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0); /* Win32 */
// ret = (wai_sem(sobj) == E_OK); /* uITRON */
@ -97,7 +97,7 @@ int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get
// ret = (xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE); /* FreeRTOS */
return ret;
return ret;
}
@ -108,11 +108,11 @@ int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get
/* This function is called on leaving file functions to unlock the volume.
*/
void ff_rel_grant (
_SYNC_t sobj /* Sync object to be signaled */
void ff_rel_grant(
_SYNC_t sobj /* Sync object to be signaled */
)
{
ReleaseMutex(sobj); /* Win32 */
ReleaseMutex(sobj); /* Win32 */
// sig_sem(sobj); /* uITRON */
@ -133,11 +133,11 @@ void ff_rel_grant (
/* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
*/
void* ff_memalloc ( /* Returns pointer to the allocated memory block */
UINT msize /* Number of bytes to allocate */
void *ff_memalloc( /* Returns pointer to the allocated memory block */
UINT msize /* Number of bytes to allocate */
)
{
return malloc(msize);
return malloc(msize);
}
@ -145,11 +145,11 @@ void* ff_memalloc ( /* Returns pointer to the allocated memory block */
/* Free a memory block */
/*------------------------------------------------------------------------*/
void ff_memfree (
void* mblock /* Pointer to the memory block to free */
void ff_memfree(
void *mblock /* Pointer to the memory block to free */
)
{
free(mblock);
free(mblock);
}
#endif

View File

@ -46,7 +46,8 @@
static struct dhcpc_state s;
struct dhcp_msg {
struct dhcp_msg
{
u8_t op, htype, hlen, hops;
u8_t xid[4];
u16_t secs, flags;
@ -201,28 +202,30 @@ parse_options(u8_t *optptr, int len)
u8_t *end = optptr + len;
u8_t type = 0;
while(optptr < end) {
switch(*optptr) {
case DHCP_OPTION_SUBNET_MASK:
memcpy(s.netmask, optptr + 2, 4);
break;
case DHCP_OPTION_ROUTER:
memcpy(s.default_router, optptr + 2, 4);
break;
case DHCP_OPTION_DNS_SERVER:
memcpy(s.dnsaddr, optptr + 2, 4);
break;
case DHCP_OPTION_MSG_TYPE:
type = *(optptr + 2);
break;
case DHCP_OPTION_SERVER_ID:
memcpy(s.serverid, optptr + 2, 4);
break;
case DHCP_OPTION_LEASE_TIME:
memcpy(s.lease_time, optptr + 2, 4);
break;
case DHCP_OPTION_END:
return type;
while (optptr < end)
{
switch (*optptr)
{
case DHCP_OPTION_SUBNET_MASK:
memcpy(s.netmask, optptr + 2, 4);
break;
case DHCP_OPTION_ROUTER:
memcpy(s.default_router, optptr + 2, 4);
break;
case DHCP_OPTION_DNS_SERVER:
memcpy(s.dnsaddr, optptr + 2, 4);
break;
case DHCP_OPTION_MSG_TYPE:
type = *(optptr + 2);
break;
case DHCP_OPTION_SERVER_ID:
memcpy(s.serverid, optptr + 2, 4);
break;
case DHCP_OPTION_LEASE_TIME:
memcpy(s.lease_time, optptr + 2, 4);
break;
case DHCP_OPTION_END:
return type;
}
optptr += optptr[1] + 2;
@ -235,9 +238,10 @@ parse_msg(void)
{
struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
if(m->op == DHCP_REPLY &&
memcmp(m->xid, xid, sizeof(xid)) == 0 &&
memcmp(m->chaddr, s.mac_addr, s.mac_len) == 0) {
if (m->op == DHCP_REPLY &&
memcmp(m->xid, xid, sizeof(xid)) == 0 &&
memcmp(m->chaddr, s.mac_addr, s.mac_len) == 0)
{
memcpy(s.ipaddr, m->yiaddr, 4);
return parse_options(&m->options[4], uip_datalen());
}
@ -253,57 +257,67 @@ PT_THREAD(handle_dhcp(void))
s.state = STATE_SENDING;
s.ticks = CLOCK_SECOND;
do {
do
{
send_discover();
timer_set(&s.timer, s.ticks);
PT_YIELD(&s.pt);
PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));
if(uip_newdata() && parse_msg() == DHCPOFFER) {
if (uip_newdata() && parse_msg() == DHCPOFFER)
{
s.state = STATE_OFFER_RECEIVED;
break;
}
if(s.ticks < CLOCK_SECOND * 60) {
if (s.ticks < CLOCK_SECOND * 60)
{
s.ticks *= 2;
}
} while(s.state != STATE_OFFER_RECEIVED);
}
while (s.state != STATE_OFFER_RECEIVED);
s.ticks = CLOCK_SECOND;
do {
do
{
send_request();
timer_set(&s.timer, s.ticks);
PT_YIELD(&s.pt);
PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));
if(uip_newdata() && parse_msg() == DHCPACK) {
if (uip_newdata() && parse_msg() == DHCPACK)
{
s.state = STATE_CONFIG_RECEIVED;
break;
}
if(s.ticks <= CLOCK_SECOND * 10) {
if (s.ticks <= CLOCK_SECOND * 10)
{
s.ticks += CLOCK_SECOND;
} else {
}
else
{
PT_RESTART(&s.pt);
}
} while(s.state != STATE_CONFIG_RECEIVED);
}
while (s.state != STATE_CONFIG_RECEIVED);
#if 0
printf("Got IP address %d.%d.%d.%d\n",
uip_ipaddr1(s.ipaddr), uip_ipaddr2(s.ipaddr),
uip_ipaddr3(s.ipaddr), uip_ipaddr4(s.ipaddr));
uip_ipaddr1(s.ipaddr), uip_ipaddr2(s.ipaddr),
uip_ipaddr3(s.ipaddr), uip_ipaddr4(s.ipaddr));
printf("Got netmask %d.%d.%d.%d\n",
uip_ipaddr1(s.netmask), uip_ipaddr2(s.netmask),
uip_ipaddr3(s.netmask), uip_ipaddr4(s.netmask));
uip_ipaddr1(s.netmask), uip_ipaddr2(s.netmask),
uip_ipaddr3(s.netmask), uip_ipaddr4(s.netmask));
printf("Got DNS server %d.%d.%d.%d\n",
uip_ipaddr1(s.dnsaddr), uip_ipaddr2(s.dnsaddr),
uip_ipaddr3(s.dnsaddr), uip_ipaddr4(s.dnsaddr));
uip_ipaddr1(s.dnsaddr), uip_ipaddr2(s.dnsaddr),
uip_ipaddr3(s.dnsaddr), uip_ipaddr4(s.dnsaddr));
printf("Got default router %d.%d.%d.%d\n",
uip_ipaddr1(s.default_router), uip_ipaddr2(s.default_router),
uip_ipaddr3(s.default_router), uip_ipaddr4(s.default_router));
uip_ipaddr1(s.default_router), uip_ipaddr2(s.default_router),
uip_ipaddr3(s.default_router), uip_ipaddr4(s.default_router));
printf("Lease expires in %ld seconds\n",
ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1]));
ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1]));
#endif
dhcpc_configured(&s);
@ -314,7 +328,8 @@ PT_THREAD(handle_dhcp(void))
* PT_END restarts the thread so we do this instead. Eventually we
* should reacquire expired leases here.
*/
while(1) {
while (1)
{
PT_YIELD(&s.pt);
}
@ -332,7 +347,8 @@ dhcpc_init(const void *mac_addr, int mac_len)
s.state = STATE_INITIAL;
uip_ipaddr(addr, 255,255,255,255);
s.conn = uip_udp_new(&addr, HTONS(DHCPC_SERVER_PORT));
if(s.conn != NULL) {
if (s.conn != NULL)
{
uip_udp_bind(s.conn, HTONS(DHCPC_CLIENT_PORT));
}
PT_INIT(&s.pt);
@ -349,7 +365,8 @@ dhcpc_request(void)
{
u16_t ipaddr[2];
if(s.state == STATE_INITIAL) {
if (s.state == STATE_INITIAL)
{
uip_ipaddr(ipaddr, 0,0,0,0);
uip_sethostaddr(ipaddr);
/* handle_dhcp(PROCESS_EVENT_NONE, NULL);*/

View File

@ -36,7 +36,8 @@
#include "uip_timer.h"
#include "pt.h"
struct dhcpc_state {
struct dhcpc_state
{
struct pt pt;
char state;
struct uip_udp_conn *conn;

View File

@ -65,7 +65,8 @@ hello_world_appcall(void)
* If a new connection was just established, we should initialize
* the protosocket in our applications' state structure.
*/
if(uip_connected()) {
if (uip_connected())
{
PSOCK_INIT(&s->p, s->inputbuffer, sizeof(s->inputbuffer));
}

View File

@ -33,7 +33,8 @@
of our application, and the memory required for this state is
allocated together with each TCP connection. One application state
for each TCP connection. */
typedef struct hello_world_state {
typedef struct hello_world_state
{
struct psock p;
char inputbuffer[10];
char name[40];

View File

@ -68,18 +68,18 @@ struct httpd_state *hs;
//
//*****************************************************************************
static const char page_not_found[] =
"HTTP/1.0 404 OK\r\n"
"Server: UIP/1.0 (http://www.sics.se/~adam/uip/)\r\n"
"Content-type: text/html\r\n\r\n"
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd\">"
"<html>"
"HTTP/1.0 404 OK\r\n"
"Server: UIP/1.0 (http://www.sics.se/~adam/uip/)\r\n"
"Content-type: text/html\r\n\r\n"
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd\">"
"<html>"
"<head>"
"<title>Page Not Found!</title>"
"<title>Page Not Found!</title>"
"</head>"
"<body>"
"Page Not Found!"
"Page Not Found!"
"</body>"
"</html>";
"</html>";
//*****************************************************************************
//
@ -88,33 +88,33 @@ static const char page_not_found[] =
//
//*****************************************************************************
static const char default_page_buf1of3[] =
"HTTP/1.0 200 OK\r\n"
"Server: UIP/1.0 (http://www.sics.se/~adam/uip/)\r\n"
"Content-type: text/html\r\n\r\n"
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd\">"
"<html>"
"HTTP/1.0 200 OK\r\n"
"Server: UIP/1.0 (http://www.sics.se/~adam/uip/)\r\n"
"Content-type: text/html\r\n\r\n"
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd\">"
"<html>"
"<head>"
"<title>Welcome to the uIP web server!</title>"
"<title>Welcome to the uIP web server!</title>"
"</head>"
"<body>"
"<center>"
"<h1>&micro;IP Web Server</h1>"
"<p>This web page is served by a small web server running on top of "
"the <a href=\"http://www.sics.se/~adam/uip/\">&micro;IP embedded TCP/IP "
"stack</a>."
"<hr width=\"75%\">"
"<p>The &micro;IP stack is running on a "
"<a href=\"http://www.ti.com\">Texas Instruments</a> "
"Stellaris<small><sup>&reg;</sup></small> Ethernet Evaluation Kit"
"<hr width=\"75%\">"
"<p>This page has been sent ";
"<center>"
"<h1>&micro;IP Web Server</h1>"
"<p>This web page is served by a small web server running on top of "
"the <a href=\"http://www.sics.se/~adam/uip/\">&micro;IP embedded TCP/IP "
"stack</a>."
"<hr width=\"75%\">"
"<p>The &micro;IP stack is running on a "
"<a href=\"http://www.ti.com\">Texas Instruments</a> "
"Stellaris<small><sup>&reg;</sup></small> Ethernet Evaluation Kit"
"<hr width=\"75%\">"
"<p>This page has been sent ";
static char default_page_buf2of3[] =
"00001";
"00001";
static const char default_page_buf3of3[] =
" times since reset!"
"</center>"
" times since reset!"
"</center>"
"</body>"
"</html>";
"</html>";
//*****************************************************************************
//
@ -125,51 +125,51 @@ static const char default_page_buf3of3[] =
static void
httpd_inc_page_count(void)
{
//
// Increment the 'ones' digit. If it wraps, then increment the 'tens'
// digit.
//
default_page_buf2of3[4]++;
if(default_page_buf2of3[4] == 0x3a)
{
default_page_buf2of3[4] = 0x30;
default_page_buf2of3[3]++;
}
//
// Increment the 'ones' digit. If it wraps, then increment the 'tens'
// digit.
//
default_page_buf2of3[4]++;
if (default_page_buf2of3[4] == 0x3a)
{
default_page_buf2of3[4] = 0x30;
default_page_buf2of3[3]++;
}
//
// If the 'tens' digit wraps, increment the 'hundreds' digit.
//
if(default_page_buf2of3[3] == 0x3a)
{
default_page_buf2of3[3] = 0x30;
default_page_buf2of3[2]++;
}
//
// If the 'tens' digit wraps, increment the 'hundreds' digit.
//
if (default_page_buf2of3[3] == 0x3a)
{
default_page_buf2of3[3] = 0x30;
default_page_buf2of3[2]++;
}
//
// If the 'hundreds' digit wraps, increment the 'thousands' digit.
//
if(default_page_buf2of3[2] == 0x3a)
{
default_page_buf2of3[2] = 0x30;
default_page_buf2of3[1]++;
}
//
// If the 'hundreds' digit wraps, increment the 'thousands' digit.
//
if (default_page_buf2of3[2] == 0x3a)
{
default_page_buf2of3[2] = 0x30;
default_page_buf2of3[1]++;
}
//
// If the 'thousands' digit wraps, increment the 'ten-thousands' digit.
//
if(default_page_buf2of3[1] == 0x3a)
{
default_page_buf2of3[1] = 0x30;
default_page_buf2of3[0]++;
}
//
// If the 'thousands' digit wraps, increment the 'ten-thousands' digit.
//
if (default_page_buf2of3[1] == 0x3a)
{
default_page_buf2of3[1] = 0x30;
default_page_buf2of3[0]++;
}
//
// If the 'ten-thousands' digit wrapped, start over.
//
if(default_page_buf2of3[0] == 0x3a)
{
default_page_buf2of3[0] = 0x30;
}
//
// If the 'ten-thousands' digit wrapped, start over.
//
if (default_page_buf2of3[0] == 0x3a)
{
default_page_buf2of3[0] = 0x30;
}
}
//*****************************************************************************
@ -182,10 +182,10 @@ httpd_inc_page_count(void)
void
httpd_init(void)
{
//
// Listen to port 80.
//
uip_listen(HTONS(80));
//
// Listen to port 80.
//
uip_listen(HTONS(80));
}
//*****************************************************************************
@ -196,129 +196,129 @@ httpd_init(void)
void
httpd_appcall(void)
{
switch(uip_conn->lport)
switch (uip_conn->lport)
{
//
// This is the web server:
//
case HTONS(80):
{
//
// Pick out the application state from the uip_conn structure.
//
hs = (struct httpd_state *)&(uip_conn->appstate);
//
// We use the uip_ test functions to deduce why we were
// called. If uip_connected() is non-zero, we were called
// because a remote host has connected to us. If
// uip_newdata() is non-zero, we were called because the
// remote host has sent us new data, and if uip_acked() is
// non-zero, the remote host has acknowledged the data we
// previously sent to it. */
if (uip_connected())
{
//
// This is the web server:
// Since we have just been connected with the remote host, we
// reset the state for this connection. The ->count variable
// contains the amount of data that is yet to be sent to the
// remote host, and the ->state is set to HTTP_NOGET to signal
// that we haven't received any HTTP GET request for this
// connection yet.
//
case HTONS(80):
hs->state = HTTP_NOGET;
hs->count = 0;
return;
}
else if (uip_poll())
{
//
// If we are polled ten times, we abort the connection. This is
// because we don't want connections lingering indefinately in
// the system.
//
if (hs->count++ >= 10)
{
//
// Pick out the application state from the uip_conn structure.
//
hs = (struct httpd_state *)&(uip_conn->appstate);
//
// We use the uip_ test functions to deduce why we were
// called. If uip_connected() is non-zero, we were called
// because a remote host has connected to us. If
// uip_newdata() is non-zero, we were called because the
// remote host has sent us new data, and if uip_acked() is
// non-zero, the remote host has acknowledged the data we
// previously sent to it. */
if(uip_connected())
{
//
// Since we have just been connected with the remote host, we
// reset the state for this connection. The ->count variable
// contains the amount of data that is yet to be sent to the
// remote host, and the ->state is set to HTTP_NOGET to signal
// that we haven't received any HTTP GET request for this
// connection yet.
//
hs->state = HTTP_NOGET;
hs->count = 0;
return;
}
else if(uip_poll())
{
//
// If we are polled ten times, we abort the connection. This is
// because we don't want connections lingering indefinately in
// the system.
//
if(hs->count++ >= 10)
{
uip_abort();
}
return;
}
else if(uip_newdata() && hs->state == HTTP_NOGET)
{
//
// This is the first data we receive, and it should contain a
// GET.
//
// Check for GET.
//
if(BUF_APPDATA[0] != 'G' ||
BUF_APPDATA[1] != 'E' ||
BUF_APPDATA[2] != 'T' ||
BUF_APPDATA[3] != ' ')
{
//
// If it isn't a GET, we abort the connection.
//
uip_abort();
return;
}
//
// Check to see what we should send.
//
if((BUF_APPDATA[4] == '/') &&
(BUF_APPDATA[5] == ' '))
{
//
// Send buffer 1
//
uip_send(default_page_buf1of3,
sizeof(default_page_buf1of3) - 1);
}
else
{
uip_send(page_not_found,
sizeof(page_not_found) - 1);
hs->count = 3;
}
}
else if(uip_acked())
{
hs->count++;
if(hs->count == 1)
{
uip_send(default_page_buf2of3,
sizeof(default_page_buf2of3) - 1);
}
else if(hs->count == 2)
{
uip_send(default_page_buf3of3,
sizeof(default_page_buf3of3) - 1);
}
else if(hs->count == 3)
{
httpd_inc_page_count();
uip_close();
}
else
{
uip_close();
}
}
//
// Finally, return to uIP. Our outgoing packet will soon be on its
// way...
//
return;
uip_abort();
}
return;
}
else if (uip_newdata() && hs->state == HTTP_NOGET)
{
//
// This is the first data we receive, and it should contain a
// GET.
//
// Check for GET.
//
if (BUF_APPDATA[0] != 'G' ||
BUF_APPDATA[1] != 'E' ||
BUF_APPDATA[2] != 'T' ||
BUF_APPDATA[3] != ' ')
{
//
// If it isn't a GET, we abort the connection.
//
uip_abort();
return;
}
default:
//
// Check to see what we should send.
//
if ((BUF_APPDATA[4] == '/') &&
(BUF_APPDATA[5] == ' '))
{
//
// Should never happen.
//
uip_abort();
break;
//
// Send buffer 1
//
uip_send(default_page_buf1of3,
sizeof(default_page_buf1of3) - 1);
}
else
{
uip_send(page_not_found,
sizeof(page_not_found) - 1);
hs->count = 3;
}
}
else if (uip_acked())
{
hs->count++;
if (hs->count == 1)
{
uip_send(default_page_buf2of3,
sizeof(default_page_buf2of3) - 1);
}
else if (hs->count == 2)
{
uip_send(default_page_buf3of3,
sizeof(default_page_buf3of3) - 1);
}
else if (hs->count == 3)
{
httpd_inc_page_count();
uip_close();
}
else
{
uip_close();
}
}
//
// Finally, return to uIP. Our outgoing packet will soon be on its
// way...
//
return;
}
default:
{
//
// Should never happen.
//
uip_abort();
break;
}
}
}

View File

@ -51,8 +51,8 @@ void httpd_appcall(void);
//*****************************************************************************
struct httpd_state
{
u8_t state;
u16_t count;
u8_t state;
u16_t count;
};
#endif // __HTTPD_H__

View File

@ -73,7 +73,8 @@
#define MAX_RETRIES 8
/** \internal The DNS message header. */
struct dns_hdr {
struct dns_hdr
{
u16_t id;
u8_t flags1, flags2;
#define DNS_FLAG1_RESPONSE 0x80
@ -94,7 +95,8 @@ struct dns_hdr {
};
/** \internal The DNS answer message structure. */
struct dns_answer {
struct dns_answer
{
/* DNS answer record starts with either a domain name or a pointer
to a name already present somewhere in the packet. */
u16_t type;
@ -104,7 +106,8 @@ struct dns_answer {
uip_ipaddr_t ipaddr;
};
struct namemap {
struct namemap
{
#define STATE_UNUSED 0
#define STATE_NEW 1
#define STATE_ASKING 2
@ -145,16 +148,19 @@ parse_name(unsigned char *query)
{
unsigned char n;
do {
do
{
n = *query++;
while(n > 0) {
while (n > 0)
{
/* printf("%c", *query);*/
++query;
--n;
};
/* printf(".");*/
} while(*query != 0);
}
while (*query != 0);
/* printf("\n");*/
return query + 1;
}
@ -173,28 +179,37 @@ check_entries(void)
static u8_t n;
register struct namemap *namemapptr;
for(i = 0; i < RESOLV_ENTRIES; ++i) {
for (i = 0; i < RESOLV_ENTRIES; ++i)
{
namemapptr = &names[i];
if(namemapptr->state == STATE_NEW ||
namemapptr->state == STATE_ASKING) {
if(namemapptr->state == STATE_ASKING) {
if(--namemapptr->tmr == 0) {
if(++namemapptr->retries == MAX_RETRIES) {
namemapptr->state = STATE_ERROR;
resolv_found(namemapptr->name, NULL);
continue;
}
namemapptr->tmr = namemapptr->retries;
} else {
/* printf("Timer %d\n", namemapptr->tmr);*/
/* Its timer has not run out, so we move on to next
entry. */
continue;
}
} else {
namemapptr->state = STATE_ASKING;
namemapptr->tmr = 1;
namemapptr->retries = 0;
if (namemapptr->state == STATE_NEW ||
namemapptr->state == STATE_ASKING)
{
if (namemapptr->state == STATE_ASKING)
{
if (--namemapptr->tmr == 0)
{
if (++namemapptr->retries == MAX_RETRIES)
{
namemapptr->state = STATE_ERROR;
resolv_found(namemapptr->name, NULL);
continue;
}
namemapptr->tmr = namemapptr->retries;
}
else
{
/* printf("Timer %d\n", namemapptr->tmr);*/
/* Its timer has not run out, so we move on to next
entry. */
continue;
}
}
else
{
namemapptr->state = STATE_ASKING;
namemapptr->tmr = 1;
namemapptr->retries = 0;
}
hdr = (struct dns_hdr *)uip_appdata;
memset(hdr, 0, sizeof(struct dns_hdr));
@ -205,21 +220,24 @@ check_entries(void)
nameptr = namemapptr->name;
--nameptr;
/* Convert hostname into suitable query format. */
do {
++nameptr;
nptr = query;
++query;
for(n = 0; *nameptr != '.' && *nameptr != 0; ++nameptr) {
*query = *nameptr;
++query;
++n;
}
*nptr = n;
} while(*nameptr != 0);
do
{
static unsigned char endquery[] =
{0,0,1,0,1};
memcpy(query, endquery, 5);
++nameptr;
nptr = query;
++query;
for (n = 0; *nameptr != '.' && *nameptr != 0; ++nameptr)
{
*query = *nameptr;
++query;
++n;
}
*nptr = n;
}
while (*nameptr != 0);
{
static unsigned char endquery[] =
{0,0,1,0,1};
memcpy(query, endquery, 5);
}
uip_udp_send((unsigned char)(query + 5 - (char *)uip_appdata));
break;
@ -256,15 +274,17 @@ newdata(void)
table. */
i = htons(hdr->id);
namemapptr = &names[i];
if(i < RESOLV_ENTRIES &&
namemapptr->state == STATE_ASKING) {
if (i < RESOLV_ENTRIES &&
namemapptr->state == STATE_ASKING)
{
/* This entry is now finished. */
namemapptr->state = STATE_DONE;
namemapptr->err = hdr->flags2 & DNS_FLAG2_ERR_MASK;
/* Check for error. If so, call callback to inform. */
if(namemapptr->err != 0) {
if (namemapptr->err != 0)
{
namemapptr->state = STATE_ERROR;
resolv_found(namemapptr->name, NULL);
return;
@ -280,42 +300,49 @@ newdata(void)
match. */
nameptr = parse_name((char *)uip_appdata + 12) + 4;
while(nanswers > 0) {
while (nanswers > 0)
{
/* The first byte in the answer resource record determines if it
is a compressed record or a normal one. */
if(*nameptr & 0xc0) {
/* Compressed name. */
nameptr +=2;
/* printf("Compressed anwser\n");*/
} else {
/* Not compressed name. */
nameptr = parse_name((char *)nameptr);
is a compressed record or a normal one. */
if (*nameptr & 0xc0)
{
/* Compressed name. */
nameptr +=2;
/* printf("Compressed anwser\n");*/
}
else
{
/* Not compressed name. */
nameptr = parse_name((char *)nameptr);
}
ans = (struct dns_answer *)nameptr;
/* printf("Answer: type %x, class %x, ttl %x, length %x\n",
htons(ans->type), htons(ans->class), (htons(ans->ttl[0])
<< 16) | htons(ans->ttl[1]), htons(ans->len));*/
htons(ans->type), htons(ans->class), (htons(ans->ttl[0])
<< 16) | htons(ans->ttl[1]), htons(ans->len));*/
/* Check for IP address type and Internet class. Others are
discarded. */
if(ans->type == HTONS(1) &&
ans->class == HTONS(1) &&
ans->len == HTONS(4)) {
/* printf("IP address %d.%d.%d.%d\n",
htons(ans->ipaddr[0]) >> 8,
htons(ans->ipaddr[0]) & 0xff,
htons(ans->ipaddr[1]) >> 8,
htons(ans->ipaddr[1]) & 0xff);*/
/* XXX: we should really check that this IP address is the one
we want. */
namemapptr->ipaddr[0] = ans->ipaddr[0];
namemapptr->ipaddr[1] = ans->ipaddr[1];
discarded. */
if (ans->type == HTONS(1) &&
ans->class == HTONS(1) &&
ans->len == HTONS(4))
{
/* printf("IP address %d.%d.%d.%d\n",
htons(ans->ipaddr[0]) >> 8,
htons(ans->ipaddr[0]) & 0xff,
htons(ans->ipaddr[1]) >> 8,
htons(ans->ipaddr[1]) & 0xff);*/
/* XXX: we should really check that this IP address is the one
we want. */
namemapptr->ipaddr[0] = ans->ipaddr[0];
namemapptr->ipaddr[1] = ans->ipaddr[1];
resolv_found(namemapptr->name, namemapptr->ipaddr);
return;
} else {
nameptr = nameptr + 10 + htons(ans->len);
resolv_found(namemapptr->name, namemapptr->ipaddr);
return;
}
else
{
nameptr = nameptr + 10 + htons(ans->len);
}
--nanswers;
}
@ -330,11 +357,14 @@ newdata(void)
void
resolv_appcall(void)
{
if(uip_udp_conn->rport == HTONS(53)) {
if(uip_poll()) {
if (uip_udp_conn->rport == HTONS(53))
{
if (uip_poll())
{
check_entries();
}
if(uip_newdata()) {
if (uip_newdata())
{
newdata();
}
}
@ -355,18 +385,22 @@ resolv_query(char *name)
lseq = lseqi = 0;
for(i = 0; i < RESOLV_ENTRIES; ++i) {
for (i = 0; i < RESOLV_ENTRIES; ++i)
{
nameptr = &names[i];
if(nameptr->state == STATE_UNUSED) {
if (nameptr->state == STATE_UNUSED)
{
break;
}
if(seqno - nameptr->seqno > lseq) {
if (seqno - nameptr->seqno > lseq)
{
lseq = seqno - nameptr->seqno;
lseqi = i;
}
}
if(i == RESOLV_ENTRIES) {
if (i == RESOLV_ENTRIES)
{
i = lseqi;
nameptr = &names[i];
}
@ -400,10 +434,12 @@ resolv_lookup(char *name)
/* Walk through the list to see if the name is in there. If it is
not, we return NULL. */
for(i = 0; i < RESOLV_ENTRIES; ++i) {
for (i = 0; i < RESOLV_ENTRIES; ++i)
{
nameptr = &names[i];
if(nameptr->state == STATE_DONE &&
strcmp(name, nameptr->name) == 0) {
if (nameptr->state == STATE_DONE &&
strcmp(name, nameptr->name) == 0)
{
return nameptr->ipaddr;
}
}
@ -421,7 +457,8 @@ resolv_lookup(char *name)
u16_t *
resolv_getserver(void)
{
if(resolv_conn == NULL) {
if (resolv_conn == NULL)
{
return NULL;
}
return resolv_conn->ripaddr;
@ -437,7 +474,8 @@ resolv_getserver(void)
void
resolv_conf(u16_t *dnsserver)
{
if(resolv_conn != NULL) {
if (resolv_conn != NULL)
{
uip_udp_remove(resolv_conn);
}
@ -453,7 +491,8 @@ resolv_init(void)
{
static u8_t i;
for(i = 0; i < RESOLV_ENTRIES; ++i) {
for (i = 0; i < RESOLV_ENTRIES; ++i)
{
names[i].state = STATE_DONE;
}

View File

@ -33,38 +33,38 @@
* $Id: smtp-strings.c,v 1.3 2006/06/11 21:46:37 adam Exp $
*/
const char smtp_220[4] =
/* "220" */
/* "220" */
{0x32, 0x32, 0x30, };
const char smtp_helo[6] =
/* "HELO " */
/* "HELO " */
{0x48, 0x45, 0x4c, 0x4f, 0x20, };
const char smtp_mail_from[12] =
/* "MAIL FROM: " */
/* "MAIL FROM: " */
{0x4d, 0x41, 0x49, 0x4c, 0x20, 0x46, 0x52, 0x4f, 0x4d, 0x3a, 0x20, };
const char smtp_rcpt_to[10] =
/* "RCPT TO: " */
/* "RCPT TO: " */
{0x52, 0x43, 0x50, 0x54, 0x20, 0x54, 0x4f, 0x3a, 0x20, };
const char smtp_data[7] =
/* "DATA\r\n" */
/* "DATA\r\n" */
{0x44, 0x41, 0x54, 0x41, 0xd, 0xa, };
const char smtp_to[5] =
/* "To: " */
/* "To: " */
{0x54, 0x6f, 0x3a, 0x20, };
const char smtp_cc[5] =
/* "Cc: " */
/* "Cc: " */
{0x43, 0x63, 0x3a, 0x20, };
const char smtp_from[7] =
/* "From: " */
/* "From: " */
{0x46, 0x72, 0x6f, 0x6d, 0x3a, 0x20, };
const char smtp_subject[10] =
/* "Subject: " */
/* "Subject: " */
{0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3a, 0x20, };
const char smtp_quit[7] =
/* "QUIT\r\n" */
/* "QUIT\r\n" */
{0x51, 0x55, 0x49, 0x54, 0xd, 0xa, };
const char smtp_crnl[3] =
/* "\r\n" */
/* "\r\n" */
{0xd, 0xa, };
const char smtp_crnlperiodcrnl[6] =
/* "\r\n.\r\n" */
/* "\r\n.\r\n" */
{0xd, 0xa, 0x2e, 0xd, 0xa, };

View File

@ -86,7 +86,8 @@ PT_THREAD(smtp_thread(void))
PSOCK_READTO(&s.psock, ISO_nl);
if(strncmp(s.inputbuffer, smtp_220, 3) != 0) {
if (strncmp(s.inputbuffer, smtp_220, 3) != 0)
{
PSOCK_CLOSE(&s.psock);
smtp_done(2);
PSOCK_EXIT(&s.psock);
@ -98,7 +99,8 @@ PT_THREAD(smtp_thread(void))
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_2) {
if (s.inputbuffer[0] != ISO_2)
{
PSOCK_CLOSE(&s.psock);
smtp_done(3);
PSOCK_EXIT(&s.psock);
@ -110,7 +112,8 @@ PT_THREAD(smtp_thread(void))
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_2) {
if (s.inputbuffer[0] != ISO_2)
{
PSOCK_CLOSE(&s.psock);
smtp_done(4);
PSOCK_EXIT(&s.psock);
@ -122,20 +125,23 @@ PT_THREAD(smtp_thread(void))
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_2) {
if (s.inputbuffer[0] != ISO_2)
{
PSOCK_CLOSE(&s.psock);
smtp_done(5);
PSOCK_EXIT(&s.psock);
}
if(s.cc != 0) {
if (s.cc != 0)
{
PSOCK_SEND_STR(&s.psock, (char *)smtp_rcpt_to);
PSOCK_SEND_STR(&s.psock, s.cc);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_2) {
if (s.inputbuffer[0] != ISO_2)
{
PSOCK_CLOSE(&s.psock);
smtp_done(6);
PSOCK_EXIT(&s.psock);
@ -146,7 +152,8 @@ PT_THREAD(smtp_thread(void))
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_3) {
if (s.inputbuffer[0] != ISO_3)
{
PSOCK_CLOSE(&s.psock);
smtp_done(7);
PSOCK_EXIT(&s.psock);
@ -156,7 +163,8 @@ PT_THREAD(smtp_thread(void))
PSOCK_SEND_STR(&s.psock, s.to);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
if(s.cc != 0) {
if (s.cc != 0)
{
PSOCK_SEND_STR(&s.psock, (char *)smtp_cc);
PSOCK_SEND_STR(&s.psock, s.cc);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
@ -175,7 +183,8 @@ PT_THREAD(smtp_thread(void))
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnlperiodcrnl);
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_2) {
if (s.inputbuffer[0] != ISO_2)
{
PSOCK_CLOSE(&s.psock);
smtp_done(8);
PSOCK_EXIT(&s.psock);
@ -189,11 +198,13 @@ PT_THREAD(smtp_thread(void))
void
smtp_appcall(void)
{
if(uip_closed()) {
if (uip_closed())
{
s.connected = 0;
return;
}
if(uip_aborted() || uip_timedout()) {
if (uip_aborted() || uip_timedout())
{
s.connected = 0;
smtp_done(1);
return;
@ -231,12 +242,13 @@ smtp_configure(char *lhostname, void *server)
*/
unsigned char
smtp_send(char *to, char *cc, char *from,
char *subject, char *msg, u16_t msglen)
char *subject, char *msg, u16_t msglen)
{
struct uip_conn *conn;
conn = uip_connect(smtpserver, HTONS(25));
if(conn == NULL) {
if (conn == NULL)
{
return 0;
}
s.connected = 1;

View File

@ -71,14 +71,15 @@ void smtp_init(void);
/* Functions. */
void smtp_configure(char *localhostname, u16_t *smtpserver);
unsigned char smtp_send(char *to, char *from,
char *subject, char *msg,
u16_t msglen);
char *subject, char *msg,
u16_t msglen);
#define SMTP_SEND(to, cc, from, subject, msg) \
smtp_send(to, cc, from, subject, msg, strlen(msg))
void smtp_appcall(void);
struct smtp_state {
struct smtp_state
{
u8_t state;
char *to;
char *from;

View File

@ -1,42 +1,43 @@
/*
* Copyright (c) 2003, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY 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.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: shell.c,v 1.1 2006/06/07 09:43:54 adam Exp $
*
*/
/*
* Copyright (c) 2003, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY 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.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: shell.c,v 1.1 2006/06/07 09:43:54 adam Exp $
*
*/
#include "shell.h"
#include <string.h>
struct ptentry {
struct ptentry
{
char *commandstr;
void (* pfunc)(char *str);
};
@ -48,8 +49,10 @@ static void
parse(register char *str, struct ptentry *t)
{
struct ptentry *p;
for(p = t; p->commandstr != NULL; ++p) {
if(strncmp(p->commandstr, str, strlen(p->commandstr)) == 0) {
for (p = t; p->commandstr != NULL; ++p)
{
if (strncmp(p->commandstr, str, strlen(p->commandstr)) == 0)
{
break;
}
}
@ -61,11 +64,13 @@ static void
inttostr(register char *str, unsigned int i)
{
str[0] = '0' + i / 100;
if(str[0] == '0') {
if (str[0] == '0')
{
str[0] = ' ';
}
str[1] = '0' + (i / 10) % 10;
if(str[0] == ' ' && str[1] == '0') {
if (str[0] == ' ' && str[1] == '0')
{
str[1] = ' ';
}
str[2] = '0' + i % 10;
@ -86,20 +91,23 @@ help(char *str)
static void
unknown(char *str)
{
if(strlen(str) > 0) {
if (strlen(str) > 0)
{
shell_output("Unknown command: ", str);
}
}
/*---------------------------------------------------------------------------*/
static struct ptentry parsetab[] =
{{"stats", help},
{"conn", help},
{"help", help},
{"exit", shell_quit},
{"?", help},
{
{"stats", help},
{"conn", help},
{"help", help},
{"exit", shell_quit},
{"?", help},
/* Default action */
{NULL, unknown}};
/* Default action */
{NULL, unknown}
};
/*---------------------------------------------------------------------------*/
void
shell_init(void)

View File

@ -42,7 +42,8 @@
#define ISO_nl 0x0a
#define ISO_cr 0x0d
struct telnetd_line {
struct telnetd_line
{
char line[TELNETD_CONF_LINELEN];
};
MEMB(linemem, struct telnetd_line, TELNETD_CONF_NUMLINES);
@ -86,13 +87,16 @@ sendline(char *line)
{
static unsigned int i;
for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
if(s.lines[i] == NULL) {
for (i = 0; i < TELNETD_CONF_NUMLINES; ++i)
{
if (s.lines[i] == NULL)
{
s.lines[i] = line;
break;
}
}
if(i == TELNETD_CONF_NUMLINES) {
if (i == TELNETD_CONF_NUMLINES)
{
dealloc_line(line);
}
}
@ -102,7 +106,8 @@ shell_prompt(char *str)
{
char *line;
line = alloc_line();
if(line != NULL) {
if (line != NULL)
{
strncpy(line, str, TELNETD_CONF_LINELEN);
/* petsciiconv_toascii(line, TELNETD_CONF_LINELEN);*/
sendline(line);
@ -116,14 +121,17 @@ shell_output(char *str1, char *str2)
char *line;
line = alloc_line();
if(line != NULL) {
if (line != NULL)
{
len = strlen(str1);
strncpy(line, str1, TELNETD_CONF_LINELEN);
if(len < TELNETD_CONF_LINELEN) {
if (len < TELNETD_CONF_LINELEN)
{
strncpy(line + len, str2, TELNETD_CONF_LINELEN - len);
}
len = strlen(line);
if(len < TELNETD_CONF_LINELEN - 2) {
if (len < TELNETD_CONF_LINELEN - 2)
{
line[len] = ISO_cr;
line[len+1] = ISO_nl;
line[len+2] = 0;
@ -146,9 +154,11 @@ acked(void)
{
static unsigned int i;
while(s.numsent > 0) {
while (s.numsent > 0)
{
dealloc_line(s.lines[0]);
for(i = 1; i < TELNETD_CONF_NUMLINES; ++i) {
for (i = 1; i < TELNETD_CONF_NUMLINES; ++i)
{
s.lines[i - 1] = s.lines[i];
}
s.lines[TELNETD_CONF_NUMLINES - 1] = NULL;
@ -164,18 +174,23 @@ senddata(void)
bufptr = uip_appdata;
buflen = 0;
for(s.numsent = 0; s.numsent < TELNETD_CONF_NUMLINES &&
s.lines[s.numsent] != NULL ; ++s.numsent) {
for (s.numsent = 0; s.numsent < TELNETD_CONF_NUMLINES &&
s.lines[s.numsent] != NULL ; ++s.numsent)
{
lineptr = s.lines[s.numsent];
linelen = strlen(lineptr);
if(linelen > TELNETD_CONF_LINELEN) {
if (linelen > TELNETD_CONF_LINELEN)
{
linelen = TELNETD_CONF_LINELEN;
}
if(buflen + linelen < uip_mss()) {
if (buflen + linelen < uip_mss())
{
memcpy(bufptr, lineptr, linelen);
bufptr += linelen;
buflen += linelen;
} else {
}
else
{
break;
}
}
@ -187,8 +202,10 @@ closed(void)
{
static unsigned int i;
for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
if(s.lines[i] != NULL) {
for (i = 0; i < TELNETD_CONF_NUMLINES; ++i)
{
if (s.lines[i] != NULL)
{
dealloc_line(s.lines[i]);
}
}
@ -197,20 +214,25 @@ closed(void)
static void
get_char(u8_t c)
{
if(c == ISO_cr) {
if (c == ISO_cr)
{
return;
}
s.buf[(int)s.bufptr] = c;
if(s.buf[(int)s.bufptr] == ISO_nl ||
s.bufptr == sizeof(s.buf) - 1) {
if(s.bufptr > 0) {
if (s.buf[(int)s.bufptr] == ISO_nl ||
s.bufptr == sizeof(s.buf) - 1)
{
if (s.bufptr > 0)
{
s.buf[(int)s.bufptr] = 0;
/* petsciiconv_topetscii(s.buf, TELNETD_CONF_LINELEN);*/
}
shell_input(s.buf);
s.bufptr = 0;
} else {
}
else
{
++s.bufptr;
}
}
@ -220,7 +242,8 @@ sendopt(u8_t option, u8_t value)
{
char *line;
line = alloc_line();
if(line != NULL) {
if (line != NULL)
{
line[0] = TELNET_IAC;
line[1] = option;
line[2] = value;
@ -240,63 +263,72 @@ newdata(void)
len = uip_datalen();
dataptr = (char *)uip_appdata;
while(len > 0 && s.bufptr < sizeof(s.buf)) {
while (len > 0 && s.bufptr < sizeof(s.buf))
{
c = *dataptr;
++dataptr;
--len;
switch(s.state) {
case STATE_IAC:
if(c == TELNET_IAC) {
get_char(c);
s.state = STATE_NORMAL;
} else {
switch(c) {
case TELNET_WILL:
s.state = STATE_WILL;
break;
case TELNET_WONT:
s.state = STATE_WONT;
break;
case TELNET_DO:
s.state = STATE_DO;
break;
case TELNET_DONT:
s.state = STATE_DONT;
break;
default:
s.state = STATE_NORMAL;
break;
}
}
break;
case STATE_WILL:
/* Reply with a DONT */
sendopt(TELNET_DONT, c);
s.state = STATE_NORMAL;
break;
switch (s.state)
{
case STATE_IAC:
if (c == TELNET_IAC)
{
get_char(c);
s.state = STATE_NORMAL;
}
else
{
switch (c)
{
case TELNET_WILL:
s.state = STATE_WILL;
break;
case TELNET_WONT:
s.state = STATE_WONT;
break;
case TELNET_DO:
s.state = STATE_DO;
break;
case TELNET_DONT:
s.state = STATE_DONT;
break;
default:
s.state = STATE_NORMAL;
break;
}
}
break;
case STATE_WILL:
/* Reply with a DONT */
sendopt(TELNET_DONT, c);
s.state = STATE_NORMAL;
break;
case STATE_WONT:
/* Reply with a DONT */
sendopt(TELNET_DONT, c);
s.state = STATE_NORMAL;
break;
case STATE_DO:
/* Reply with a WONT */
sendopt(TELNET_WONT, c);
s.state = STATE_NORMAL;
break;
case STATE_DONT:
/* Reply with a WONT */
sendopt(TELNET_WONT, c);
s.state = STATE_NORMAL;
break;
case STATE_NORMAL:
if(c == TELNET_IAC) {
s.state = STATE_IAC;
} else {
get_char(c);
}
break;
case STATE_WONT:
/* Reply with a DONT */
sendopt(TELNET_DONT, c);
s.state = STATE_NORMAL;
break;
case STATE_DO:
/* Reply with a WONT */
sendopt(TELNET_WONT, c);
s.state = STATE_NORMAL;
break;
case STATE_DONT:
/* Reply with a WONT */
sendopt(TELNET_WONT, c);
s.state = STATE_NORMAL;
break;
case STATE_NORMAL:
if (c == TELNET_IAC)
{
s.state = STATE_IAC;
}
else
{
get_char(c);
}
break;
}
@ -308,9 +340,11 @@ void
telnetd_appcall(void)
{
static unsigned int i;
if(uip_connected()) {
if (uip_connected())
{
/* tcp_markconn(uip_conn, &s);*/
for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
for (i = 0; i < TELNETD_CONF_NUMLINES; ++i)
{
s.lines[i] = NULL;
}
s.bufptr = 0;
@ -319,31 +353,36 @@ telnetd_appcall(void)
shell_start();
}
if(s.state == STATE_CLOSE) {
if (s.state == STATE_CLOSE)
{
s.state = STATE_NORMAL;
uip_close();
return;
}
if(uip_closed() ||
uip_aborted() ||
uip_timedout()) {
if (uip_closed() ||
uip_aborted() ||
uip_timedout())
{
closed();
}
if(uip_acked()) {
if (uip_acked())
{
acked();
}
if(uip_newdata()) {
if (uip_newdata())
{
newdata();
}
if(uip_rexmit() ||
uip_newdata() ||
uip_acked() ||
uip_connected() ||
uip_poll()) {
if (uip_rexmit() ||
uip_newdata() ||
uip_acked() ||
uip_connected() ||
uip_poll())
{
senddata();
}
}

View File

@ -46,7 +46,8 @@ void telnetd_appcall(void);
#define TELNETD_CONF_NUMLINES 16
#endif
struct telnetd_state {
struct telnetd_state
{
char *lines[TELNETD_CONF_NUMLINES];
char buf[TELNETD_CONF_LINELEN];
char bufptr;

View File

@ -1,93 +1,93 @@
const char http_http[8] =
/* "http://" */
/* "http://" */
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0 };
const char http_200[5] =
/* "200 " */
/* "200 " */
{0x32, 0x30, 0x30, 0x20, 0 };
const char http_301[5] =
/* "301 " */
/* "301 " */
{0x33, 0x30, 0x31, 0x20, 0 };
const char http_302[5] =
/* "302 " */
/* "302 " */
{0x33, 0x30, 0x32, 0x20, 0 };
const char http_get[5] =
/* "GET " */
/* "GET " */
{0x47, 0x45, 0x54, 0x20, 0 };
const char http_10[9] =
/* "HTTP/1.0" */
/* "HTTP/1.0" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0 };
const char http_11[9] =
/* "HTTP/1.1" */
/* "HTTP/1.1" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0 };
const char http_content_type[15] =
/* "content-type: " */
/* "content-type: " */
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0 };
const char http_texthtml[10] =
/* "text/html" */
/* "text/html" */
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0 };
const char http_location[11] =
/* "location: " */
/* "location: " */
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0 };
const char http_host[7] =
/* "host: " */
/* "host: " */
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0 };
const char http_crnl[3] =
/* "\r\n" */
/* "\r\n" */
{0xd, 0xa, 0 };
const char http_index_html[12] =
/* "/index.html" */
/* "/index.html" */
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
const char http_404_html[10] =
/* "/404.html" */
/* "/404.html" */
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
const char http_content_type_html[28] =
/* "Content-type: text/html\r\n\r\n" */
/* "Content-type: text/html\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_css [27] =
/* "Content-type: text/css\r\n\r\n" */
/* "Content-type: text/css\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_text[28] =
/* "Content-type: text/text\r\n\r\n" */
/* "Content-type: text/text\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_png [28] =
/* "Content-type: image/png\r\n\r\n" */
/* "Content-type: image/png\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_gif [28] =
/* "Content-type: image/gif\r\n\r\n" */
/* "Content-type: image/gif\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_jpg [29] =
/* "Content-type: image/jpeg\r\n\r\n" */
/* "Content-type: image/jpeg\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_binary[43] =
/* "Content-type: application/octet-stream\r\n\r\n" */
/* "Content-type: application/octet-stream\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_html[6] =
/* ".html" */
/* ".html" */
{0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
const char http_shtml[7] =
/* ".shtml" */
/* ".shtml" */
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0 };
const char http_htm[5] =
/* ".htm" */
/* ".htm" */
{0x2e, 0x68, 0x74, 0x6d, 0 };
const char http_css[5] =
/* ".css" */
/* ".css" */
{0x2e, 0x63, 0x73, 0x73, 0 };
const char http_png[5] =
/* ".png" */
/* ".png" */
{0x2e, 0x70, 0x6e, 0x67, 0 };
const char http_gif[5] =
/* ".gif" */
/* ".gif" */
{0x2e, 0x67, 0x69, 0x66, 0 };
const char http_jpg[5] =
/* ".jpg" */
/* ".jpg" */
{0x2e, 0x6a, 0x70, 0x67, 0 };
const char http_text[6] =
/* ".text" */
/* ".text" */
{0x2e, 0x74, 0x65, 0x78, 0x74, 0 };
const char http_txt[5] =
/* ".txt" */
/* ".txt" */
{0x2e, 0x74, 0x78, 0x74, 0 };
const char http_user_agent_fields[77] =
/* "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n" */
/* "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x28, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, 0 };

View File

@ -119,12 +119,12 @@ init_connection(void)
s.state = WEBCLIENT_STATE_STATUSLINE;
s.getrequestleft = sizeof(http_get) - 1 + 1 +
sizeof(http_10) - 1 +
sizeof(http_crnl) - 1 +
sizeof(http_host) - 1 +
sizeof(http_crnl) - 1 +
strlen(http_user_agent_fields) +
strlen(s.file) + strlen(s.host);
sizeof(http_10) - 1 +
sizeof(http_crnl) - 1 +
sizeof(http_host) - 1 +
sizeof(http_crnl) - 1 +
strlen(http_user_agent_fields) +
strlen(s.file) + strlen(s.host);
s.getrequestptr = 0;
s.httpheaderlineptr = 0;
@ -145,17 +145,20 @@ webclient_get(char *host, u16_t port, char *file)
/* First check if the host is an IP address. */
ipaddr = &addr;
if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
if (uiplib_ipaddrconv(host, (unsigned char *)addr) == 0)
{
ipaddr = (uip_ipaddr_t *)resolv_lookup(host);
if(ipaddr == NULL) {
if (ipaddr == NULL)
{
return 0;
}
}
conn = uip_connect(ipaddr, htons(port));
if(conn == NULL) {
if (conn == NULL)
{
return 0;
}
@ -169,7 +172,7 @@ webclient_get(char *host, u16_t port, char *file)
/*-----------------------------------------------------------------------------------*/
static unsigned char *
copy_string(unsigned char *dest,
const unsigned char *src, unsigned char len)
const unsigned char *src, unsigned char len)
{
strncpy(dest, src, len);
return dest + len;
@ -182,7 +185,8 @@ senddata(void)
char *getrequest;
char *cptr;
if(s.getrequestleft > 0) {
if (s.getrequestleft > 0)
{
cptr = getrequest = (char *)uip_appdata;
cptr = copy_string(cptr, http_get, sizeof(http_get) - 1);
@ -197,11 +201,11 @@ senddata(void)
cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1);
cptr = copy_string(cptr, http_user_agent_fields,
strlen(http_user_agent_fields));
strlen(http_user_agent_fields));
len = s.getrequestleft > uip_mss()?
uip_mss():
s.getrequestleft;
uip_mss():
s.getrequestleft;
uip_send(&(getrequest[s.getrequestptr]), len);
}
}
@ -211,10 +215,11 @@ acked(void)
{
u16_t len;
if(s.getrequestleft > 0) {
if (s.getrequestleft > 0)
{
len = s.getrequestleft > uip_mss()?
uip_mss():
s.getrequestleft;
uip_mss():
s.getrequestleft;
s.getrequestleft -= len;
s.getrequestptr += len;
}
@ -225,41 +230,53 @@ parse_statusline(u16_t len)
{
char *cptr;
while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
while (len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline))
{
s.httpheaderline[s.httpheaderlineptr] = *(char *)uip_appdata;
++((char *)uip_appdata);
--len;
if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
if (s.httpheaderline[s.httpheaderlineptr] == ISO_nl)
{
if((strncmp(s.httpheaderline, http_10,
sizeof(http_10) - 1) == 0) ||
(strncmp(s.httpheaderline, http_11,
sizeof(http_11) - 1) == 0)) {
cptr = &(s.httpheaderline[9]);
s.httpflag = HTTPFLAG_NONE;
if(strncmp(cptr, http_200, sizeof(http_200) - 1) == 0) {
/* 200 OK */
s.httpflag = HTTPFLAG_OK;
} else if(strncmp(cptr, http_301, sizeof(http_301) - 1) == 0 ||
strncmp(cptr, http_302, sizeof(http_302) - 1) == 0) {
/* 301 Moved permanently or 302 Found. Location: header line
will contain thw new location. */
s.httpflag = HTTPFLAG_MOVED;
} else {
s.httpheaderline[s.httpheaderlineptr - 1] = 0;
}
} else {
uip_abort();
webclient_aborted();
return 0;
if ((strncmp(s.httpheaderline, http_10,
sizeof(http_10) - 1) == 0) ||
(strncmp(s.httpheaderline, http_11,
sizeof(http_11) - 1) == 0))
{
cptr = &(s.httpheaderline[9]);
s.httpflag = HTTPFLAG_NONE;
if (strncmp(cptr, http_200, sizeof(http_200) - 1) == 0)
{
/* 200 OK */
s.httpflag = HTTPFLAG_OK;
}
else if (strncmp(cptr, http_301, sizeof(http_301) - 1) == 0 ||
strncmp(cptr, http_302, sizeof(http_302) - 1) == 0)
{
/* 301 Moved permanently or 302 Found. Location: header line
will contain thw new location. */
s.httpflag = HTTPFLAG_MOVED;
}
else
{
s.httpheaderline[s.httpheaderlineptr - 1] = 0;
}
}
else
{
uip_abort();
webclient_aborted();
return 0;
}
/* We're done parsing the status line, so we reset the pointer
and start parsing the HTTP headers.*/
and start parsing the HTTP headers.*/
s.httpheaderlineptr = 0;
s.state = WEBCLIENT_STATE_HEADERS;
break;
} else {
}
else
{
++s.httpheaderlineptr;
}
}
@ -271,13 +288,16 @@ casecmp(char *str1, const char *str2, char len)
{
static char c;
while(len > 0) {
while (len > 0)
{
c = *str1;
/* Force lower-case characters. */
if(c & 0x40) {
if (c & 0x40)
{
c |= 0x20;
}
if(*str2 != c) {
if (*str2 != c)
{
return 1;
}
++str1;
@ -293,60 +313,72 @@ parse_headers(u16_t len)
char *cptr;
static unsigned char i;
while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
while (len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline))
{
s.httpheaderline[s.httpheaderlineptr] = *(char *)uip_appdata;
++((char *)uip_appdata);
--len;
if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
if (s.httpheaderline[s.httpheaderlineptr] == ISO_nl)
{
/* We have an entire HTTP header line in s.httpheaderline, so
we parse it. */
if(s.httpheaderline[0] == ISO_cr) {
/* This was the last header line (i.e., and empty "\r\n"), so
we are done with the headers and proceed with the actual
data. */
s.state = WEBCLIENT_STATE_DATA;
return len;
we parse it. */
if (s.httpheaderline[0] == ISO_cr)
{
/* This was the last header line (i.e., and empty "\r\n"), so
we are done with the headers and proceed with the actual
data. */
s.state = WEBCLIENT_STATE_DATA;
return len;
}
s.httpheaderline[s.httpheaderlineptr - 1] = 0;
/* Check for specific HTTP header fields. */
if(casecmp(s.httpheaderline, http_content_type,
sizeof(http_content_type) - 1) == 0) {
/* Found Content-type field. */
cptr = strchr(s.httpheaderline, ';');
if(cptr != NULL) {
*cptr = 0;
}
strncpy(s.mimetype, s.httpheaderline +
sizeof(http_content_type) - 1, sizeof(s.mimetype));
} else if(casecmp(s.httpheaderline, http_location,
sizeof(http_location) - 1) == 0) {
cptr = s.httpheaderline +
sizeof(http_location) - 1;
if (casecmp(s.httpheaderline, http_content_type,
sizeof(http_content_type) - 1) == 0)
{
/* Found Content-type field. */
cptr = strchr(s.httpheaderline, ';');
if (cptr != NULL)
{
*cptr = 0;
}
strncpy(s.mimetype, s.httpheaderline +
sizeof(http_content_type) - 1, sizeof(s.mimetype));
}
else if (casecmp(s.httpheaderline, http_location,
sizeof(http_location) - 1) == 0)
{
cptr = s.httpheaderline +
sizeof(http_location) - 1;
if(strncmp(cptr, http_http, 7) == 0) {
cptr += 7;
for(i = 0; i < s.httpheaderlineptr - 7; ++i) {
if(*cptr == 0 ||
*cptr == '/' ||
*cptr == ' ' ||
*cptr == ':') {
s.host[i] = 0;
break;
}
s.host[i] = *cptr;
++cptr;
}
}
strncpy(s.file, cptr, sizeof(s.file));
/* s.file[s.httpheaderlineptr - i] = 0;*/
if (strncmp(cptr, http_http, 7) == 0)
{
cptr += 7;
for (i = 0; i < s.httpheaderlineptr - 7; ++i)
{
if (*cptr == 0 ||
*cptr == '/' ||
*cptr == ' ' ||
*cptr == ':')
{
s.host[i] = 0;
break;
}
s.host[i] = *cptr;
++cptr;
}
}
strncpy(s.file, cptr, sizeof(s.file));
/* s.file[s.httpheaderlineptr - i] = 0;*/
}
/* We're done parsing, so we reset the pointer and start the
next line. */
next line. */
s.httpheaderlineptr = 0;
} else {
}
else
{
++s.httpheaderlineptr;
}
}
@ -360,16 +392,19 @@ newdata(void)
len = uip_datalen();
if(s.state == WEBCLIENT_STATE_STATUSLINE) {
if (s.state == WEBCLIENT_STATE_STATUSLINE)
{
len = parse_statusline(len);
}
if(s.state == WEBCLIENT_STATE_HEADERS && len > 0) {
if (s.state == WEBCLIENT_STATE_HEADERS && len > 0)
{
len = parse_headers(len);
}
if(len > 0 && s.state == WEBCLIENT_STATE_DATA &&
s.httpflag != HTTPFLAG_MOVED) {
if (len > 0 && s.state == WEBCLIENT_STATE_DATA &&
s.httpflag != HTTPFLAG_MOVED)
{
webclient_datahandler((char *)uip_appdata, len);
}
}
@ -377,7 +412,8 @@ newdata(void)
void
webclient_appcall(void)
{
if(uip_connected()) {
if (uip_connected())
{
s.timer = 0;
s.state = WEBCLIENT_STATE_STATUSLINE;
senddata();
@ -385,49 +421,63 @@ webclient_appcall(void)
return;
}
if(s.state == WEBCLIENT_STATE_CLOSE) {
if (s.state == WEBCLIENT_STATE_CLOSE)
{
webclient_closed();
uip_abort();
return;
}
if(uip_aborted()) {
if (uip_aborted())
{
webclient_aborted();
}
if(uip_timedout()) {
if (uip_timedout())
{
webclient_timedout();
}
if(uip_acked()) {
if (uip_acked())
{
s.timer = 0;
acked();
}
if(uip_newdata()) {
if (uip_newdata())
{
s.timer = 0;
newdata();
}
if(uip_rexmit() ||
uip_newdata() ||
uip_acked()) {
if (uip_rexmit() ||
uip_newdata() ||
uip_acked())
{
senddata();
} else if(uip_poll()) {
}
else if (uip_poll())
{
++s.timer;
if(s.timer == WEBCLIENT_TIMEOUT) {
if (s.timer == WEBCLIENT_TIMEOUT)
{
webclient_timedout();
uip_abort();
return;
}
/* senddata();*/
/* senddata();*/
}
if(uip_closed()) {
if(s.httpflag != HTTPFLAG_MOVED) {
if (uip_closed())
{
if (s.httpflag != HTTPFLAG_MOVED)
{
/* Send NULL data to signal EOF. */
webclient_datahandler(NULL, 0);
} else {
if(resolv_lookup(s.host) == NULL) {
resolv_query(s.host);
}
else
{
if (resolv_lookup(s.host) == NULL)
{
resolv_query(s.host);
}
webclient_get(s.host, s.port, s.file);
}

View File

@ -52,7 +52,8 @@
#define WEBCLIENT_CONF_MAX_URLLEN 100
struct webclient_state {
struct webclient_state
{
u8_t timer;
u8_t state;
u8_t httpflag;

View File

@ -1,102 +1,102 @@
const char http_http[8] =
/* "http://" */
/* "http://" */
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, };
const char http_200[5] =
/* "200 " */
/* "200 " */
{0x32, 0x30, 0x30, 0x20, };
const char http_301[5] =
/* "301 " */
/* "301 " */
{0x33, 0x30, 0x31, 0x20, };
const char http_302[5] =
/* "302 " */
/* "302 " */
{0x33, 0x30, 0x32, 0x20, };
const char http_get[5] =
/* "GET " */
/* "GET " */
{0x47, 0x45, 0x54, 0x20, };
const char http_10[9] =
/* "HTTP/1.0" */
/* "HTTP/1.0" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, };
const char http_11[9] =
/* "HTTP/1.1" */
/* "HTTP/1.1" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, };
const char http_content_type[15] =
/* "content-type: " */
/* "content-type: " */
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
const char http_texthtml[10] =
/* "text/html" */
/* "text/html" */
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
const char http_location[11] =
/* "location: " */
/* "location: " */
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
const char http_host[7] =
/* "host: " */
/* "host: " */
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
const char http_crnl[3] =
/* "\r\n" */
/* "\r\n" */
{0xd, 0xa, };
const char http_index_html[12] =
/* "/index.html" */
/* "/index.html" */
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
const char http_404_html[10] =
/* "/404.html" */
/* "/404.html" */
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
const char http_referer[9] =
/* "Referer:" */
/* "Referer:" */
{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
const char http_header_200[84] =
/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
const char http_header_404[91] =
/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
const char http_content_type_plain[29] =
/* "Content-type: text/plain\r\n\r\n" */
/* "Content-type: text/plain\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_html[28] =
/* "Content-type: text/html\r\n\r\n" */
/* "Content-type: text/html\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_css [27] =
/* "Content-type: text/css\r\n\r\n" */
/* "Content-type: text/css\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_text[28] =
/* "Content-type: text/text\r\n\r\n" */
/* "Content-type: text/text\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_png [28] =
/* "Content-type: image/png\r\n\r\n" */
/* "Content-type: image/png\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_gif [28] =
/* "Content-type: image/gif\r\n\r\n" */
/* "Content-type: image/gif\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_jpg [29] =
/* "Content-type: image/jpeg\r\n\r\n" */
/* "Content-type: image/jpeg\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_binary[43] =
/* "Content-type: application/octet-stream\r\n\r\n" */
/* "Content-type: application/octet-stream\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
const char http_html[6] =
/* ".html" */
/* ".html" */
{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
const char http_shtml[7] =
/* ".shtml" */
/* ".shtml" */
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, };
const char http_htm[5] =
/* ".htm" */
/* ".htm" */
{0x2e, 0x68, 0x74, 0x6d, };
const char http_css[5] =
/* ".css" */
/* ".css" */
{0x2e, 0x63, 0x73, 0x73, };
const char http_png[5] =
/* ".png" */
/* ".png" */
{0x2e, 0x70, 0x6e, 0x67, };
const char http_gif[5] =
/* ".gif" */
/* ".gif" */
{0x2e, 0x67, 0x69, 0x66, };
const char http_jpg[5] =
/* ".jpg" */
/* ".jpg" */
{0x2e, 0x6a, 0x70, 0x67, };
const char http_text[5] =
/* ".txt" */
/* ".txt" */
{0x2e, 0x74, 0x78, 0x74, };
const char http_txt[5] =
/* ".txt" */
/* ".txt" */
{0x2e, 0x74, 0x78, 0x74, };

View File

@ -74,8 +74,10 @@ httpd_cgi(char *name)
const struct httpd_cgi_call **f;
/* Find the matching name in the table, return the function. */
for(f = calls; *f != NULL; ++f) {
if(strncmp((*f)->name, name, strlen((*f)->name)) == 0) {
for (f = calls; *f != NULL; ++f)
{
if (strncmp((*f)->name, name, strlen((*f)->name)) == 0)
{
return (*f)->function;
}
}
@ -102,31 +104,48 @@ PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
static const char closed[] = /* "CLOSED",*/
{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
static const char syn_rcvd[] = /* "SYN-RCVD",*/
{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
0x44, 0};
{
0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
0x44, 0
};
static const char syn_sent[] = /* "SYN-SENT",*/
{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
0x54, 0};
{
0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
0x54, 0
};
static const char established[] = /* "ESTABLISHED",*/
{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
0x45, 0x44, 0};
{
0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
0x45, 0x44, 0
};
static const char fin_wait_1[] = /* "FIN-WAIT-1",*/
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
0x54, 0x2d, 0x31, 0};
{
0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
0x54, 0x2d, 0x31, 0
};
static const char fin_wait_2[] = /* "FIN-WAIT-2",*/
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
0x54, 0x2d, 0x32, 0};
{
0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
0x54, 0x2d, 0x32, 0
};
static const char closing[] = /* "CLOSING",*/
{0x43, 0x4c, 0x4f, 0x53, 0x49,
0x4e, 0x47, 0};
{
0x43, 0x4c, 0x4f, 0x53, 0x49,
0x4e, 0x47, 0
};
static const char time_wait[] = /* "TIME-WAIT,"*/
{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
0x49, 0x54, 0};
{
0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
0x49, 0x54, 0
};
static const char last_ack[] = /* "LAST-ACK"*/
{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
0x4b, 0};
{
0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
0x4b, 0
};
static const char *states[] = {
static const char *states[] =
{
closed,
syn_rcvd,
syn_sent,
@ -135,7 +154,8 @@ static const char *states[] = {
fin_wait_2,
closing,
time_wait,
last_ack};
last_ack
};
static unsigned short
@ -146,18 +166,18 @@ generate_tcp_stats(void *arg)
conn = &uip_conns[s->count];
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE,
"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
htons(conn->lport),
htons(conn->ripaddr[0]) >> 8,
htons(conn->ripaddr[0]) & 0xff,
htons(conn->ripaddr[1]) >> 8,
htons(conn->ripaddr[1]) & 0xff,
htons(conn->rport),
states[conn->tcpstateflags & UIP_TS_MASK],
conn->nrtx,
conn->timer,
(uip_outstanding(conn))? '*':' ',
(uip_stopped(conn))? '!':' ');
"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
htons(conn->lport),
htons(conn->ripaddr[0]) >> 8,
htons(conn->ripaddr[0]) & 0xff,
htons(conn->ripaddr[1]) >> 8,
htons(conn->ripaddr[1]) & 0xff,
htons(conn->rport),
states[conn->tcpstateflags & UIP_TS_MASK],
conn->nrtx,
conn->timer,
(uip_outstanding(conn))? '*':' ',
(uip_stopped(conn))? '!':' ');
}
/*---------------------------------------------------------------------------*/
static
@ -166,8 +186,10 @@ PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
PSOCK_BEGIN(&s->sout);
for(s->count = 0; s->count < UIP_CONNS; ++s->count) {
if((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) {
for (s->count = 0; s->count < UIP_CONNS; ++s->count)
{
if ((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED)
{
PSOCK_GENERATOR_SEND(&s->sout, generate_tcp_stats, s);
}
}
@ -180,7 +202,7 @@ generate_net_stats(void *arg)
{
struct httpd_state *s = (struct httpd_state *)arg;
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE,
"%5u\n", ((uip_stats_t *)&uip_stat)[s->count]);
"%5u\n", ((uip_stats_t *)&uip_stat)[s->count]);
}
static
@ -190,8 +212,9 @@ PT_THREAD(net_stats(struct httpd_state *s, char *ptr))
#if UIP_STATISTICS
for(s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t);
++s->count) {
for (s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t);
++s->count)
{
PSOCK_GENERATOR_SEND(&s->sout, generate_net_stats, s);
}

View File

@ -57,7 +57,8 @@ typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *));
httpd_cgifunction httpd_cgi(char *name);
struct httpd_cgi_call {
struct httpd_cgi_call
{
const char *name;
const httpd_cgifunction function;
};

View File

@ -53,15 +53,17 @@ httpd_fs_strcmp(const char *str1, const char *str2)
{
u8_t i;
i = 0;
loop:
loop:
if(str2[i] == 0 ||
str1[i] == '\r' ||
str1[i] == '\n') {
if (str2[i] == 0 ||
str1[i] == '\r' ||
str1[i] == '\n')
{
return 0;
}
if(str1[i] != str2[i]) {
if (str1[i] != str2[i])
{
return 1;
}
@ -78,11 +80,13 @@ httpd_fs_open(const char *name, struct httpd_fs_file *file)
#endif /* HTTPD_FS_STATISTICS */
struct httpd_fsdata_file_noconst *f;
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
f != NULL;
f = (struct httpd_fsdata_file_noconst *)f->next) {
for (f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
f != NULL;
f = (struct httpd_fsdata_file_noconst *)f->next)
{
if(httpd_fs_strcmp(name, f->name) == 0) {
if (httpd_fs_strcmp(name, f->name) == 0)
{
file->data = f->data;
file->len = f->len;
#if HTTPD_FS_STATISTICS
@ -103,7 +107,8 @@ httpd_fs_init(void)
{
#if HTTPD_FS_STATISTICS
u16_t i;
for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
for (i = 0; i < HTTPD_FS_NUMFILES; i++)
{
count[i] = 0;
}
#endif /* HTTPD_FS_STATISTICS */
@ -117,11 +122,13 @@ u16_t httpd_fs_count
u16_t i;
i = 0;
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
f != NULL;
f = (struct httpd_fsdata_file_noconst *)f->next) {
for (f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
f != NULL;
f = (struct httpd_fsdata_file_noconst *)f->next)
{
if(httpd_fs_strcmp(name, f->name) == 0) {
if (httpd_fs_strcmp(name, f->name) == 0)
{
return count[i];
}
++i;

View File

@ -37,7 +37,8 @@
#define HTTPD_FS_STATISTICS 1
struct httpd_fs_file {
struct httpd_fs_file
{
char *data;
int len;
};

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,8 @@
#include "uip.h"
struct httpd_fsdata_file {
struct httpd_fsdata_file
{
const struct httpd_fsdata_file *next;
const char *name;
const char *data;
@ -49,7 +50,8 @@ struct httpd_fsdata_file {
#endif /* HTTPD_FS_STATISTICS */
};
struct httpd_fsdata_file_noconst {
struct httpd_fsdata_file_noconst
{
struct httpd_fsdata_file *next;
char *name;
char *data;

View File

@ -81,9 +81,12 @@ generate_part_of_file(void *state)
{
struct httpd_state *s = (struct httpd_state *)state;
if(s->file.len > uip_mss()) {
if (s->file.len > uip_mss())
{
s->len = uip_mss();
} else {
}
else
{
s->len = s->file.len;
}
memcpy(uip_appdata, s->file.data, s->len);
@ -96,11 +99,13 @@ PT_THREAD(send_file(struct httpd_state *s))
{
PSOCK_BEGIN(&s->sout);
do {
do
{
PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s);
s->file.len -= s->len;
s->file.data += s->len;
} while(s->file.len > 0);
}
while (s->file.len > 0);
PSOCK_END(&s->sout);
}
@ -132,47 +137,62 @@ PT_THREAD(handle_script(struct httpd_state *s))
PT_BEGIN(&s->scriptpt);
while(s->file.len > 0) {
while (s->file.len > 0)
{
/* Check if we should start executing a script. */
if(*s->file.data == ISO_percent &&
*(s->file.data + 1) == ISO_bang) {
if (*s->file.data == ISO_percent &&
*(s->file.data + 1) == ISO_bang)
{
s->scriptptr = s->file.data + 3;
s->scriptlen = s->file.len - 3;
if(*(s->scriptptr - 1) == ISO_colon) {
httpd_fs_open(s->scriptptr + 1, &s->file);
PT_WAIT_THREAD(&s->scriptpt, send_file(s));
} else {
PT_WAIT_THREAD(&s->scriptpt,
httpd_cgi(s->scriptptr)(s, s->scriptptr));
if (*(s->scriptptr - 1) == ISO_colon)
{
httpd_fs_open(s->scriptptr + 1, &s->file);
PT_WAIT_THREAD(&s->scriptpt, send_file(s));
}
else
{
PT_WAIT_THREAD(&s->scriptpt,
httpd_cgi(s->scriptptr)(s, s->scriptptr));
}
next_scriptstate(s);
/* The script is over, so we reset the pointers and continue
sending the rest of the file. */
sending the rest of the file. */
s->file.data = s->scriptptr;
s->file.len = s->scriptlen;
} else {
}
else
{
/* See if we find the start of script marker in the block of HTML
to be sent. */
to be sent. */
if(s->file.len > uip_mss()) {
s->len = uip_mss();
} else {
s->len = s->file.len;
if (s->file.len > uip_mss())
{
s->len = uip_mss();
}
else
{
s->len = s->file.len;
}
if(*s->file.data == ISO_percent) {
ptr = strchr(s->file.data + 1, ISO_percent);
} else {
ptr = strchr(s->file.data, ISO_percent);
if (*s->file.data == ISO_percent)
{
ptr = strchr(s->file.data + 1, ISO_percent);
}
if(ptr != NULL &&
ptr != s->file.data) {
s->len = (int)(ptr - s->file.data);
if(s->len >= uip_mss()) {
s->len = uip_mss();
}
else
{
ptr = strchr(s->file.data, ISO_percent);
}
if (ptr != NULL &&
ptr != s->file.data)
{
s->len = (int)(ptr - s->file.data);
if (s->len >= uip_mss())
{
s->len = uip_mss();
}
}
PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s));
s->file.data += s->len;
@ -194,20 +214,33 @@ PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
PSOCK_SEND_STR(&s->sout, statushdr);
ptr = strrchr(s->filename, ISO_period);
if(ptr == NULL) {
if (ptr == NULL)
{
PSOCK_SEND_STR(&s->sout, http_content_type_binary);
} else if(strncmp(http_html, ptr, 5) == 0 ||
strncmp(http_shtml, ptr, 6) == 0) {
}
else if (strncmp(http_html, ptr, 5) == 0 ||
strncmp(http_shtml, ptr, 6) == 0)
{
PSOCK_SEND_STR(&s->sout, http_content_type_html);
} else if(strncmp(http_css, ptr, 4) == 0) {
}
else if (strncmp(http_css, ptr, 4) == 0)
{
PSOCK_SEND_STR(&s->sout, http_content_type_css);
} else if(strncmp(http_png, ptr, 4) == 0) {
}
else if (strncmp(http_png, ptr, 4) == 0)
{
PSOCK_SEND_STR(&s->sout, http_content_type_png);
} else if(strncmp(http_gif, ptr, 4) == 0) {
}
else if (strncmp(http_gif, ptr, 4) == 0)
{
PSOCK_SEND_STR(&s->sout, http_content_type_gif);
} else if(strncmp(http_jpg, ptr, 4) == 0) {
}
else if (strncmp(http_jpg, ptr, 4) == 0)
{
PSOCK_SEND_STR(&s->sout, http_content_type_jpg);
} else {
}
else
{
PSOCK_SEND_STR(&s->sout, http_content_type_plain);
}
PSOCK_END(&s->sout);
@ -220,25 +253,31 @@ PT_THREAD(handle_output(struct httpd_state *s))
PT_BEGIN(&s->outputpt);
if(!httpd_fs_open(s->filename, &s->file)) {
if (!httpd_fs_open(s->filename, &s->file))
{
httpd_fs_open(http_404_html, &s->file);
strcpy(s->filename, http_404_html);
PT_WAIT_THREAD(&s->outputpt,
send_headers(s,
http_header_404));
send_headers(s,
http_header_404));
PT_WAIT_THREAD(&s->outputpt,
send_file(s));
} else {
send_file(s));
}
else
{
PT_WAIT_THREAD(&s->outputpt,
send_headers(s,
http_header_200));
send_headers(s,
http_header_200));
ptr = strchr(s->filename, ISO_period);
if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) {
if (ptr != NULL && strncmp(ptr, http_shtml, 6) == 0)
{
PT_INIT(&s->scriptpt);
PT_WAIT_THREAD(&s->outputpt, handle_script(s));
} else {
}
else
{
PT_WAIT_THREAD(&s->outputpt,
send_file(s));
send_file(s));
}
}
PSOCK_CLOSE(&s->sout);
@ -253,18 +292,23 @@ PT_THREAD(handle_input(struct httpd_state *s))
PSOCK_READTO(&s->sin, ISO_space);
if(strncmp(s->inputbuf, http_get, 4) != 0) {
if (strncmp(s->inputbuf, http_get, 4) != 0)
{
PSOCK_CLOSE_EXIT(&s->sin);
}
PSOCK_READTO(&s->sin, ISO_space);
if(s->inputbuf[0] != ISO_slash) {
if (s->inputbuf[0] != ISO_slash)
{
PSOCK_CLOSE_EXIT(&s->sin);
}
if(s->inputbuf[1] == ISO_space) {
if (s->inputbuf[1] == ISO_space)
{
strncpy(s->filename, http_index_html, sizeof(s->filename));
} else {
}
else
{
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
}
@ -273,10 +317,12 @@ PT_THREAD(handle_input(struct httpd_state *s))
s->state = STATE_OUTPUT;
while(1) {
while (1)
{
PSOCK_READTO(&s->sin, ISO_nl);
if(strncmp(s->inputbuf, http_referer, 8) == 0) {
if (strncmp(s->inputbuf, http_referer, 8) == 0)
{
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
/* httpd_log(&s->inputbuf[9]);*/
}
@ -289,7 +335,8 @@ static void
handle_connection(struct httpd_state *s)
{
handle_input(s);
if(s->state == STATE_OUTPUT) {
if (s->state == STATE_OUTPUT)
{
handle_output(s);
}
}
@ -299,8 +346,11 @@ httpd_appcall(void)
{
struct httpd_state *s = (struct httpd_state *)&(uip_conn->appstate);
if(uip_closed() || uip_aborted() || uip_timedout()) {
} else if(uip_connected()) {
if (uip_closed() || uip_aborted() || uip_timedout())
{
}
else if (uip_connected())
{
PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
PT_INIT(&s->outputpt);
@ -308,17 +358,25 @@ httpd_appcall(void)
/* timer_set(&s->timer, CLOCK_SECOND * 100);*/
s->timer = 0;
handle_connection(s);
} else if(s != NULL) {
if(uip_poll()) {
}
else if (s != NULL)
{
if (uip_poll())
{
++s->timer;
if(s->timer >= 20) {
uip_abort();
if (s->timer >= 20)
{
uip_abort();
}
} else {
}
else
{
s->timer = 0;
}
handle_connection(s);
} else {
}
else
{
uip_abort();
}
}

View File

@ -38,7 +38,8 @@
#include "psock.h"
#include "httpd-fs.h"
struct httpd_state {
struct httpd_state
{
unsigned char timer;
struct psock sin, sout;
struct pt outputpt, scriptpt;

Some files were not shown because too many files have changed in this diff Show More