[PATCH 5 of 5] General improvements to arch dependent code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

 This patch provides access to members of structures and sizes of
structures from assembly code.

  Currently, access to member structures from assembly is hardcoded in
the source program. For example, to load the user stack pointer from
the task structure, the sequence of instructions is:

    mov bx, _current
    mov ax, 2[bx]

The offset of member t_regs.sp of structure task_struct is 2 (the
second line in the above assembly code). Someone found this offset to
be 2 and put this offset in many places as 2. Unfortunately, the
offsets have to be calculated by the compiler, as the assembler
program knows nothing about structures.

A better approach is to use a symbol instead of 2. For example, in a
"asm-offsets.h" file put:

#define TASK_USER_SP 2

After including the "asm-offsets.h" file, the sequence of assembly
instructions is now:

    mov bx,_current
    mov ax,TASK_USER_SP[bx]

Now if the offset changes, you have to correct the offset in a single place.

The best approach is to generate the file  "asm-offsets.h" by the
compiler itself because the offsets are compiler (and compile options)
dependent. This is the method used in mainstream linux.

This patch implements:

 1. automatic generation of "asm-offsets.h" file from data defined in
"arch/i86/kernel/asm-offsets.c"

 2. Use of the above mechanism to access several members of structure
task_struct in files irqtab.c and process.c

 3. Now that offsets are easy to use, make some simplifications to
interrupt handling code.

 4. Optimization of assembly code of bios16.c file.

There is a reduction of 32 bytes in code size.

The kernel was built and the Image tested in qemu and dioscuri
emulators. Also tested in a ppro pc booting from floppy.

Greetings,

Juan

Attachment: elksF.patch
Description: Binary data


[Index of Archives]     [Kernel]     [Linux ia64]     [DCCP]     [Linux for ARM]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux