nckernel  0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
serial.c File Reference
#include <slibc.h>
#include <sys/types.h>
#include <sys/io.h>
#include <stdio.h>
#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stddef.h>
#include <assert.h>
#include <list.h>
#include <object.h>
#include <vfs.h>
#include <device.h>
#include <serial.h>
#include <interrupt.h>
#include <isr.h>
#include <debug.h>
Include dependency graph for serial.c:

Go to the source code of this file.

Data Structures

struct  context
 

Macros

#define DATA5   0x00
 
#define DATA6   0x01
 
#define DATA7   0x02
 
#define DATA8   0x03
 
#define EVEN_PARITY   0x02
 
#define NO_PARITY   0x00
 
#define ODD_PARITY   0x01
 
#define SERIAL_MAX_SPEED   115200
 
#define STOPBITS1   0x00
 
#define STOPBITS2   0x01
 

Enumerations

enum  IER {
  RX = 0x01, TX = 0x02, RX_STAT = 0x04, MODEM_STAT = 0x08,
  SLEEP_MODE = 0x10, LOW_POWER = 0x20
}
 
enum  port_offset {
  DATA = 0x00, INTR_ENABLE = 0x01, BAUD_LO = 0x00, BAUD_HI = 0x01,
  FIFO = 0x02, LINE_CTRL = 0x03, MODEM_CTRL = 0x04, LINE_STATUS = 0x05,
  MODEM_STATUS = 0x06, SCRATCH = 0x07
}
 

Functions

int serial_close (struct ninfo *ninfo, struct nctx *ctx)
 
int serial_init (void)
 Serial 장치를 사용할 수 있도록 초기화 하는 함수 More...
 
int serial_ioctl (struct ninfo *ninfo, struct nctx *ctx, int request, va_list va)
 
int serial_open (struct ninfo *ninfo, struct nctx *ctx)
 
int serial_read (struct ninfo *ninfo, struct nctx *ctx, void *buf, size_t size)
 
int serial_write (struct ninfo *ninfo, struct nctx *ctx, const void *buf, size_t size)
 

Macro Definition Documentation

#define DATA5   0x00

Definition at line 47 of file serial.c.

#define DATA6   0x01

Definition at line 48 of file serial.c.

#define DATA7   0x02

Definition at line 49 of file serial.c.

#define DATA8   0x03

Definition at line 50 of file serial.c.

#define EVEN_PARITY   0x02

Definition at line 57 of file serial.c.

#define NO_PARITY   0x00

Definition at line 55 of file serial.c.

#define ODD_PARITY   0x01

Definition at line 56 of file serial.c.

#define SERIAL_MAX_SPEED   115200

Definition at line 59 of file serial.c.

#define STOPBITS1   0x00

Definition at line 52 of file serial.c.

#define STOPBITS2   0x01

Definition at line 53 of file serial.c.

Enumeration Type Documentation

enum IER
Enumerator
RX 

Enable Received Data Available Interrupt

TX 

Enable Transmitter Holding Register Empty Intr

RX_STAT 
MODEM_STAT 

Enable Modem Status Interrupt

SLEEP_MODE 

Enable Sleep Mode (16750)

LOW_POWER 

Enable Low Power Mode (16750)

Definition at line 61 of file serial.c.

Enumerator
DATA 

Data Register (w/o DLAB)

INTR_ENABLE 

Interrupt enable register (w/o DLAB)

BAUD_LO 

Baudrate divisor low byte (w DLAB)

BAUD_HI 

Baudrate divisor hi byte (w DLAB)

FIFO 

Interrupt identification and FIFO ctrl register

LINE_CTRL 

Line control register (MSB = DLAB)

MODEM_CTRL 

Modem control register

LINE_STATUS 

Line status register

MODEM_STATUS 

Modem status register

SCRATCH 

Scratch register

Definition at line 34 of file serial.c.

Function Documentation

int serial_close ( struct ninfo ninfo,
struct nctx ctx 
)
Note
If there is one more serial driver is exists, don't remove ISR handler.

Definition at line 213 of file serial.c.

References ninfo_dev::device, free(), IRQ_NR_SERIAL_EVEN, IRQ_NR_SERIAL_ODD, MINOR, NULL, nctx::priv, ninfo::priv, and unregister_irq().

Here is the call graph for this function:

int serial_ioctl ( struct ninfo ninfo,
struct nctx ctx,
int  request,
va_list  va 
)
int serial_open ( struct ninfo ninfo,
struct nctx ctx 
)
Note
If a isr is already registered, do not add this again

Definition at line 107 of file serial.c.

References ninfo_dev::device, ENODEV, ENOMEM, free(), IRQ_NR_SERIAL_EVEN, IRQ_NR_SERIAL_ODD, malloc(), MINOR, NORMAL_PRIORITY, NULL, nctx::offset, nctx::priv, ninfo::priv, and register_irq().

Here is the call graph for this function:

int serial_read ( struct ninfo ninfo,
struct nctx ctx,
void *  buf,
size_t  size 
)

Definition at line 141 of file serial.c.

References EBUSY, nctx::priv, and context::setup.

int serial_write ( struct ninfo ninfo,
struct nctx ctx,
const void *  buf,
size_t  size 
)

Definition at line 154 of file serial.c.

References EBUSY, nctx::priv, and context::setup.