2002-11-29 14:40:31 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* em.h */
|
|
|
|
/* */
|
|
|
|
/* API for extended memory access */
|
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2012-07-22 11:36:09 +00:00
|
|
|
/* (C) 2002-2012, Ullrich von Bassewitz */
|
2011-07-07 20:19:35 +00:00
|
|
|
/* Roemerstrasse 52 */
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2002-11-29 14:40:31 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _EM_H
|
|
|
|
#define _EM_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Definitions */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Size of an extended memory page */
|
|
|
|
#define EM_PAGE_SIZE 256
|
|
|
|
|
|
|
|
/* Error codes */
|
|
|
|
#define EM_ERR_OK 0 /* No error */
|
|
|
|
#define EM_ERR_NO_DRIVER 1 /* No driver available */
|
|
|
|
#define EM_ERR_CANNOT_LOAD 2 /* Error loading driver */
|
|
|
|
#define EM_ERR_INV_DRIVER 3 /* Invalid driver */
|
|
|
|
#define EM_ERR_NO_DEVICE 4 /* Device (hardware) not found */
|
2012-07-22 11:36:09 +00:00
|
|
|
#define EM_ERR_INSTALLED 5 /* A driver is already installed */
|
2002-11-29 14:40:31 +00:00
|
|
|
|
2002-12-01 18:06:57 +00:00
|
|
|
/* Parameters for the em_copy_... functions. NOTE: The first seven bytes
|
2014-06-30 09:10:35 +00:00
|
|
|
** have the same order and alignment as needed for the Commodore REU, so
|
|
|
|
** don't change the order without changing the assembler file that defines
|
|
|
|
** the struct offsets and the code in the REU driver.
|
|
|
|
*/
|
2002-11-29 14:40:31 +00:00
|
|
|
struct em_copy {
|
|
|
|
void* buf; /* Memory buffer to copy from or to */
|
2002-12-01 18:06:57 +00:00
|
|
|
unsigned char offs; /* Offset into page */
|
|
|
|
unsigned page; /* Starting page to copy from or to */
|
2002-11-29 14:40:31 +00:00
|
|
|
unsigned count; /* Number of bytes to copy */
|
|
|
|
unsigned char unused; /* Make the size 8 bytes */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Functions */
|
2002-11-29 14:40:31 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char __fastcall__ em_load_driver (const char* driver);
|
2003-02-10 22:31:45 +00:00
|
|
|
/* Load and install an extended memory driver. Return an error code. */
|
2002-11-29 14:40:31 +00:00
|
|
|
|
2011-07-07 20:19:35 +00:00
|
|
|
unsigned char em_unload (void);
|
2003-02-10 22:31:45 +00:00
|
|
|
/* Uninstall, then unload the currently loaded driver. */
|
|
|
|
|
2021-05-16 20:57:28 +00:00
|
|
|
unsigned char __fastcall__ em_install (const void* driver);
|
2003-02-10 22:31:45 +00:00
|
|
|
/* Install an already loaded driver. Return an error code. */
|
|
|
|
|
2011-07-07 20:19:35 +00:00
|
|
|
unsigned char em_uninstall (void);
|
2003-02-10 22:31:45 +00:00
|
|
|
/* Uninstall the currently loaded driver and return an error code.
|
2014-06-30 09:10:35 +00:00
|
|
|
** Note: This call does not free allocated memory.
|
|
|
|
*/
|
2002-11-29 14:40:31 +00:00
|
|
|
|
2011-07-07 20:19:35 +00:00
|
|
|
unsigned em_pagecount (void);
|
2002-11-29 14:40:31 +00:00
|
|
|
/* Return the total number of 256 byte pages available in extended memory. */
|
|
|
|
|
|
|
|
void* __fastcall__ em_map (unsigned page);
|
|
|
|
/* Unmap the current page from memory and map a new one. The function returns
|
2014-06-30 09:10:35 +00:00
|
|
|
** a pointer to the location of the page in memory. Note: Without calling
|
|
|
|
** em_commit, the old contents of the memory window may be lost!
|
|
|
|
*/
|
2002-11-29 14:40:31 +00:00
|
|
|
|
2002-12-05 18:57:53 +00:00
|
|
|
void* __fastcall__ em_use (unsigned page);
|
2003-02-10 22:31:45 +00:00
|
|
|
/* Tell the driver that the memory window is associated with a given page.
|
2014-06-30 09:10:35 +00:00
|
|
|
** This call is very similar to em_map. The difference is that the driver
|
|
|
|
** does not necessarily transfer the current contents of the extended
|
|
|
|
** memory into the returned window. If you're going to just write to the
|
|
|
|
** window and the current contents of the window are invalid or no longer
|
|
|
|
** use, this call may perform better than em_map.
|
|
|
|
*/
|
2002-12-05 18:57:53 +00:00
|
|
|
|
2011-07-07 20:19:35 +00:00
|
|
|
void em_commit (void);
|
2002-12-01 18:06:57 +00:00
|
|
|
/* Commit changes in the memory window to extended storage. If the contents
|
2014-06-30 09:10:35 +00:00
|
|
|
** of the memory window have been changed, these changes may be lost if
|
|
|
|
** em_map, em_copyfrom or em_copyto are called without calling em_commit
|
|
|
|
** first. Note: Not calling em_commit does not mean that the changes are
|
|
|
|
** discarded, it does just mean that some drivers will discard the changes.
|
|
|
|
*/
|
2002-11-29 14:40:31 +00:00
|
|
|
|
|
|
|
void __fastcall__ em_copyfrom (const struct em_copy* copy_data);
|
|
|
|
/* Copy from extended into linear memory. Note: This may invalidate the
|
2014-06-30 09:10:35 +00:00
|
|
|
** currently mapped page.
|
|
|
|
*/
|
2002-11-29 14:40:31 +00:00
|
|
|
|
|
|
|
void __fastcall__ em_copyto (const struct em_copy* copy_data);
|
|
|
|
/* Copy from linear into extended memory. Note: This may invalidate the
|
2014-06-30 09:10:35 +00:00
|
|
|
** currently mapped page.
|
|
|
|
*/
|
2002-11-29 14:40:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-07-07 20:19:35 +00:00
|
|
|
/* End of em.h */
|
2002-11-29 14:40:31 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|