forked from emutos/emutos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
241e198
commit a9289b3
Showing
13 changed files
with
351 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
/*.img | ||
/*.rom | ||
/*.dc42 | ||
/autoboot.bin | ||
/autoboot.adr | ||
/*.map | ||
/localconf.h | ||
/makefile.dep | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
/* | ||
* 68kmbc.c - 68k-MBC specific functions | ||
* | ||
* Copyright (C) 2021 The EmuTOS development team | ||
* | ||
* Authors: | ||
* VRI Vincent Rivière | ||
* | ||
* This file is distributed under the GPL, version 2 or at your | ||
* option any later version. See doc/license.txt for details. | ||
*/ | ||
|
||
/* #define ENABLE_KDEBUG */ | ||
|
||
#include "emutos.h" | ||
#include "68kmbc.h" | ||
#include "asm.h" | ||
#include "ikbd.h" | ||
#include "gemerror.h" | ||
#include "disk.h" | ||
|
||
#ifdef MACHINE_68KMBC | ||
|
||
struct m68kmbc_ports | ||
{ | ||
UBYTE excwr; | ||
#define excrd excwr | ||
UBYTE stopc; | ||
#define ser1rx stopc | ||
UBYTE sysflg; | ||
UBYTE ser2rx; | ||
}; | ||
|
||
#define M68KMBC_PORTS (*(volatile struct m68kmbc_ports *)0x000ffffc) | ||
|
||
/* I/O write operations */ | ||
#define USRLED_OPC 0x00 /* USER LED opcode */ | ||
#define SER1TX_OPC 0x01 /* SERIAL 1 TX opcode */ | ||
#define SETIRQ_OPC 0x02 /* SETIRQ opcode */ | ||
#define SELLBA_OPC 0x13 /* SELLBA opcode */ | ||
#define WRITELBA_OPC 0x14 /* WRITELBA opcode */ | ||
|
||
/* I/O read operations */ | ||
#define DATETIME_OPC 0x84 /* DATETIME opcode */ | ||
#define READLBA_OPC 0x89 /* READLBA opcode */ | ||
#define ERRLBA_OPC 0x90 /* ERRLBA opcode */ | ||
|
||
/* Interrupt vectors */ | ||
#define VEC_IPL1 (*(volatile PFVOID*)0x100) /* IPL1 interrupt (Serial 1 Rx) */ | ||
|
||
void m68kmbc_machine_init(void) | ||
{ | ||
/* Enable IPL1 interrupt (Serial 1 Rx) */ | ||
VEC_IPL1 = m68kmbc_ipl1; | ||
M68KMBC_PORTS.stopc = SETIRQ_OPC; | ||
M68KMBC_PORTS.excwr = TRUE; | ||
} | ||
|
||
BOOL m68kmbc_ser1_can_write(void) | ||
{ | ||
return TRUE; | ||
} | ||
|
||
void m68kmbc_ser1_write_byte(UBYTE b) | ||
{ | ||
WORD old_sr; | ||
|
||
old_sr = set_sr(0x2700); | ||
M68KMBC_PORTS.stopc = SER1TX_OPC; | ||
M68KMBC_PORTS.excwr = b; | ||
set_sr(old_sr); | ||
} | ||
|
||
void m68kmbc_ipl1_interrupt_handler(void) | ||
{ | ||
/* Read the ASCII character */ | ||
UBYTE ascii = M68KMBC_PORTS.ser1rx; | ||
|
||
/* And append a new IOREC value into the IKBD buffer */ | ||
push_ascii_ikbdiorec(ascii); | ||
} | ||
|
||
void m68kmbc_light_user_led(BOOL light) | ||
{ | ||
WORD old_sr; | ||
|
||
old_sr = set_sr(0x2700); | ||
M68KMBC_PORTS.stopc = USRLED_OPC; | ||
M68KMBC_PORTS.excwr = light; | ||
set_sr(old_sr); | ||
} | ||
|
||
ULONG m68kmbc_getdt(void) | ||
{ | ||
WORD old_sr; | ||
UWORD seconds, minutes, hours; | ||
UWORD day, month, year; | ||
UWORD tempC; | ||
ULONG date, time; | ||
|
||
old_sr = set_sr(0x2700); | ||
M68KMBC_PORTS.stopc = DATETIME_OPC; | ||
seconds = M68KMBC_PORTS.excrd; | ||
minutes = M68KMBC_PORTS.excrd; | ||
hours = M68KMBC_PORTS.excrd; | ||
day = M68KMBC_PORTS.excrd; | ||
month = M68KMBC_PORTS.excrd; | ||
year = 2000 + M68KMBC_PORTS.excrd; | ||
tempC = M68KMBC_PORTS.excrd; | ||
set_sr(old_sr); | ||
|
||
date = day | ||
| (month << 5) | ||
| ((year - 1980) << 9); | ||
|
||
time = (seconds >> 1) | ||
| (minutes << 5) | ||
| (hours << 11); | ||
|
||
UNUSED(tempC); | ||
|
||
return MAKE_ULONG(date, time); | ||
} | ||
|
||
static void m68kmbc_select_sector(ULONG sector) | ||
{ | ||
M68KMBC_PORTS.stopc = SELLBA_OPC; | ||
M68KMBC_PORTS.excwr = LOBYTE(LOWORD(sector)); | ||
M68KMBC_PORTS.excwr = HIBYTE(LOWORD(sector)); | ||
M68KMBC_PORTS.excwr = LOBYTE(HIWORD(sector)); | ||
M68KMBC_PORTS.excwr = HIBYTE(HIWORD(sector)); | ||
} | ||
|
||
static LONG m68kmbc_read_sector(ULONG sector, UBYTE *buf) | ||
{ | ||
WORD old_sr; | ||
int i; | ||
|
||
old_sr = set_sr(0x2700); | ||
|
||
m68kmbc_select_sector(sector); | ||
|
||
M68KMBC_PORTS.stopc = READLBA_OPC; | ||
|
||
for (i = 0; i < SECTOR_SIZE; i++) | ||
*buf++ = M68KMBC_PORTS.excrd; | ||
|
||
set_sr(old_sr); | ||
|
||
return E_OK; | ||
} | ||
|
||
static LONG m68kmbc_write_sector(ULONG sector, const UBYTE *buf) | ||
{ | ||
WORD old_sr; | ||
|
||
old_sr = set_sr(0x2700); | ||
|
||
//m68kmbc_select_sector(sector); | ||
|
||
set_sr(old_sr); | ||
|
||
return ERR; | ||
} | ||
|
||
LONG m68kmbc_rw(UWORD rw, ULONG sector, UWORD count, UBYTE *buf, WORD dev) | ||
{ | ||
LONG ret; | ||
|
||
if (dev != 0) | ||
return EUNDEV; | ||
|
||
while (count--) | ||
{ | ||
if ((rw & RW_RW) == RW_READ) | ||
ret = m68kmbc_read_sector(sector, buf); | ||
else | ||
ret = m68kmbc_write_sector(sector, buf); | ||
|
||
if (ret) | ||
return ret; | ||
|
||
sector++; | ||
buf += SECTOR_SIZE; | ||
} | ||
|
||
return E_OK; | ||
} | ||
|
||
#endif /* MACHINE_68KMBC */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 68kmbc.h - 68k-MBC specific functions | ||
* | ||
* Copyright (C) 2021 The EmuTOS development team | ||
* | ||
* Authors: | ||
* VRI Vincent Rivière | ||
* | ||
* This file is distributed under the GPL, version 2 or at your | ||
* option any later version. See doc/license.txt for details. | ||
*/ | ||
|
||
#ifndef _68KMBC_H | ||
#define _68KMBC_H | ||
|
||
#ifdef MACHINE_68KMBC | ||
|
||
void m68kmbc_machine_init(void); | ||
BOOL m68kmbc_ser1_can_write(void); | ||
void m68kmbc_ser1_write_byte(UBYTE b); | ||
void m68kmbc_light_user_led(BOOL light); | ||
ULONG m68kmbc_getdt(void); | ||
|
||
void m68kmbc_ipl1(void); /* In 68kmbcasm.S */ | ||
void m68kmbc_ipl1_interrupt_handler(void); | ||
|
||
LONG m68kmbc_rw(UWORD rw, ULONG sector, UWORD count, UBYTE *buf, WORD dev); | ||
|
||
#endif /* MACHINE_68KMBC */ | ||
|
||
#endif /* _68KMBC_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 68kmbcasm.S - 68k-MBC specific assembler functions | ||
* | ||
* Copyright (C) 2021 The EmuTOS development team | ||
* | ||
* Authors: | ||
* VRI Vincent Rivière | ||
* | ||
* This file is distributed under the GPL, version 2 or at your | ||
* option any later version. See doc/license.txt for details. | ||
*/ | ||
|
||
#include "asmdefs.h" | ||
|
||
/* IPL1 interrupt (Serial 1 Rx) */ | ||
.globl _m68kmbc_ipl1 | ||
_m68kmbc_ipl1: | ||
movem.l d0-d1/a0-a1,-(sp) | ||
|
||
jbsr _m68kmbc_ipl1_interrupt_handler | ||
|
||
movem.l (sp)+,d0-d1/a0-a1 | ||
rte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.