sysprg.doc

来自「MMURTL(tm) Computer Operating System Ver」· DOC 代码 · 共 383 行 · 第 1/3 页

DOC
383
字号
	Parameter Descriptions:

	dDevice  - the device number

	dOpNum   -  identifies which operation to perform 
		0 Null operation
		1 Read (receive data from the device)
		2 Write (send data to the device)
		3 Verify (compare data on the device)

		4 Format Block (tape or disk devices)
		5 Format Track (disk devices only)
		6 Seek Block (tape or disk devices only)
		7 Seek Track (disk devcies only)

		(Communications devices)

		10 OpenDevice (comms devices)
		11 CloseDevice (comms devices)

		(RS-232 devices with explicit modem control)

		15 SetDTR
		16 SetCTS
		

		Undefined operation number below 255 are RESERVED
		
		256-n Driver Defined (driver specific)
	
	dLBA	    - Logical Block Address for I/O operation.
			For sequential devices this parameter will 
			be ignored.

	dnBlocks - Number of CONTIGUOUS Blocks for the
			operation specified. For sequentail 
			devices this will simply be the number 
			of bytes.

	pData    - Pointer to data (or buffer for reads) 
			for specified operation 

 
DeviceStat Function Implementation

The DeviceStat function provides a way to for device specific status to be returned to a caller if needed. Not all devices will return status on demand. In cases where the function doesn't or can't return status, you should return 0 to pdStatusRet and return the standard device error ErcNoStatus.

	Name		Parameters	Call Frame Offset	Return 
 
 	DeviceStat(dDevice,		EBP+20
			pStatRet, 	EBP+16
			dStatusMax,	EBP+12
			pdStatusRet)	EBP+08
										: dError

	Parameter Descriptions:

	dDevice    - Device number to status
	pStatBuf   - Pointer to buffer where status will
			   be returned
	dStatusMax - caller sets this to tell you the maximum
			   size of status to return in bytes
	pdStatusRet - Pointer to DWord where you return actual
			   size of status returned in bytes 


DeviceInit Function Implementation

Some devices may require a call to initialize them before use or to reset them after a catastrophe.  An example of initialization would be a COMMs port (for baud rate, parity, etc.).  The size of the initializing data and it's contents are device specific and should be defined with the documentation for the specific device driver. 

	Name		Parameters	Call Frame Offset	Return 
 
 	DeviceInit(dDevice,		EBP+16
			 pInitData, 	EBP+12
			 dInitData)	EBP+08
										: dError

	Parameter Descriptions:

	dDevice    - DWord indicating Device number
	pInitData  - Pointer to device specific data for
			   initialization be returned
	dInitData  - DWord indicating maximum size of status
			   to return in bytes 



InitDevDr(dDevNum, pDCBs, nDevices, fReplace)

InitDevDr is called from a device driver after it is first loaded to let the OS integrate it into the system.  After the Device driver has been loaded it should allocate ALL system resources it needs to operate and control it's devices while providing service thorugh the three standard entry points.  A 64 byte DCB must be filled out for each device the driver controls before this call is made.  When a driver controls more than one device it must provide the Device Control Blocks for each device.  The DBCs must be contiguous in memory.  If the driver is flaged as not reentrant, then all devices controlled by the driver will be locked out when the driver is busy.  This is because one contoller (such as a disk or SCSI controller) usually handles multiple devices thorugh a single set of hardware ports (and one DMA channel if applicable) and can't handle more than one active transfer at a time.  If this is not the case, and the driver can handle two devices simultaneously the driver should be broken into two separate drivers.  

The parameters to InitDevDr are as follows:

dDevNum - This is the device number that the driver is controlling.  If the driver controls more than one device, this is the first number of the devices.  This means the deivices are number consecutively.

pDCBs - This is a pointer to the DCB for the device. If more than one device is controlled this is the pointer to the first in an array of DCBs for the devices.  This means the second DCB can be located at pDCBs + 64, the second at pDCBs + 128, etcetera.  

nDevices - This is the number of devices that the driver controls.  It MUST equal the number of contiguous DCBs that the driver has filled out before the InitDevDr call is made.

fReplace - If true, the driver will be substituted for the existing driver functions already in place.  This does not mean that the existing driver will be replaced in memory, it only means the new driver will be called when the device is accessed.  A driver MUST specify at least as many devices as the original driver handled.

OS Functions for Device Drivers

The following is a list of functions that were specifically designed for device drivers.  They perform many of the tedious functions that would otherwise require assembly language and a very good knowlegde of the hardware.  Please use the MMURTL API reference for a detailed description of their use.

AllocDMAMem - Allocates memory that will be compatible with DMA operations. It also returns the physical address of the memory which is required for the DMASetUp call.

EndOfIRQ - Resets the programmible interrupt controller unit (PICU) at the end of the ISR sequence.

MaskIRQ - Masks one interrupt (prevents it from interrupting) by programming the PICU.

SetIRQVector - Sets up a vector to your ISR.

DMASetUp - Programs the DMA hardware channel specified to move data to or from your device.

UnMaskIRQ - Allows interrupts to occur from a specified channel on the PICU.


Standard Device Error Codes

MMURTL will return errors for certain conditions (such as a device being called that's not installed).  The errors codes below can also be returned by device drivers if they adequately describe the error or status. 


See Status.H for common Device Driver error codes.

-------------------- End of SysPrg Docs ----------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?