Skip to content

Commit

Permalink
Merge pull request #86 from mfld-fr/int_clean
Browse files Browse the repository at this point in the history
Drop timer-8018x.inc
  • Loading branch information
mfld-fr authored Jan 21, 2025
2 parents 429971f + 0c3d40f commit ff81307
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 119 deletions.
6 changes: 3 additions & 3 deletions int-8018x.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

// REQST and MASK register bits
#define BIT_TMR 0
// Bit 1 is reserved on all models
// Bit 1 is reserved in all variants
// Bits 2 & 3 are for DMA in XL variant
// Bits 2 & 3 are for serial and INT4 for EB variant
// Bits 2 & 3 are for serial and INT4 in EB variant
#define BIT_SER 2
#define BIT_INT4 3
#define BIT_INT0 4
Expand Down Expand Up @@ -55,7 +55,7 @@ int _int_mask [INT_LINE_MAX] =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};

// Initialized to zero by CRT
int _int_req [INT_LINE_MAX];
int _int_req [INT_LINE_MAX];
int _int_serv [INT_LINE_MAX];

word_t imask;
Expand Down
11 changes: 4 additions & 7 deletions int-8xxx.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// EMU86 - 8259 interrupt controller
// EMU86 - 8259 interrupt controller (PC/XT/AT)
//------------------------------------------------------------------------------

#include "emu-int.h"
Expand All @@ -24,12 +24,9 @@ int _int_vect [INT_LINE_MAX] =
int _int_mask [INT_LINE_MAX] =
{ 0, 1, 1, 1, 1, 1, 1, 1}; // timer unmasked by default

int _int_req [INT_LINE_MAX] =
{ 0, 0, 0, 0, 0, 0, 0, 0};

int _int_serv [INT_LINE_MAX] =
{ 0, 0, 0, 0, 0, 0, 0, 0};

// Initialized to zero by CRT
int _int_req [INT_LINE_MAX];
int _int_serv [INT_LINE_MAX];

// PIC I/O write

Expand Down
2 changes: 1 addition & 1 deletion int-8xxx.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// EMU86 - ELKS interrupt controller (8259)
// EMU86 - 8259 interrupt controller (PC/XT/AT)
//------------------------------------------------------------------------------

#pragma once
Expand Down
9 changes: 3 additions & 6 deletions int-r8810.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ int _int_vect [INT_LINE_MAX] =
int _int_mask [INT_LINE_MAX] =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}; // FIXME: unmask timer & serial by program

int _int_req [INT_LINE_MAX] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

int _int_serv [INT_LINE_MAX] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

// Initialized to zero by CRT
int _int_req [INT_LINE_MAX];
int _int_serv [INT_LINE_MAX];

// PIC I/O write

Expand Down
16 changes: 8 additions & 8 deletions timer-8018x.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

#define REG_T0CNT 0 // timer 0 count register
#define REG_T0CMPA 1 // timer 0 max A register
#define REG_T0CMPB 2 //
#define REG_T0CON 3 //
#define REG_T0CMPB 2 // timer 0 max B register
#define REG_T0CON 3 // timer 0 mode & control register

#define REG_T1CNT 4 // timer 0 count register
#define REG_T1CMPA 5 // timer 0 max A register
#define REG_T1CMPB 6 //
#define REG_T1CON 7 //
#define REG_T1CNT 4 // timer 1 count register
#define REG_T1CMPA 5 // timer 1 max A register
#define REG_T1CMPB 6 // timer 1 max B register
#define REG_T1CON 7 // timer 1 mode & control register

#define REG_T2CNT 8 // timer 2 count register
#define REG_T2CMPA 9 // timer 2 max register
Expand All @@ -38,8 +38,8 @@ static word_t timer_regs [TIMER_REG_COUNT];
#define TIMER_CON_EXT 0x0004 // not implemented
#define TIMER_CON_P 0x0008
#define TIMER_CON_RTG 0x0010 // not implemented
#define TIMER_CON_MC 0x0020
#define TIMER_CON_RIU 0x1000
#define TIMER_CON_MC 0x0020
#define TIMER_CON_RIU 0x1000
#define TIMER_CON_INT 0x2000
#define TIMER_CON_INH 0x4000
#define TIMER_CON_EN 0x8000 // timer enabled
Expand Down
93 changes: 0 additions & 93 deletions timer-8018x.inc

This file was deleted.

79 changes: 78 additions & 1 deletion timer-r8810.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,81 @@
#include "int-r8810.h"
#include "timer-8018x.h"

#include "timer-8018x.inc"
#define TIMER0_COUNT 0 // timer 0 count register
#define TIMER0_MAX 1 // timer 0 max A register
#define TIMER0_MODE 3 // timer 0 mode & control register

#define TIMER2_COUNT 8 // timer 2 count register
#define TIMER2_MAX 9 // timer 2 max register
#define TIMER2_MODE 11 // timer 2 mode & control register

static word_t timer_regs [TIMER_REG_COUNT];

#define TIMER_MODE_EN 0x8000 // timer enabled


// Timer device procedure
// Called from main emulator loop

void timer_proc (void)
{
int timer2 = 0;

if (timer_regs [TIMER2_MODE] & TIMER_MODE_EN)
{
timer_regs [TIMER2_COUNT]++;
if (timer_regs [TIMER2_COUNT] == timer_regs [TIMER2_MAX]) {
timer_regs [TIMER2_COUNT] = 0;
timer2 = 1;
}
}

if (timer_regs [TIMER0_MODE] & TIMER_MODE_EN)
{
if (timer2) timer_regs [TIMER0_COUNT]++;
if (timer_regs [TIMER0_COUNT] == timer_regs [TIMER0_MAX]) {
timer_regs [TIMER0_COUNT] = 0;
int_line_set (INT_LINE_TIMER0, 1);
}
else
{
int_line_set (INT_LINE_TIMER0, 0);
}
}
}


// Timer I/O read

int timer_io_read (word_t p, word_t * w)
{
int r = p >> 1;
*w = timer_regs [r];
return 0;
}


// Timer I/O write

int timer_io_write (word_t p, word_t w)
{
int r = p >> 1;
timer_regs [r] = w;
return 0;
}


// Timer initialization

void timer_init ()
{
// FIXME: enable timers by program

timer_regs [TIMER0_MODE] = TIMER_MODE_EN;
timer_regs [TIMER0_COUNT] = 0;
timer_regs [TIMER0_MAX] = 1000;

timer_regs [TIMER2_MODE] = TIMER_MODE_EN;
timer_regs [TIMER2_COUNT] = 0;
timer_regs [TIMER2_MAX] = 5000;
}

0 comments on commit ff81307

Please sign in to comment.