FreeBSD 1

Similar documents
FUJITSU ULTRA LVD SCSI Host Bus Adapter Driver 3.0 説明書

program.dvi

Lab GPIO_35 GPIO

tutorial_lc.dvi

bitvisor-ipc v12b.key

DA100データアクイジションユニット通信インタフェースユーザーズマニュアル

Linux on ITRON-ハイブリッド構造の実装


Express5800/320Fc-MR

Linuxデバイスドライバ.PDF

double float

thesis.dvi

Express5800/R320a-E4/Express5800/R320b-M4ユーザーズガイド

Minimum C Minimum C Minimum C BNF T okenseq W hite Any D

Condition DAQ condition condition 2 3 XML key value

8 if switch for while do while 2

: Nonblocking I/O readpartial read EOF Solaris FILE 256 ungetc SEGV errno stdio considered harmful p.

Nios® II HAL API を使用したソフトウェア・サンプル集 「Modular Scatter-Gather DMA Core」

N Express5800/R320a-E4 N Express5800/R320a-M4 ユーザーズガイド

Express5800/R320a-E4, Express5800/R320b-M4ユーザーズガイド

DocuWide 2051/2051MF 補足説明書

1 機能概要 複数ペリフェラル ( デバイスと呼びます ) を並行動作させて その IO 完了などのイベントを1カ所で待ち合わせて イベントドリブン処理を可能にします イベントは16 個を扱えます シーケンス処理を組めるように 特定のイベントだけ選別して待ち合わせる機能があります 待ち合わせるときに

Gpci4ソフト_下位DLL_説明書3版.PDF

CM-3G 周辺モジュール拡張技術文書 MS5607センサ(温度、気圧)

Complex Lab – Operating Systems - Graphical Console

Express5800/R110a-1Hユーザーズガイド

SystemC 2.0を用いた簡易CPUバスモデルの設計

RX600 & RX200シリーズ アプリケーションノート RX用仮想EEPROM

r07.dvi

ohp07.dvi

untitled

Express5800/320Fa-L/320Fa-LR/320Fa-M/320Fa-MR


1) // 2) I/O 3) Japan Advanced Institute of Science and Technology 2013/07/26 1

untitled

I. Opal SSC 1. Opal SSC 2. Opal Storage 3. Opal Storage MBR Shadowing 6. SP II. TCG Opal SSC HDD 9. Opal SSC HDD *1. TCG: Trusted Computin

SystemC言語概論

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

ストラドプロシージャの呼び出し方

Express5800/320Fa-L/320Fa-LR

WinDriver PCI Quick Start Guide

解きながら学ぶC++入門編

CodeIgniter Con 2011, Tokyo Japan, February

PBASIC 2.5 PBASIC 2.5 $PBASIC directive PIN type New DEBUG control characters DEBUGIN Line continuation for comma-delimited lists IF THEN ELSE * SELEC

Java演習(4) -- 変数と型 --

Compatibility list: vTESTstudio/CANoe

mbed_library_study_meeting_v1.0.key

00-COVER.P65

IO Linux Vyatta PC

void hash1_init(int *array) int i; for (i = 0; i < HASHSIZE; i++) array[i] = EMPTY; /* i EMPTY */ void hash1_insert(int *array, int n) if (n < 0 n >=

( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h>

[ 1] 1 Hello World!! 1 #include <s t d i o. h> 2 3 int main ( ) { 4 5 p r i n t f ( H e l l o World!! \ n ) ; 6 7 return 0 ; 8 } 1:

untitled

1:. Csmith,, (B!=0? A/B : A),.,., Orange3 [3], Orange4 [4],., Csmith., Csmith GCC LLVM.,,., Orange3, Orange4,, if for., Orange4, C, Csmith.,., if, for

RX600 & RX200シリーズ RX用シンプルフラッシュAPI アプリケーションノート

リアルタイムシステム

1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l

r03.dvi

J.JSSAC Vol. 7, No. 2, Mathematica Maple,., Open asir Open xxx asir. Open xxx Open asir, asir., Open xxx, Linux Open asir Open sm1 (kan/sm1). C

【注意事項】RXファミリ 組み込み用TCP/IP M3S-T4-Tiny

Nios II ソフトウェア開発ハンドブック Version 1.2 第5章. HAL用デバイス・ドライバの開発 ver.1.1

X Window System X X &

compiler-text.dvi

ohp03.dvi

1.ppt

Microsoft Word - C.....u.K...doc

説明資料: SANRISE, StorEdgeシリーズ向けVeritas VxVM-DMP 3

2

スレッド

PostgreSQL 解析ドキュメント

:30 12:00 I. I VI II. III. IV. a d V. VI

Microsoft Word - 第5回 基本データ構造2(連結リスト).doc

fp.gby

2

GNU Emacs GNU Emacs

microSTATION Operation guide

imcs04 ソフトウェアマニュアル imcs04 ソフトウェアマニュアル Ver1.4 株式会社イクシスリサーチ , ixs Research Corporation All right reserved.

Transcription:

FreeBSD 1

UNIX OS 1 ( ) open, close, read, write, ioctl (cdevsw) OS DMA 2

(8 ) (24 ) 256 open/close/read/write Ioctl 3

2 2 I/O I/O CPU 4

open/close/read/write open, read, write open/close read/write /dev open read/write read/write ioctl read/write 5

(psm.c) (cdevsw) static struct cdevsw psm_cdevsw = { /* open psmopen, /* close psmclose, /* read psmread, /* write nowrite, /* ioctl psmioctl, /* poll psmpoll, /* mmap nommap, }; /* strategy nostrategy, /* name "psm", /* maj CDEV_MAJOR, /* #define CDEV_MAJOR 21 /* dump nodump, /* psize nopsize, /* flags 0, /* bmaj -1 psmopen, psmclose, psmread,psmioctl 6

static d_open_t psmopen(dev_t dev, int flag, int fmt, struct proc *p) dev 0 flag: open() fmt S _IFCHR p: psmopen open() static d_close_t psmclose(dev_t dev, int flag, int fmt, struct proc *p) dev 0 flag fmt S _IFCHR p: psmclose dev ( / (i ) close() 7

static d_read_t psmread(dev_t dev, struct uio *uio, int flag) dev uio 0 flag: IO _NDELAY psmread read() static d_ioctl_t psmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) ioctl() dev cmd addr 0 flag ioctl() 8

struct psm_softc { /* Driver status information struct selinfo rsel; /* Process selecting for Input unsigned char state; /* Mouse driver state int config; /* driver configuration flags int flags; /* other flags KBDC kbdc; /* handle to access the keyboard controller struct resource *intr; /* IRQ resource void *ih; /* interrupt handle mousehw_t hw; /* hardware information mousemode_t mode; /* operation mode mousemode_t dflt_mode; /* default operation mode mousestatus_t status; /* accumulated mouse movement ringbuf_t queue; /* mouse status queue unsigned char ipacket[16]; /* interim input buffer int inputbytes; /* # of bytes in the input buffer int button; /* the latest button state int xold; /* previous absolute X position int yold; /* previous absolute Y position int watchdog; /* watchdog timer flag struct callout_handle callout; /* watchdog timer call out dev_t dev; dev_t bdev; }; 9

struct uio( /usr/include/sys/uio.h ) struct uio { struct iovec *uio_iov; /* int uio_iovcnt; /* off_t uio_offset; /* / int uio_resid; /* enum uio_seg uio_segflg; /* ( / ) enum uio_rw uio_rw; /* struct proc *uio_procp; /* }; uiomove( caddr_t cp, int n, struct uio *uio ) cp uio n ( ) uio cp n ( ) 0 uio uiomove() uio 10

static int psmopen(dev_t dev, int flag, int fmt, struct proc *p) { /* int unit = PSM_UNIT(dev); struct psm_softc *sc; int command_byte; int err; int s; /* Get device data sc = PSM_SOFTC(unit); if ((sc == NULL) (sc->state & PSM_VALID) == 0) return (ENXIO); /* ENXIO if (sc->state & PSM_OPEN) return (EBUSY); /* EBUSY device_busy(devclass_get_device(psm_devclass, unit)); /* sc->rsel.si_flags = 0; sc->rsel.si_pid = 0; sc->mode.level = sc->dflt_mode.level; sc->mode.protocol = sc->dflt_mode.protocol; sc->watchdog = FALSE; /* sc->queue.count = 0; sc->queue.head = 0; sc->queue.tail = 0; sc->status.flags = 0; 11

sc->status.button = 0; sc->status.obutton = 0; sc->status.dx = 0; sc->status.dy = 0; sc->status.dz = 0; sc->button = 0; /* bzero(sc->ipacket, sizeof(sc->ipacket)); sc->inputbytes = 0; /* err = doopen(unit, command_byte); /* done if (err == 0) sc->state = PSM_OPEN; kbdc_lock(sc->kbdc, FALSE); return (err); } static int psmread(dev_t dev, struct uio *uio, int flag) { /* ( )uio register struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev)); 12

unsigned char buf[psm_smallbufsize]; int error = 0; int s; int l; /* EIO if ((sc->state & PSM_VALID) == 0) return EIO; /* block until mouse activity occured s = spltty(); while (sc->queue.count <= 0) { if (PSM_NBLOCKIO(dev)) { splx(s); return EWOULDBLOCK; } sc->state = PSM_ASLP; error = tsleep((caddr_t) sc, PZERO PCATCH, "psmrea", 0); sc->state &= ~PSM_ASLP; if (error) { splx(s); return error; } else if ((sc->state & PSM_VALID) == 0) { /* the device disappeared! splx(s); return EIO; } } splx(s); 13

/* copy data to the user land while ((sc->queue.count > 0) && (uio->uio_resid > 0)) { /* s = spltty(); l = min(sc->queue.count, uio->uio_resid); if (l > sizeof(buf)) /* sizeof(buf) l = sizeof(buf); /* if (l > sizeof(sc->queue.buf) - sc->queue.head) { bcopy(&sc->queue.buf[sc->queue.head], &buf[0], sizeof(sc->queue.buf) - sc->queue.head); bcopy(&sc->queue.buf[0], &buf[sizeof(sc->queue.buf) - sc->queue.head], l - (sizeof(sc->queue.buf) - sc->queue.head)); } else { bcopy(&sc->queue.buf[sc->queue.head], &buf[0], l); } /* sc->queue.count -= l; sc->queue.head = (sc->queue.head + l) % sizeof(sc->queue.buf); splx(s); /* uio error = uiomove(buf, l, uio); if (error) } return error; } 14

static int psmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) { /* ( ) cmd struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev)); mousemode_t mode; mousestatus_t status; #if (defined(mouse_getvars)) mousevar_t *var; #endif mousedata_t *data; int stat[3]; int command_byte; int error = 0; int s; /* Perform IOCTL command switch (cmd) { case OLD_MOUSE_GETHWINFO: s = spltty(); ((old_mousehw_t *)addr)->buttons = sc->hw.buttons; ((old_mousehw_t *)addr)->iftype = sc->hw.iftype; ((old_mousehw_t *)addr)->type = sc->hw.type; ((old_mousehw_t *)addr)->hwid = sc->hw.hwid & 0x00ff; 15

splx(s); case MOUSE_GETHWINFO: case OLD_MOUSE_GETMODE: case MOUSE_GETMODE: case OLD_MOUSE_SETMODE: case MOUSE_SETMODE: case MOUSE_GETLEVEL: case MOUSE_SETLEVEL: case MOUSE_GETSTATUS: #if (defined(mouse_getvars)) case MOUSE_GETVARS: case MOUSE_SETVARS: 16

return ENODEV; #endif /* MOUSE_GETVARS case MOUSE_READSTATE: case MOUSE_READDATA: #if (defined(mouse_setresolution)) case MOUSE_SETRESOLUTION: #endif /* MOUSE_SETRESOLUTION #if (defined(mouse_setrate)) case MOUSE_SETRATE: #endif /* MOUSE_SETRATE #if (defined(mouse_setscaling)) case MOUSE_SETSCALING: #endif /* MOUSE_SETSCALING #if (defined(mouse_gethwid)) case MOUSE_GETHWID: 17

#endif /* MOUSE_GETHWID default: return ENOTTY; } return error; } /usr/src/sys/isa/joy.c /usr/src/sys/isa/psm.c FreeBSD 18