Learn ARM development (10)

Publisher:BlissfulCharmLatest update time:2024-11-14 Source: cnblogs Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/* Call all initialization functions in a loop*/
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr)
{
if ((*init_fnc_ptr)() != 0)
{
/* When each function fails to initialize, it will hang here. */
hang();
}
}
Last time, we talked about calling all initialization functions in the function pointer array for initialization. Now let's analyze in detail what they do, what kind of initialization they do, and how to prepare for the subsequent operation. The first initialization function is CPU initialization (cpu_init). This function is in cpu/s3c44b0/cpu.c. Its function is to perform S3C44B0 initialization. The content of this function is as follows:
/*
CPU initialization.
Cai Junsheng 2005/07/23
*/
int cpu_init (void)
{
/* Clear the buffer */
icache_enable();

return 0;
}

It calls the function icache_enable(), which is used to initialize the buffer of S3C44B0 and enable the CPU buffer. Because after the CPU is powered on, its initialization value is not to enable the internal 8K buffer, which must be set by the program. Then see how the called function initializes the internal buffer?
/*
CPU memory buffer initialization.
Cai Junsheng 2005/07/23
*/
void icache_enable (void)
{
ulong reg;

/* Clear the memory buffer. */
s3c44b0_flush_cache();

/*
Initialize the buffer and
set the start and end addresses of the non-buffer.
The first register indicates that the following address should not be cached. The lower 16 bits are the start address and
the upper 16 bits are the end address. And the space size is bounded by 4K.
0x0000:0000 - 0x0C00:0000
*/
NCACHBE0 = 0xC0000000;
NCACHBE1 = 0x00000000;

/*
Set SYSCFG register to enable 8K buffer.
*/
reg = SYSCFG;
reg |= 0x00000006; /* 8kB */
SYSCFG = reg;
}

In this function, the first function called is to clear the buffer. It has some special features, as follows:
/*
Initialize the internal buffer of the CPU.
Cai Junsheng 2005/07/23
*/
static void s3c44b0_flush_cache(void)
{
volatile int i;
/* Clear the buffer. Each time, read and write 4 32-bit bytes, so add 16. */
for( i = 0x10002000; i < 0x10004800; i += 16 )
{
*((int *)i)=0x0;
}
}

It uses a for loop to initialize the internal buffer. Since S3C44B0 determines that each read and write is performed by 16 bytes. Therefore, i here is constantly adding 16 bytes. However, why is the area from 0x10000000 to 0x10001fff not cleared here? I don't understand this either. I will try to clear it when I have time to see if there is any problem!
So far, the buffer has been cleared, and it is necessary to set those memory areas not to be cached. Because not all memory needs to be buffered, for example, reading external IO does not require buffering; reading FLASH does not require buffering. Therefore, set the starting address of the first non-buffer to NCACHBE0 = 0xC0000000. The lower 16 bits of this value are the starting address 0x0000, and its 32-bit address starts from 0x00000000. Its upper 16 bits are the ending address 0Xc000, and its 32-bit address ends from 0Xc0000000. Finally, by setting the value of the [2:1] bit of the SYSCFG register to 11, the 8K memory data and instruction buffers are enabled. So far, the CPU buffer initialization and enablement have been set.

Reference address:Learn ARM development (10)

Previous article:Learn ARM development(11)
Next article:Learn ARM development(9)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号