Page 1 of 1
What are the basic kernel operations which require assembly?
Posted: Sat Feb 11, 2012 9:28 pm
by anadon
What are the basic kernel operations which require assembly?
I'm looking around and learning what I can about assembly. I've got the basic concepts, and will be practicing as well. But, I want to know what to keep an eye out for in terms of parts of the kernel which should be done in assembly. More specifically, amd64. Very specifically--Intel i7 740QM.
I know this is beginner, but hey, its where I'm at.
And yes, my C is fine.
Thanks!
Re: What are the basic kernel operations which require assem
Posted: Sat Feb 11, 2012 9:29 pm
by anadon
I have the manual for the processor, but its so big I am not going through it all that fast...
Re: What are the basic kernel operations which require assem
Posted: Sat Feb 11, 2012 9:50 pm
by bubach
It really depends. With an advanced bootloader you could get away with very little. But why do you even ask? It's the kind of thing you'll know when you get there, and have read the wiki & tutorials..
Re: What are the basic kernel operations which require assem
Posted: Sun Feb 12, 2012 1:09 am
by Brendan
Hi,
anadon wrote:What are the basic kernel operations which require assembly?
A (possibly partial) list:
- CPU mode switches. Needed at least once in boot code intended for BIOS (but more likely to be much more). Possibly not needed at all when booting from UEFI.
- The task switch code in the scheduler (not the code that decides which task to switch to, but the small piece that actually does the final switch)
- Interrupt handler entry and exit (but not necessarily the interrupt handler itself)
- Kernel API entry and exit (but not necessarily the kernel API itself)
- Special purpose CPU instructions. This typically means inline assembly macros/wrappers around instructions like CLI/STI, RDSTC, RDMSR/WRMSR, CPUID, IN, OUT, FXSAVE, LGDT/LIDT, MOV to/from CRn, HLT, INVLPG, etc.
- Anything that needs to guarantee atomicity (e.g. for things like spinlocks, lock-free algorithms, etc); unless you can use something like atomic built-ins instead
That's everything I can think of at the moment.
Cheers,
Brendan
Re: What are the basic kernel operations which require assem
Posted: Sun Feb 12, 2012 1:24 pm
by anadon
Good list!
Re: What are the basic kernel operations which require assem
Posted: Sat Feb 18, 2012 10:16 am
by anadon
I would like to be able to code more on it--it's fun. But I can't go as fast as I want to. No hurry, but I'd like to go faster.
Re: What are the basic kernel operations which require assem
Posted: Wed Feb 22, 2012 9:40 am
by huh
All software NEEDS assembly, or more specifically, all software NEEDS to be run as binary. if you compile some c code there are 3 steps to make an executable:
1: make the c code into assembly (all code , even java, need to go to this stage)
2: assemble, build to .o or .bin file
2: link
the last step is not needed. if you write in c you will be able to use the asm(""); keyword, now you can write in at&t syntax (or type .intel_syntax to change to intel syntax).
PS: as you know, scripting languages are not compiled at all, they are interpreted
PS: the last ps was pointless
Re: What are the basic kernel operations which require assem
Posted: Wed Feb 22, 2012 9:59 am
by Solar
@ huh:
You're wrong. While some compilers work with an intermediate Assembly stage, this is by no means imperative. GCC, for example, works with GENERIC, GIMPLE, and RTL - no Assembly involved. If you use the "-S" option, the Assembly output is artificially generated from the intermediary binary representation.
Anyway, this was not what the OP asked about.
Re: What are the basic kernel operations which require assem
Posted: Wed Feb 22, 2012 2:08 pm
by huh
Here are some of the basic things a kernel could do:
printing functions, set the screen mode, get keyboard inupt, some sort of command line, cursor movment, mm (memory management): simple functions like cleaning registers to managing RAM.
Re: What are the basic kernel operations which require assem
Posted: Wed Feb 22, 2012 2:33 pm
by Solar
Second fail at second attempt. The question was. "What are the basic kernel operations which require assembly?", and it has been answered.
Half the things you listed can be done in any system programming language.
Re: What are the basic kernel operations which require assem
Posted: Sat Feb 25, 2012 4:33 am
by bluemoon
And half of the things he listed aren't kernel operations.