added readme with data checkout instructions, and changed the paths in
[eradicate] / src / dos / djdpmi.c
1 #ifdef __DJGPP__
2 #include <dpmi.h>
3 #include <sys/nearptr.h>
4 #include "cdpmi.h"
5 #include "inttypes.h"
6
7 uint16_t dpmi_alloc(unsigned int par, uint16_t *sel)
8 {
9         int tmp;
10         uint16_t seg = __dpmi_allocate_dos_memory(par, &tmp);
11         *sel = tmp;
12         return seg;
13 }
14
15 void dpmi_free(uint16_t sel)
16 {
17         __dpmi_free_dos_memory(sel);
18 }
19
20 void *dpmi_mmap(uint32_t phys_addr, unsigned int size)
21 {
22         __dpmi_meminfo mem;
23         mem.address = phys_addr;
24         mem.size = size;
25         __dpmi_physical_address_mapping(&mem);
26         return (void*)(mem.address - __djgpp_base_address);
27 }
28
29 void dpmi_munmap(void *addr)
30 {
31         __dpmi_meminfo mem;
32         mem.address = (uint32_t)addr + __djgpp_base_address;
33         __dpmi_free_physical_address_mapping(&mem);
34 }
35 #endif  /* __DJGPP__ */