x68000:writing_drivers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
x68000:writing_drivers [2014/07/11 00:05] – eidis | x68000:writing_drivers [2014/07/11 01:19] – eidis | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Writing drivers ====== | ====== Writing drivers ====== | ||
+ | |||
+ | ---- | ||
The following information was kindly contributed by our forum member **Lydux**. | The following information was kindly contributed by our forum member **Lydux**. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | Original thread can be found here: | ||
+ | http:// | ||
So I've decided to share with you some of my study and work. | So I've decided to share with you some of my study and work. | ||
Line 13: | Line 20: | ||
**Note :** the following contains very hard stuff ! I might be confusing sometimes, sorry in advance. Don't hesitate to ask for help if you do not understand something. Thank you. | **Note :** the following contains very hard stuff ! I might be confusing sometimes, sorry in advance. Don't hesitate to ask for help if you do not understand something. Thank you. | ||
- | |||
**Terminology :** | **Terminology :** | ||
Line 21: | Line 27: | ||
* Char : 1 character = 1 byte | * Char : 1 character = 1 byte | ||
* All data types are CPU specific : M68K family. So, byte ordering is always "Big Endian" | * All data types are CPU specific : M68K family. So, byte ordering is always "Big Endian" | ||
- | |||
====== Compilation flags, libraries and startup code ====== | ====== Compilation flags, libraries and startup code ====== | ||
Line 89: | Line 94: | ||
**Command execution result flags :** | **Command execution result flags :** | ||
- | This list contains all acceptable values to fill the result status flags in the request packet header. S_**** flags will display (or hide) the " | + | This list contains all acceptable values to fill the result status flags in the request packet header. S_**** flags will display (or hide) the " |
+ | |||
+ | " | ||
* 0x1000 - S_ABORT : " | * 0x1000 - S_ABORT : " | ||
Line 155: | Line 162: | ||
- | Output parameters : | + | **Output parameters :** |
^ Position | ^ Position | ||
| 14 | Byte |Media status. Possible values are : | | | 14 | Byte |Media status. Possible values are : | | ||
- | | | | + | | | -1 |M_CHANGED : Media was changed |
- | | | | + | | | 0 |M_DONT_KNOW : Media state unknown |
- | | | | + | | | 1 |M_NOT_CHANGED : Media still in and ready | |
+ | |||
+ | **Human68K standard media type list :** | ||
- | Human68K standard media type list : | ||
Note : this list isn't exhaustive ! A driver can provide its own set. So, a program or driver should never rely on these values to determine the media type. | Note : this list isn't exhaustive ! A driver can provide its own set. So, a program or driver should never rely on these values to determine the media type. | ||
+ | |||
I will not explain them, names pretty much speak for themselves. | I will not explain them, names pretty much speak for themselves. | ||
- | | + | * 0xE0 - MD_2DD_10 |
- | 0xE5 - MD_1D_9 | + | |
- | 0xE6 - MD_2D_9 | + | |
- | 0xE7 - MD_1D_8 | + | |
- | 0xE8 - MD_2D_8 | + | |
- | 0xEA - MD_2HT | + | |
- | 0xEB - MD_2HS | + | |
- | 0xEC - MD_2HDE | + | |
- | 0xEE - MD_1DD_9 | + | |
- | 0xEF - MD_1DD_8 | + | |
- | 0xF4 - MD_DAT | + | |
- | 0xF5 - MD_CDROM | + | |
- | 0xF6 - MD_MO | + | |
- | 0xF7 - MD_SCSIHD | + | |
- | 0xF8 - MD_SASIHD | + | |
- | 0xF9 - MD_RAMDISK | + | |
- | 0xFA - MD_2HQ | + | |
- | 0xFB - MD_2DD_8 | + | |
- | 0xFC - MD_2DD_9 | + | |
- | 0xFD - MD_2HC | + | |
- | 0xFE - MD_2HD | + | |
Line 193: | Line 202: | ||
- | Command ID : 0x02 (C_BLDBPB) | + | **Command ID :** 0x02 (C_BLDBPB) |
- | Availability : Block | + | |
- | Description :This command is proceed when a media have previously been reported as " | + | |
- | Input parameters :none | + | |
- | Output parameters : | + | |
- | Position Type Description | + | |
- | 18 Long Pointer to the requested unit BPB | + | |
- | 0x03 - IOCTL input | + | **Availability :** Block |
- | Command ID : 0x03 (C_IOCTLIN) | + | |
- | Availability : Block/ | + | **Description :** This command is proceed when a media have previously been reported as " |
- | Description :Request the driver to read raw arbitrary datas from the specified unit. This request is initiated by an userspace application (IOCTL). | + | |
- | Input parameters : | + | **Input parameters :** none |
- | Position Type Description | + | |
- | 14 Long Pointer to a buffer that' | + | **Output parameters :** |
- | 18 Long Buffer size | + | |
- | Output parameters :none | + | ^ Position |
+ | | 18 | Long | Pointer to the requested unit BPB | | ||
+ | |||
+ | |||
+ | ===== 0x03 - IOCTL input ===== | ||
+ | |||
+ | **Command ID :** 0x03 (C_IOCTLIN) | ||
+ | |||
+ | **Availability :** Block/ | ||
+ | |||
+ | **Description :** Request the driver to read raw arbitrary datas from the specified unit. This request is initiated by an userspace application (IOCTL). | ||
+ | |||
+ | **Input parameters :** | ||
+ | |||
+ | ^ | ||
+ | | | ||
+ | | | ||
+ | |||
+ | **Output parameters :** none | ||
+ | |||
+ | ===== 0x04 - Input (read) ===== | ||
+ | |||
+ | **Command ID :** 0x04 (C_INPUT) | ||
+ | |||
+ | **Availability :** Block/ | ||
+ | |||
+ | **Description :** Request the driver to read data from the specified unit. This request is initiated by the kernel. | ||
+ | |||
+ | **Input parameters :** | ||
+ | |||
+ | ^ Position | ||
+ | | 13 | Byte |Block device driver only. Media type. | | ||
+ | | 14 | Long |Pointer to a buffer that' | ||
+ | | 18 | Long |Block device driver : number of sector to read. A sector length is normally specified by the BPB. | | ||
+ | | | |Character device driver : Buffer size. | | ||
+ | | 22 | Long |Block device driver only : logical start sector to read from. | | ||
- | 0x04 - Input (read) | + | **Output parameters :** none |
- | Command ID : 0x04 (C_INPUT) | + | |
- | Availability : Block/ | + | |
- | Description :Request the driver to read data from the specified unit. This request is initiated by the kernel. | + | |
- | Input parameters : | + | |
- | Position Type Description | + | |
- | 13 Byte Block device driver only. Media type. | + | |
- | 14 Long Pointer to a buffer that' | + | |
- | 18 Long Block device driver : number of sector to read. A sector length is normally specified by the BPB. | + | |
- | Character device driver : Buffer size. | + | |
- | 22 Long Block device driver only : logical start sector to read from. | + | |
- | Output parameters :none | + | |
Note for block device driver : as the kernel is responsible for handling the FAT, you just have to seek to the specified start sector location and read the wanted amount of data from there according to the requested amount of sectors and the BPB. However, the driver is still responsible of the logical to physical partition translation ! So, seek correctly. | Note for block device driver : as the kernel is responsible for handling the FAT, you just have to seek to the specified start sector location and read the wanted amount of data from there according to the requested amount of sectors and the BPB. However, the driver is still responsible of the logical to physical partition translation ! So, seek correctly. | ||
- | 0x05 - Read no wait | + | ===== 0x05 - Read no wait ===== |
- | Command ID : 0x05 (C_NDREAD) | + | |
- | Availability : Character | + | |
- | Description :To check furthermore. A strange command code that allow a driver to send back a device prereaded byte. Maybe dedicated command to some simple interrupt driven device. | + | |
- | Input parameters :none | + | |
- | Output parameters : | + | |
- | Position Type Description | + | |
- | 13 Byte Prereaded byte | + | |
- | 0x05 - Drive control/ | + | **Command ID :** 0x05 (C_NDREAD) |
- | Command ID : 0x05 (C_DRVCTL) | + | |
- | Availability : Block | + | |
- | Description : To check furthermore. This seems to be really X68000 specific floppy drive command, or some kind of kernel hack by Human68k developpers. It does some kind of IOCTL, but internally to the kernel to dis/allow and control of FDD ejection, LEDs or media write protection control... | + | |
- | 0x06 - Input status | + | **Availability :** Character |
- | Command ID : 0x06 (C_ISTAT) | + | |
- | Availability : Character | + | |
- | Description :Kernel perform this command before the INPUT one to check if reading on the specified unit is actually possible or not. There is no parameter. Just fill the result flags in the request packet header accordingly. | + | |
- | Input parameters :none | + | |
- | Output parameters :none | + | |
- | 0x07 - Input flush | + | **Description :** To check furthermore. A strange command code that allow a driver to send back a device prereaded byte. Maybe dedicated command to some simple interrupt driven device. |
- | Command ID : 0x07 (C_IFLUSH) | + | |
- | Availability : Character | + | |
- | Description :Request the driver to flush the specified unit input buffer. There is no parameter. Just fill the result flags in the request packet header accordingly. | + | |
- | Input parameters :none | + | |
- | Output parameters :none | + | |
- | 0x08 - Output (write) | + | **Input parameters :** none |
- | Command ID : 0x08 (C_OUTPUT) | + | |
- | Availability : Block/ | + | **Output parameters :** |
- | Description :Request the driver to write data to a specified unit. This request is initiated by the kernel. | + | |
- | Input parameters : | + | ^ Position |
- | Position Type Description | + | | 13 | Byte |Prereaded byte | |
- | 14 Long Pointer to a buffer that contains data to write to the unit. | + | |
- | 18 Long Block device driver : number of sector to write. A sector length is normally specified by the BPB. | + | ===== 0x05 - Drive control/ |
- | Character device driver : Buffer size. | + | |
- | 22 Long Block device driver only : logical start sector to write to. | + | **Command ID :** 0x05 (C_DRVCTL) |
- | Output parameters :none | + | |
+ | **Availability :** Block | ||
+ | |||
+ | **Description :** //To check furthermore.// | ||
+ | |||
+ | ===== 0x06 - Input status ===== | ||
+ | |||
+ | **Command ID :** 0x06 (C_ISTAT) | ||
+ | |||
+ | **Availability :** Character | ||
+ | |||
+ | **Description :** Kernel perform this command before the INPUT one to check if reading on the specified unit is actually possible or not. There is no parameter. Just fill the result flags in the request packet header accordingly. | ||
+ | |||
+ | **Input parameters :** none | ||
+ | |||
+ | **Output parameters :** none | ||
+ | |||
+ | ===== 0x07 - Input flush ===== | ||
+ | |||
+ | **Command ID :** 0x07 (C_IFLUSH) | ||
+ | |||
+ | **Availability :** Character | ||
+ | |||
+ | **Description :** Request the driver to flush the specified unit input buffer. There is no parameter. Just fill the result flags in the request packet header accordingly. | ||
+ | |||
+ | **Input parameters :** none | ||
+ | |||
+ | **Output parameters :** none | ||
+ | |||
+ | ===== 0x08 - Output (write) | ||
+ | |||
+ | **Command ID :** 0x08 (C_OUTPUT) | ||
+ | |||
+ | **Availability :** Block/ | ||
+ | |||
+ | **Description :** Request the driver to write data to a specified unit. This request is initiated by the kernel. | ||
+ | |||
+ | **Input parameters :** | ||
+ | |||
+ | ^ | ||
+ | | | ||
+ | | | ||
+ | | | |Character device driver : Buffer size. | | ||
+ | | | ||
+ | |||
+ | **Output parameters :** none | ||
Note for block device driver : as the kernel is responsible for handling the FAT, you just have to seek to the specified start sector location and read the wanted amount of data from there according to the requested amount of sectors and the BPB. However, the driver is still responsible of the logical to physical partition translation ! So, seek correctly. | Note for block device driver : as the kernel is responsible for handling the FAT, you just have to seek to the specified start sector location and read the wanted amount of data from there according to the requested amount of sectors and the BPB. However, the driver is still responsible of the logical to physical partition translation ! So, seek correctly. | ||
- | 0x09 - Output with verify | + | ===== 0x09 - Output with verify |
- | Command ID : 0x09 (C_OUTVFY) | + | |
- | Availability : Block/ | + | |
- | Description : Same as "0x08 - Output (write)", | + | |
- | Input parameters :same as the "0x08 - Output (write)" | + | |
- | 0x0A - Output status | + | **Command ID :** 0x09 (C_OUTVFY) |
- | Command ID : 0x0A (C_OSTAT) | + | |
- | Availability : Character | + | |
- | Description :Kernel perform this command before the OUTPUT one to check if writing to the specified unit is actually possible or not. There is no parameter. Just fill the result flags in the request packet header accordingly. | + | |
- | Input parameters :none | + | |
- | Output parameters :none | + | |
- | 0x0B - Output flush | + | **Availability :** Block/Character |
- | Command ID : 0x0B (C_OFLUSH) | + | |
- | Availability : Character | + | |
- | Description :Request the driver to flush the specified unit output buffer. There is no parameter. Just fill the result flags in the request packet header accordingly. | + | |
- | Input parameters :none | + | |
- | Output parameters :none | + | |
- | 0x0C - IOCTL out | + | **Description :** Same as " |
- | Command ID : 0x0C (C_IOCTLOUT) | + | |
- | Availability : Block/ | + | |
- | Description : | + | |
- | Input parameters : | + | |
- | Position Type Description | + | |
- | 14 Long Pointer to a buffer | + | |
- | 18 Long Buffer size | + | |
- | Output parameters :none | + | |
- | 0x13 - Generic IOCTL | + | **Input parameters :** same as the "0x08 - Output |
- | Command ID : 0x13 (C_GENIOCTL) | + | |
- | Availability : Block/ | + | |
- | Description :Perform a IOCTL command understood only by the driver and an userspace program. | + | |
- | Input parameters : | + | |
- | Position Type Description | + | |
- | 14 Long Optional pointer to a buffer. That buffer is totally specific to the IOCTL command ID. | + | |
- | 18 Word IOCTL command ID. There is no restriction to this value. | + | |
- | Output | + | |
+ | ===== 0x0A - Output status ===== | ||
+ | |||
+ | **Command ID :** 0x0A (C_OSTAT) | ||
+ | |||
+ | **Availability :** Character | ||
+ | |||
+ | **Description :** Kernel perform this command before the OUTPUT one to check if writing to the specified unit is actually possible or not. There is no parameter. Just fill the result flags in the request packet header accordingly. | ||
+ | |||
+ | **Input parameters :** none | ||
+ | |||
+ | **Output parameters :** none | ||
+ | |||
+ | ===== 0x0B - Output flush ===== | ||
+ | |||
+ | **Command ID :** 0x0B (C_OFLUSH) | ||
+ | |||
+ | **Availability :** Character | ||
+ | |||
+ | **Description :** Request the driver to flush the specified unit output buffer. There is no parameter. Just fill the result flags in the request packet header accordingly. | ||
+ | |||
+ | **Input parameters :** none | ||
+ | |||
+ | **Output parameters :** none | ||
+ | |||
+ | ===== 0x0C - IOCTL out ===== | ||
+ | |||
+ | **Command ID :** 0x0C (C_IOCTLOUT) | ||
+ | |||
+ | **Availability :** Block/ | ||
+ | |||
+ | **Description :** Request the driver to write raw arbitrary datas to the specified unit. This request is initiated by an userspace application (IOCTL). | ||
+ | |||
+ | **Input parameters :** | ||
+ | |||
+ | ^ Position | ||
+ | | 14 | Long |Pointer to a buffer that' | ||
+ | | 18 | Long |Buffer size | | ||
+ | |||
+ | **Output parameters :** none | ||
+ | |||
+ | ===== 0x13 - Generic IOCTL ===== | ||
+ | |||
+ | **Command ID :** 0x13 (C_GENIOCTL) | ||
+ | |||
+ | **Availability :** Block/ | ||
+ | |||
+ | **Description :** Perform a IOCTL command understood only by the driver and an userspace program. | ||
+ | |||
+ | **Input parameters :** | ||
+ | |||
+ | ^ Position | ||
+ | | 14 | Long |Optional pointer to a buffer. That buffer is totally specific to the IOCTL command ID. | | ||
+ | | 18 | Word |IOCTL command ID. There is no restriction to this value. | ||
+ | |||
+ | **Output parameters :** none | ||
+ | |||
+ | ====== Extend command code ====== | ||
- | Extend command code | ||
These following request command codes are only performed when the driver header have the " | These following request command codes are only performed when the driver header have the " | ||
+ | |||
I actually do not know very much about them but they seems to be really filesystem level. | I actually do not know very much about them but they seems to be really filesystem level. | ||
+ | |||
Here is all known command ID : | Here is all known command ID : | ||
- | | + | * 0x40 - CR_INIT |
- | 0x41 - CR_SEARCH_DIR | + | |
- | 0x42 - CR_CREATE_DIR | + | |
- | 0x43 - CR_DELETE_DIR | + | |
- | 0x44 - CR_RENAME_FILE | + | |
- | 0x45 - CR_DELETE_FILE | + | |
- | 0x46 - CR_CHMOD | + | |
- | 0x47 - CR_FILES | + | |
- | 0x48 - CR_NFILES | + | |
- | 0x49 - CR_CREATE | + | |
- | 0x4A - CR_OPEN | + | |
- | 0x4B - CR_CLOS | + | |
- | 0x4C - CR_READ | + | |
- | 0x4D - CR_WRITE | + | |
- | 0x4E - CR_SEEK | + | |
- | 0x4F - CR_TIMEMOD | + | |
- | 0x50 - CR_GETCAP | + | |
- | 0x51 - CR_CONTROL | + | |
- | 0x52 - CR_BUILD_BPB | + | |
- | 0x53 - CR_IOCTL_IN | + | |
- | 0x54 - CR_IOCTL_OUT | + | |
- | 0x55 - CR_IOCTL_SPECIAL | + | |
- | 0x56 - CR_ABORT | + | |
- | 0x57 - CR_MEDIA_CHECK | + | |
- | 0x58 - CR_LOCK | + | |
I do have parameters. I will write them later. | I do have parameters. I will write them later. | ||
- | BIOS Parameter Block (BPB) | + | ====== |
I will not explain this structure as there is plenty of informations about it on the internet. | I will not explain this structure as there is plenty of informations about it on the internet. | ||
+ | |||
Starting from wikipedia : http:// | Starting from wikipedia : http:// | ||
+ | |||
Just read everything you can about FAT12 and FAT16. 95% of these also apply to Human68k. | Just read everything you can about FAT12 and FAT16. 95% of these also apply to Human68k. | ||
- | Most of difference is the byte ordering, which is big endian instead of little endian. The structure is also a bit different. From my ddk.h file : | ||
- | Code: [Select] | ||
+ | Most of difference is the byte ordering, which is big endian instead of little endian. The structure is also a bit different. | ||
+ | |||
+ | From my ddk.h file : | ||
+ | |||
+ | < | ||
struct bpb { | struct bpb { | ||
UWORD bpb_nbyte; | UWORD bpb_nbyte; | ||
Line 361: | Line 447: | ||
ULONG bpb_huge; | ULONG bpb_huge; | ||
}; | }; | ||
+ | </ | ||
See ? Only the " | See ? Only the " | ||
x68000/writing_drivers.txt · Last modified: 2019/08/27 20:45 by 127.0.0.1