summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/devcpu.h
blob: e4a37575858df8f657f152e1d7e4c3f8ee21c638 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************

    devcpu.h

    CPU device definitions.

***************************************************************************/

#ifndef MAME_EMU_DEVCPU_H
#define MAME_EMU_DEVCPU_H

#pragma once

#include "didisasm.h"
#include "diexec.h"

#include <utility>


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> cpu_device

class cpu_device :  public device_t,
					public device_execute_interface,
					public device_memory_interface,
					public device_state_interface,
					public device_disasm_interface
{
public:
	virtual ~cpu_device();

	// configuration helpers
	void set_force_no_drc(bool value) { m_force_no_drc = value; }
	bool allow_drc() const;

	virtual bool cpu_is_interruptible() const;

	// To be used only for interruptible cpus
	bool access_to_be_redone() noexcept { return std::exchange(m_access_to_be_redone, false); }
	bool access_to_be_redone_noclear() noexcept { return m_access_to_be_redone; }

	// Returns true if the access must be aborted
	bool access_before_time(u64 access_time, u64 current_time) noexcept;
	bool access_before_delay(u32 cycles, const void *tag) noexcept;

	// The access has already happened, nothing to abort
	void access_after_delay(u32 cycles) noexcept;

	void defer_access() noexcept;
	void retry_access() noexcept;

protected:
	// construction/destruction
	cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);

private:
	// configured state
	bool m_force_no_drc;                   // whether or not to force DRC off

	bool m_access_to_be_redone;            // whether an access needs to be redone
	const void *m_access_before_delay_tag; // if the tag matches on access_before_delay, consider the delay to have already happened
};

#endif // MAME_EMU_DEVCPU_H