Hi,

 I'm trying to port x86info to Solaris/OpenSolaris.  However, I encountered a 
problem wrt. MP tables.
x86info accepts a "-mp" option, and will dump the MP tables via lseek/read 
/dev/mem.  

 From the MultiProcessor Specification 1.4, this table should be probed as 
following:

The MP Floating Pointer Structure. This structure contains a physical address 
pointer to the
MP configuration table and other MP feature information bytes. When present, 
this structure
indicates that the system conforms to the MP specification. This structure must 
be stored in at
least one of the following memory locations, because the operating system 
searches for the MP
floating pointer structure in the order described below:
a. In the first kilobyte of Extended BIOS Data Area (EBDA), or
b. Within the last kilobyte of system base memory (e.g., 639K-640K for systems 
with 640
    KB of base memory or 511K-512K for systems with 512 KB of base memory) if 
the
    EBDA segment is undefined, or
c. In the BIOS ROM address space between 0F0000h and 0FFFFFh.


But when you run x86info as root, the reading always fails:

[js226...@git x86info]$ sudo x86info
x86info v1.21.  Dave Jones 2001-2007
Feedback to <da...@redhat.com>.

readEntry: Bad address
Found 4 cpus[js226...@git x86info]$ 


I wrote a program to do what the function apic_probe() of x86info project does

/* filename: mem.c
 *
 * This is a silly program does what the function apic_probe() of x86info 
project does:
 *      
 *      -> open /dev/mem
 *      -> seek where the MP config table is
 *      -> read 1024 bytes for EBDA
 */
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

typedef unsigned long vm_offset_t;
#define BIOS_SIZE  0x10000
#define ONE_KBYTE  1024



int main(void)
{
        uint16_t segment;
        vm_offset_t target;
        unsigned int buffer[BIOS_SIZE];

        int fd = open("/dev/mem", O_RDONLY);
        if (fd == -1) {
                perror("open");
                exit(EXIT_FAILURE);
        }

        if (lseek(fd, 0x040e, SEEK_SET) == (off_t)-1 ) {
                perror("lseek");
                exit(EXIT_FAILURE);
        }

        if (read(fd, &segment, 2) == -1) {
                perror("read");
                exit(EXIT_FAILURE);
        }

        printf("%hx\n", segment);

        if (segment) {
                target = (vm_offset_t)segment << 4;
                if (lseek(fd, target, SEEK_SET) == (off_t)-1 ) {
                        perror("lseek");
                        exit(EXIT_FAILURE);
                }

                if (read(fd, buffer, ONE_KBYTE) == -1) {
                        perror("read");
                        exit(EXIT_FAILURE);
                } else
                        printf("read of 1024 bytes of EBDA succeeded\n");
        }


        return 0;
}


[js226...@git ~]$ sudo ./mem 
9ec0
read: Bad address


Besides, I have test x86info in both Solaris/Linux on a machine. Linux's 
/dev/mem driver handled this reading correctly.

Any clues? 



-- 
Thanks,
Jike Song, SW Engineer
Sun Microsystems China(ERI)
Tel: (86-10)62673147

_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to