@ZeroG
Quote:
devices/prtbase.h: strange functionpointers in struct PrinterExtendedData.
Quote:
VOID ped_Init(void)
VOID ped_Expunge(void)
LONG ped_Open(void)
VOID ped_Close(void)
In the Comments of the pointers:
Quote:
LONG ped_Init(struct PrinterData * pd)
VOID ped_Expunge(VOID)
LONG ped_Open(struct printerIO * ior)
VOID ped_Close(struct printerIO * ior)
And finally in the Printerdriver Example from the NDK3.9:
Quote:
VOID DriverExpunge(VOID)
VOID DriverInit(struct PrinterData * pd)
VOID DriverClose(struct printerIO *ior)
LONG DriverOpen(struct printerIO *ior)
Well, those strange function pointers probably date back
to the ancient times where non-ANSI C compilers had still
to be supported (which dont accept parameter lists here).
Replacing them with those from the comments is also not
possible, those are broken too, the guy who defined them
probably didnt notice that there doesnt exist a "struct printerIO"
anywhere in AmigaOS (only a "union printerIO"), and that
only old compilers wont complain about nonexisting structures
in parameter lists of a function pointer declaration.
To complicate it even more, those function pointers dont
use register arguments but stack arguments, and to finally
confuse you, they may point to PPC code which expects arguments
passed as defined in the SysV ABI.
In the current version of the include file, the function pointers
are still declared without arguments, just to force everybody to
use proper casts, and the following comments are present:
Quote:
A note on the function pointers in these data structure definitions:
unless otherwise specified, all functions expect that their parameters
are passed on the *stack* rather than in CPU registers. Every parameter
must be passed a 32 bit long word, i.e. an "UWORD" will use the same
stack space as an "ULONG".
When the printer driver is PPC native, the function pointers will
point to PPC native functions, otherwise to 68K stubs or functions.
[...]
When the printer driver is PPC native, the function pointers
point to PPC native functions.
[...]
/* called after LoadSeg, returns zero for success:
*
* LONG ped_Init(struct PrinterData * pd);
*/
[...]
/* called before UnLoadSeg:
*
* VOID ped_Expunge(VOID);
*/
[..]
/* called at OpenDevice, returns zero for success:
*
* LONG ped_Open(struct printerIO * ior);
*/
[..]
/* called at CloseDevice:
*
* VOID ped_Close(struct printerIO * ior);
*/
[...]
Starting with printer.device 51.12 PPC native printer drivers
are supported. Those must contain a global symbol "PrinterSegment"
which defines the start of the struct PrinterSegment, to keep this
in the binary, driver writers can call "strip -KPrinterSegment ...".
and the driver example source contains
Quote:
LONG SAVEDS STDARGS
DriverInit(struct PrinterData * pd)
[...]
VOID SAVEDS STDARGS
DriverExpunge(VOID)
[...]
LONG SAVEDS STDARGS
DriverOpen(union printerIO *ior UNUSED)
[...]
VOID SAVEDS STDARGS
DriverClose(union printerIO *ior UNUSED)
which allows to build both 68k and PPC drivers.