Guidelines for Implementing I/O Function Calls
For mrv4_open():
- Control the number of simultaneous times that the users attempt to open the device. This is useful if you want to grant access to device only to one program user at a time.
- Initialise ports to a convenient status.
- Install interrupt handlers.
- Disable hardware interrupts.
- Ask for a free irq number.
- Unmask that interrupt (The Jourdain book listed in Resources is a good place to learn how to program the Intel 8119 chip).
- Enable hardware interrupts again.
For mrv4_release():
- Specific device operations (stop the robot).
- Uninstall interrupts.
- Disable hardware interrupts.
- Mask the interrupt.
- Enable hardware interrupts again.
- Leave the ports in an adequate (relaxed) state.
For mrv4_write():
- Catch input arguments.
- Transform input into internal variables.
- Process input information.
- Write to ports.
- Return the number of bytes which have been written.
For mrv4_read():
- Read ports.
- Store the incoming data into internal variables.
- Process the data.
- Return information via argument.
- Return the number of bytes.
For mrv4_ioctl():
- Catch the command (and the argument, if any).
- Select from the command the function to perform.
- Perform the requested operation.
- Return an OK status.