XINU
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Typedefs | Functions | Variables
kernel.h File Reference

XINU OSのkernel部分で使用する汎用的な宣言。 More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CONTEXT   64
 ランタイムスタックの関数呼び出しコンテキスト上のByte More...
 
#define EOF   (-2)
 ファイルの終端(End of File)に達した場合(読み込み処理に用いる) More...
 
#define FALSE   0
 Boolean False(0) More...
 
#define local   static
 ローカル関数かローカル変数の宣言 More...
 
#define MINSTK   400
 最小のスタックサイズ(Byte) More...
 
#define NULL   0
 連結リスト用のNULLポインタ More...
 
#define NULLCH   '\0'
 NULL文字(NULL終端) More...
 
#define NULLSTK   8192 /* stack size for null process */
 NULLプロセスのスタックサイズ More...
 
#define NULLSTR   ""
 空文字 More...
 
#define OK   (1)
 処理が成功した場合 More...
 
#define QUANTUM   2
 ミリ秒単位のタイムスライス More...
 
#define SYSERR   (-1)
 処理が失敗した場合 More...
 
#define TIMEOUT   (-3)
 システムコールがタイムアウトした場合 More...
 
#define TRUE   1
 Boolean True(1) More...
 

Typedefs

typedef byte bool8
 Boolean値 More...
 
typedef int32 bpid32
 バッファプールID More...
 
typedef unsigned char byte
 符号なし8ビット値(unsigned char) More...
 
typedef int32 dbid32
 データブロックID(ファイルシステムで使用する) More...
 
typedef int32 devcall
 デバイスコール関数 返り値の型 More...
 
typedef int32 did32
 デバイスID More...
 
typedef int32 ibid32
 ブロックIDのインデックス(ファイルシステムで使用する) More...
 
typedef short int16
 符号あり16ビット整数(short) More...
 
typedef int int32
 符号あり32ビット整数(int) More...
 
typedef void interrupt
 割り込みハンドラ 返り値の型 More...
 
typedef uint32 intmask
 保存された割り込みマスク More...
 
typedef int32 pid32
 プロセスID More...
 
typedef int16 pri16
 プロセス優先度 More...
 
typedef int32 process
 プロセスの最上位レベル関数 返り値の型 More...
 
typedef int16 qid16
 キューID More...
 
typedef int32 shellcmd
 シェルコール関数 返り値の型 More...
 
typedef int32 sid32
 セマフォID More...
 
typedef int32 status
 ステータスを意味する返り値の型(OK/SYSERR) More...
 
typedef int32 syscall
 システムコール関数 返り値の型 More...
 
typedef int32 uid32
 UDPテーブルディスクリプタのID. More...
 
typedef unsigned short uint16
 符号なし16ビット整数(unsigned short) More...
 
typedef unsigned int uint32
 符号なし32ビット整数(unsigned int) More...
 
typedef unsigned long long uint64
 符号なし64ビット整数(unsigned long long) More...
 
typedef unsigned char uint8
 符号なし8ビット値(unsigned char) More...
 
typedef uint32 umsg32
 プロセス間で渡されるメッセージ More...
 

Functions

syscall kgetc (void)
 ポーリングI/Oを使用して、コンソールのシリアルラインから文字を読み取る。 More...
 
syscall kprintf (char *fmt,...)
 ポーリングI/Oを使用して、フォーマットされた文字列をコンソールに出力する。 More...
 
syscall kputc (byte)
 ポーリングI/Oを使用して、コンソールのシリアルラインに文字を書き込む。 More...
 

Variables

qid16 readylist
 READY状態のプロセスリストに対するグローバルID. More...
 

Detailed Description

XINU OSのkernel部分で使用する汎用的な宣言。

Definition in file kernel.h.

Macro Definition Documentation

◆ CONTEXT

#define CONTEXT   64

ランタイムスタックの関数呼び出しコンテキスト上のByte

Definition at line 91 of file kernel.h.

◆ EOF

#define EOF   (-2)

ファイルの終端(End of File)に達した場合(読み込み処理に用いる)

Definition at line 81 of file kernel.h.

Referenced by lflgetc(), lflread(), shell(), ttygetc(), ttyread(), and xsh_cat().

◆ FALSE

#define FALSE   0

◆ local

#define local   static

ローカル関数かローカル変数の宣言

Definition at line 60 of file kernel.h.

◆ MINSTK

#define MINSTK   400

最小のスタックサイズ(Byte)

Definition at line 89 of file kernel.h.

Referenced by create().

◆ NULL

#define NULL   0

◆ NULLCH

#define NULLCH   '\0'

◆ NULLSTK

#define NULLSTK   8192 /* stack size for null process */

NULLプロセスのスタックサイズ

Definition at line 96 of file kernel.h.

Referenced by sysinit().

◆ NULLSTR

#define NULLSTR   ""

空文字

Definition at line 72 of file kernel.h.

Referenced by naminit().

◆ OK

#define OK   (1)

◆ QUANTUM

#define QUANTUM   2

ミリ秒単位のタイムスライス

Definition at line 93 of file kernel.h.

Referenced by clkhandler(), clkinit(), and resched().

◆ SYSERR

#define SYSERR   (-1)

処理が失敗した場合

Definition at line 79 of file kernel.h.

Referenced by addargs(), arp_alloc(), arp_in(), arp_resolve(), chprio(), close(), control(), create(), dequeue(), dhcp_bld_req(), dns_bldq(), dns_geta(), dnslookup(), dot2ip(), enqueue(), eth_phy_read(), eth_phy_reset(), eth_phy_write(), ethcontrol(), ethinit(), freebuf(), freemem(), getbuf(), getc(), getdev(), getlocalip(), getmem(), getprio(), getstk(), gettime(), getutime(), gpiocontrol(), icmp_in(), icmp_mkpkt(), icmp_recv(), icmp_register(), icmp_release(), icmp_send(), init(), insert(), insertd(), ioerr(), ip_enqueue(), ip_out(), ip_send(), kill(), lexan(), lfdballoc(), lfflush(), lfgetmode(), lfibput(), lflclose(), lflcontrol(), lflgetc(), lflputc(), lflread(), lflseek(), lflwrite(), lfscheck(), lfsckfmt(), lfscreate(), lfsopen(), mark(), mkbufpool(), mount(), namcpy(), naminit(), namlen(), nammap(), namopen(), namrepl(), net_init(), netin(), newpid(), newqueue(), newsem(), open(), ptcount(), ptcreate(), ptdelete(), ptinit(), ptrecv(), ptreset(), ptsend(), putc(), rdsbufalloc(), rdsclose(), rdscomm(), rdscontrol(), rdsinit(), rdsopen(), rdsprocess(), rdsread(), rdswrite(), read(), ready(), recvtime(), resched_cntl(), resume(), rflclose(), rflgetc(), rflputc(), rflread(), rflseek(), rflwrite(), rfscomm(), rfscontrol(), rfsgetmode(), rfsinit(), rfsndmsg(), rfsopen(), seek(), semcount(), semcreate(), semdelete(), semreset(), send(), set_evec(), shell(), signal(), signaln(), sleep(), sleepms(), startup(), suspend(), tftp_send1(), tftpget_mb(), ttycontrol(), ttyread(), ttywrite(), udp_recv(), udp_recvaddr(), udp_register(), udp_release(), udp_send(), udp_sendto(), unsleep(), wait(), write(), xsh_cat(), xsh_date(), xsh_kill(), xsh_ls(), xsh_netinfo(), xsh_ping(), xsh_rdstest(), xsh_udpecho(), and xsh_udpeserver().

◆ TIMEOUT

#define TIMEOUT   (-3)

◆ TRUE

#define TRUE   1

Typedef Documentation

◆ bool8

typedef byte bool8

Boolean値

Definition at line 36 of file kernel.h.

◆ bpid32

typedef int32 bpid32

バッファプールID

Definition at line 34 of file kernel.h.

◆ byte

typedef unsigned char byte

符号なし8ビット値(unsigned char)

Definition at line 7 of file kernel.h.

◆ dbid32

typedef int32 dbid32

データブロックID(ファイルシステムで使用する)

Definition at line 42 of file kernel.h.

◆ devcall

typedef int32 devcall

デバイスコール関数 返り値の型

Definition at line 49 of file kernel.h.

◆ did32

typedef int32 did32

デバイスID

Definition at line 28 of file kernel.h.

◆ ibid32

typedef int32 ibid32

ブロックIDのインデックス(ファイルシステムで使用する)

Definition at line 40 of file kernel.h.

◆ int16

typedef short int16

符号あり16ビット整数(short)

Definition at line 13 of file kernel.h.

◆ int32

typedef int int32

符号あり32ビット整数(int)

Definition at line 11 of file kernel.h.

◆ interrupt

typedef void interrupt

割り込みハンドラ 返り値の型

Definition at line 55 of file kernel.h.

◆ intmask

typedef uint32 intmask

保存された割り込みマスク

Definition at line 38 of file kernel.h.

◆ pid32

typedef int32 pid32

プロセスID

Definition at line 26 of file kernel.h.

◆ pri16

typedef int16 pri16

プロセス優先度

Definition at line 30 of file kernel.h.

◆ process

typedef int32 process

プロセスの最上位レベル関数 返り値の型

Definition at line 53 of file kernel.h.

◆ qid16

typedef int16 qid16

キューID

Definition at line 24 of file kernel.h.

◆ shellcmd

typedef int32 shellcmd

シェルコール関数 返り値の型

Definition at line 51 of file kernel.h.

◆ sid32

typedef int32 sid32

セマフォID

Definition at line 22 of file kernel.h.

◆ status

typedef int32 status

ステータスを意味する返り値の型(OK/SYSERR)

Definition at line 57 of file kernel.h.

◆ syscall

typedef int32 syscall

システムコール関数 返り値の型

Definition at line 47 of file kernel.h.

◆ uid32

typedef int32 uid32

UDPテーブルディスクリプタのID.

Definition at line 44 of file kernel.h.

◆ uint16

typedef unsigned short uint16

符号なし16ビット整数(unsigned short)

Definition at line 17 of file kernel.h.

◆ uint32

typedef unsigned int uint32

符号なし32ビット整数(unsigned int)

Definition at line 15 of file kernel.h.

◆ uint64

typedef unsigned long long uint64

符号なし64ビット整数(unsigned long long)

Definition at line 19 of file kernel.h.

◆ uint8

typedef unsigned char uint8

符号なし8ビット値(unsigned char)

Definition at line 9 of file kernel.h.

◆ umsg32

typedef uint32 umsg32

プロセス間で渡されるメッセージ

Definition at line 32 of file kernel.h.

Function Documentation

◆ kgetc()

syscall kgetc ( void  )

ポーリングI/Oを使用して、コンソールのシリアルラインから文字を読み取る。

Definition at line 59 of file kprintf.c.

References _doprnt(), CONSOLE, devtab, disable(), dentry::dvcsr, uart_csreg::ier, uart_csreg::lsr, restore(), and UART_LSR_DR.

60 {
61  int irmask;
62  volatile struct uart_csreg *regptr;
63  byte c;
64  struct dentry *devptr;
65  intmask mask;
66 
67  /* Disable interrupts */
68  mask = disable();
69 
70  devptr = (struct dentry *)&devtab[CONSOLE];
71  regptr = (struct uart_csreg *)devptr->dvcsr;
72 
73  irmask = regptr->ier; /* Save UART interrupt state. */
74  regptr->ier = 0; /* Disable UART interrupts. */
75 
76  while (0 == (regptr->lsr & UART_LSR_DR))
77  {
78  ; /* Do Nothing */
79  }
80 
81  /* Read character from Receive Holding Register */
82 
83  c = regptr->rbr;
84  regptr->ier = irmask; /* Restore UART interrupts. */
85 
86  restore(mask);
87  return c;
88 }
unsigned char byte
符号なし8ビット値(unsigned char)
Definition: kernel.h:7
volatile uint32 lsr
Definition: uart.h:22
void restore(intmask)
#define CONSOLE
Definition: conf.h:28
volatile uint32 ier
Definition: uart.h:17
Definition: conf.h:6
struct dentry devtab[]
Definition: conf.c:11
uint32 intmask
保存された割り込みマスク
Definition: kernel.h:38
void * dvcsr
Definition: conf.h:19
intmask disable(void)
割り込み禁止(intr.Sに定義がある)
#define UART_LSR_DR
Definition: uart.h:101
Here is the call graph for this function:

◆ kprintf()

syscall kprintf ( char *  fmt,
  ... 
)

ポーリングI/Oを使用して、フォーマットされた文字列をコンソールに出力する。

ポーリングI/Oを使用して、フォーマットされた文字列をコンソールに出力する。

Polled I/Oを使用したシステムコール。

Parameters
[in]fmt文字列を表示する際のフォーマット情報
[in]...可変長引数

Definition at line 98 of file kprintf.c.

References _doprnt(), CONSOLE, devtab, kputc(), OK, va_end, and va_start.

Referenced by arp_alloc(), arp_dump(), arp_in(), dhcp_bld_req(), dnslookup(), ethinit(), ethread(), getlocalip(), hexadump(), hexdump(), ip_enqueue(), ip_in(), ipout(), irq_dispatch(), lflcontrol(), lfsckfmt(), lfsopen(), main(), naminit(), nulluser(), panic(), pdump(), pdumph(), rdscomm(), rdscontrol(), rdsopen(), rflread(), rflwrite(), rfscomm(), rfscontrol(), rfsndmsg(), rfsopen(), startup(), stop(), sysinit(), tftp_send1(), tftpget_mb(), xdone(), and xsh_rdstest().

99 {
100  va_list ap;
101 
102  va_start(ap, fmt);
103  _doprnt(fmt, ap, (int (*)(int))kputc, (int)&devtab[CONSOLE]);
104  va_end(ap);
105  return OK;
106 }
#define CONSOLE
Definition: conf.h:28
#define OK
処理が成功した場合
Definition: kernel.h:77
void _doprnt(char *, va_list, int(*)(int), int)
#define va_start(last, va)
va_list型を初期化し、可変長引数の使用を開始する。
Definition: stdarg.h:25
struct dentry devtab[]
Definition: conf.c:11
#define va_end(va)
可変長引数の処理を終了する。
Definition: stdarg.h:42
__builtin_va_list va_list
可変個の実引数を扱うための情報を保持するための型(__builtin_va_listはGCCに定義された型) ...
Definition: stdarg.h:7
syscall kputc(byte c)
ポーリングI/Oを使用して、コンソールのシリアルラインに文字を書き込む。
Definition: kprintf.c:13
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kputc()

syscall kputc ( byte  )

ポーリングI/Oを使用して、コンソールのシリアルラインに文字を書き込む。

Definition at line 13 of file kprintf.c.

References uart_csreg::buffer, CONSOLE, devtab, disable(), dentry::dvcsr, uart_csreg::lsr, OK, restore(), and UART_LSR_THRE.

Referenced by kprintf().

16 {
17  struct dentry *devptr;
18  volatile struct uart_csreg *csrptr;
19  intmask mask;
20 
21  /* Disable interrupts */
22  mask = disable();
23 
24  /* Get CSR address of the console */
25 
26  devptr = (struct dentry *)&devtab[CONSOLE];
27  csrptr = (struct uart_csreg *)devptr->dvcsr;
28 
29  /* wait for UART transmit queue to empty */
30 
31  while ((csrptr->lsr & UART_LSR_THRE) == 0)
32  {
33  ;
34  }
35 
36  /* write the character */
37 
38  csrptr->buffer = c;
39 
40  /* Honor CRLF - when writing NEWLINE also send CARRIAGE RETURN */
41 
42  if (c == '\n')
43  {
44  while ((csrptr->lsr & UART_LSR_THRE) == 0)
45  {
46  ;
47  }
48  csrptr->buffer = '\r';
49  }
50 
51  restore(mask);
52  return OK;
53 }
volatile uint32 lsr
Definition: uart.h:22
#define UART_LSR_THRE
Definition: uart.h:103
void restore(intmask)
volatile uint32 buffer
Definition: uart.h:15
#define CONSOLE
Definition: conf.h:28
#define OK
処理が成功した場合
Definition: kernel.h:77
Definition: conf.h:6
struct dentry devtab[]
Definition: conf.c:11
uint32 intmask
保存された割り込みマスク
Definition: kernel.h:38
void * dvcsr
Definition: conf.h:19
intmask disable(void)
割り込み禁止(intr.Sに定義がある)
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ readylist

qid16 readylist

READY状態のプロセスリストに対するグローバルID.

READY状態のプロセスリストに対するグローバルID.

Definition at line 9 of file ready.c.

Referenced by ready(), resched(), and sysinit().