summaryrefslogtreecommitdiff
path: root/StdLibPrivateInternalFiles/Include/Device/IIO.h
blob: 4eb3623cdcda59cad6f0bdb2f996b1bdbce6da99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/** @file
  Constants and declarations for the Interactive IO library.

  Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
  This program and the accompanying materials are licensed and made available
  under the terms and conditions of the BSD License which accompanies this
  distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php.

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _INTERACTIVE_IO_H
#define _INTERACTIVE_IO_H

#include  <sys/EfiSysCall.h>
#include  <sys/termios.h>
#include  <Containers/Fifo.h>
#include  <kfile.h>

__BEGIN_DECLS

typedef struct _IIO_Instance  cIIO;

cIIO * EFIAPI New_cIIO(void);   // Creates a new cIIO structure

/*  Types of Member functions of the TTY I/O "class". */
typedef void    (EFIAPI *cIIO_Delete)    (cIIO *This);

typedef ssize_t (EFIAPI *cIIO_Read)      (struct __filedes *filp, size_t BufferSize, VOID *Buffer);

typedef ssize_t (EFIAPI *cIIO_Write)     (struct __filedes *filp, const char *buf, ssize_t n);

typedef ssize_t (EFIAPI *cIIO_Echo)      (struct __filedes *filp, wchar_t EChar, BOOLEAN EchoIsOK);

/** Structure defining an instance of the Interactive I/O "class".  **/
struct _IIO_Instance {
  /* ######## Public Functions ######## */
  cIIO_Delete      Delete;
  cIIO_Read        Read;
  cIIO_Write       Write;
  cIIO_Echo        Echo;

  /* ######## PRIVATE Data ######## */

  // Wide input buffer -- stdin
  cFIFO          *InBuf;

  // Wide output buffer -- stdout
  cFIFO          *OutBuf;

  // Attributes for characters in the output buffer
  UINT8          *AttrBuf;

  // Wide output buffer -- stderr
  cFIFO          *ErrBuf;

  // Character conversion states for the buffers
  mbstate_t       OutState;
  mbstate_t       ErrState;

  //  Cursor position at beginning of operation
  //  and at each character thereafter.
  CURSOR_XY       InitialXY;
  CURSOR_XY       CurrentXY;

  UINTN           MaxColumn;    // Width of the output device
  UINTN           MaxRow;       // Height of the output device

  // termios structure
  struct termios  Termio;
};

// Helper Functions
ssize_t IIO_CanonRead     (struct __filedes *filp);
ssize_t IIO_NonCanonRead  (struct __filedes *filp);
ssize_t IIO_WriteOne      (struct __filedes *filp, cFIFO *Buf, wchar_t InCh);
ssize_t IIO_EchoOne       (struct __filedes *filp, wchar_t InCh, BOOLEAN EchoIsOK);

__END_DECLS
#endif  /* _INTERACTIVE_IO_H */