Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

DJGPP - Mapping small blocks of physmem beyond 1MB - __dpmi? (Developers)

posted by RayeR Homepage, CZ, 17.07.2011, 14:47

I tried to midify code for single mapping and then varied size of constant
BIOS_IMAGE_SIZE2 0x10000000
If it was less or equal 0x10000000 it works if greater then it crashed. I have installed 2GB RAM. I don't know how it will behave on 4GB sysatem wher ACPI SDT base will be higher close to 0xFFFFFFFF, probably it will crash with much smaller size when roll over...


//***************** copy SDT table from physical address to local buffer, parse header and calc checksum
long copy_sdt(Byte *p_buffer, DWord phys_ptr) // returns SDT length, 0 if bad checksum, negative if read error
{
  ACPI_SDT_HEADER sdt_header;          // temporarly stored SDT header to obtain full SDT size
  __dpmi_meminfo meminfo;              // DPMI meminfo structure for physical memory mapping
  int sdt_selector;                    // selector of segment descriptor of mapped SDT
#define BIOS_IMAGE_SIZE2 0x10000000
  meminfo.address=phys_ptr;            // mapped physical address
  meminfo.size=BIOS_IMAGE_SIZE2;        // mapped physical area size (128kB) large enough for SDT (possibly may roll-over 32bit range but will not be accessed)
  if (__dpmi_physical_address_mapping(&meminfo)!=0) // map physical memory area to linear
    return(-2);                        // if failed return -2
  if ((sdt_selector=__dpmi_allocate_ldt_descriptors(1))<0) // allocate 1 descriptor (desribing our new segment) in LDT and return it's selector
    return(-1);                        // if failed return -1
  __dpmi_set_segment_base_address(sdt_selector, meminfo.address); // set segment base to linear ptr
  __dpmi_set_segment_limit(sdt_selector, BIOS_IMAGE_SIZE2-1); // set segment limit to 128kB-1
  movedata(sdt_selector, 0, _my_ds(), (unsigned)&sdt_header, sizeof(ACPI_SDT_HEADER)); // copy SDT header from physical memory to temp buffer
  if (sdt_header.length<sizeof(ACPI_SDT_HEADER)) // check SDT lenght
    {                                  // if less than header size=invalid
    __dpmi_free_ldt_descriptor(sdt_selector); // free temporary allocated LDT descriptor
    return(0);                         // return 0
    }
  movedata(sdt_selector, 0, _my_ds(), (unsigned)p_buffer, sdt_header.length); // copy full SDT from physical memory to target buffer
  __dpmi_free_ldt_descriptor(sdt_selector); // free temporary allocated LDT descriptor
  if (calc_checksum(p_buffer, sdt_header.length)==0) // calculate checksum
    return(sdt_header.length);         // if match return full SDT lenght
  else                                 // data_length=full_length-header_length
    return(0);                         // else return 0
}

---
DOS gives me freedom to unlimited HW access.

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 203 users online (0 registered, 203 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum