summaryrefslogtreecommitdiff
path: root/src/arch/amd64/drivers
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/arch/amd64/drivers/bochs.c (renamed from src/arch/amd64/fb.c)34
-rw-r--r--src/arch/amd64/drivers/pci.c (renamed from src/arch/amd64/pci.c)2
-rw-r--r--src/arch/amd64/drivers/pic.c (renamed from src/arch/amd64/pic.c)2
-rw-r--r--src/arch/amd64/drivers/pic.h (renamed from src/arch/amd64/pic.h)0
-rw-r--r--src/arch/amd64/drivers/serial.c (renamed from src/arch/amd64/serial.c)3
5 files changed, 13 insertions, 28 deletions
diff --git a/src/arch/amd64/fb.c b/src/arch/amd64/drivers/bochs.c
index 8560166..5383213 100644
--- a/src/arch/amd64/fb.c
+++ b/src/arch/amd64/drivers/bochs.c
@@ -3,8 +3,9 @@
#include <stdint.h>
#include <panic.h>
#include <pci.h>
+#include <bochs.h>
-#include "bindings.h"
+#include "../bindings.h"
#define INDEX 0x1CE
#define DATA 0x1CF
@@ -52,38 +53,21 @@ static void set_mode(uint16_t width, uint16_t height, uint16_t bit_depth, int lf
(clear ? 0 : DATA_NO_CLEAR_MEM));
}
-//static void set_bank(uint16_t bank) {
-// write(INDEX_BANK, bank);
-//}
+uint32_t* bochs_init(uint16_t width, uint16_t height, uint8_t bit_depth) {
-int fb_init(uint16_t width, uint16_t height) {
-
- set_mode(width, height, 32, true, true);
+ set_mode(width, height, bit_depth, true, true);
if (!is_available())
- panic("bochs framebuffer not avaliable");
+ return NULL;
struct pci_device bochs = {0};
bool found = pci_findby_id(&bochs, BOCHS_PCI_DEVICE, BOCHS_PCI_VENDOR, NULL);
if (!found)
- panic("bochs pci device not avaliable");
+ return NULL;
uint32_t bar0 = pci_rcfg_d(bochs, PCI_BAR0_D);
- uint32_t *fb = (uint32_t*) (uintptr_t) bar0;
- fb = mmap(fb, width * height * 4);
-
- for (uint16_t y = 0; y < height; y++) {
- for (uint16_t x = 0; x < width; x++) {
- double dx = x / (double) width,
- dy = y / (double) height,
- dz = (2 - dx - dy) / 2;
- uint32_t r = (uint32_t)(dx * 255),
- g = (uint32_t)(dy * 255),
- b = (uint32_t)(dz * 255);
- fb[x + y * width] = (b << 0) | (g << 8) | (r << 16);
- }
- }
-
+ uint32_t *addr = (uint32_t*) (uintptr_t) bar0;
+ addr = mmap(addr, width * height * bit_depth);
- return 0;
+ return addr;
}
diff --git a/src/arch/amd64/pci.c b/src/arch/amd64/drivers/pci.c
index 7b30f0e..410eb7e 100644
--- a/src/arch/amd64/pci.c
+++ b/src/arch/amd64/drivers/pci.c
@@ -3,7 +3,7 @@
#include <panic.h>
#include <lib.h>
-#include "bindings.h"
+#include "../bindings.h"
#define CONF_ADDR 0xCF8
#define CONF_DATA 0xCFC
diff --git a/src/arch/amd64/pic.c b/src/arch/amd64/drivers/pic.c
index c25856b..be7716f 100644
--- a/src/arch/amd64/pic.c
+++ b/src/arch/amd64/drivers/pic.c
@@ -1,4 +1,4 @@
-#include "bindings.h"
+#include "../bindings.h"
#include "pic.h"
#define PIC1 0x20 /* IO base address for master PIC */
diff --git a/src/arch/amd64/pic.h b/src/arch/amd64/drivers/pic.h
index 2a4670e..2a4670e 100644
--- a/src/arch/amd64/pic.h
+++ b/src/arch/amd64/drivers/pic.h
diff --git a/src/arch/amd64/serial.c b/src/arch/amd64/drivers/serial.c
index fe21629..b9e351e 100644
--- a/src/arch/amd64/serial.c
+++ b/src/arch/amd64/drivers/serial.c
@@ -1,5 +1,6 @@
#include <serial.h>
-#include "bindings.h"
+
+#include "../bindings.h"
#define PORT 0x3F8