User Tools

Site Tools


x68000:writing_drivers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
x68000:writing_drivers [2014/07/11 00:44] eidisx68000:writing_drivers [2019/08/27 20:45] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
 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://nfggames.com/forum2/index.php?topic=5417.0
  
 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 16:
  
 **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 23:
   * 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" and a pointer is 32 bits (long).   * All data types are CPU specific : M68K family. So, byte ordering is always "Big Endian" and a pointer is 32 bits (long).
- 
  
 ====== Compilation flags, libraries and startup code ====== ====== Compilation flags, libraries and startup code ======
Line 89: Line 90:
 **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 "A"bort, "R"etry and "I"gnore line, and E_**** will show an appropriate error message. "Result status" member can be any combination of S_**** flags (ORed together), but only one E_**** can be set.+This list contains all acceptable values to fill the result status flags in the request packet header. S_**** flags will display (or hide) the "A"bort, "R"etry and "I"gnore line, and E_**** will show an appropriate error message. 
 + 
 +"Result status" member can be any combination of S_**** flags (ORed together), but only one E_**** can be set.
  
   * 0x1000 - S_ABORT : "A"bort the whole request.   * 0x1000 - S_ABORT : "A"bort the whole request.
Line 155: Line 158:
  
   
-Output parameters :+**Output parameters :**
  
 ^  Position  ^  Type  ^  Description  ^ ^  Position  ^  Type  ^  Description  ^
Line 220: Line 223:
  
 ^  Position  ^  Type  ^  Description  ^ ^  Position  ^  Type  ^  Description  ^
-|  14  |  Long  |  Pointer to a buffer that'll contain readed data from the unit. The driver is responsible of filling this buffer. +|  14  |  Long  |Pointer to a buffer that'll contain readed data from the unit. The driver is responsible of filling this buffer. 
-|  18  |  Long  |  Buffer size  |+|  18  |  Long  |Buffer size  |
   
 **Output parameters :** none **Output parameters :** none
Line 227: Line 230:
 ===== 0x04 - Input (read) ===== ===== 0x04 - Input (read) =====
  
-Command ID : 0x04 (C_INPUT)+**Command ID :** 0x04 (C_INPUT)
  
 **Availability :** Block/Character **Availability :** Block/Character
Line 238: Line 241:
 |  13  |  Byte  |Block device driver only. Media type.  |     |  13  |  Byte  |Block device driver only. Media type.  |    
 |  14  |  Long  |Pointer to a buffer that'll contain the readed data from the unit.The driver is responsible of filling this buffer.  | |  14  |  Long  |Pointer to a buffer that'll contain the readed data from the unit.The driver is responsible of filling this buffer.  |
-|  18  |  Long  |Block device driver : number of sector to read. A sector length is normally specified by the BPB. +|  18  |  Long  |Block device driver : number of sector to read. A sector length is normally specified by the BPB.  | 
-Character device driver : Buffer size.  | +| | |Character device driver : Buffer size.  |
 |  22  |  Long  |Block device driver only : logical start sector to read from.  | |  22  |  Long  |Block device driver only : logical start sector to read from.  |
  
Line 248: Line 251:
 ===== 0x05 - Read no wait ===== ===== 0x05 - Read no wait =====
  
-Command ID : 0x05 (C_NDREAD)+**Command ID :** 0x05 (C_NDREAD)
  
 **Availability :** Character **Availability :** Character
Line 267: Line 270:
 **Availability :** Block **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...+**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 ===== ===== 0x06 - Input status =====
Line 305: Line 308:
 ^  Position  ^  Type  ^  Description  ^ ^  Position  ^  Type  ^  Description  ^
 |  14  |  Long  |Pointer to a buffer that contains data to write to the unit.| |  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.  |||Character device driver : Buffer size.  | +|  18  |  Long  |Block device driver : number of sector to write. A sector length is normally specified by the BPB.  
 +| | |Character device driver : Buffer size.  |
 |  22  |  Long  |Block device driver only : logical start sector to write to.  |  |  22  |  Long  |Block device driver only : logical start sector to write to.  |
- +
 **Output parameters :** none **Output parameters :** none
  
Line 381: Line 385:
  
 These following request command codes are only performed when the driver header have the "attribute" flag set with the value 0x2000 (Remote device driver). These following request command codes are only performed when the driver header have the "attribute" flag set with the value 0x2000 (Remote device driver).
 +
 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 +  * 0x40 - CR_INIT 
-    0x41 - CR_SEARCH_DIR +  0x41 - CR_SEARCH_DIR 
-    0x42 - CR_CREATE_DIR +  0x42 - CR_CREATE_DIR 
-    0x43 - CR_DELETE_DIR +  0x43 - CR_DELETE_DIR 
-    0x44 - CR_RENAME_FILE +  0x44 - CR_RENAME_FILE 
-    0x45 - CR_DELETE_FILE +  0x45 - CR_DELETE_FILE 
-    0x46 - CR_CHMOD +  0x46 - CR_CHMOD 
-    0x47 - CR_FILES +  0x47 - CR_FILES 
-    0x48 - CR_NFILES +  0x48 - CR_NFILES 
-    0x49 - CR_CREATE +  0x49 - CR_CREATE 
-    0x4A - CR_OPEN +  0x4A - CR_OPEN 
-    0x4B - CR_CLOS +  0x4B - CR_CLOS 
-    0x4C - CR_READ +  0x4C - CR_READ 
-    0x4D - CR_WRITE +  0x4D - CR_WRITE 
-    0x4E - CR_SEEK +  0x4E - CR_SEEK 
-    0x4F - CR_TIMEMOD +  0x4F - CR_TIMEMOD 
-    0x50 - CR_GETCAP +  0x50 - CR_GETCAP 
-    0x51 - CR_CONTROL +  0x51 - CR_CONTROL 
-    0x52 - CR_BUILD_BPB +  0x52 - CR_BUILD_BPB 
-    0x53 - CR_IOCTL_IN +  0x53 - CR_IOCTL_IN 
-    0x54 - CR_IOCTL_OUT +  0x54 - CR_IOCTL_OUT 
-    0x55 - CR_IOCTL_SPECIAL +  0x55 - CR_IOCTL_SPECIAL 
-    0x56 - CR_ABORT +  0x56 - CR_ABORT 
-    0x57 - CR_MEDIA_CHECK +  0x57 - CR_MEDIA_CHECK 
-    0x58 - CR_LOCK+  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)+====== 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://en.wikipedia.org/wiki/BIOS_parameter_block Starting from wikipedia : http://en.wikipedia.org/wiki/BIOS_parameter_block
 +
 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 :
 +
 +<file>
 struct bpb { struct bpb {
   UWORD bpb_nbyte; /* Bytes per sector */   UWORD bpb_nbyte; /* Bytes per sector */
Line 431: Line 443:
   ULONG bpb_huge; /* Size in sectors if bpb_nsize == 0 (32 bits) */   ULONG bpb_huge; /* Size in sectors if bpb_nsize == 0 (32 bits) */
 }; };
 +</file>
  
 See ? Only the "number of FAT" and "number of reserved sectors" members are swapped. See ? Only the "number of FAT" and "number of reserved sectors" members are swapped.
  
x68000/writing_drivers.1405003498.txt.gz · Last modified: 2019/08/27 20:44 (external edit)