diff options
author | H. Peter Anvin <hpa@zytor.com> | 2003-01-28 04:14:23 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2003-01-28 04:14:23 +0000 |
commit | ee8b6e2236c74b39d07b8d6fb2761ac08a17ebdf (patch) | |
tree | 64df8cc7a7ecac9847623b5e00e4aaeb89c94f2e | |
parent | 2b2952fdbd76978cc864a870758b79ae33a20048 (diff) | |
download | klibc-ee8b6e2236c74b39d07b8d6fb2761ac08a17ebdf.tar.gz |
Update information for how to port to a new architectureklibc-0.74
-rw-r--r-- | klibc/arch/README | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/klibc/arch/README b/klibc/arch/README index b97aaca96063c..eceb23de4bc71 100644 --- a/klibc/arch/README +++ b/klibc/arch/README @@ -1,8 +1,16 @@ -Each architecture needs a crt0.S file. The crt0.S assembly routine -typically corresponds to the following pseudo-C code. In addition, -each architecture needs any support routines that gcc-generated code -expects to find in the system library -- Alpha, for example, needs -divide subroutines. +To port klibc to a new architecture, you need: + +a) A directory structure + +Each archtecture has an arch/ directory, which should include an +MCONFIG and a Makefile.inc file. + +b) Startup code (arch/*/crt0.S) + +The crt0.S assembly routine typically corresponds to the following +pseudo-C code. In addition, each architecture needs any support +routines that gcc-generated code expects to find in the system library +-- Alpha, for example, needs divide subroutines. The "getenvtest" test program is a very good test for proper crt0.S functionality. @@ -22,5 +30,38 @@ __noreturn _start(void) } +c) A setenv implementation (arch/*/setjmp.S, arch/*/include/klibc/archsetjmp.h) + +On most (but not all!) architectures, this entails creating a setjmp +buffer big enough to hold all callee-saved registers, plus the stack +pointer and the return address. In setjmp.S you have: + +* A "setjmp" function that writes out the callee-saved registers, the + stack pointer and the return address to the buffer pointed to by the + first argument, and then returns zero normally. + + On some architectures you need to take some kind of action to make + sure the contents of the stack is actually manifest in memory and + not cached in the CPU. In some cases (e.g. on SPARC) this will + automatically spill the registers onto the stack; then they don't + need to be spilled into the jmp_buf. + +* A "longjmp" function that read back these same registers from the + jmp_buf pointed to by the first argument, and returns the second + argument *to the address specified in the jmp_buf*. + + On some architectures you need to take some kind of action to flush + any cached stack data or return stack. + + +d) Any support functions needed by gcc, *unless* they are in libgcc + *and* libgcc is usable for klibc on your particular platform. If + libgcc isn't usable for klibc (on MIPS, for example, libgcc is + compiled in a way that is not compatible with klibc) there are + reasonably good clones of most of the libgcc functions in the libgcc + directory. To use them, add them to ARCHOBJS in + arch/*/Makefile.inc. + - +e) A link location for the shared klibc. This should be specified in + SHAREDFLAGS in arch/*/MCONFIG. |