summaryrefslogtreecommitdiff
path: root/StdLib/LibC/Uefi/InteractiveIO/IIOutilities.h
blob: 778b612ea59f4d384181724ad79b8468f7530c01 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/** @file
  Utilities for Interactive I/O Functions.

  The functions assume that isatty() is TRUE at the time they are called.

  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 _IIO_UTILITIES_H
#define _IIO_UTILITIES_H

#include  <sys/EfiSysCall.h>

__BEGIN_DECLS

/** Get the low-level UEFI protocol associated with an open file.

    @param[in]    fd    File descriptor for an open file.
    @param[out]   filp  NULL, or a pointer to where a pointer to the file's
                        file descriptor structure is to be stored.

    @return   Returns NULL if fd is not a valid file descriptor, otherwise
              a pointer to the file's associated UEFI protocol is returned.
**/
void *
EFIAPI
IIO_GetDeviceProto (
  int                 fd,
  struct __filedes  **filp    // Optional - filp == NULL if unused
  );

/** Get a character either from the input buffer or from hardware.

    @param[in]    filp      Pointer to a file descriptor structure.
    @param[in]    First     Set to TRUE to identify the initial read.

    @return   Returns a character read from either the input buffer
              or from the open file (device) identified by filp.
              A return value of WEOF indicates an error has occurred.
**/
wint_t
EFIAPI
IIO_GetInChar (
  struct __filedes *filp,
  BOOLEAN           First
  );

/** Get the current cursor position.

    @param[in]      fd      File descriptor for an open file.
    @param[out]     Column  Pointer to where the current cursor column is to be stored.
    @param[out]     Row     Pointer to where the current cursor row is to be stored.

    @retval   -1    fd is not an IIO output device.
    @retval    0    Cursor position retrieved, Cursor is Not Visible.
    @retval    1    Cursor position retrieved, Cursor is Visible.
**/
int
EFIAPI
IIO_GetCursorPosition (
  int       fd,
  UINT32   *Column,
  UINT32   *Row
  );

/** Set the cursor position.

    @param[in]    filp    Pointer to the output device's file descriptor structure.
    @param[in]    StartXY Pointer to a cursor coordinate (XY) structure indicating
                          the desired coordinate to move the cursor to.

    @retval   -1    fd is not an IIO output device
    @retval    0    Cursor position set successfully.
**/
int
EFIAPI
IIO_SetCursorPosition (
  struct __filedes *filp,
  CURSOR_XY        *StartXY
  );

/** Get Output screen size and mode.

    @param[in]    fd    File descriptor of the output device.
    @param[out]   Col   Pointer to where to store the MAX Column, or NULL.
    @param[out]   Row   Pointer to where to store the MAX Row, or NULL.

    @retval   <0    An error occurred.  The reason is in errno and EFIerrno.
                      * EIO     UEFI QueryMode failed
                      * ENOTTY  fd does not refer to an interactive output device
    @retval   >=0   Current output mode
**/
int
EFIAPI
IIO_GetOutputSize (
  int       fd,
  UINTN    *Col,
  UINTN    *Row
);

/** Calculate the number of character positions between two X/Y coordinate pairs.

    Using the current output device characteristics, calculate the number of
    characters between two coordinates.

    @param[in]      This      Pointer to the IIO instance to be examined.
    @param[in]      StartXY   Pointer to the starting coordinate pair.
    @param[in]      EndXY     Pointer to the ending coordinate pair.

    @return   Returns the difference between the starting and ending coordinates.
              The return value is positive if the coordinates contained in EndXY
              are larger than StartXY, otherwise the return value is negative.
**/
int
EFIAPI
IIO_CursorDelta (
  cIIO         *This,
  CURSOR_XY    *StartXY,
  CURSOR_XY    *EndXY
  );

__END_DECLS
#endif  /* _IIO_UTILITIES_H */