Problem
What are some common porting issues when moving from the SCO XENIX platform to SCO OpenServer 5?
Solution
Here are some issues that have arisen:
Device Driver development:By far the most common issue was device driver porting. In many cases, include files have changed. For instance, in SCO XENIX error 100 mapped to "not a character device" in:
/usr/include/sys/errno.hIn SCO OpenServer 5.0 error 100 mapped to a tcp error, "protocol not supported". Obviously this can have an undesirable impact on a program which depends on this error detecting a character device. In this particular case, the solution is to look for error 25 (which gives the somewhat cryptic error "Not a typewriter") instead of error 100.
Some drivers are written in both assembly and C code. How can these
be linked into the kernel under SCO OpenServer 5.0? The ld(CP)
command allows you to do this with the "-r" flag. For instance,
"asm.o" and "ccode.o" can be combined into a Driver.o file like this:ld -r asm.o ccode.o -o Driver.oHere are some more notes concerning driver development:
- XENIX device drivers frequently had the assumption in them that a kernel virtual address was identical to a physical hardware address. This assumption was made true by the XENIX kernel's memory management code. This is not the case in UNIX; driver writers need to understand the difference and use appropriate addressing as needed.
- b_blkno in the buf structure is now kept in 512-byte units, no longer 1K units as in XENIX.
- vecintsw and vecintlev are now named ivect and intpri.
- cmn_err parameter ordering is different.- cvttoaddr is no longer necessary to handle 8086/286 binaries.
- raw read and write routines that used to call physio now should usually be using some form of dma_breakup or pio_breakup as appropriate (instead of directly passing their strategy routine).
- XENIX used memget for memory allocation in driver init routines; these don't need to be special cased any more (UNIX memory management is fully set up prior to driver init, XENIX memory management was only partially set up at driver init).
Application Development:Another issue involves the XENIX functions "opendir()", "readdir()"
and so on. In XENIX these functions operated on struct direct
whereas UNIX's readdir operates on struct dirent. Under SCO UNIX
Version 4.2 you could choose to use the XENIX versions of readdir
by including sys/ndir.h. (In this case _XENIX_readdir function was
used). Under SCO OpenServer 5, the XENIX type of these functions are
not supported any more; they are not part of any library. The
correct approach is to use dirent-based directory handling functions.There are many functions that "went away" when UNIX replaced XENIX. Some of the more common are nap(), many semaphore functions such as creatsem(), many shared data functions such as sdget(). These will show up as undefined symbols if they are compiled on an OpenServer 5.0 system, unless the "-lx" flag is included in the compile line. This will link in the extended library /usr/lib/libx.a. In many cases the old functions have been replaced with more portable ones, for instance, semop() and related functions for semaphores, shmget() and related functions for shared memory. nap() can be simulated with select().
Provided in the XENIX/DOS Cross Development Supplement is the
codeview(cv) debugger. This is offered as an alternative to the
current dbx* series of debuggers in SCO OpenServer 5.0. Developers
who are used to writing in a XENIX environment may be more
comfortable with this tool, although dbXtra/dbxtra/dbx are the
current debuggers and are recommended for best results.