XINU
getdev.c
Go to the documentation of this file.
1 /* getdev.c - getdev */
2 
3 #include <xinu.h>
4 #include <string.h>
5 
6 /*------------------------------------------------------------------------
7  * getdev - Convert a device name to a device ID
8  *------------------------------------------------------------------------
9  */
11  char *devname /* Name of the device */
12  )
13 {
14  intmask mask; /* Saved interrupt mask */
15  did32 id; /* Value to return to caller */
16 
17  mask = disable();
18  for (id = 0; id < NDEVS; id++) {
19  if (strncmp(devname, devtab[id].dvname, DEVNAMLEN)) {
20  restore(mask);
21  return id;
22  }
23  }
24  restore(mask);
25  return (did32) SYSERR;
26 }
int32 strncmp(const char *, const char *, int32)
void restore(intmask)
#define NDEVS
Definition: conf.h:74
全てのシステムヘッダファイルをインクルードする。
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
struct dentry devtab[]
Definition: conf.c:11
uint32 intmask
保存された割り込みマスク
Definition: kernel.h:38
int32 did32
デバイスID
Definition: kernel.h:28
char * dvname
Definition: conf.h:9
#define DEVNAMLEN
デバイス名の最大サイズ
Definition: device.h:7
did32 getdev(char *devname)
Definition: getdev.c:10
intmask disable(void)
割り込み禁止(intr.Sに定義がある)