Driver optimization.

Rogier Wolff (R.E.Wolff@bitwizard.nl)
Sun, 30 Jun 1996 12:53:55 +0200 (MET DST)


I was reading some NT sources (No, please don't shoot me :-), and
found something that Linux should've had for quite a while now.

Initialization code is interspersed with the actual driver code.
I think that the phrase

#pragma alloc_text(INIT,ParInitializeDeviceObject)

in then NT sources means that the routine ParInitializeDeviceObject
will be allocated in a special segment called "INIT".

If strict (*) rules about these are kept, we could even free the
memory associated with initializing the system...... Otherwise,
having them together increases cache performance.

Implementation:
Ideally gcc should grok an #pragma similar to the MSC compiler above.
Otherwise an "asm" statement could be inserted before and after
init routines to switch to a different segement. The problem with
this approach is that a string in the routine causes an
.section .rodata
.LC0:
.string "this is the string
.text
to be emitted just before the function, undoing the simple
asm (".section .init");
A way around this needs to be found.
In ELF lots of segments get mapped the same as .text, ".init" is
indeed one of them, so if you don't want to go and edit binutils, you
could just use one of those (I don't know if ".init" is already used).

This could go on the "wishlist for 2.1" and/or someone could pick
it up.....

Roger Wolff.

(*) i.e. don't call the init routine again when a full reset is
invoked or something like that...... :-)