]> git.sur5r.net Git - cc65/blob - include/em.h
Replaced em_mapclean by em_commit
[cc65] / include / em.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                   em.h                                    */
4 /*                                                                           */
5 /*                      API for extended memory access                       */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2002      Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@musoftware.de                                            */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef _EM_H
37 #define _EM_H
38
39
40
41 /*****************************************************************************/
42 /*                                  Definitions                              */
43 /*****************************************************************************/
44
45
46
47 /* Size of an extended memory page */
48 #define EM_PAGE_SIZE          256
49
50 /* Error codes */
51 #define EM_ERR_OK               0       /* No error */
52 #define EM_ERR_NO_DRIVER        1       /* No driver available */
53 #define EM_ERR_CANNOT_LOAD      2       /* Error loading driver */
54 #define EM_ERR_INV_DRIVER       3       /* Invalid driver */
55 #define EM_ERR_NO_DEVICE        4       /* Device (hardware) not found */
56
57 /* Parameters for the em_copy_... functions. NOTE: The first seven bytes
58  * have the same order and alignment as needed for the Commodore REU, so
59  * don't change the order without changing the assembler file that defines
60  * the struct offsets and the code in the REU driver.
61  */
62 struct em_copy {
63     void*           buf;        /* Memory buffer to copy from or to */
64     unsigned char   offs;       /* Offset into page */
65     unsigned        page;       /* Starting page to copy from or to */
66     unsigned        count;      /* Number of bytes to copy */
67     unsigned char   unused;     /* Make the size 8 bytes */
68 };
69
70
71
72 /*****************************************************************************/
73 /*                                 Functions                                 */
74 /*****************************************************************************/
75
76
77
78 unsigned char __fastcall__ em_load_driver (const char* driver);
79 /* Load an extended memory driver and return an error code */
80
81 unsigned char em_unload (void);
82 /* Unload the currently loaded driver. */
83
84 unsigned em_pagecount (void);
85 /* Return the total number of 256 byte pages available in extended memory. */
86
87 void* __fastcall__ em_map (unsigned page);
88 /* Unmap the current page from memory and map a new one. The function returns
89  * a pointer to the location of the page in memory. Note: Without calling 
90  * em_commit, the old contents of the memory window may be lost!
91  */
92
93 void __fastcall__ em_commit (void);
94 /* Commit changes in the memory window to extended storage. If the contents
95  * of the memory window have been changed, these changes may be lost if
96  * em_map, em_copyfrom or em_copyto are called without calling em_commit 
97  * first. Note: Not calling em_commit does not mean that the changes are
98  * discarded, it does just mean that some drivers will discard the changes.
99  */
100
101 void __fastcall__ em_copyfrom (const struct em_copy* copy_data);
102 /* Copy from extended into linear memory. Note: This may invalidate the
103  * currently mapped page.
104  */
105
106 void __fastcall__ em_copyto (const struct em_copy* copy_data);
107 /* Copy from linear into extended memory. Note: This may invalidate the
108  * currently mapped page.
109  */
110
111
112
113 /* End of em.h */
114 #endif
115
116
117