- Timestamp:
-
09/12/13 12:15:42 (11 years ago)
- Author:
-
Jinyang
- Comment:
-
/* Step 3: Build a Basic PCI-CAN device in qemu */
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v64
|
v65
|
|
412 | 412 | == Add writing routine == |
413 | 413 | |
414 | | The writing routine is simple. We add the can_chr_write() function as writing routine. |
415 | | |
| 414 | The writing routine is simple. We use the can_chr_write() function as a writing routine, we also should assign this function to CharDriverState.chr_write If we want to call the writing routine in PCI-CAN device, the function qemu_chr_fe_write() should be called instead of calling the can_chr_write() function directly. |
| 415 | |
| 416 | The source code is just like the following, details in qemu-char.c file. |
| 417 | static int can_chr_write(CharDriverState *chr, const uint8_t *buf, int len) |
| 418 | { |
| 419 | ...... |
| 420 | } |
| 421 | static CharDriverState *qemu_chr_open_can(QemuOpts *opts) |
| 422 | { |
| 423 | CharDriverState *chr; |
| 424 | ...... |
| 425 | chr->chr_write = can_chr_write; |
| 426 | ...... |
| 427 | } |
| 428 | This is same with the ioctl funciton. |
| 429 | == Add reading routine == |
416 | 430 | |
417 | 431 | |