| 1 | (* |
| 2 | * Copyright (C) 2006-2007 XenSource Ltd. |
| 3 | * Copyright (C) 2008 Citrix Ltd. |
| 4 | * Author Vincent Hanquez <[email protected]> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Lesser General Public License as published |
| 8 | * by the Free Software Foundation; version 2.1 only. with the special |
| 9 | * exception on linking described in file LICENSE. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU Lesser General Public License for more details. |
| 15 | *) |
| 16 | |
| 17 | type mmap_interface |
| 18 | |
| 19 | type mmap_prot_flag = RDONLY | WRONLY | RDWR |
| 20 | type mmap_map_flag = SHARED | PRIVATE |
| 21 | |
| 22 | (* mmap: fd -> prot_flag -> map_flag -> length -> offset -> interface *) |
| 23 | external mmap: Unix.file_descr -> mmap_prot_flag -> mmap_map_flag |
| 24 | -> int -> int -> mmap_interface = "stub_mmap_init" |
| 25 | external unmap: mmap_interface -> unit = "stub_mmap_final" |
| 26 | (* read: interface -> start -> length -> data *) |
| 27 | external read: mmap_interface -> int -> int -> string = "stub_mmap_read" |
| 28 | (* write: interface -> data -> start -> unit *) |
| 29 | external write: mmap_interface -> string -> int -> unit = "stub_mmap_write" |
| 30 | (* getpagesize: unit -> size of page *) |
| 31 | external getpagesize: unit -> int = "stub_mmap_getpagesize" |