[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH] CDI CMOS code added, floppy driver updated accordingly
From: Matthew Iselin <matthewi@mattpc-vbox1.(none)>
Signed-off-by: Matthew Iselin <matthewi@mattpc-vbox1.(none)>
---
src/modules/cdi/floppy/device.c | 24 +++++++++++++++++-----
src/modules/cdi/include/cdi/cmos.h | 38 ++++++++++++++++++++++++++++++++++++
src/modules/cdi/lib/cmos.c | 31 +++++++++++++++++++++++++++++
3 files changed, 87 insertions(+), 6 deletions(-)
mode change 100644 => 100755 src/modules/cdi/floppy/device.c
create mode 100755 src/modules/cdi/include/cdi/cmos.h
create mode 100644 src/modules/cdi/lib/cmos.c
diff --git a/src/modules/cdi/floppy/device.c b/src/modules/cdi/floppy/device.c
old mode 100644
new mode 100755
index c88a875..de66090
--- a/src/modules/cdi/floppy/device.c
+++ b/src/modules/cdi/floppy/device.c
@@ -34,6 +34,7 @@
#include "cdi/misc.h"
#include "cdi/io.h"
#include "cdi/dma.h"
+#include "cdi/cmos.h"
#include "device.h"
@@ -473,7 +474,7 @@ static int floppy_drive_sector_read(struct floppy_device* device, uint32_t lba,
uint8_t sector;
uint8_t cylinder;
uint8_t head;
- uint8_t status;
+ uint8_t status = 0;
uint8_t data;
struct cdi_dma_handle dma_handle;
@@ -540,7 +541,7 @@ static int floppy_drive_sector_read(struct floppy_device* device, uint32_t lba,
// IRQ bestaetigen
floppy_drive_int_sense(device);
floppy_reset_irqcnt(device);
- floppy_read_data(device, buffer + bytes_done++);
+ floppy_read_data(device, (uint8_t*) buffer + bytes_done++);
}
}
@@ -600,7 +601,7 @@ static int floppy_drive_sector_write(struct floppy_device* device, uint32_t lba,
uint8_t sector;
uint8_t cylinder;
uint8_t head;
- uint8_t status;
+ uint8_t status = 0;
uint8_t data;
struct cdi_dma_handle dma_handle;
@@ -701,7 +702,18 @@ static int floppy_drive_sector_write(struct floppy_device* device, uint32_t lba,
*/
int floppy_device_probe(struct floppy_device* device)
{
- return 1;
+ // Read floppy presence from CMOS
+ uint8_t t = cdi_cmos_read(0x10);
+
+ // Each nibble contains information about the device type
+ if(device->id == 0) {
+ return (t >> 4);
+ }
+ else if(device->id == 1){
+ return (t & 0xF);
+ }
+
+ return 0;
}
/**
@@ -818,7 +830,7 @@ int floppy_read_blocks(struct cdi_storage_device* dev, uint64_t block,
// Wenn das schief geht, wird mehrmals probiert
for (j = 0; (j < 5) && (result != 0); j++) {
result = floppy_drive_sector_read(device, (uint32_t) block + i,
- buffer + i * dev->block_size);
+ (char*) buffer + i * dev->block_size);
}
}
@@ -843,7 +855,7 @@ int floppy_write_blocks(struct cdi_storage_device* dev, uint64_t block,
// Wenn das schief geht, wird mehrmals probiert
for (j = 0; (j < 5) && (result != 0); j++) {
result = floppy_drive_sector_write(device, (uint32_t) block + i,
- buffer + i * dev->block_size);
+ (char*) buffer + i * dev->block_size);
}
}
diff --git a/src/modules/cdi/include/cdi/cmos.h b/src/modules/cdi/include/cdi/cmos.h
new file mode 100755
index 0000000..c16547c
--- /dev/null
+++ b/src/modules/cdi/include/cdi/cmos.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2008 Matthew Iselin
+ *
+ * This program is free software. It comes without any warranty, to
+ * the extent permitted by applicable law. You can redistribute it
+ * and/or modify it under the terms of the Do What The Fuck You Want
+ * To Public License, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/projects/COPYING.WTFPL for more details.
+ */
+
+#ifndef _CDI_CMOS_H_
+#define _CDI_CMOS_H_
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Performs CMOS reads
+ * @param index Index within CMOS RAM to read from.
+ * @return Result of reading CMOS RAM at specified index.
+ */
+uint8_t cdi_cmos_read(uint8_t index);
+
+/**
+ * Performs CMOS writes
+ * @param index Index within CMOS RAM to write to.
+ * @param value Value to write to the CMOS
+ */
+void cdi_cmos_write(uint8_t index, uint8_t value);
+
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
+#endif
diff --git a/src/modules/cdi/lib/cmos.c b/src/modules/cdi/lib/cmos.c
new file mode 100644
index 0000000..eee3fad
--- /dev/null
+++ b/src/modules/cdi/lib/cmos.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008 Matthew Iselin
+ *
+ * This program is free software. It comes without any warranty, to
+ * the extent permitted by applicable law. You can redistribute it
+ * and/or modify it under the terms of the Do What The Fuck You Want
+ * To Public License, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/projects/COPYING.WTFPL for more details.
+ */
+
+#include <cdi/bios.h>
+#include <syscall.h>
+#include <stdlib.h>
+
+/**
+ * Performs CMOS reads
+ * @param index Index within CMOS RAM to read from.
+ * @return Result of reading CMOS RAM at specified index.
+ */
+uint8_t cdi_cmos_read(uint8_t index) {
+ return 0;
+}
+
+/**
+ * Performs CMOS writes
+ * @param index Index within CMOS RAM to write to.
+ * @param value Value to write to the CMOS
+ */
+void cdi_cmos_write(uint8_t index, uint8_t value) {
+}
+
--
1.5.6.3