Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
sdcard.h
Go to the documentation of this file.
1 /* A work-in-progess MEGA65 (Commodore 65 clone origins) emulator
2  Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu
3  Copyright (C)2016-2022 LGB (Gábor Lénárt) <lgblgblgb@gmail.com>
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18 
19 #ifndef XEMU_MEGA65_SDCARD_H_INCLUDED
20 #define XEMU_MEGA65_SDCARD_H_INCLUDED
21 
22 #define SD_ST_EXT_BUS 0x80
23 #define SD_ST_ERROR 0x40
24 #define SD_ST_FSM_ERROR 0x20
25 // 0x10 was the SDHC bit, but now MEGA65 does not support non-SDHC cards!
26 #define SD_ST_MAPPED 0x08
27 #define SD_ST_RESET 0x04
28 #define SD_ST_BUSY1 0x02
29 #define SD_ST_BUSY0 0x01
30 
31 extern int sdcard_init ( const char *fn, const int virtsd_flag, const int default_d81_is_from_sd_in );
32 extern Uint32 sdcard_get_size ( void );
33 extern void sdcard_write_register ( int reg, Uint8 data );
34 extern Uint8 sdcard_read_register ( int reg );
35 
36 extern int sdcard_read_block ( Uint32 block, Uint8 *buffer );
37 extern int sdcard_write_block ( Uint32 block, Uint8 *buffer );
38 
39 extern int sdcard_force_external_mount ( const int unit, const char *filename, const char *cry );
40 extern int sdcard_force_external_mount_with_image_creation ( const int unit, const char *filename, const int do_overwrite, const char *cry );
41 extern int sdcard_unmount ( const int unit );
42 extern int sdcard_default_d81_mount ( const int unit );
43 extern const char *sdcard_get_mount_info ( const int unit, int *is_internal );
44 
45 extern void sdcard_notify_system_start_begin ( void );
46 extern void sdcard_notify_system_start_end ( void );
47 
48 // disk buffer for SD (can be mapped to I/O space too), F011, and some "3.5K scratch space"
49 extern Uint8 disk_buffers[0x1000];
52 extern Uint8 sd_status;
53 
54 extern const char xemu_external_d81_signature[];
55 
56 static inline int has_block_nonzero_byte ( const Uint8 *p )
57 {
58  for (register unsigned int a = 0; a < 512; a++)
59  if (p[a])
60  return 1;
61  return 0;
62 }
63 
64 #ifdef XEMU_SNAPSHOT_SUPPORT
65 #include "xemu/emutools_snapshot.h"
66 extern int sdcard_snapshot_load_state ( const struct xemu_snapshot_definition_st *def , struct xemu_snapshot_block_st *block );
67 extern int sdcard_snapshot_save_state ( const struct xemu_snapshot_definition_st *def );
68 #endif
69 
70 #endif
sdcard_unmount
int sdcard_unmount(const int unit)
Definition: sdcard.c:959
fn
const char * fn
Definition: roms.c:42
m65-memcontent-generator.data
data
Definition: m65-memcontent-generator.py:119
Uint32
uint32_t Uint32
Definition: fat32.c:49
Uint8
uint8_t Uint8
Definition: fat32.c:51
sdcard_default_d81_mount
int sdcard_default_d81_mount(const int unit)
Definition: sdcard.c:821
sdcard_get_mount_info
const char * sdcard_get_mount_info(const int unit, int *is_internal)
Definition: sdcard.c:917
disk_buffers
Uint8 disk_buffers[0x1000]
Definition: sdcard.c:74
block
Uint32 block
Definition: fat32.c:156
xemu_external_d81_signature
const char xemu_external_d81_signature[]
Definition: sdcard.c:84
sdcard_force_external_mount
int sdcard_force_external_mount(const int unit, const char *filename, const char *cry)
Definition: sdcard.c:925
sdcard_read_block
int sdcard_read_block(Uint32 block, Uint8 *buffer)
Definition: sdcard.c:548
sdcard_write_block
int sdcard_write_block(Uint32 block, Uint8 *buffer)
Definition: sdcard.c:569
emutools_snapshot.h
sdcard_init
int sdcard_init(const char *fn, const int virtsd_flag, const int default_d81_is_from_sd_in)
Definition: sdcard.c:328
sdcard_write_register
void sdcard_write_register(int reg, Uint8 data)
Definition: sdcard.c:973
sdcard_notify_system_start_begin
void sdcard_notify_system_start_begin(void)
Definition: sdcard.c:778
sdcard_force_external_mount_with_image_creation
int sdcard_force_external_mount_with_image_creation(const int unit, const char *filename, const int do_overwrite, const char *cry)
Definition: sdcard.c:951
sdcard_get_size
Uint32 sdcard_get_size(void)
Definition: sdcard.c:305
sd_status
Uint8 sd_status
Definition: sdcard.c:58
sdcard_read_register
Uint8 sdcard_read_register(int reg)
Definition: sdcard.c:1035
disk_buffer_io_mapped
Uint8 * disk_buffer_io_mapped
Definition: sdcard.c:80
disk_buffer_cpu_view
Uint8 * disk_buffer_cpu_view
Definition: sdcard.c:76
sdcard_notify_system_start_end
void sdcard_notify_system_start_end(void)
Definition: sdcard.c:790