Cleanup Commit
[tpg/acess2.git] / Modules / Interfaces / EDI / edi / edi_port_io.h
1 #ifndef EDI_PORT_IO_H
2
3 /* Copyright (c)  2006  Eli Gottlieb.
4  * Permission is granted to copy, distribute and/or modify this document
5  * under the terms of the GNU Free Documentation License, Version 1.2
6  * or any later version published by the Free Software Foundation;
7  * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
8  * Texts.  A copy of the license is included in the file entitled "COPYING". */
9
10 /* Modified by thePowersGang (John Hodge)
11  * - Surround variable definitions with an #ifdef IMPLEMENTING_EDI
12  */
13
14 #define EDI_PORT_IO_H
15
16 /*! \file edi_port_io.h
17  * \brief Declaration and description of EDI's port I/O class.
18  *
19  * Data structures and algorithms this header represents:
20  *
21  *      DATA STRUCTURE AND ALGORITHM: PORT I/O OBJECTS - A class named "EDI-IO-PORT" is defined as an encapsulation of the port I/O
22  * used on some machine architectures.  Each object of this class represents a single I/O port which can be read from and written to
23  * in various sizes.  Each port can be held by one object only at a time. */
24
25 #include "edi_objects.h"
26
27 /*! \brief Macro to create methods for reading from ports.
28  *
29  * This macro creates four similar methods, differing in the size of the type they read from the I/O port held by the object.  Their
30  * parameter is a pointer to the output type, which is filled with the value read from the I/O port.  They return 1 for success, -1
31  * for an uninitialized I/O port object, and 0 for other errors. */
32 #define port_read_method(type,name) int32_t (*name)(object_pointer port_object, type *out)
33 /*! \brief Macro to create methods for writing to ports.
34  *
35  * This macro creates four more similar methods, differing in the size of the type they write to the I/O port held by the object.
36  * Their parameter is the value to write to the port.  They return 1 for success, -1 for an uninitialized I/O port object and 0 for
37  * other errors. */
38 #define port_write_method(type,name) int32_t (*name)(object_pointer port_object, type in)
39
40 /*! \brief Name of EDI I/O port class. (Constant)
41  *
42  * A CPP constant with the value of #io_port_class */
43 #define IO_PORT_CLASS   "EDI-IO-PORT"
44 /*! \brief Name of EDI I/O port class.
45  *
46  * An edi_string_t containing the class name "EDI-IO-PORT". */
47 #if defined(EDI_MAIN_FILE) || defined(IMPLEMENTING_EDI)
48 const edi_string_t io_port_class = IO_PORT_CLASS;
49 #else
50 extern const edi_string_t io_port_class;
51 #endif
52
53 #ifndef IMPLEMENTING_EDI
54 /*! \brief int32_t EDI-IO-PORT.init_io_port(unsigned int16_t port);
55  *
56  * This method takes an unsigned int16_t representing a particular I/O port and initializes the invoked EDI-IO-PORT object with it.
57  * The method returns 1 if successful, -1 if the I/O port could not be obtained for the object, and 0 for all other errors. */
58 EDI_DEFVAR int32_t (*init_io_port)(object_pointer port_object, uint16_t port);
59 /*! \brief Get the port number from a port object. */
60 EDI_DEFVAR uint16_t (*get_port_number)(object_pointer port);
61 /*! \brief Method created by port_read_method() in order to read bytes (int8s) from I/O ports. */
62 EDI_DEFVAR int32_t (*read_byte_io_port)(object_pointer port_object, int8_t *out);
63 /*! \brief Method created by port_read_method() in order to read words (int16s) from I/O ports. */
64 EDI_DEFVAR int32_t (*read_word_io_port)(object_pointer port_object, int16_t *out);
65 /*! \brief Method created by port_read_method() in order to read longwords (int32s) from I/O ports. */
66 EDI_DEFVAR int32_t (*read_long_io_port)(object_pointer port_object, int32_t *out);
67 /*! \brief Method created by port_read_method() in order to read long longwords (int64s) from I/O ports. */
68 EDI_DEFVAR int32_t (*read_longlong_io_port)(object_pointer port_object,int64_t *out);
69 /*! \brief Method of EDI-IO-PORT to read long strings of data from I/O ports.
70  *
71  * Reads arbitrarily long strings of data from the given I/O port.  Returns 1 for success, -1 for an uninitialized port object, -2
72  * for a bad pointer to the destination buffer, and 0 for all other errors. */
73 EDI_DEFVAR int32_t (*read_string_io_port)(object_pointer port_object, uint32_t data_length, uint8_t *out);
74 /*! \brief Method created by port_write_method() in order to write bytes (int8s) to I/O ports. */
75 EDI_DEFVAR int32_t (*write_byte_io_port)(object_pointer port_object, int8_t in);
76 /*! \brief Method created by port_write_method() in order to write words (int16s) to I/O ports. */
77 EDI_DEFVAR int32_t (*write_word_io_port)(object_pointer port_object, int16_t in);
78 /*! \brief Method created by port_write_method() in order to write longwords (int32s) to I/O ports. */
79 EDI_DEFVAR int32_t (*write_long_io_port)(object_pointer port_object, int32_t in);
80 /*! \brief Method created by port_write_method() in order to write long longwords (int64s) to I/O ports. */
81 EDI_DEFVAR int32_t (*write_longlong_io_port)(object_pointer port_object, int64_t in);
82 /*! \brief Method of EDI-IO-PORT to write long strings of data to I/O ports.
83  *
84  * Writes arbitrarily long strings of data to the given I/O port.  Returns 1 for success, -1 for an uninitialized port object, -2
85  * for a bad pointer to the source buffer, and 0 for all other errors. */
86 EDI_DEFVAR int32_t (*write_string_io_port)(object_pointer port_object, uint32_t data_length, uint8_t *in);
87
88 #endif // defined(IMPLEMENTING_EDI)
89
90 #endif

UCC git Repository :: git.ucc.asn.au