Browse Source

Doxygenation

tags/v0.9.3
Michael Brown 19 years ago
parent
commit
bf32da87f0
2 changed files with 138 additions and 36 deletions
  1. 59
    32
      src/core/console.c
  2. 79
    4
      src/include/console.h

+ 59
- 32
src/core/console.c View File

@@ -1,31 +1,24 @@
1
-/*
2
- * Central console switch.  Various console devices can be selected
3
- * via the build options CONSOLE_FIRMWARE, CONSOLE_SERIAL etc.
4
- * config.c picks up on these definitions and drags in the relevant
5
- * objects.  The linker compiles the console_drivers table for us; we
6
- * simply delegate to each console_driver that we find in the table.
7
- *
8
- * Doing it this way allows for changing CONSOLE_XXX without
9
- * rebuilding anything other than config.o.  This is extremely useful
10
- * for rom-o-matic.
11
- */
12
-
13 1
 #include "stddef.h"
14 2
 #include "console.h"
15 3
 
16
-/* FIXME: we need a cleaner way to pick up cpu_nap().  It makes a
17
- * real-mode call, and so we don't want to use it with LinuxBIOS.
18
- */
4
+/** @file */
5
+
19 6
 #include "bios.h"
20 7
 
21 8
 static struct console_driver console_drivers[0] __table_start ( console );
22 9
 static struct console_driver console_drivers_end[0] __table_end ( console );
23 10
 
24
-/*****************************************************************************
25
- * putchar : write a single character to each console
26
- *****************************************************************************
11
+/**
12
+ * Write a single character to each console device.
13
+ *
14
+ * @v character		Character to be written
15
+ * @ret None
16
+ * @err None
17
+ *
18
+ * The character is written out to all enabled console devices, using
19
+ * each device's console_driver::putchar() method.
20
+ *
27 21
  */
28
-
29 22
 void putchar ( int character ) {
30 23
 	struct console_driver *console;
31 24
 
@@ -40,10 +33,18 @@ void putchar ( int character ) {
40 33
 	}
41 34
 }
42 35
 
43
-/*****************************************************************************
44
- * has_input : check to see if any input is available on any console,
45
- * and return a pointer to the console device if so
46
- *****************************************************************************
36
+/**
37
+ * Check to see if any input is available on any console.
38
+ *
39
+ * @v None
40
+ * @ret console		Console device that has input available, if any.
41
+ * @ret NULL		No console device has input available.
42
+ * @err None
43
+ *
44
+ * All enabled console devices are checked once for available input
45
+ * using each device's console_driver::iskey() method.  The first
46
+ * console device that has available input will be returned, if any.
47
+ *
47 48
  */
48 49
 static struct console_driver * has_input ( void ) {
49 50
 	struct console_driver *console;
@@ -58,13 +59,30 @@ static struct console_driver * has_input ( void ) {
58 59
 	return NULL;
59 60
 }
60 61
 
61
-/*****************************************************************************
62
- * getchar : read a single character from any console
62
+/**
63
+ * Read a single character from any console.
64
+ *
65
+ * @v None
66
+ * @ret character	Character read from a console.
67
+ * @err None
68
+ *
69
+ * A character will be read from the first enabled console device that
70
+ * has input available using that console's console_driver::getchar()
71
+ * method.  If no console has input available to be read, this method
72
+ * will block.  To perform a non-blocking read, use something like
73
+ *
74
+ * @code
75
+ *
76
+ *   int key = iskey() ? getchar() : -1;
77
+ *
78
+ * @endcode
79
+ *
80
+ * The character read will not be echoed back to any console.
81
+ *
82
+ * @bug We need a cleaner way to pick up cpu_nap().  It makes a
83
+ * real-mode call, and so we don't want to use it with LinuxBIOS.
63 84
  *
64
- * NOTE : this function does not echo the character, and it does block
65
- *****************************************************************************
66 85
  */
67
-
68 86
 int getchar ( void ) {
69 87
 	struct console_driver *console;
70 88
 	int character = 256;
@@ -92,11 +110,20 @@ int getchar ( void ) {
92 110
 	return character;
93 111
 }
94 112
 
95
-/*****************************************************************************
96
- * iskey : check to see if any input is available on any console
97
- *****************************************************************************
113
+/** Check for available input on any console.
114
+ *
115
+ * @v None
116
+ * @ret True		Input is available on a console
117
+ * @ret False		Input is not available on any console
118
+ * @err None
119
+ *
120
+ * All enabled console devices are checked once for available input
121
+ * using each device's console_driver::iskey() method.  If any console
122
+ * device has input available, this call will return True.  If this
123
+ * call returns True, you can then safely call getchar() without
124
+ * blocking.
125
+ *
98 126
  */
99
-
100 127
 int iskey ( void ) {
101 128
 	return has_input() ? 1 : 0;
102 129
 }

+ 79
- 4
src/include/console.h View File

@@ -5,19 +5,94 @@
5 5
 #include "vsprintf.h"
6 6
 #include "tables.h"
7 7
 
8
-/*
9
- * Consoles that cannot be used before their INIT_FN() has completed
10
- * should set disabled = 1 initially.  This allows other console
11
- * devices to still be used to print out early debugging messages.
8
+/** @file
9
+ *
10
+ * User interaction.
11
+ *
12
+ * Various console devices can be selected via the build options
13
+ * CONSOLE_FIRMWARE, CONSOLE_SERIAL etc.  The console functions
14
+ * putchar(), getchar() and iskey() delegate to the individual console
15
+ * drivers.
16
+ *
12 17
  */
13 18
 
19
+/**
20
+ * A console driver
21
+ *
22
+ * Defines the functions that implement a particular console type.
23
+ * Must be made part of the console drivers table by using
24
+ * #__console_driver.
25
+ *
26
+ * @note Consoles that cannot be used before their INIT_FN() has
27
+ * completed should set #disabled=1 initially.  This allows other
28
+ * console devices to still be used to print out early debugging
29
+ * messages.
30
+ *
31
+ */
14 32
 struct console_driver {
33
+	/** Console is disabled.
34
+	 *
35
+	 * The console's putchar(), getchar() and iskey() methods will
36
+	 * not be called while #disabled==1.  Typically the
37
+	 * console's initialisation functions (called via INIT_FN())
38
+	 * will set #disabled=0 upon completion.
39
+	 *
40
+	 */
15 41
 	int disabled;
42
+
43
+	/** Write a character to the console.
44
+	 *
45
+	 * @v character		Character to be written
46
+	 * @ret None
47
+	 * @err None
48
+	 *
49
+	 */
16 50
 	void ( *putchar ) ( int character );
51
+
52
+	/** Read a character from the console.
53
+	 *
54
+	 * @v None
55
+	 * @ret character	Character read
56
+	 * @err None
57
+	 *
58
+	 * If no character is available to be read, this method will
59
+	 * block.  The character read should not be echoed back to the
60
+	 * console.
61
+	 *
62
+	 */
17 63
 	int ( *getchar ) ( void );
64
+
65
+	/** Check for available input.
66
+	 *
67
+	 * @v None
68
+	 * @ret True		Input is available
69
+	 * @ret False		Input is not available
70
+	 * @err None
71
+	 *
72
+	 * This should return True if a subsequent call to getchar()
73
+	 * will not block.
74
+	 *
75
+	 */
18 76
 	int ( *iskey ) ( void );
19 77
 };
20 78
 
79
+/**
80
+ * Mark a <tt> struct console_driver </tt> as being part of the
81
+ * console drivers table.
82
+ *
83
+ * Use as e.g.
84
+ *
85
+ * @code
86
+ *
87
+ *   struct console_driver my_console __console_driver = {
88
+ *      .putchar = my_putchar,
89
+ *	.getchar = my_getchar,
90
+ *	.iskey = my_iskey,
91
+ *   };
92
+ *
93
+ * @endcode
94
+ *
95
+ */
21 96
 #define __console_driver __table ( console, 01 )
22 97
 
23 98
 /* Function prototypes */

Loading…
Cancel
Save