Changeset 1920


Ignore:
Timestamp:
Apr 26, 2005, 4:22:50 AM (20 years ago)
Author:
bird
Message:

Having some fun.

Location:
trunk/src/emx/src/lib/misc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/misc/sysctl.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1919 r1920  
    4141
    4242#include <sys/param.h>
    43 #define _KERNEL
    44 #include <sys/sysctl.h>
    4543#include <386/builtin.h>
    4644#include <sys/fmutex.h>
     
    4947#include <string.h>
    5048#include <stdio.h>
     49#define _KERNEL
     50#include <sys/sysctl.h>
    5151
    5252#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC
     
    7474static int sysctl_root(SYSCTL_HANDLER_ARGS);
    7575
    76 struct sysctl_oid_list sysctl__children; /* root list */
     76struct sysctl_oid_list sysctl__children = {0}; /* root list */
    7777
    7878static struct sysctl_oid *
  • trunk/src/emx/src/lib/misc/sysctl_mib.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1919 r1920  
    134134#endif
    135135
     136#if 0 /* in sysctl_os2.c */
    136137//char kernelname[MAXPATHLEN] = "/kernel";      /* XXX bloat */
    137138//
     
    139140//    kernelname, sizeof kernelname, "Name of kernel file booted");
    140141
    141 #ifdef SMP
    142 SYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD,
    143     &mp_ncpus, 0, "Number of active CPUs");
    144 #else
    145 SYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD,
    146     0, 1, "Number of active CPUs");
     142//#ifdef SMP
     143//SYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD,
     144//    &mp_ncpus, 0, "Number of active CPUs");
     145//#else
     146//SYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD,
     147//    0, 1, "Number of active CPUs");
     148//#endif
    147149#endif
    148150
  • trunk/src/emx/src/lib/misc/sysctl_os2.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1919 r1920  
    2525 */
    2626
     27/*******************************************************************************
     28*   Header Files                                                               *
     29*******************************************************************************/
    2730#include "libc-alias.h"
    2831
    2932#define INCL_BASE
    3033#define INCL_ERRORS
    31 #include <os2.h>
     34#define INCL_FSMACROS
     35#include <os2emx.h>
    3236
    3337#include <unistd.h>
     
    5357        } u;
    5458        ULONG ul;
     59        FS_VAR_SAVE_LOAD();
    5560
    5661        /* Try the highres timer first. */
     
    7580            tv.tv_sec -= ul / 1000;
    7681        }
     82        FS_RESTORE();
    7783        if (tv.tv_usec < 0)
    7884        {
     
    103109        0, 0, sysctl_kern_bootfile, "A", "Kernel file");
    104110
     111
     112/*
     113 * HW
     114 */
     115
     116SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
     117        "i386", sizeof("i386"), "Machine");
     118
     119/**
     120 * HW_MODEL
     121 */
     122static int sysctl_hw_model(SYSCTL_HANDLER_ARGS)
     123{
     124    static union
     125    {
     126        char        szModel[17];
     127        uint32_t    uRegs[4];
     128    } u;
     129    if (!u.szModel[0])
     130    {
     131        int i;
     132        asm ("cpuid\n"
     133             : "=a" (i),
     134               "=b" (u.uRegs[0]),
     135               "=c" (u.uRegs[2]),
     136               "=d" (u.uRegs[1])
     137             : "a" (0)
     138             );
     139    }
     140
     141    return (sysctl_handle_string(oidp, u.szModel, sizeof(u.szModel), req));
     142}
     143
     144SYSCTL_PROC(_hw, HW_MODEL, hw_model, CTLFLAG_RD,
     145        0, 0, sysctl_hw_model, "A", "Process model");
     146
     147/**
     148 * Number of CPUs.
     149 */
     150static int sysctl_hw_ncpus(SYSCTL_HANDLER_ARGS)
     151{
     152    static u_int cCpus;
     153    if (!cCpus)
     154    {
     155        ULONG ul;
     156        FS_VAR_SAVE_LOAD();
     157        if (DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &ul, sizeof(ul)))
     158            ul = 1;
     159        cCpus = ul;
     160        FS_RESTORE();
     161    }
     162
     163    return (sysctl_handle_int(oidp, &cCpus, 0, req));
     164}
     165
     166SYSCTL_PROC(_hw, HW_NCPU, ncpus, CTLFLAG_RD,
     167        0, 0, sysctl_hw_ncpus, "UI", "number of cpus");
     168
     169
     170SYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD,
     171        "i386", sizeof("i386"), "Machine arch");
     172
Note: See TracChangeset for help on using the changeset viewer.