help!!!! getting system information

I need to know how to get system information, only function i can find is
devctl(), they had a nice qnx_info() in qnx4, but migration kit doesnt tell
you how to write the equivalent functions

  1. total memory , available memory left.

  2. video card information.

  3. operating system version.

  4. cpu’s information.

Ran Zhang wrote:

  1. total memory , available memory left.

I think total memory you have to walk the syspage adding up ram
sections. Bascially something like this:

static uint64_t get_total_mem(void) {
char *str = SYSPAGE_ENTRY(strings)->data;
struct asinfo_entry *as = SYSPAGE_ENTRY(asinfo);
uint64_t total = 0;
unsigned num;

for(num = _syspage_ptr->asinfo.entry_size / sizeof(*as);
num > 0; --num) {
if(strcmp(&str[as->name], “ram”) == 0) {
total += as->end - as->start + 1;
}
++as;
}
return total;
}

Free memory is available as the size of “/proc”, so do a
“stat(”/proc", &st);" and look at st.st_size (bytes). Or
“ls -ld /proc” from the shell.

  1. operating system version.

#include <sys/utsname.h>
uname();

-or-

#include <confname.h>
sysconf(); // _CS_RELEASE, _CS_VERSION, etc

Or from the shell, the “uname” or “getconf” utilities.

  1. cpu’s information.

Again I think this is another walk-the-syspage thing, looking
at the “cpu” section. Refer <sys/syspage.h>

struct cpuinfo_entry *cpu = SYSPAGE_ENTRY(cpuinfo);

This will be an array based on ‘numcpu’ field in root of syspage.

Actually you should be looking for “sysram” since that is what is used for
ram allocations.

Cheers,

Colin

John Garvey wrote:

Ran Zhang wrote:

  1. total memory , available memory left.

I think total memory you have to walk the syspage adding up ram
sections. Bascially something like this:

static uint64_t get_total_mem(void) {
char *str = SYSPAGE_ENTRY(strings)->data;
struct asinfo_entry *as = SYSPAGE_ENTRY(asinfo);
uint64_t total = 0;
unsigned num;

for(num = _syspage_ptr->asinfo.entry_size / sizeof(*as);
num > 0; --num) {
if(strcmp(&str[as->name], “ram”) == 0) {
total += as->end - as->start + 1;
}
++as;
}
return total;
}

Free memory is available as the size of “/proc”, so do a
“stat(”/proc", &st);" and look at st.st_size (bytes). Or
“ls -ld /proc” from the shell.

  1. operating system version.

#include <sys/utsname.h
uname();

-or-

#include <confname.h
sysconf(); // _CS_RELEASE, _CS_VERSION, etc

Or from the shell, the “uname” or “getconf” utilities.

  1. cpu’s information.

Again I think this is another walk-the-syspage thing, looking
at the “cpu” section. Refer <sys/syspage.h

struct cpuinfo_entry *cpu = SYSPAGE_ENTRY(cpuinfo);

This will be an array based on ‘numcpu’ field in root of syspage.