linux-8086.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Juan Perez-Sanchez <lithoxs@gmail.com>
To: linux-8086 <linux-8086@vger.kernel.org>
Subject: [PATCH 5 of 5] General improvements to arch dependent code
Date: Tue, 29 May 2012 15:25:30 -0500	[thread overview]
Message-ID: <CAD6VGua-yGmKo6wcK5ifM=+QKMGiAoytL0QzPecC-=BxTZmQ1A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1747 bytes --]

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 #2: elksF.patch --]
[-- Type: application/octet-stream, Size: 14041 bytes --]

                 reply	other threads:[~2012-05-29 20:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAD6VGua-yGmKo6wcK5ifM=+QKMGiAoytL0QzPecC-=BxTZmQ1A@mail.gmail.com' \
    --to=lithoxs@gmail.com \
    --cc=linux-8086@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).