[LINUX] ARM Architecture »Porting

Originally, it is a part of the Linux Kernel source code, so it will be treated as GPLv2 (recognition that it should be).

https://www.kernel.org/doc/html/latest/index.html

Licensing documentation

The following describes the license of the Linux kernel source code (GPLv2), how to properly mark the license of individual files in the source tree, as well as links to the full license text.

https://www.kernel.org/doc/html/latest/process/license-rules.html#kernel-licensing

https://www.kernel.org/doc/html/latest/arm/porting.html


Porting

Taken from list archive at http://lists.arm.linux.org.uk/pipermail/linux-arm-kernel/2001-July/004064.html

Initial definitions

The following symbol definitions rely on you knowing the translation that __virt_to_phys() does for your machine. This macro converts the passed virtual address to a physical address. Normally, it is simply:

The following symbol definitions assume that you know the conversion that __virt_to_phys () does for your machine. This macro translates the passed virtual address into a physical address. Usually it's simple:

phys = virt - PAGE_OFFSET + PHYS_OFFSET

Decompressor Symbols

ZTEXTADDR

Start address of decompressor. There’s no point in talking about virtual or physical addresses here, since the MMU will be off at the time when you call the decompressor code. You normally call the kernel at this address to start it booting. This doesn’t have to be located in RAM, it can be in flash or other read-only or read-write addressable medium.

The starting address of the decompressor. It doesn't matter if it's a virtual address or a physical address, but the MMU is off when calling the decompressor code. Normally, the kernel calls this address when it starts booting. It does not have to be RAM, it may be flash or other read-only, read-write media.

ZBSSADDR

Start address of zero-initialised work area for the decompressor. This must be pointing at RAM. The decompressor will zero initialise this for you. Again, the MMU will be off.

The working memory start address that is initialized to 0 for the decompressor. It must be in RAM. The decompressor will initialize this with 0. Again, the MMU must be off.

ZRELADDR

This is the address where the decompressed kernel will be written, and eventually executed. The following constraint must be valid:

The address where the decompressed kernel is written and executed. This must meet the following constraints.

__virt_to_phys(TEXTADDR) == ZRELADDR

The initial part of the kernel is carefully coded to be position independent.

The initialization part of the kernel is carefully coded to be position-independent code.

INITRD_PHYS

Physical address to place the initial RAM disk. Only relevant if you are using the bootpImage stuff (which only works on the old struct param_struct).

initial RAM The physical address where the disk is located. Only relevant if you are using bootpImage (only works with the old struct param_struct).

INITRD_VIRT

Virtual address of the initial RAM disk. The following constraint must be valid:

The virtual address where the initial RAM disk is located. This must meet the following constraints.

__virt_to_phys(INITRD_VIRT) == INITRD_PHYS

PARAMS_PHYS

Physical address of the struct param_struct or tag list, giving the kernel various parameters about its execution environment.

A physical address for a param_struct structure or tag list that provides the kernel with various parameters related to execution completion.

Kernel Symbols

PHYS_OFFSET

Physical start address of the first bank of RAM.

The physical address where the first bank of RAM starts.

PAGE_OFFSET

Virtual start address of the first bank of RAM. During the kernel boot phase, virtual address PAGE_OFFSET will be mapped to physical address PHYS_OFFSET, along with any other mappings you supply. This should be the same value as TASK_SIZE.

The virtual address where the first bank of RAM starts. During the kernel boot phase, the virtual address PAGE_OFFSET is mapped to the physical address PHTS_OFFSET, along with other user-specified mappings. This should be the same value as TASK_SIZE.

TASK_SIZE

The maximum size of a user process in bytes. Since user space always starts at zero, this is the maximum address that a user process can access+1. The user space stack grows down from this address.

Maximum size of the user process, in bytes. Since user space always starts at 0, this is the address +1 that the user process can access. The user space stack grows from this address.

Any virtual address below TASK_SIZE is deemed to be user process area, and therefore managed dynamically on a process by process basis by the kernel. I’ll call this the user segment.

Virtual addresses less than TASK_SIZE are considered area of the user process and are dynamically managed by the kernel on a per-process basis. This is called a user segment.

Anything above TASK_SIZE is common to all processes. I’ll call this the kernel segment.

Anything that exceeds TASK_SIZE will be common to all processes. This is called the kernel segment.

(In other words, you can’t put IO mappings below TASK_SIZE, and hence PAGE_OFFSET).

(In other words, IO mapping cannot be placed after TASK_SIZE and therefore placed after PAGE_OFFSET)

TEXTADDR

Virtual start address of kernel, normally PAGE_OFFSET + 0x8000. This is where the kernel image ends up. With the latest kernels, it must be located at 32768 bytes into a 128MB region. Previous kernels placed a restriction of 256MB here.

The starting address of the kernel in virtual space, usually PAGE_OFFSET + 0x8000. This is where this is the final position of the kernel image. In modern kernels, it should be in a region from 32768 bytes to 128MB. The traditional kernel has a 256MB limit.

DATAADDR

Virtual address for the kernel data segment. Must not be defined when using the decompressor.

The virtual address of the kernel data segment. If you use decompressor, do not define it.

VMALLOC_START / VMALLOC_END

Virtual addresses bounding the vmalloc() area. There must not be any static mappings in this area; vmalloc will overwrite them. The addresses must also be in the kernel segment (see above). Normally, the vmalloc() area starts VMALLOC_OFFSET bytes above the last virtual RAM address (found using variable high_memory).

The virtual address that borders the vmalloc () area. There should be no static mapping in this area. vmalloc overwrites them. The address must also be included in the kernel segment (above). The vmalloc () area usually starts at VMALLOC_OFFSET bytes and is located at the end of the RAM address on the virtual address (discovered using the high_memory variable).

VMALLOC_OFFSET Offset normally incorporated into VMALLOC_START to provide a hole between virtual RAM and the vmalloc area. We do this to allow out of bounds memory accesses (eg, something writing off the end of the mapped memory map) to be caught. Normally set to 8MB.

Architecture Specific Macros

BOOT_MEM(pram,pio,vio)

pram specifies the physical start address of RAM. Must always be present, and should be the same as PHYS_OFFSET.

pram specifies the physical starting address of RAM. Must always be present and must be the same as PHYS_OFFSET.

pio is the physical address of an 8MB region containing IO for use with the debugging macros in arch/arm/kernel/debug-armv.S.

pio is the physical address of the 8MB area containing the IO used by the debug macros in arch / arm / kernel / debug-armv.S.

vio is the virtual address of the 8MB debugging region.

vio is the virtual address of the 8MB debug area.

It is expected that the debugging region will be re-initialised by the architecture specific code later in the code (via the MAPIO function).

The debug area is expected to be reinitialized later in the code by the architecture specific code (via the MAPIO function).

BOOT_PARAMS

Same as, and see PARAMS_PHYS.

Please refer to it because it is the same as PARAMS_PHYS.

FIXUP(func)

Machine specific fixups, run before memory subsystems have been initialised.

Machine-specific correction process. It runs before the memory subsystems are initialized.

MAPIO(func)

Machine specific function to map IO areas (including the debug region above).

Machine-specific IO area mapping function (including debug region mentioned above)

INITIRQ(func)

Machine specific function to initialise interrupts.

Machine-specific initial interrupt function.

Recommended Posts

ARM Architecture »Porting
Porting MicroPython
Run Linux on ARM architecture with QEMU