Is memory space above RTEMS workspace free to use?

Ian Jiang ianjiang.cn at gmail.com
Tue Dec 4 14:09:28 UTC 2007


	In order to save some system status to a hard disk, I want to transmit the content between the start of the data section and the end of the RTEMS workspace in the memory space to a disk file, using the memory space above the RTEMS workspace. However, writting to the disk file failed. (In fact, it was failed to open the file.)

My testing program works like this:

1) Declaring global variables
char *space_start = NULL;
char *space_end = NULL;
char *buffer_start = NULL;
char *buffer_end = NULL;


2) The system status, i.e. the start and end position in the memory space, which I want to save, is as follows:
    space_start = (char *)(&_data_start);
    space_end = (char*)
            (BSP_Configuration.work_space_start
            + BSP_Configuration.work_space_size
            - 1);

3) The free space which I want to use as a temporary buffer is as follows:
    buffer_start = space_end + 1;
    buffer_end = buffer_start + (space_end - space_start);



4) The following codes copy the system status to the temporary buffer:
    char* scan_source = space_start;
    char* scan_dest = buffer_start;
    while (scan_source <= space_end)
    {
        *scan_dest = *scan_source;
        scan_source++;
        scan_dest++;
    }

5) However open the disk file failed finally with error "Not a directory"
    fd = open("/mnt/hda1/status.dat", O_CREAT | O_RDWR | O_TRUNC);
    if (fd < 0) {
        printk("Open file failed: %s\n", strerror(errno));
        return;
    }

In fact, I have alread had an IDE disk with only partition /dev/hda1 mounted at /mnt/hda1, and everything would be ok if step 4) was removed. It also worked if step 4) was kept but file operations in step 5) was replaced with a simple printk(), i.e. the printk() worked well.

I used to thought that the memory sapce above the end of RTEMS worksapce had nothing to do with RTEMS. Now I am afraid that is not correct. My final aim is to find a piece of memory space which would not be used by RTEMS but could be managed by myself.

My program was running under RTEMS-4.6.99.3 in a VMware virtual box with arch i386 and bsp pc386. I used to use RTEMS-4.7.1 but it could not work even if file operations in step 5) was replaced with a simple printk() while step 4) was kept.




Best wishes!
 				
--------------
Ian Jiang
ianjiang.cn at gmail.com
2007-12-04 21:17:22




More information about the users mailing list