Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
vinriviere committed Nov 17, 2021
1 parent 241e198 commit a9289b3
Show file tree
Hide file tree
Showing 13 changed files with 351 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
/*.img
/*.rom
/*.dc42
/autoboot.bin
/autoboot.adr
/*.map
/localconf.h
/makefile.dep
Expand Down
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ bios_src += memory.S processor.S vectors.S aciavecs.S bios.c xbios.c acsi.c \
pmmu030.c 68040_pmmu.S \
amiga.c amiga2.S spi_vamp.c \
lisa.c lisa2.S \
68kmbc.c 68kmbcasm.S \
delay.c delayasm.S sd.c memory2.c bootparams.c scsi.c nova.c \
dsp.c dsp2.S

Expand Down Expand Up @@ -760,6 +761,27 @@ m548x-bas:
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS404))) bytes more than TOS 4.04)"
@printf "$(LOCALCONFINFO)"

# 68k-MBC images

.PHONY: 68kmbc
NODEP += 68kmbc
68kmbc: UNIQUE = $(COUNTRY)
68kmbc: override DEF += -DMACHINE_68KMBC
68kmbc: WITH_AES = 0
68kmbc:
@echo "# Building 68k-MBC Autoboot EmuTOS in autoboot.bin"
$(MAKE) DEF='$(DEF)' UNIQUE=$(UNIQUE) WITH_AES=$(WITH_AES) autoboot.bin
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS404))) bytes more than TOS 4.04)"
@printf "$(LOCALCONFINFO)"

autoboot.bin: emutos.img
cp $< $@
@LOAD=$(call SHELL_SYMADDR,__text,emutos.map);\
EXEC=$(call SHELL_SYMADDR,m68kmbc_main,emutos.map);\
echo $$LOAD $$EXEC >autoboot.adr
cat autoboot.adr

#
# Special variants of EmuTOS running in RAM instead of ROM.
# In this case, emutos.img needs to be loaded into RAM by some loader.
Expand Down
190 changes: 190 additions & 0 deletions bios/68kmbc.c
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 */
31 changes: 31 additions & 0 deletions bios/68kmbc.h
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 */
23 changes: 23 additions & 0 deletions bios/68kmbcasm.S
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
7 changes: 7 additions & 0 deletions bios/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "lisa.h"
#include "disk.h"
#include "acsi.h"
#include "68kmbc.h"

#if (CONF_WITH_MONSTER || CONF_WITH_IKBD_CLOCK)
static UBYTE int2bcd(UWORD a)
Expand Down Expand Up @@ -1276,6 +1277,12 @@ LONG gettime(void)
return lisa_getdt();
}
#endif /* MACHINE_LISA */
#ifdef MACHINE_68KMBC
else if (TRUE)
{
return m68kmbc_getdt();
}
#endif /* MACHINE_68KMBC */
#if CONF_WITH_NVRAM
else if (has_nvram)
{
Expand Down
20 changes: 19 additions & 1 deletion bios/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "sd.h"
#include "../bdos/bdosstub.h"
#include "string.h"
#include "68kmbc.h"

/*==== Defines ============================================================*/

Expand Down Expand Up @@ -182,7 +183,7 @@ void disk_init_all(void)
#if CONF_WITH_SCSI || CONF_WITH_ARANYM
8, 9, 10, 11, 12, 13, 14, 15, /* SCSI */
#endif
#if CONF_WITH_ACSI
#if CONF_WITH_ACSI || defined(MACHINE_68KMBC)
0, 1, 2, 3, 4, 5, 6, 7, /* ACSI */
#endif
#if CONF_WITH_SDMMC
Expand Down Expand Up @@ -269,6 +270,10 @@ LONG disk_mediach(UWORD unit)
}
#endif

#ifdef MACHINE_68KMBC
return MEDIANOCHANGE;
#endif /* MACHINE_68KMBC */

/*
* if less than half a second since last access, assume no mediachange
*/
Expand Down Expand Up @@ -830,6 +835,11 @@ static LONG internal_inquire(UWORD unit, ULONG *blocksize, ULONG *deviceflags, c
ret = EUNDEV;
}

#ifdef MACHINE_68KMBC
if (major == 0)
ret = E_OK;
#endif /* MACHINE_68KMBC */

/* if device doesn't exist, we're done */
if (ret == EUNDEV)
return ret;
Expand Down Expand Up @@ -946,6 +956,14 @@ LONG disk_rw(UWORD unit, UWORD rw, ULONG sector, UWORD count, UBYTE *buf)
bus = GET_BUS(major);
reldev = major - bus * DEVICES_PER_BUS;

#ifdef MACHINE_68KMBC
{
ret = m68kmbc_rw(rw, sector, count, buf, reldev);
KDEBUG(("m68kmbc_rw() returned %ld\n", ret));
return ret;
}
#endif /* MACHINE_68KMBC */

/* EmuTOS extension: Rwabs without byteswap on IDE */
no_byteswap = rw & RW_NOBYTESWAP;
rw &= ~RW_NOBYTESWAP;
Expand Down
4 changes: 3 additions & 1 deletion bios/initinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ WORD initinfo(ULONG *pshiftbits)
pair_start(_("CPU type"));
#ifdef __mcoldfire__
cprintf("ColdFire V4e");
#elif defined(MACHINE_68KMBC)
cprintf("M68008");
#else
# if CONF_WITH_APOLLO_68080
if (is_apollo_68080)
Expand Down Expand Up @@ -375,7 +377,7 @@ WORD initinfo(ULONG *pshiftbits)
* . a Shift key is held down, or
* . the user selects an alternate boot drive
*/
while (1)
while (0/*1*/)
{
/* Wait until timeout or keypress */
long end = hz_200 + INITINFO_DURATION * 200UL;
Expand Down
Loading

0 comments on commit a9289b3

Please sign in to comment.