Adding preliminary bus drivers

This commit is contained in:
Gregory Kenneth Bowne 2023-07-15 15:13:47 -07:00
parent 3c103367d0
commit 7cc909d389
14 changed files with 447 additions and 0 deletions

32
src/drivers/audio/audio.c Normal file
View File

@ -0,0 +1,32 @@
#include "audio.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Audio controller base address
#define AUDIO_BASE_ADDRESS 0x0000
// Audio controller data port
#define AUDIO_DATA_PORT 0x00
// Audio controller command port
#define AUDIO_COMMAND_PORT 0x01
// Initialize the audio driver
void audio_init()
{
// Add any necessary initialization code here
}
// Play audio from a buffer
void audio_play(const uint8_t *buffer, size_t size)
{
// Add any necessary code to play audio from the buffer here
}
// Stop audio playback
void audio_stop()
{
// Add any necessary code to stop audio playback here
}

17
src/drivers/audio/audio.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef AUDIO_H
#define AUDIO_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Initialize the audio driver
void audio_init();
// Play audio from a buffer
void audio_play(const uint8_t* buffer, size_t size);
// Stop audio playback
void audio_stop();
#endif

44
src/drivers/bus/eisa.c Normal file
View File

@ -0,0 +1,44 @@
#include "eisa.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// EISA bus controller base address
#define EISA_BASE_ADDRESS 0x0000
// EISA bus controller data port
#define EISA_DATA_PORT 0x00
// EISA bus controller command port
#define EISA_COMMAND_PORT 0x01
// Initialize the EISA bus
void eisa_init()
{
// Add any necessary initialization code here
}
// Detect and configure EISA devices
void eisa_detect_devices()
{
// Add any necessary device detection and configuration code here
}
// Read from an EISA device
uint8_t eisa_read(uint16_t port)
{
uint8_t value;
// Read from the specified port
__asm__ volatile("inb %1, %0" : "=a"(value) : "dN"(port));
return value;
}
// Write to an EISA device
void eisa_write(uint16_t port, uint8_t value)
{
// Write the specified value to the specified port
__asm__ volatile("outb %0, %1" : : "a"(value), "dN"(port));
}

20
src/drivers/bus/eisa.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef EISA_H
#define EISA_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Initialize the EISA bus
void eisa_init();
// Detect and configure EISA devices
void eisa_detect_devices();
// Read from an EISA device
uint8_t eisa_read(uint16_t port);
// Write to an EISA device
void eisa_write(uint16_t port, uint8_t value);
#endif

44
src/drivers/bus/isa.c Normal file
View File

@ -0,0 +1,44 @@
#include "isa.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// ISA bus controller base address
#define ISA_BASE_ADDRESS 0x0000
// ISA bus controller data port
#define ISA_DATA_PORT 0x00
// ISA bus controller command port
#define ISA_COMMAND_PORT 0x01
// Initialize the ISA bus
void isa_init()
{
// Add any necessary initialization code here
}
// Detect and configure ISA devices
void isa_detect_devices()
{
// Add any necessary device detection and configuration code here
}
// Read from an ISA device
uint8_t isa_read(uint16_t port)
{
uint8_t value;
// Read from the specified port
__asm__ volatile("inb %1, %0" : "=a"(value) : "dN"(port));
return value;
}
// Write to an ISA device
void isa_write(uint16_t port, uint8_t value)
{
// Write the specified value to the specified port
__asm__ volatile("outb %0, %1" : : "a"(value), "dN"(port));
}

20
src/drivers/bus/isa.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef ISA_H
#define ISA_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Initialize the ISA bus
void isa_init();
// Detect and configure ISA devices
void isa_detect_devices();
// Read from an ISA device
uint8_t isa_read(uint16_t port);
// Write to an ISA device
void isa_write(uint16_t port, uint8_t value);
#endif

44
src/drivers/bus/mca.c Normal file
View File

@ -0,0 +1,44 @@
#include "mca.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// MCA bus controller base address
#define MCA_BASE_ADDRESS 0x0000
// MCA bus controller data port
#define MCA_DATA_PORT 0x00
// MCA bus controller command port
#define MCA_COMMAND_PORT 0x01
// Initialize the MCA bus
void mca_init()
{
// Add any necessary initialization code here
}
// Detect and configure MCA devices
void mca_detect_devices()
{
// Add any necessary device detection and configuration code here
}
// Read from an MCA device
uint8_t mca_read(uint16_t port)
{
uint8_t value;
// Read from the specified port
__asm__ volatile("inb %1, %0" : "=a"(value) : "dN"(port));
return value;
}
// Write to an MCA device
void mca_write(uint16_t port, uint8_t value)
{
// Write the specified value to the specified port
__asm__ volatile("outb %0, %1" : : "a"(value), "dN"(port));
}

20
src/drivers/bus/mca.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef MCA_H
#define MCA_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Initialize the MCA bus
void mca_init();
// Detect and configure MCA devices
void mca_detect_devices();
// Read from an MCA device
uint8_t mca_read(uint16_t port);
// Write to an MCA device
void mca_write(uint16_t port, uint8_t value);
#endif

44
src/drivers/bus/pci.c Normal file
View File

@ -0,0 +1,44 @@
#include "pci.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// PCI bus controller base address
#define PCI_BASE_ADDRESS 0x0000
// PCI bus controller data port
#define PCI_DATA_PORT 0x00
// PCI bus controller command port
#define PCI_COMMAND_PORT 0x01
// Initialize the PCI bus
void pci_init()
{
// Add any necessary initialization code here
}
// Detect and configure PCI devices
void pci_detect_devices()
{
// Add any necessary device detection and configuration code here
}
// Read from a PCI device
uint8_t pci_read(uint16_t port)
{
uint8_t value;
// Read from the specified port
__asm__ volatile("inb %1, %0" : "=a"(value) : "dN"(port));
return value;
}
// Write to a PCI device
void pci_write(uint16_t port, uint8_t value)
{
// Write the specified value to the specified port
__asm__ volatile("outb %0, %1" : : "a"(value), "dN"(port));
}

20
src/drivers/bus/pci.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef PCI_H
#define PCI_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Initialize the PCI bus
void pci_init();
// Detect and configure PCI devices
void pci_detect_devices();
// Read from a PCI device
uint8_t pci_read(uint16_t port);
// Write to a PCI device
void pci_write(uint16_t port, uint8_t value);
#endif

44
src/drivers/bus/vesa.c Normal file
View File

@ -0,0 +1,44 @@
#include "vesa.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// VESA bus controller base address
#define VESA_BASE_ADDRESS 0x0000
// VESA bus controller data port
#define VESA_DATA_PORT 0x00
// VESA bus controller command port
#define VESA_COMMAND_PORT 0x01
// Initialize the VESA bus
void vesa_init()
{
// Add any necessary initialization code here
}
// Detect and configure VESA devices
void vesa_detect_devices()
{
// Add any necessary device detection and configuration code here
}
// Read from a VESA device
uint8_t vesa_read(uint16_t port)
{
uint8_t value;
// Read from the specified port
__asm__ volatile("inb %1, %0" : "=a"(value) : "dN"(port));
return value;
}
// Write to a VESA device
void vesa_write(uint16_t port, uint8_t value)
{
// Write the specified value to the specified port
__asm__ volatile("outb %0, %1" : : "a"(value), "dN"(port));
}

20
src/drivers/bus/vesa.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef VESA_H
#define VESA_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Initialize the VESA bus
void vesa_init();
// Detect and configure VESA devices
void vesa_detect_devices();
// Read from a VESA device
uint8_t vesa_read(uint16_t port);
// Write to a VESA device
void vesa_write(uint16_t port, uint8_t value);
#endif

View File

@ -0,0 +1,51 @@
#include "display.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Display controller base address
#define DISPLAY_BASE_ADDRESS 0x0000
// Display controller data port
#define DISPLAY_DATA_PORT 0x00
// Display controller command port
#define DISPLAY_COMMAND_PORT 0x01
// Initialize the display driver
void display_init()
{
// Add any necessary initialization code here
}
// Set the display mode
void display_set_mode(uint32_t width, uint32_t height, uint32_t bpp)
{
// Add any necessary code to set the display mode here
}
// Draw a pixel at the specified coordinates
void display_draw_pixel(uint32_t x, uint32_t y, uint32_t color)
{
// Add any necessary code to draw a pixel here
}
// Clear the display with the specified color
void display_clear(uint32_t color)
{
// Add any necessary code to clear the display here
}
// Draw a character at the specified coordinates
void display_draw_char(uint32_t x, uint32_t y, char c, uint32_t color)
{
// Add any necessary code to draw a character here
}
// Draw a string at the specified coordinates
void display_draw_string(uint32_t x, uint32_t y, const char *str,
uint32_t color)
{
// Add any necessary code to draw a string here
}

View File

@ -0,0 +1,27 @@
#ifndef DISPLAY_H
#define DISPLAY_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Initialize the display driver
void display_init();
// Set the display mode
void display_set_mode(uint32_t width, uint32_t height, uint32_t bpp);
// Draw a pixel at the specified coordinates
void display_draw_pixel(uint32_t x, uint32_t y, uint32_t color);
// Clear the display with the specified color
void display_clear(uint32_t color);
// Draw a character at the specified coordinates
void display_draw_char(uint32_t x, uint32_t y, char c, uint32_t color);
// Draw a string at the specified coordinates
void display_draw_string(uint32_t x, uint32_t y, const char *str,
uint32_t color);
#endif