
	      Differences between Linux/68k and Linux/i386
	     ==============================================

Date: Mar 5, 1996
Linux/68k version: 1.2.13pl8
Author: Roman.Hodek@informatik.uni-erlangen.de (Roman Hodek)

0) Introduction
===============

This document tries to describe all user visible differences between
Linux/68k and Linux/i386 (and maybe other Linux ports). "User visible"
means that the difference isn't only in the kernel sources, but can be
noticed somehow from a user program.

  The list in this document may not be complete yet. Volunteers are
welcome to improve it.


1) Devices
==========

1.1) Missing Devices
--------------------

Some device drivers are not implemented under Linux/68k, because the
physical devices cannot be attached to a m68k machine anyway. I omit
these obvious cases (e.g. non-ATAPI and non-SCSI CD-ROM drives) here.
More interesting are devices not realized due to other reasons.

  The only point here is /dev/port. This represents the Intel's I/O
address space, what is obviously nonsense on a Motorola machine. Some
system applications use /dev/port for directly programming the hardware.
Where this is really necessary, Linux/68k provides appropriate ioctls.


1.2) New Devices
----------------

These devices are implemented only by Linux/68k:

 - char  10 4: /dev/amigamouse   Amiga mouse
 - char  10 5: /dev/atarimouse   Atari mouse
 - char  28 x: /dev/slm*         Atari SLM laser printer
 - block 28 x: /dev/ad*          Atari ACSI bus (disk, CD)
 - char  29 x: /dev/fb*          Framebuffer
 - block 37 0: /dev/z2ram        Zorro II ramdisk


2) System Calls
===============

2.1) Missing System Calls
-------------------------

The following system calls are not provided by Linux/68k, because they
correspond to Intel specialities:

 - ioperm (101)
 - iopl (110)
 - vm86 (113)
 - modify_ldt (123)


2.2) New System Calls
---------------------

Linux/68k currently provides one system call not found in other Linux
versions, though it is not strictly m68k-specific. It's

  int cacheflush(unsigned long addr, int scope, int cache, unsigned long len);

  The system call number is 123 (modify_ldt for Linux/i386). 'addr' and
'len' define an area in the virtual address space of the calling process
to work on. 'scope' defines the granularity of the operation and can be
one of:

#define FLUSH_SCOPE_LINE    1   /* Flush a cache line (CPU-dependend, 16
				 * bytes for m68k) */
#define FLUSH_SCOPE_PAGE    2   /* Flush a page */
#define FLUSH_SCOPE_ALL     3   /* Flush the whole cache -- superuser only */

and 'cache' defines the caches to operate on:

#define FLUSH_CACHE_DATA    1   /* Writeback and flush data cache */
#define FLUSH_CACHE_INSN    2   /* Flush instruction cache */
#define FLUSH_CACHE_BOTH    3   /* Flush/push both caches */

(These definitions can be found in <asm/cachectl.h>.)

  The 'cacheflush' syscall is intended for use in applications, where a
piece of code is constructed and later executed. For architectures with
separated data and instruction caches, this scheme doesn't work without
writing back the data cache to memory first, and then invalidating the
instruction cache. E.g. pointers to nested functions in gcc are
implemented by 'trampolines', that are short pieces of code on the
stack. And the GNU libc uses this feature.


3) ioctls
=========

Linux/68k itself or some devices only in Linux/68k support some ioctls
not found in other Linux versions:


3.1) tty devices
----------------

These ioctls are to implement functionality that is done via /dev/port
under Linux/i386:

 - KDGHWCLK (0x4b50): get hardware clock
   
   The ioctl argument is a pointer to a structure

     struct hwclk_time {
  	unsigned sec;     /* 0..59 */
  	unsigned min;     /* 0..59 */
  	unsigned hour;    /* 0..23 */
  	unsigned day;     /* 1..31 */
  	unsigned mon;     /* 0..11 */
  	unsigned year;    /* 70... */
  	int      wday;    /* 0..6, 0 is Sunday, -1 means unknown/don't set */
     };

   that is filled in by the kernel.

 - KDSHWCLK (0x4b51): set hardware clock

   The ioctl argument is a pointer to a struct hwclk_time as above. The
   kernel puts the values given into the hardware clock.

 - KDKBDREP (0x4b52): get/set keyboard repeating parameters

   The ioctl argument is a pointer to a structure

     struct kbd_repeat {
  	 int delay;
  	 int rate;
     };

   Both values are in msecs, a negative value means "don't change".
   'delay' is the time to wait before keyboard repeating starts, and
   'rate' is the interval between two characters generated.

 - GIO_XFONT (0x4b53): extended get console font

   Requests the current console font data from the kernel. The argument
   is a pointer to a structure

     struct linux_xconfont {
         int width;     /* width of font */
         int height;    /* height of font */
         char data[0];  /* font data or font name */
     };

   The caller has to fill in the 'width' and 'heigth' fields with an
   alloction length, i.e. he is prepared to accept at most width*height
   bytes of data in the 'data' field. After returning, the kernel has
   copied the font data into 'data' and updated 'width' and 'height' to
   the actual values.

 - PIO_XFONT (0x4b54): extended set console font

   The argument is a struct linux_xconfont as defined above. In the
   normal mode, the caller fills in all three fields and the font with
   respective width and height will be set for the appropriate console.
   The font data are organized in bytes, i.e. the width is padded to a
   full byte. All bytes for one glyph are adjacent and there's no
   padding at the end of a glyph. All together, this means a glyph needs
   ((w+7)/8)*h bytes for representation.

   There are two special modes of PIO_XFONT: If 'width' is 0, the kernel
   is instructed to activate a predefined font. The name of the font is
   found in the 'data' field. The Linux/68k kernel currently knows the
   default fonts "VGA8x16" and "VGA8x8".

   If 'width' is 1, the font of another console will be copied. The
   number of the other console is given in 'height', 'data' is unused.
   This feature is for to conserve memory, as user defined fonts have to
   be kmalloc-ed in the kernel.

   If either 'width' or 'height' are negative, that is replace by the
   current font's extensions (in case that is useful...).

There are two programs that used /dev/port: 'clock' and 'kbdrate'. The
m68k versions of these use the ioctls above if they exist, else the old
hardware-dependent method. Thus they should be portable.

There's also a m68k version of 'setfont', using the PIO_XFONT call. No
attempt has been made to make this work with PIO_FONT also, since there
are lots of differences.


3.2) Framebuffer
----------------

All framebuffer devices have a standard set of ioctls to control video
mode and other display properties:

 - FBIOGET_VSCREENINFO (0x4600): get variable screen infos
 - FBIOPUT_VSCREENINFO (0x4601): set variable screen infos
 - FBIOGET_FSCREENINFO (0x4602): get fixed screen infos
 - FBIOGETCMAP (0x4604): get the colormap
 - FBIOPUTCMAP (0x4605): set the colormap
 - FBIOPAN_DISPLAY (0x4606): pan the display

(More detailed description still to do...)


3.3) Atari SLM Laser Printer
----------------------------

The Atari laser printer supports the following special ioctl codes:

 - SLMIOGSTAT (0xa100): get SLM status

   A structure

     struct SLM_status {
         int   stat;       /* numeric status code */
         char  str[40];    /* status string */
     };

   is returned, which gives a numeric status code (0 = ok) and a textual
   description.

 - SLMIOGPSIZE (0xa101): get current paper size

   Returns a structure

     struct SLM_paper_size {
         int width;
         int height;
     };

   which tells about the size of the paper in units of 300dpi pixels.

 - SLMIOGMFEED (0xa102): get current manual feed status

   Returns 0 for automatic paper feed and 1 for manual feed active. (Not
   yet implemented)

 - SLMIORESET (0xa140): reset the SLM

   This ioctl resets the printer device, i.e. throws away any received
   but not yet printed data. (Not yet implemented)

 - SLMIOSPSIZE (0xa181): set paper size

   Change the current paper size. The argument is a struct
   SLM_paper_size as defined above. (Not yet implemented)

 - SLMIOSMFEED (0xa182): set manual feed

   Set (!= 0) or reset (0) the manual feed of the printer. (Not yet
   implemented)


3.4) Atari SCC Serial Ports
---------------------------

The SCC driver on the Atari has some special ioctls to tell the kernel
about what clocks are attached to the SCC, and what divisors the driver
should use for certain baud settings.

 - TIOCGATSCC (0x54c0): get SCC configuration

   This ioctl fills in a structure

     struct atari_SCCserial {
         unsigned RTxC_base;	/* base_baud of RTxC */
     	 unsigned TRxC_base;	/* base_baud of TRxC */
     	 unsigned PCLK_base;	/* base_baud of PCLK, for both channels! */
     	 struct {
      	     unsigned clksrc;	/* CLK_RTxC, CLK_TRxC or CLK_PCLK */
      	     unsigned divisor;	/* divisor for base baud, valid values:
     			         * see below */
     	 } baud_table[17];	/* For 50, 75, 110, 135, 150, 200, 300,
     				 * 600, 1200, 1800, 2400, 4800, 9600,
     			         * 19200, 38400, 57600 and 115200 bps. The
     			         * last two could be replaced by other
     			         * rates > 38400 if they're not possible.
     	 		         */
     };

   Each base_baud value is the frequency of the respective clock source
   divided by 16. The SCC has three possible clock sources: RTxC, TRxC
   (separate for each channel) and PCLK (the master clock, shared
   between the channels). A base_baud value can be 0, which means the
   clock input is not connected and should not be used.

   The real speed for a baud setting (e.g. by stty) is defined by
   selecting a clock source and a divisor. There are 17 speed constants,
   see in the comment. Not every divisor is valid for each clock source,
   due to internal processing in the SCC:

    - RTxC: 1 or even (1, 2 and 4 are the direct modes, > 4 use
            the BRG)
    - TRxC: 1, 2 or 4 (no BRG, only direct modes possible)
    - PCLK: >= 4 and even (no direct modes, only BRG)

 - TIOCSATSCC (0x54c1): set SCC configuration

   This ioctl changes the SCC speed configuration according to a struct
   atari_SCCserial as defined above. Note that PCLK_base is shared
   between the two channels!

   Since setting the speeds requires some calculations of divisors and
   least errors, there is a tool 'setSCCserial' that does that job.

 - TIOCDATSCC (0x54c2): reset configuration to defaults

   This ioctl resets the SCC speed configuration to the driver's bootup
   defaults and thus undoes previous TIOCSATSCC calls.



/* Local Variables: */
/* mode: text       */
/* fill-column: 72  */
/* tab-width: 8     */
/* End:             */
