summaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-05-05 09:54:48 -0400
committerFreya Murphy <freya@freyacat.org>2025-05-05 09:58:20 -0400
commit592c6992c7ea0c2e4cbea79fadb1c845f2fc050e (patch)
tree5d98b664749b67eb20d7fc279ff36bcf44843f21 /kernel/include
parentoff by one (diff)
downloadcomus-592c6992c7ea0c2e4cbea79fadb1c845f2fc050e.tar.gz
comus-592c6992c7ea0c2e4cbea79fadb1c845f2fc050e.tar.bz2
comus-592c6992c7ea0c2e4cbea79fadb1c845f2fc050e.zip
pc spkr
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/comus/drivers/pit.h14
-rw-r--r--kernel/include/comus/drivers/ps2.h13
-rw-r--r--kernel/include/comus/drivers/spkr.h29
-rw-r--r--kernel/include/lib/klib.h5
4 files changed, 59 insertions, 2 deletions
diff --git a/kernel/include/comus/drivers/pit.h b/kernel/include/comus/drivers/pit.h
index 77f0a14..22b8153 100644
--- a/kernel/include/comus/drivers/pit.h
+++ b/kernel/include/comus/drivers/pit.h
@@ -9,13 +9,23 @@
#ifndef PIT_H_
#define PIT_H_
+#define CHAN_TIMER 0x40
+#define CHAN_SPKR 0x42
+
#include <stdint.h>
// how many time the pit has ticked
// not accurate time, good for spinning though
extern volatile uint64_t ticks;
-uint16_t pit_read_divider(void);
-void pit_set_divider(uint16_t count);
+/**
+ * Read timer frequency
+ */
+uint32_t pit_read_freq(uint8_t chan);
+
+/**
+ * Set timer frequency
+ */
+void pit_set_freq(uint8_t chan, uint32_t hz);
#endif
diff --git a/kernel/include/comus/drivers/ps2.h b/kernel/include/comus/drivers/ps2.h
index 7634e5f..c012ad4 100644
--- a/kernel/include/comus/drivers/ps2.h
+++ b/kernel/include/comus/drivers/ps2.h
@@ -9,6 +9,8 @@
#ifndef PS2_H_
#define PS2_H_
+#include <stdint.h>
+
/**
* Initalize the ps2 controller
*/
@@ -24,4 +26,15 @@ void ps2kb_recv(void);
*/
void ps2mouse_recv(void);
+/**
+ * Set ps2 led state
+ *
+ * Bits
+ * ----
+ * 0 - Scroll lock
+ * 1 - Num Lock
+ * 2 - Caps lock
+ */
+int ps2_set_leds(uint8_t state);
+
#endif /* ps2.h */
diff --git a/kernel/include/comus/drivers/spkr.h b/kernel/include/comus/drivers/spkr.h
new file mode 100644
index 0000000..f9e427e
--- /dev/null
+++ b/kernel/include/comus/drivers/spkr.h
@@ -0,0 +1,29 @@
+/**
+ * @file spkr.h
+ *
+ * @author Freya Murphy <freya@freyacat.org>
+ *
+ * PC Speaker
+ */
+
+#ifndef SPKR_H_
+#define SPKR_H_
+
+#include <stdint.h>
+
+/**
+ * Play a tone on the pc speaker continuously
+ */
+void spkr_play_tone(uint32_t hz);
+
+/**
+ * Shut up the pc speaker
+ */
+void spkr_quiet(void);
+
+/**
+ * Beep the pc speaker for a short period
+ */
+void spkr_beep(void);
+
+#endif /* spkr.h */
diff --git a/kernel/include/lib/klib.h b/kernel/include/lib/klib.h
index b4d26ed..f549a09 100644
--- a/kernel/include/lib/klib.h
+++ b/kernel/include/lib/klib.h
@@ -264,6 +264,11 @@ __attribute__((noreturn, format(printf, 3, 4))) void
__panic(unsigned int line, const char *file, const char *format, ...);
/**
+ * Loop kernel in fatal notifier (beep and blink caps lock key)
+ */
+__attribute__((noreturn)) void fatal_loop(void);
+
+/**
* Fill dst with a stack trace consisting of return addresses in order
* from top to bottom
*