The Kernel Kit Table of Contents     The Kernel Kit Index

System Information

Declared in: be/kernel/OS.h

Library: libroot.so

The following functions, types, and structures convey information about the system, such as the number of CPUs, when the kernel was built, and whether your computer is on fire.


System Info Functions


get_system_info()

                                                         
  

status_t get_system_info(system_info *info)

The get_system_info() function tells you more than you want to know about the physical capacities of your computer and other statistics of your operating system. The function copies this information into the system_info argument info. You must allocate info before passing it in.

RETURN CODES

get_system_info() always returns B_OK.


is_computer_on()

                                                         
  

int32 is_computer_on(void)

Returns 1 if the computer is on. If the computer isn't on, the value returned by this function is undefined.


is_computer_on_fire()

                                                         
  

double is_computer_on_fire(void)

Returns the temperature of the motherboard if the computer is currently on fire. If the computer isn't on fire, the function returns some other value.


System Info Structures and Constants


cpu_info

                                                         
  

typedef struct {
      bigtime_t active_time;
      } cpu_info

The cpu_info structure provides information about your computer's CPU(s). You retrieve the structure by looking in the cpu_infos field of the system_info structure. The cpu_infos field is an array that contains one cpu_info structure for each CPU on your motherboard.

Field Meaning
active_time The number of microseconds the CPU has spent doing useful work (i.e. not busy waiting) since the machine was booted.


cpu_type

                                                         
  

typedef enum cpu_types {
      B_CPU_PPC_601,
      B_CPU_PPC_603,
      B_CPU_PPC_603e,
      B_CPU_PPC_604,
      B_CPU_PPC_604e,
      B_CPU_PPC_750,
      B_CPU_PPC_686,
      B_CPU_AMD_29K,
      B_CPU_X86, Obsolete
      
B_CPU_MC6502,
      B_CPU_Z80,
      B_CPU_ALPHA,
      B_CPU_MIPS,
      B_CPU_HPPA,
      B_CPU_M68K,
      B_CPU_ARM,
      B_CPU_SH,
      B_CPU_SPARC,
      
      B_CPU_INTEL_X86 = 0x1000,
      
B_CPU_INTEL_PENTIUM,
      B_CPU_INTEL_PENTIUM75,
      B_CPU_INTEL_PENTIUM_486_OVERDRIVE,
      B_CPU_INTEL_PENTIUM_MMX,
      B_CPU_INTEL_PENTIUM_MMX_MODEL_4,
      B_CPU_INTEL_PENTIUM_MMX_MODEL_8,
      B_CPU_INTEL_PENTIUM75_486_OVERDRIVE,
      B_CPU_INTEL_PENTIUM_PRO,
      B_CPU_INTEL_PENTIUM_II,
      B_CPU_INTEL_PENTIUM_II_MODEL_3,
      B_CPU_INTEL_PENTIUM_II_MODEL_5,
      B_CPU_INTEL_CELERON,
      B_CPU_INTEL_PENTIUM_III,
      
      B_CPU_AMD_X86 = 0x1100,
      B_CPU_AMD_K5_MODEL0,
      B_CPU_AMD_K5_MODEL1,
      B_CPU_AMD_K5_MODEL2,
      B_CPU_AMD_K5_MODEL3,
      B_CPU_AMD_K6_MODEL6,
      B_CPU_AMD_K6_MODEL7,
      B_CPU_AMD_K6_MODEL8,
      B_CPU_AMD_K6_2,
      B_CPU_AMD_K6_MODEL9,
      B_CPU_AMD_K6_III,
      B_CPU_AMD_ATHLON_MODEL1,
      
      B_CPU_CYRIX_X86 = 0x1200,
      B_CPU_CYRIX_GXm,
      B_CPU_CYRIX_6x86MX,
      
      B_CPU_IDT_X86 = 0x1300,
      B_CPU_IDT_WINCHIP_C6,
      B_CPU_IDT_WINCHIP_2,
      
      B_CPU_RISE_X86 = 0x1400,
      B_CPU_RISE_mP6
      } cpu_type;

 
The B_X86_CPU constant is obsolete. All x86 CPUs are represented by specific vendor/model constants.


These constants represents different CPU vendors and models. To retrieve the constant that represents the CPU(s) that your computer uses, look in the cpu_type field of the system_info structure.

Note that the x86 types are grouped by vendor, where the vendor is identified by the high word, and the model by the low word. Each vendor has its own cpu_type constant, as indicated by the explicit values in the list above. If you're only interested in the vendor, mask the cpu_type value with B_CPU_X86_VENDOR_MASK, thus:

   system_info sysinfo;
   get_system_info( &sysinfo );
   
   switch ( sysinfo.cpu_type & B_CPU_X86_VENDOR_MASK ) {
      case B_CPU_INTEL_X86: ...
      case B_CPU_AMD_X86: ...
      case B_CPU_CYRIX_x86: ...
      case B_CPU_IDT_X86: ...
      case B_CPU_RISE_X86: ...
      default:
      /* Not x86. */
   }


B_CPU_X86_VENDOR_MASK

                                                         
  

B_CPU_X86_VENDOR_MASK

You mask your machine's cpu_type value with this constant to retrieve the CPU's vendor id (which is also a cpu_type value). If the CPU isn't an breed of x86, applying the mask will yield 0. See the cpu_type description for an example.


machine_id

                                                         
  

typedef int32 machine_id[2]; Currently unused

machine_id is a 64-bit number (encoded as two 32-bit numbers) that uniquely identifies this specific computer. The id number is returned as the id field (currently unused) of the system_info structure.


B_MAX_CPU_COUNT

                                                         
  

B_MAX_CPU_COUNT

This constant is set to the maximum number of CPUs that the BeOS can take advantage of. The number is machine-dependent.


platform_type

                                                         
  

typedef enum platform_types {
      B_BEBOX_PLATFORM = 0,
      B_MAC_PLATFORM,
      B_AT_CLONE_PLATFORM,
      B_ENIAC_PLATFORM,
      B_APPLE_II_PLATFORM,
      B_CRAY_PLATFORM,
      B_LISA_PLATFORM,
      B_TI_994A_PLATFORM,
      B_TIMEX_SINCLAIR_PLATFORM,
      B_ORAC_1_PLATFORM,
      B_HAL_PLATFORM,
      B_BESM_6_PLATFORM,
      B_MK_61_PLATFORM,
      B_NINTENDO_64_PLATFORM
      } platform_type;

These constants represent the various computer platforms that the BeOS does, has, should, might, or might not run on. To retrieve the constant for the machine that you're running on, look in the platform_type field of the system_info structure.


system_info

                                                         
  

typedef struct {
      machine_id id; Currently unused
      
bigtime_t boot_time;
      int32 cpu_count;
      cpu_type cpu_type;
      int32 cpu_revision;
      cpu_info cpu_infos[B_MAX_CPU_NUM];   
      int64 cpu_clock_speed;
      int64 bus_clock_speed;
      platform_type platform_type;
      int32 max_pages;
      int32 used_pages;
      int32 page_faults;
      int32 max_sems;
      int32 used_sems;
      int32 max_ports;
      int32 used_ports;
      int32 max_threads;
      int32 used_threads;
      int32 max_teams;
      int32 used_teams;
      char kernel_name[B_FILE_NAME_LENGTH];
      char kernel_build_date[B_OS_NAME_LENGTH];
      char kernel_build_time[B_OS_NAME_LENGTH];
      int64 kernel_version;
      } system_info;

The system_info structure describes your computer's hardware and operating system, and provides information about the availability of kernel resources (such as threads and ports). You retrieve a system_info structure through the get_system_info() function.

Field Meaning
id A 64-bit number (encoded as two int32s) that uniquely identifies this machine. Currently unsed.
boot_time The time at which the computer was last booted, measured in microseconds since January 1st, 1970. You can also get this information through system_time().
cpu_count The number of CPUs on your computer's motherboard.
cpu_type A constant that represents the CPU(s) make and model.
cpu_revision The revision number of the CPU(s).
cpu_infos An array of cpu_info structures, one for each CPU.
cpu_clock_speed The speed (in Hz) at which the CPU(s) operate.
bus_clock_speed The speed (in Hz) at which the bus operates.
platform_type The platform type constant that reprsents your computer.
max_resource
used_resource
These fields give the total number of RAM pages, semaphores, and so on, that the system can create, and the number that are currently in use.
page_faults The number of times the system has read a page of memory into RAM due to a page fault.
kernel_name The filename of the kernel (the leaf name, not the path).
kernel_build_date Fixed-width string that gives the date that the kernel was built; for example:
   Jun  5 1999
kernel_build_time   Fixed-width string that gives the time of day that the kernel was built; for example:        10:02:16
kernel_version   A Be-assigned number that identifies the kernel version.


The Kernel Kit Table of Contents     The Kernel Kit Index


The Be Book,
...in lovely HTML...
for BeOS Release 5.

Copyright © 2000 Be, Inc. All rights reserved..