--
047d7b41cc5cd5d441051a33ae0e
Content-Type: text/plain; charset=UTF-8
update to platform-coco3:
* now does IDE via blkdev
* shared dragon-nx32's ide transfer routine(s)
* (re)implements mbr.c for coco's partitioning scheme
--
Brett M. Gordon,
beretta42@gmail.com
<div dir="ltr"><div>update to platform-coco3:</div><div><br></div><div>* now does IDE via blkdev</div><div>* shared dragon-nx32's ide transfer routine(s)</div><div>* (re)implements mbr.c for coco's partitioning scheme</div><div><br></div><div><br></div>-- <br><div class="gmail_signature">Brett M. Gordon,<br><a href="mailto:beretta42@gmail.com" target="_blank">beretta42@gmail.com</a></div>
</div>
-CSRCS = devtty.c ttydw.c
+CSRCS = devtty.c ttydw.c mbr.c
CSRCS += devices.c main.c libc.c
-DSRCS = ../dev/devdw.c
+DSRCS = ../dev/devdw.c ../dev/blkdev.c ../dev/devide.c
+DSRCS += ../dev/devide_discard.c
-ASRCS = coco3.s crt0.s
+ASRCS = coco3.s crt0.s ../platform-dragon-nx32/ide.s
ASRCS += tricks.s commonmem.s usermem_gime.s drivewire.s
COBJS = $(CSRCS:.c=$(BINEXT))
AOBJS = $(ASRCS:.s=$(BINEXT))
-DOBJS = devdw.o
+DOBJS = devdw.o blkdev.o devide.o devide_discard.o
OBJS = $(COBJS) $(AOBJS) $(DOBJS)
CROSS_CCOPTS += -I../dev/
-JUNK = $(CSRCS:.c=.o) $(ASRCS:.s=.o)
+JUNK = $(CSRCS:.c=.o) $(ASRCS:.s=.o) $(DSRCS:.c=.o)
all: $(OBJS)
crt0.o commonmem.o \
coco3.o ../start.o ../version.o ../lowlevel-6809.o \
tricks.o main.o ../timer.o ../kdata.o devices.o \
- drivewire.o devdw.o ttydw.o \
+ drivewire.o devdw.o ttydw.o blkdev.o mbr.o devide.o devide_discard.o \
+ ../platform-dragon-nx32/ide.o \
../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \
../syscall_proc.o ../syscall_other.o ../mm.o ../bank16k.o ../swap.o \
../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o ../syscall_exec16.o \
#define NUM_DEV_TTY 10
#define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */
#define NBUFS 6 /* Number of block buffers */
-#define NMOUNTS 2 /* Number of mounts at a time - nothing mountable! */
+#define NMOUNTS 4 /* Number of mounts at a time - nothing mountable! */
#define CONFIG_COCO_KBD /* Use CoCo key maps rather than Dragon */
#define DW_VWIN_NUM 4 /* No of Virtual Window Ports */
#define DW_MIN_OFF 3 /* Minor number offset */
+/* Block device define */
+#define MAX_BLKDEV 2 /* IDE */
+#define DEVICE_IDE /* enable if IDE interface present */
+#define IDE_REG_CS1_BASE 0xFF50
+#define IDE_IS_MMIO 1 /* MMIO IDE */
#include <tty.h>
#include <vt.h>
#include <devtty.h>
+#include <blkdev.h>
struct devsw dev_tab[] = /* The device driver switch table */
{
// minor open close read write ioctl
// -----------------------------------------------------------------
- /* 0: /dev/fd Floppy disc block devices */
- { nxio_open, no_close, no_rdwr, no_rdwr, no_ioctl },
- /* 1: /dev/hd Hard disc block devices (absent) */
+ /* 0: /dev/hd Hard disc block devices (absent) */
+ { blkdev_open, no_close, blkdev_read, blkdev_write, blkdev_ioctl },
+ /* 1: /dev/fd Floppy disc block devices */
{ nxio_open, no_close, no_rdwr, no_rdwr, no_ioctl },
/* 2: /dev/tty TTY devices */
{ tty_open, my_tty_close, tty_read, tty_write, tty_ioctl },
}
void device_init(void)
{
+ devide_init( );
}
SAM_RESTORE macro
endm
+
+
+;; asm/c shared IDE stuff
+IDEDATA equ 0xFF50
+IDEDATA_L equ 0xFF58
\ No newline at end of file
--- /dev/null
+/* 2015-01-04 Will Sowerbutts */
+
+#include <kernel.h>
+#include <kdata.h>
+#include <printf.h>
+#include <blkdev.h>
+
+typedef struct {
+ uint8_t flags;
+ uint8_t type;
+ uint16_t start_h;
+ uint32_t start;
+ uint16_t len_h;
+ uint32_t len;
+ uint8_t res[2];
+} partition_table_entry_t;
+
+
+
+#define MBR_ENTRY_COUNT 14
+#define MBR_SIGNATURE 0x43435054
+typedef struct {
+ uint32_t magic; // magic no. "CCPT", big endian.
+ uint16_t sz_h; // high word of size
+ uint32_t sz; // low long of size
+ uint8_t secz; // sector size
+ uint16_t cyls; // number of cylindars
+ uint16_t heads; // number of heads
+ uint16_t secs; // number of sectors
+ uint16_t crc; // CRC of table
+ uint8_t res[13]; // reserved
+ partition_table_entry_t partition[MBR_ENTRY_COUNT];
+} boot_record_t ;
+
+
+void mbr_parse(char letter)
+{
+ boot_record_t *br;
+ uint8_t i,k = 0;
+
+ kprintf("hd%c: ", letter);
+
+ /* allocate temporary memory */
+ br = (boot_record_t *)tmpbuf();
+
+ blk_op.is_read = true;
+ blk_op.is_user = false;
+ blk_op.addr = br;
+ blk_op.lba = 0;
+ blk_op.nblock = 1;
+
+ /* FIX: should also check table's CRC */
+ if(!blk_op.blkdev->transfer() || br->magic != MBR_SIGNATURE){
+ kputs("No CCPT");
+ return;
+ }
+
+ /* add each entry to blkops struct */
+ /* This adds paritions as it finds good ones? */
+ for(i=0; i<MBR_ENTRY_COUNT; i++){
+ if( ! br->partition[i].flags ){
+ continue;
+ }
+ else{
+ blk_op.blkdev->lba_first[k] = br->partition[i].start;
+ blk_op.blkdev->lba_count[k] = br->partition[i].len;
+ kprintf("hd%c%d ", letter, k+1);
+ k++;
+ }
+ }
+
+ /* release temporary memory */
+ brelse((bufptr)br);
+}