mirror of
https://github.com/eclipse-threadx/levelx.git
synced 2026-09-14 04:06:00 +08:00
Updated copyright headers and removed trailing whitespace
This commit is contained in:
@@ -35,7 +35,7 @@ void thread_0_entry(ULONG thread_input);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
/* Enter the ThreadX kernel. */
|
||||
#ifndef LX_STANDALONE_ENABLE
|
||||
tx_kernel_enter();
|
||||
@@ -52,8 +52,8 @@ void tx_application_define(void *first_unused_memory)
|
||||
|
||||
|
||||
/* Create the main thread. */
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
}
|
||||
#endif
|
||||
@@ -68,27 +68,27 @@ UINT status;
|
||||
|
||||
ULONG *word_ptr;
|
||||
|
||||
|
||||
|
||||
/* format the simulated NOR flash. */
|
||||
|
||||
|
||||
/* Initialize LevelX. */
|
||||
_lx_nor_flash_initialize();
|
||||
|
||||
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
|
||||
/* Test 1: Simple write 100 sectors and read 100 sectors. */
|
||||
printf("Test 1: Simple write-read 100 sectors...........");
|
||||
|
||||
|
||||
lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
|
||||
/* Write 100 sectors.... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -100,13 +100,13 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -117,10 +117,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -139,9 +139,9 @@ ULONG *word_ptr;
|
||||
|
||||
/* Test 2: Write same sector 120 times. */
|
||||
printf("Test 2: Write same sector 120 times.............");
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
lx_nor_flash_initialize();
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
|
||||
@@ -149,15 +149,15 @@ ULONG *word_ptr;
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = 0xFFFFFFFF;
|
||||
|
||||
|
||||
/* Write same sector 120 sectors.... */
|
||||
for (i = 0; i < 120; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, 7, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -168,9 +168,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -181,10 +181,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != readbuffer[j])
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -196,7 +196,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write other sectors just to have additional sectors to manage. */
|
||||
if (i == 1)
|
||||
lx_nor_flash_sector_write(&nor_sim_flash, 1, buffer);
|
||||
@@ -218,7 +218,7 @@ ULONG *word_ptr;
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -410,7 +410,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -421,13 +421,13 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Point at the simulated NOR flash memory. */
|
||||
word_ptr = nor_sim_flash.lx_nor_flash_base_address;
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -439,21 +439,21 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, but before the free bit map and erase count is setup. */
|
||||
printf("Test 3: Block erase-initialize interrupted......");
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
word_ptr[3] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 111) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -462,9 +462,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -475,19 +475,19 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, and after the free bit map setup, but before erase count is setup. */
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 111) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -498,7 +498,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -516,14 +516,14 @@ ULONG *word_ptr;
|
||||
printf("Test 4: Power interrupted new block allocation..");
|
||||
word_ptr[3] = word_ptr[3] & ~((ULONG) 1);
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 110) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -532,9 +532,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -550,14 +550,14 @@ ULONG *word_ptr;
|
||||
anything else can be done. */
|
||||
word_ptr[(16*128)+3] = 0x7C00;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 109) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -568,7 +568,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -585,15 +585,15 @@ ULONG *word_ptr;
|
||||
setup. */
|
||||
word_ptr[3] = 0x7FFC;
|
||||
word_ptr[(16*128)+6] = word_ptr[(16*128)+6] & ~((ULONG) 0x40000000);
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 108) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -604,7 +604,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
/* Simulate a power interruption after a new sector is allocated, after data
|
||||
had been copied, and the superceeded bit is clear, the new entry is setup, but the old entry
|
||||
has not been invalidated. */
|
||||
@@ -614,15 +614,15 @@ ULONG *word_ptr;
|
||||
{
|
||||
word_ptr[(3*128)+i] = 0x70;
|
||||
}
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 107) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -823,7 +823,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -834,10 +834,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -848,7 +848,7 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1229,7 +1229,7 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_release(&nor_sim_flash, 7);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1252,9 +1252,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1278,7 +1278,7 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
printf("Test 5: Randow write/read sector................");
|
||||
@@ -1286,12 +1286,12 @@ ULONG *word_ptr;
|
||||
/* format the simulated NOR flash. */
|
||||
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1300,15 +1300,15 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write 100 sectors.... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1320,13 +1320,13 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1337,10 +1337,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1353,18 +1353,18 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Now, perform 1000 sector writes to randomly selected sectors, each time
|
||||
reading first to make sure the previous contents are valid. */
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Pickup random sector. */
|
||||
sector = (rand() % 100);
|
||||
|
||||
/* Read that sector. */
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, sector, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1375,10 +1375,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if ((buffer[j] & 0x0000FFFF) != sector)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1394,10 +1394,10 @@ ULONG *word_ptr;
|
||||
/* Include the itteraction in the buffer to generate a new write. */
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
buffer[j] = (buffer[j] & 0x0000FFFF) | (i << 16);
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, sector, buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
@@ -1411,9 +1411,9 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
|
||||
Reference in New Issue
Block a user