Quais são os dois arquivos head.S em fonte linux?

2

Na fonte linux existem dois arquivos head.S localizados em:

arch / arm / kernel / head.S

arch / arm / boot / compactado / head.S

Qual é o propósito de cada um e qual é a ordem de execução?

    
por gpuguy 26.06.2014 / 10:22

1 resposta

2

Eu agradeço respostas melhores, mas meu entendimento é que é o código de inicialização do kernel (que é específico da arquitetura) escrito à mão na montagem (lembre-se, neste momento, temos apenas uma CPU bare metal e acesso bruto à memória; não consigo acessar bibliotecas complexas armazenadas no sistema de arquivos porque ainda não temos gerenciador de arquivos - é como perguntar quem criou o big bang). Não confunda isso com o carregador de inicialização (que carrega o setor de inicialização do disco para a RAM). Eu mesmo os confundi na minha resposta anterior.

+------+     +--------------------+     +------------------+     +------------------------+
| BIOS | --> | Bootloader (mbr.S) | --> | startup (head.S) | --> | kernel/main.c::kmain() |
+------+     +--------------------+     +------------------+     +------------------------+

Nofinaldacabeça.Vocêveráalinha

call_C_LABEL(kmain)

queéopontodeentradaparaokernel:

kernel/main.c

Acreditoquehead.Sestánotopodaimagemdokernelemtempodecompilação.OBIOSsabeexecutaresteblocodecódigoporqueestánocomeçoeéosistemadearquivosraizdodiscoRAM.

Porqueháumapartecompactadaedescompactada,achoqueéporqueapartedemontagemespecíficadaarquiteturadaimagemdokernel,nenhumprogramadoréhabilidosoosuficienteparafazeracompactação.UmavezquepodemospularparaarotinakmainescritaemC(mascompiladaemassembly),temosacessoaumarotinadedescompressãoquetornaaáreadecoberturadokernelsignificativamentemenor.

link

The entry point using assembly

We like to write everything in C, but we cannot avoid a little bit of assembly. We will write a small file in x86 assembly-language that serves as the starting point for our kernel. All our assembly file will do is invoke an external function which we will write in C, and then halt the program flow.

How do we make sure that this assembly code will serve as the starting point of the kernel?

We will use a linker script that links the object files to produce the final kernel executable. (more explained later) In this linker script, we will explicitly specify that we want our binary to be loaded at the address 0x100000. This address, as I have said earlier, is where the kernel is expected to be. Thus, the bootloader will take care of firing the kernel’s entry point.

link

    
por 02.11.2017 / 04:52