1 /* $NetBSD: riscoscalls.h,v 1.11 2009/08/02 11:20:37 gavan Exp $ */ 2 3 /*- 4 * Copyright (c) 2001 Ben Harris 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 /* 31 * This file defines the interface for the veneers over RISC OS SWIs used 32 * by libsa. Only those SWIs actually needed by libsa are included. In 33 * general, the interface is based on the one provided by OsLib, though 34 * this implementation is independent. 35 */ 36 37 #define OS_WriteC 0x000000 38 #define XOS_WriteC 0x020000 39 #define OS_NewLine 0x000003 40 #define XOS_NewLine 0x020003 41 #define OS_ReadC 0x000004 42 #define XOS_ReadC 0x020004 43 #define OS_CLI 0x000005 44 #define XOS_CLI 0x020005 45 #define OS_Byte 0x000006 46 #define XOS_Byte 0x020006 47 #define OS_Word 0x000007 48 #define XOS_Word 0x020007 49 #define OS_Args 0x000009 50 #define XOS_Args 0x020009 51 #define OS_GBPB 0x00000c 52 #define XOS_GBPB 0x02000c 53 #define OS_Find 0x00000d 54 #define XOS_Find 0x02000d 55 #define OS_GetEnv 0x000010 56 #define XOS_GetEnv 0x020010 57 #define OS_Exit 0x000011 58 #define XOS_Exit 0x020011 59 #define OS_IntOff 0x000014 60 #define XOS_IntOff 0x020014 61 #define OS_EnterOS 0x000016 62 #define XOS_EnterOS 0x020016 63 #define OS_Module 0x00001e 64 #define XOS_Module 0x02001e 65 #define OS_FSControl 0x000029 66 #define XOS_FSControl 0x020029 67 #define OS_ServiceCall 0x000030 68 #define XOS_ServiceCall 0x020030 69 #define OS_ReadVduVariables 0x000031 70 #define XOS_ReadVduVariables 0x020031 71 #define OS_SWINumberFromString 0x000039 72 #define XOS_SWINumberFromString 0x020039 73 #define OS_ReadMonotonicTime 0x000042 74 #define XOS_ReadMonotonicTime 0x020042 75 #define OS_ReadMemMapInfo 0x000051 76 #define XOS_ReadMemMapInfo 0x020051 77 #define OS_ReadMemMapEntries 0x000052 78 #define XOS_ReadMemMapEntries 0x020052 79 #define OS_ReadSysInfo 0x000058 80 #define XOS_ReadSysInfo 0x020058 81 #define OS_Memory 0x000068 82 #define XOS_Memory 0x020068 83 84 #define Cache_Control 0x000280 85 #define XCache_Control 0x020280 86 87 #define Wimp_SlotSize 0x0400ec 88 #define XWimp_SlotSize 0x0600ec 89 90 #define FileCore_DiscOp 0x040540 91 #define XFileCore_DiscOp 0x060540 92 #define FileCore_Drives 0x040542 93 #define XFileCore_Drives 0x060542 94 #define FileCore_SectorOp 0x04054A 95 #define XFileCore_SectorOp 0x06054A 96 #define FileCore_DiscOp64 0x04054E 97 #define XFileCore_DiscOp64 0x06054E 98 99 100 #ifndef __ASSEMBLER__ 101 typedef struct os_error { 102 u_int32_t errnum; 103 char errmess[252]; 104 } os_error; 105 106 /* Errors talking to the console may as well be fatal. */ 107 108 extern void os_writec(int); 109 extern void os_new_line(void); 110 extern int os_readc(void); 111 #endif 112 113 /* OS_CLI */ 114 115 #ifndef __ASSEMBLER__ 116 extern void os_cli(char *); 117 extern os_error *xos_cli(char *); 118 #endif 119 120 /* OS_Byte */ 121 122 #define osbyte_OUTPUT_CURSOR_POSITION 165 123 #define osbyte_VAR_VSYNC_TIMER 176 124 125 #ifndef __ASSEMBLER__ 126 extern void os_byte(int, int, int, int *, int *); 127 extern int osbyte_read(int); 128 #endif 129 130 /* OS_Word */ 131 132 #define osword_WRITE_SCREEN_ADDRESS 22 133 134 #ifndef __ASSEMBLER__ 135 extern void os_word(int, char *); 136 #endif 137 138 /* OS_Args */ 139 140 #define OSArgs_ReadPtr 0 141 #define OSArgs_SetPtr 1 142 #define OSArgs_ReadExt 2 143 #define OSArgs_SetExt 3 144 #define OSArgs_ReadAllocation 4 145 #define OSArgs_ReadEOFStatus 5 146 147 #ifndef __ASSEMBLER__ 148 extern os_error *xosargs_read(int, int, int *); 149 extern os_error *xosargs_set(int, int, int); 150 151 #define xosargs_read_ptr(f, vp) xosargs_read(OSArgs_ReadPtr, (f), (vp)) 152 #define xosargs_set_ptr(f, v) xosargs_set(OSArgs_SetPtr, (f), (v)) 153 #define xosargs_read_ext(f, vp) xosargs_read(OSArgs_ReadExt, (f), (vp)) 154 #define xosargs_set_ext(f, v) xosargs_set(OSArgs_SetExt, (f), (v)) 155 #define xosargs_read_allocation(f, vp) \ 156 xosargs_read(OSArgs_ReadAllocation, (f), (vp)) 157 #define xosargs_read_eof_status(f, vp) \ 158 xosargs_read(OSArgs_ReadEOFStatus, (f), (vp)) 159 #endif 160 161 /* OS_GBPB */ 162 163 #define OSGBPB_WriteAt 1 164 #define OSGBPB_Write 2 165 #define OSGBPB_ReadAt 3 166 #define OSGBPB_Read 4 167 168 #ifndef __ASSEMBLER__ 169 extern os_error *xosgbpb_write(int, char const *, int, int *); 170 extern os_error *xosgbpb_read(int, char *, int, int *); 171 #endif 172 173 /* OS_Find */ 174 175 #define OSFind_Close 0x00 176 #define OSFind_Openin 0x40 177 #define OSFind_Openout 0x80 178 #define OSFind_Openup 0xc0 179 180 #define osfind_PATH 0x01 181 #define osfind_PATH_VAR 0x02 182 #define osfind_NO_PATH 0x03 183 #define osfind_ERROR_IF_DIR 0x04 184 #define osfind_ERROR_IF_ABSENT 0x08 185 186 #ifndef __ASSEMBLER__ 187 extern os_error *xosfind_close(int); 188 extern os_error *xosfind_open(int, char const *, char const *, int *); 189 #endif 190 191 /* OS_ReadSysInfo */ 192 193 #define OSReadSysInfo_ReadConfiguredScreenSize 0x00 194 #define OSReadSysInfo_ReadMonitorInfo 0x01 195 #define OSReadSysInfo_ReadChipPresenceAndId 0x02 196 #define OSReadSysInfo_ReadSuperIOFeatures 0x03 197 #define OSReadSysInfo_ReadPlatformClass 0x08 198 199 #define osreadsysinfo_IOEB_ASIC_PRESENT 0x01 200 #define osreadsysinfo_SUPERIO_PRESENT 0x02 201 #define osreadsysinfo_LCD_ASIC_PRESENT 0x04 202 203 #define osreadsysinfo_Platform_Unknown 0x00 204 #define osreadsysinfo_Platform_RiscPC 0x01 205 #define osreadsysinfo_Platform_A7000 0x02 206 #define osreadsysinfo_Platform_A7000Plus 0x03 207 #define osreadsysinfo_Platform_Phoebe 0x04 208 #define osreadsysinfo_Platform_Pace 0x05 209 #define osreadsysinfo_Platform_VirtualRPC 0x06 210 #define osreadsysinfo_Platform_A9 0x07 211 212 #ifndef __ASSEMBLER__ 213 extern void os_readsysinfo(int what, int *r0, int *r1, int *r2, int *r3, int *r4); 214 #define os_readsysinfo_configured_screensize(s) \ 215 os_readsysinfo(OSReadSysInfo_ReadConfiguredScreenSize, (s), 0, 0, 0, 0) 216 217 #define os_readsysinfo_monitor_info(mode, type, sync) \ 218 os_readsysinfo(OSReadSysInfo_ReadMonitorInfo, (mode), (type), (sync), 0, 0) 219 220 #define os_readsysinfo_chip_presence(ioeb, superio, lcd) \ 221 os_readsysinfo(OSReadSysInfo_ReadChipPresenceAndId, (ioeb), (superio), (lcd), 0, 0) 222 223 #define os_readsysinfo_unique_id(low, high) \ 224 os_readsysinfo(OSReadSysInfo_ReadChipPresenceAndId, 0, 0, 0, (low), (high)) 225 226 #define os_readsysinfo_superio_features(basic, extra) \ 227 os_readsysinfo(OSReadSysInfo_ReadSuperIOFeatures, (basic), (extra), 0, 0, 0) 228 229 #define os_readsysinfo_platform_class(class, flags, feature) \ 230 os_readsysinfo(OSReadSysInfo_ReadPlatformClass, (class), (flags), (feature), 0, 0) 231 232 #endif 233 234 /* OS_Memory */ 235 236 #define OSMemory_PageOp 0x00 237 #define OSMemory_ReadArrangementTableSize 0x06 238 #define OSMemory_ReadArrangementTable 0x07 239 #define OSMemory_ReadSize 0x08 240 #define OSMemory_ReadController 0x09 241 242 #define osmemory_GIVEN_PAGE_NO 0x0100 243 #define osmemory_GIVEN_LOG_ADDR 0x0200 244 #define osmemory_GIVEN_PHYS_ADDR 0x0400 245 #define osmemory_RETURN_PAGE_NO 0x0800 246 #define osmemory_RETURN_LOG_ADDR 0x1000 247 #define osmemory_RETURN_PHYS_ADDR 0x2000 248 249 #define osmemory_TYPE 0xf00 250 #define osmemory_TYPE_SHIFT 8 251 #define osmemory_TYPE_ABSENT 0x0 252 #define osmemory_TYPE_DRAM 0x1 253 #define osmemory_TYPE_VRAM 0x2 254 #define osmemory_TYPE_ROM 0x3 255 #define osmemory_TYPE_IO 0x4 256 /* 5, 6, 7 are undefined */ 257 #define osmemory_TYPE_ALLOCATABLE_MASK 0x8 /* bit signaling allocatable */ 258 259 260 #ifndef __ASSEMBLER__ 261 struct page_info { 262 int pagenumber; 263 int logical; 264 int physical; 265 }; 266 267 extern void osmemory_read_arrangement_table_size(int *size, int *nbpp); 268 extern os_error *xosmemory_read_arrangement_table_size(int *size, int *nbpp); 269 extern void osmemory_read_arrangement_table(unsigned char *block); 270 extern os_error *xosmemory_read_arrangement_table(unsigned char *block); 271 extern void osmemory_page_op(int fromto, struct page_info *block, int num_pages); 272 #endif 273 274 /* Misc */ 275 #ifndef __ASSEMBLER__ 276 extern char *os_get_env(void **, void **); 277 278 extern void os_exit(os_error const *, int) __attribute__((noreturn)); 279 280 extern void os_int_off(void); 281 282 extern void os_enter_os(void); 283 #endif 284 285 #define OSModule_Alloc 6 286 #define OSModule_Free 7 287 #define OSModule_Lookup 18 288 289 #ifndef __ASSEMBLER__ 290 extern os_error *xosmodule_alloc(int, void **); 291 extern os_error *xosmodule_free(void *); 292 extern os_error *xosmodule_lookup(char const *, int *, int *, void **, void **, 293 char **); 294 #endif 295 296 #define OSFSControl_AddFS 12 297 #define OSFSControl_SelectFS 14 298 #define OSFSControl_RemoveFS 16 299 #define OSFSControl_Shutdown 23 300 301 #define fileswitch_SUPPORTS_SPECIAL (1 << 31) 302 #define fileswitch_INTERACTIVE (1 << 30) 303 #define fileswitch_SUPPORTS_EMPTY_NAMES (1 << 29) 304 #define fileswitch_NEEDS_CREATE (1 << 28) 305 #define fileswitch_NEEDS_FLUSH (1 << 27) 306 #define fileswitch_SUPPORTS_STAMP_NAMED (1 << 26) 307 #define fileswitch_SUPPORTS_FILE_INFO (1 << 25) 308 #define fileswitch_SUPPORTS_SET_CONTEXTS (1 << 24) /* MBZ in RO3 */ 309 #define fileswitch_SUPPORTS_IMAGE (1 << 23) 310 #define fileswitch_NEEDS_URD_AND_LIB (1 << 22) 311 #define fileswitch_IMPLICIT_DIRECTORIES (1 << 21) 312 #define fileswitch_NO_LOAD_ENTRY (1 << 20) 313 #define fileswitch_NO_SAVE_ENTRY (1 << 19) 314 #define fileswitch_NO_FILE_ENTRIES (1 << 18) 315 #define fileswitch_HAS_EXTRA_FLAGS (1 << 17) 316 #define fileswitch_READ_ONLY (1 << 16) 317 318 #define fileswitch_SUPPORTS_DIR_CHANGE (1 << 0) 319 #define fileswitch_NEEDS_CAT (1 << 1) 320 #define fileswitch_NEEDS_EX (1 << 2) 321 322 #define fileswitch_NOT_FOUND 0 323 #define fileswitch_IS_FILE 1 324 #define fileswitch_IS_DIR 2 325 #define fileswitch_IS_IMAGE 3 326 327 #define fileswitch_ATTR_OWNER_READ (1 << 0) 328 #define fileswitch_ATTR_OWNER_WRITE (1 << 1) 329 #define fileswitch_ATTR_OWNER_LOCKED (1 << 3) 330 #define fileswitch_ATTR_WORLD_READ (1 << 4) 331 #define fileswitch_ATTR_WORLD_WRITE (1 << 5) 332 #define fileswitch_ATTR_WORLD_LOCKED (1 << 7) 333 334 #ifndef __ASSEMBLER__ 335 struct fileswitch_dirent { 336 uint32_t loadaddr; 337 uint32_t execaddr; 338 uint32_t length; 339 uint32_t attr; 340 uint32_t objtype; 341 char name[1]; /* Actually variable length */ 342 }; 343 344 extern os_error *xosfscontrol_shutdown(void); 345 #endif 346 347 #define Service_FSRedeclare 0x40 348 #define Service_PreReset 0x45 349 350 #ifndef __ASSEMBLER__ 351 extern void service_pre_reset(void); 352 #endif 353 354 #define os_MODEVAR_LOG2_BPP 9 355 #define os_MODEVAR_XWIND_LIMIT 11 356 #define os_MODEVAR_YWIND_LIMIT 12 357 #define os_VDUVAR_DISPLAY_START 149 358 #define os_VDUVAR_TOTAL_SCREEN_SIZE 150 359 #define os_VDUVAR_TCHAR_SPACEY 170 360 361 #ifndef __ASSEMBLER__ 362 extern void os_read_vdu_variables(const int *, int *); 363 364 extern os_error *xos_swi_number_from_string(char const *, int *); 365 366 extern unsigned int os_read_monotonic_time(void); 367 368 extern void os_read_mem_map_info(int *, int *); 369 370 struct os_mem_map_request { 371 int page_no; 372 void *map; 373 int access; 374 #define os_AREA_ACCESS_READ_WRITE 0 375 #define os_AREA_ACCESS_READ_ONLY 1 376 #define os_AREA_ACCESS_NONE 3 377 }; 378 379 extern void os_read_mem_map_entries(struct os_mem_map_request *); 380 381 extern os_error xcache_control(u_int, u_int, u_int *); 382 383 #endif 384 385 #define FileCoreDiscOp_ReadSectors 1 386 387 #ifndef __ASSEMBLER__ 388 389 struct filecore_disc { 390 u_int8_t log2secsize; 391 u_int8_t secspertrack; 392 u_int8_t heads; 393 u_int8_t density; 394 u_int8_t idlen; 395 u_int8_t log2bpmp; 396 u_int8_t skew; 397 u_int8_t bootoption; 398 u_int8_t lowsector; 399 u_int8_t nzones; 400 u_int16_t zone_spare; 401 u_int32_t root; 402 u_int32_t disc_size; 403 u_int16_t disc_id; 404 char disc_name[10]; 405 u_int32_t disc_type; 406 u_int32_t disc_size_hi; 407 u_int8_t share_size; 408 u_int8_t big_flag; 409 u_int8_t reserved[22]; 410 }; 411 412 struct filecore_daddr64 { 413 uint32_t drive; 414 uint64_t daddr; 415 }; 416 417 extern os_error *xfilecorediscop_read_sectors(uint32_t, uint32_t, void *, 418 size_t, void *, uint32_t *, void **, size_t *); 419 extern os_error *xfilecoresectorop_read_sectors(uint32_t, uint32_t, void *, 420 size_t, void *, uint32_t *, void **, size_t *); 421 extern os_error *xfilecorediscop64_read_sectors(uint32_t, 422 struct filecore_daddr64 *, void *, size_t, struct filecore_disc const *, 423 void *, uint32_t *, void **, size_t *); 424 extern os_error *xfilecore_drives(void *, int *, int *, int *); 425 426 #endif 427 428 /* RISC OS Error numbers */ 429 430 #define error_IS_ADIR 0xa8 431 #define error_TOO_MANY_OPEN_FILES 0xc0 432 #define error_FILE_NOT_FOUND 0xd6 433 434 #ifndef __ASSEMBLER__ 435 extern int riscos_errno(os_error *); 436 #endif 437