Porting Linux to another platform requirementsminimal graphic requirements linux distributionPorting Binder...

Citing paywalled articles accessed via illegal web sharing

A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?

Use two 8s and two 3s to make the number 24

Which one of these password policies are more secure?

Does a phylactery of a lich have to be a box?

Why zero tolerance on nudity in space?

Can a long polymer chain interact with itself via van der Waals forces?

How can I get my players to come to the game session after agreeing to a date?

Cat is tipping over bed-side lamps during the night

Why is it that Bernie Sanders is always called a "socialist"?

Can a person refuse a presidential pardon?

A title for a history book

Advice for a new journal editor

How would an AI self awareness kill switch work?

How did Ancient Greek 'πυρ' become English 'fire?'

Story about a person invited to join council of intellects

How much mayhem could I cause as a sentient fish?

Do theoretical physics suggest that gravity is the exchange of gravitons or deformation/bending of spacetime?

What is the difference between rolling more dice versus fewer dice?

In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were added to the source directory?

How old is the day of 24 equal hours?

Can I make estimated tax payments instead of withholding from my paycheck?

Why is Agricola named as such?

kill -0 <PID> は何をするのでしょうか?



Porting Linux to another platform requirements


minimal graphic requirements linux distributionPorting Binder IPC to Linuxporting kernel config to different architectureLinux/Embedded Linux - Understanding the Kernel and additional BSP specific componentsPorting Linux on LPC2148 boardFreebsd porting and pkg-staticCross compile linux kernel moduleIs Linux's monolithic nature (part of) the problem with ARM drivers?Getting big endian linux build to boot on ARM with u-bootWhat is the difference between different implemetation of arm64/aarch64 for Linux or other software to run on?













2















I know that Linux is available and has been ported for many different platforms such as for X86, ARM, PowerPC etc.



However, in terms of porting, what is required exactly?



My understanding is that Linux is software written in C. Therefore when porting Linux originally from X86 to ARM or others for example, is it not just a matter of re-compiling the code with the compiler for the specific target architecture?



Putting device drivers for different peripherals aside, what else would need to be done when porting Linux to a new architecture. Does the compiler not take care of everything for us?










share|improve this question




















  • 2





    Can we assume that you've looked at the architecture-specific kernel sources? git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/…

    – Kusalananda
    2 hours ago
















2















I know that Linux is available and has been ported for many different platforms such as for X86, ARM, PowerPC etc.



However, in terms of porting, what is required exactly?



My understanding is that Linux is software written in C. Therefore when porting Linux originally from X86 to ARM or others for example, is it not just a matter of re-compiling the code with the compiler for the specific target architecture?



Putting device drivers for different peripherals aside, what else would need to be done when porting Linux to a new architecture. Does the compiler not take care of everything for us?










share|improve this question




















  • 2





    Can we assume that you've looked at the architecture-specific kernel sources? git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/…

    – Kusalananda
    2 hours ago














2












2








2








I know that Linux is available and has been ported for many different platforms such as for X86, ARM, PowerPC etc.



However, in terms of porting, what is required exactly?



My understanding is that Linux is software written in C. Therefore when porting Linux originally from X86 to ARM or others for example, is it not just a matter of re-compiling the code with the compiler for the specific target architecture?



Putting device drivers for different peripherals aside, what else would need to be done when porting Linux to a new architecture. Does the compiler not take care of everything for us?










share|improve this question
















I know that Linux is available and has been ported for many different platforms such as for X86, ARM, PowerPC etc.



However, in terms of porting, what is required exactly?



My understanding is that Linux is software written in C. Therefore when porting Linux originally from X86 to ARM or others for example, is it not just a matter of re-compiling the code with the compiler for the specific target architecture?



Putting device drivers for different peripherals aside, what else would need to be done when porting Linux to a new architecture. Does the compiler not take care of everything for us?







linux compiling arm x86 portability






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago









Rui F Ribeiro

40.6k1479137




40.6k1479137










asked 2 hours ago









Engineer999Engineer999

1827




1827








  • 2





    Can we assume that you've looked at the architecture-specific kernel sources? git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/…

    – Kusalananda
    2 hours ago














  • 2





    Can we assume that you've looked at the architecture-specific kernel sources? git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/…

    – Kusalananda
    2 hours ago








2




2





Can we assume that you've looked at the architecture-specific kernel sources? git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/…

– Kusalananda
2 hours ago





Can we assume that you've looked at the architecture-specific kernel sources? git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/…

– Kusalananda
2 hours ago










1 Answer
1






active

oldest

votes


















4














Even though most of the code in the Linux kernel is written in C, there are still many parts of that code that are very specific to the platform where it's running and need to account for that.



One particular example of this is virtual memory, which works in similar fashion on most architectures (hierarchy of page tables) but has specific details for each architecture (such as the number of levels in each architecture, and this has been increasing even on x86 with introduction of new larger chips.) The Linux kernel code introduces macros to handle traversing these hierarchies that can be elided by the compiler on architectures which have fewer levels of page tables (so that code is written in C, but takes details of the architecture into consideration.)



Many other areas are very specific to each architecture and need to be handled with arch-specific code. Most of these involve code in assembly language though. Examples are:




  • Context Switching: Context switching involves saving the value of all registers for the process being switched out and restoring the registers from the saved set of the process scheduled into the CPU. Even the number and set of registers is very specific to each architecture. This code is typically implemented in assembly, to allow full access to the registers and also to make sure it runs as fast as possible, since performance of context switching can be critical to the system.


  • System Calls: The mechanism by which userspace code can trigger a system call is usually specific to the architecture (and sometimes even to the specific CPU model, for instance Intel and AMD introduced different instructions for that, older CPUs might lack those instructions, so details for those will still be unique.)


  • Interrupt Handlers: Details of how to handle interrupts (hardware interrupts) are usually platform-specific and usually require some assembly-level glue to handle the specific calling conventions in use for the platform. Also, primitives for enabling/disabling interrupts are usually platform-specific and require assembly code as well.


  • Initialization: Details of how initialization should happen also usually include details that are specific to the platform and often require some assembly code to handle the entry point to the kernel. On platforms that have multiple CPUs (SMP), details on how to bring other CPUs online are usually platform-specific as well.


  • Locking Primitives: Implementation of locking primitives (such as spinlocks) usually involve platform-specific details as well, since some architectures provide (or prefer) different CPU instructions to efficiently implement those. Some will implement atomic operations, some will provide a cmpxchg that can atomically test/update (but fail if another writer got in first), others will include a "lock" modifier to CPU instructions. These will often involve writing assembly code as well.



There are probably other areas where platform- or architecture-specific code is needed in a kernel (or, specifically, in the Linux kernel.) Looking at the kernel source tree, there are architecture-specific subtrees under arch/ and under include/arch/ where you can find more examples of this.



Some are actually surprising, for instance you'll see that the number of system calls available on each architecture is distinct and some system calls will exist in some architectures and not others. (Even on x86, the list of syscalls differs between a 32-bit and a 64-bit kernel.)



In short, there's plenty of cases a kernel needs to be aware that are specific to a platform. The Linux kernel tries to abstract most of those, so higher-level algorithms (such as how memory management and scheduling works) can be implemented in C and work the same (or mostly the same) on all architectures.






share|improve this answer



















  • 1





    Thanks. Great information

    – Engineer999
    17 mins ago






  • 1





    Very nice write-up! The variation in the number of syscalls is mostly related to history: new ports include the valid syscalls at the time of the port, they don’t bother with the historical baggage present in older ports, so deprecated syscalls typically aren’t present in ports newer than the deprecation. (That doesn’t cover all the scenarios...)

    – Stephen Kitt
    8 mins ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503502%2fporting-linux-to-another-platform-requirements%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














Even though most of the code in the Linux kernel is written in C, there are still many parts of that code that are very specific to the platform where it's running and need to account for that.



One particular example of this is virtual memory, which works in similar fashion on most architectures (hierarchy of page tables) but has specific details for each architecture (such as the number of levels in each architecture, and this has been increasing even on x86 with introduction of new larger chips.) The Linux kernel code introduces macros to handle traversing these hierarchies that can be elided by the compiler on architectures which have fewer levels of page tables (so that code is written in C, but takes details of the architecture into consideration.)



Many other areas are very specific to each architecture and need to be handled with arch-specific code. Most of these involve code in assembly language though. Examples are:




  • Context Switching: Context switching involves saving the value of all registers for the process being switched out and restoring the registers from the saved set of the process scheduled into the CPU. Even the number and set of registers is very specific to each architecture. This code is typically implemented in assembly, to allow full access to the registers and also to make sure it runs as fast as possible, since performance of context switching can be critical to the system.


  • System Calls: The mechanism by which userspace code can trigger a system call is usually specific to the architecture (and sometimes even to the specific CPU model, for instance Intel and AMD introduced different instructions for that, older CPUs might lack those instructions, so details for those will still be unique.)


  • Interrupt Handlers: Details of how to handle interrupts (hardware interrupts) are usually platform-specific and usually require some assembly-level glue to handle the specific calling conventions in use for the platform. Also, primitives for enabling/disabling interrupts are usually platform-specific and require assembly code as well.


  • Initialization: Details of how initialization should happen also usually include details that are specific to the platform and often require some assembly code to handle the entry point to the kernel. On platforms that have multiple CPUs (SMP), details on how to bring other CPUs online are usually platform-specific as well.


  • Locking Primitives: Implementation of locking primitives (such as spinlocks) usually involve platform-specific details as well, since some architectures provide (or prefer) different CPU instructions to efficiently implement those. Some will implement atomic operations, some will provide a cmpxchg that can atomically test/update (but fail if another writer got in first), others will include a "lock" modifier to CPU instructions. These will often involve writing assembly code as well.



There are probably other areas where platform- or architecture-specific code is needed in a kernel (or, specifically, in the Linux kernel.) Looking at the kernel source tree, there are architecture-specific subtrees under arch/ and under include/arch/ where you can find more examples of this.



Some are actually surprising, for instance you'll see that the number of system calls available on each architecture is distinct and some system calls will exist in some architectures and not others. (Even on x86, the list of syscalls differs between a 32-bit and a 64-bit kernel.)



In short, there's plenty of cases a kernel needs to be aware that are specific to a platform. The Linux kernel tries to abstract most of those, so higher-level algorithms (such as how memory management and scheduling works) can be implemented in C and work the same (or mostly the same) on all architectures.






share|improve this answer



















  • 1





    Thanks. Great information

    – Engineer999
    17 mins ago






  • 1





    Very nice write-up! The variation in the number of syscalls is mostly related to history: new ports include the valid syscalls at the time of the port, they don’t bother with the historical baggage present in older ports, so deprecated syscalls typically aren’t present in ports newer than the deprecation. (That doesn’t cover all the scenarios...)

    – Stephen Kitt
    8 mins ago
















4














Even though most of the code in the Linux kernel is written in C, there are still many parts of that code that are very specific to the platform where it's running and need to account for that.



One particular example of this is virtual memory, which works in similar fashion on most architectures (hierarchy of page tables) but has specific details for each architecture (such as the number of levels in each architecture, and this has been increasing even on x86 with introduction of new larger chips.) The Linux kernel code introduces macros to handle traversing these hierarchies that can be elided by the compiler on architectures which have fewer levels of page tables (so that code is written in C, but takes details of the architecture into consideration.)



Many other areas are very specific to each architecture and need to be handled with arch-specific code. Most of these involve code in assembly language though. Examples are:




  • Context Switching: Context switching involves saving the value of all registers for the process being switched out and restoring the registers from the saved set of the process scheduled into the CPU. Even the number and set of registers is very specific to each architecture. This code is typically implemented in assembly, to allow full access to the registers and also to make sure it runs as fast as possible, since performance of context switching can be critical to the system.


  • System Calls: The mechanism by which userspace code can trigger a system call is usually specific to the architecture (and sometimes even to the specific CPU model, for instance Intel and AMD introduced different instructions for that, older CPUs might lack those instructions, so details for those will still be unique.)


  • Interrupt Handlers: Details of how to handle interrupts (hardware interrupts) are usually platform-specific and usually require some assembly-level glue to handle the specific calling conventions in use for the platform. Also, primitives for enabling/disabling interrupts are usually platform-specific and require assembly code as well.


  • Initialization: Details of how initialization should happen also usually include details that are specific to the platform and often require some assembly code to handle the entry point to the kernel. On platforms that have multiple CPUs (SMP), details on how to bring other CPUs online are usually platform-specific as well.


  • Locking Primitives: Implementation of locking primitives (such as spinlocks) usually involve platform-specific details as well, since some architectures provide (or prefer) different CPU instructions to efficiently implement those. Some will implement atomic operations, some will provide a cmpxchg that can atomically test/update (but fail if another writer got in first), others will include a "lock" modifier to CPU instructions. These will often involve writing assembly code as well.



There are probably other areas where platform- or architecture-specific code is needed in a kernel (or, specifically, in the Linux kernel.) Looking at the kernel source tree, there are architecture-specific subtrees under arch/ and under include/arch/ where you can find more examples of this.



Some are actually surprising, for instance you'll see that the number of system calls available on each architecture is distinct and some system calls will exist in some architectures and not others. (Even on x86, the list of syscalls differs between a 32-bit and a 64-bit kernel.)



In short, there's plenty of cases a kernel needs to be aware that are specific to a platform. The Linux kernel tries to abstract most of those, so higher-level algorithms (such as how memory management and scheduling works) can be implemented in C and work the same (or mostly the same) on all architectures.






share|improve this answer



















  • 1





    Thanks. Great information

    – Engineer999
    17 mins ago






  • 1





    Very nice write-up! The variation in the number of syscalls is mostly related to history: new ports include the valid syscalls at the time of the port, they don’t bother with the historical baggage present in older ports, so deprecated syscalls typically aren’t present in ports newer than the deprecation. (That doesn’t cover all the scenarios...)

    – Stephen Kitt
    8 mins ago














4












4








4







Even though most of the code in the Linux kernel is written in C, there are still many parts of that code that are very specific to the platform where it's running and need to account for that.



One particular example of this is virtual memory, which works in similar fashion on most architectures (hierarchy of page tables) but has specific details for each architecture (such as the number of levels in each architecture, and this has been increasing even on x86 with introduction of new larger chips.) The Linux kernel code introduces macros to handle traversing these hierarchies that can be elided by the compiler on architectures which have fewer levels of page tables (so that code is written in C, but takes details of the architecture into consideration.)



Many other areas are very specific to each architecture and need to be handled with arch-specific code. Most of these involve code in assembly language though. Examples are:




  • Context Switching: Context switching involves saving the value of all registers for the process being switched out and restoring the registers from the saved set of the process scheduled into the CPU. Even the number and set of registers is very specific to each architecture. This code is typically implemented in assembly, to allow full access to the registers and also to make sure it runs as fast as possible, since performance of context switching can be critical to the system.


  • System Calls: The mechanism by which userspace code can trigger a system call is usually specific to the architecture (and sometimes even to the specific CPU model, for instance Intel and AMD introduced different instructions for that, older CPUs might lack those instructions, so details for those will still be unique.)


  • Interrupt Handlers: Details of how to handle interrupts (hardware interrupts) are usually platform-specific and usually require some assembly-level glue to handle the specific calling conventions in use for the platform. Also, primitives for enabling/disabling interrupts are usually platform-specific and require assembly code as well.


  • Initialization: Details of how initialization should happen also usually include details that are specific to the platform and often require some assembly code to handle the entry point to the kernel. On platforms that have multiple CPUs (SMP), details on how to bring other CPUs online are usually platform-specific as well.


  • Locking Primitives: Implementation of locking primitives (such as spinlocks) usually involve platform-specific details as well, since some architectures provide (or prefer) different CPU instructions to efficiently implement those. Some will implement atomic operations, some will provide a cmpxchg that can atomically test/update (but fail if another writer got in first), others will include a "lock" modifier to CPU instructions. These will often involve writing assembly code as well.



There are probably other areas where platform- or architecture-specific code is needed in a kernel (or, specifically, in the Linux kernel.) Looking at the kernel source tree, there are architecture-specific subtrees under arch/ and under include/arch/ where you can find more examples of this.



Some are actually surprising, for instance you'll see that the number of system calls available on each architecture is distinct and some system calls will exist in some architectures and not others. (Even on x86, the list of syscalls differs between a 32-bit and a 64-bit kernel.)



In short, there's plenty of cases a kernel needs to be aware that are specific to a platform. The Linux kernel tries to abstract most of those, so higher-level algorithms (such as how memory management and scheduling works) can be implemented in C and work the same (or mostly the same) on all architectures.






share|improve this answer













Even though most of the code in the Linux kernel is written in C, there are still many parts of that code that are very specific to the platform where it's running and need to account for that.



One particular example of this is virtual memory, which works in similar fashion on most architectures (hierarchy of page tables) but has specific details for each architecture (such as the number of levels in each architecture, and this has been increasing even on x86 with introduction of new larger chips.) The Linux kernel code introduces macros to handle traversing these hierarchies that can be elided by the compiler on architectures which have fewer levels of page tables (so that code is written in C, but takes details of the architecture into consideration.)



Many other areas are very specific to each architecture and need to be handled with arch-specific code. Most of these involve code in assembly language though. Examples are:




  • Context Switching: Context switching involves saving the value of all registers for the process being switched out and restoring the registers from the saved set of the process scheduled into the CPU. Even the number and set of registers is very specific to each architecture. This code is typically implemented in assembly, to allow full access to the registers and also to make sure it runs as fast as possible, since performance of context switching can be critical to the system.


  • System Calls: The mechanism by which userspace code can trigger a system call is usually specific to the architecture (and sometimes even to the specific CPU model, for instance Intel and AMD introduced different instructions for that, older CPUs might lack those instructions, so details for those will still be unique.)


  • Interrupt Handlers: Details of how to handle interrupts (hardware interrupts) are usually platform-specific and usually require some assembly-level glue to handle the specific calling conventions in use for the platform. Also, primitives for enabling/disabling interrupts are usually platform-specific and require assembly code as well.


  • Initialization: Details of how initialization should happen also usually include details that are specific to the platform and often require some assembly code to handle the entry point to the kernel. On platforms that have multiple CPUs (SMP), details on how to bring other CPUs online are usually platform-specific as well.


  • Locking Primitives: Implementation of locking primitives (such as spinlocks) usually involve platform-specific details as well, since some architectures provide (or prefer) different CPU instructions to efficiently implement those. Some will implement atomic operations, some will provide a cmpxchg that can atomically test/update (but fail if another writer got in first), others will include a "lock" modifier to CPU instructions. These will often involve writing assembly code as well.



There are probably other areas where platform- or architecture-specific code is needed in a kernel (or, specifically, in the Linux kernel.) Looking at the kernel source tree, there are architecture-specific subtrees under arch/ and under include/arch/ where you can find more examples of this.



Some are actually surprising, for instance you'll see that the number of system calls available on each architecture is distinct and some system calls will exist in some architectures and not others. (Even on x86, the list of syscalls differs between a 32-bit and a 64-bit kernel.)



In short, there's plenty of cases a kernel needs to be aware that are specific to a platform. The Linux kernel tries to abstract most of those, so higher-level algorithms (such as how memory management and scheduling works) can be implemented in C and work the same (or mostly the same) on all architectures.







share|improve this answer












share|improve this answer



share|improve this answer










answered 32 mins ago









filbrandenfilbranden

9,61621343




9,61621343








  • 1





    Thanks. Great information

    – Engineer999
    17 mins ago






  • 1





    Very nice write-up! The variation in the number of syscalls is mostly related to history: new ports include the valid syscalls at the time of the port, they don’t bother with the historical baggage present in older ports, so deprecated syscalls typically aren’t present in ports newer than the deprecation. (That doesn’t cover all the scenarios...)

    – Stephen Kitt
    8 mins ago














  • 1





    Thanks. Great information

    – Engineer999
    17 mins ago






  • 1





    Very nice write-up! The variation in the number of syscalls is mostly related to history: new ports include the valid syscalls at the time of the port, they don’t bother with the historical baggage present in older ports, so deprecated syscalls typically aren’t present in ports newer than the deprecation. (That doesn’t cover all the scenarios...)

    – Stephen Kitt
    8 mins ago








1




1





Thanks. Great information

– Engineer999
17 mins ago





Thanks. Great information

– Engineer999
17 mins ago




1




1





Very nice write-up! The variation in the number of syscalls is mostly related to history: new ports include the valid syscalls at the time of the port, they don’t bother with the historical baggage present in older ports, so deprecated syscalls typically aren’t present in ports newer than the deprecation. (That doesn’t cover all the scenarios...)

– Stephen Kitt
8 mins ago





Very nice write-up! The variation in the number of syscalls is mostly related to history: new ports include the valid syscalls at the time of the port, they don’t bother with the historical baggage present in older ports, so deprecated syscalls typically aren’t present in ports newer than the deprecation. (That doesn’t cover all the scenarios...)

– Stephen Kitt
8 mins ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503502%2fporting-linux-to-another-platform-requirements%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Benedict Cumberbatch Contingut Inicis Debut professional Premis Filmografia bàsica Premis i...

Monticle de plataforma Contingut Est de Nord Amèrica Interpretacions Altres cultures Vegeu...

Escacs Janus Enllaços externs Menú de navegacióEscacs JanusJanusschachBrainKing.comChessV