Linux Kernel Architecture

(Jacob Rumans) #1
Mauerer runapp01.tex V1 - 09/04/2008 6:08pm Page 1135

Appendix A: Architecture Specifics


unsigned long cr2, trap_no, error_code;
/* floating point info */
union i387_union i387 __attribute__((aligned(16)));
/* IO permissions. the bitmap could be moved into the GDT, that would make
switch faster for a limited number of ioperm using tasks. -AK */
int ioperm;
unsigned long *io_bitmap_ptr;
unsigned io_bitmap_max;
/* cached TLS descriptors. */
u64 tls_array[GDT_ENTRY_TLS_ENTRIES];
} __attribute__((aligned(16)));

include/adm-x86/processor_64.h
union i387_union {
struct i387_fxsave_struct fxsave;
};

Formally, thei387_unionused to save the floating-point registers has the same name as in IA32.
However, because AMD64 processors always have a math coprocessor, no software emulation needs to
be included.

A.8 Bit Operations and Endianness


The kernel frequently works with bit fields; for instance, when searching for a free slot in an allocation
bitmap. This section describes the facilities provided for bit operations. It also describes how endianness
questions are settled.

A.8.1 Manipulation of Bit Chains


Although some of the functions needed for bit manipulation are implemented in C, the kernel prefers
optimized assembler functions that are able to exploitthe special features of the individual processors.
Because some operations are atomic, they cannot be implemented in assembler code. The architecture-
specific parts of the kernel must define the following functions in<asm-arch/bitops.h>:

❑ void set_bit(int nr, volatile unsigned long * addr)sets the bit at positionnr;counting
begins ataddr.
❑ int test_bit(int nr, const volatile unsigned long * addr)checks whether the specified bit
is set.
❑ void clear_bit(int nr, volatile unsigned long * addr)deletes the bit at positionnr(count-
ing begins ataddr).
❑ void change_bit(int nr, volatile unsigned long * addr)reverses the bit value at positionnr
(counting begins ataddr); in other words, a set bit is unset and vice versa.
❑ int test_and_set_bit(int nr, volatile unsigned long * addr)sets a bit and returns its for-
mer value.
❑ int test_and_clear_bit(int nr, volatile unsigned long * addr)deletes a bit and returns its
former value.
❑ int test_and_change_bit(int nr, volatile unsigned long* addr)reverses a bit value and
returns its former value.
Free download pdf