1 /* Kernel specific structures and functions 2 * 3 * Copyright 2004, Haiku Inc. All Rights Reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef _OS_H 7 #define _OS_H 8 9 10 #include <stdarg.h> 11 12 #include <SupportDefs.h> 13 #include <StorageDefs.h> 14 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 /*-------------------------------------------------------------*/ 21 /* System constants */ 22 23 #define B_OS_NAME_LENGTH 32 24 #define B_PAGE_SIZE 4096 25 #define B_INFINITE_TIMEOUT (9223372036854775807LL) 26 27 enum { 28 B_TIMEOUT = 8, /* relative timeout */ 29 B_RELATIVE_TIMEOUT = 8, /* fails after a relative timeout with B_WOULD_BLOCK */ 30 B_ABSOLUTE_TIMEOUT = 16, /* fails after an absolute timeout with B_WOULD BLOCK */ 31 }; 32 33 /*-------------------------------------------------------------*/ 34 /* Types */ 35 36 typedef int32 area_id; 37 typedef int32 port_id; 38 typedef int32 sem_id; 39 typedef int32 team_id; 40 typedef int32 thread_id; 41 42 43 /*-------------------------------------------------------------*/ 44 /* Areas */ 45 46 typedef struct area_info { 47 area_id area; 48 char name[B_OS_NAME_LENGTH]; 49 size_t size; 50 uint32 lock; 51 uint32 protection; 52 team_id team; 53 uint32 ram_size; 54 uint32 copy_count; 55 uint32 in_count; 56 uint32 out_count; 57 void *address; 58 } area_info; 59 60 /* area locking */ 61 #define B_NO_LOCK 0 62 #define B_LAZY_LOCK 1 63 #define B_FULL_LOCK 2 64 #define B_CONTIGUOUS 3 65 #define B_LOMEM 4 66 67 /* address spec for create_area(), and clone_area() */ 68 #define B_ANY_ADDRESS 0 69 #define B_EXACT_ADDRESS 1 70 #define B_BASE_ADDRESS 2 71 #define B_CLONE_ADDRESS 3 72 #define B_ANY_KERNEL_ADDRESS 4 73 74 /* area protection */ 75 #define B_READ_AREA 1 76 #define B_WRITE_AREA 2 77 78 extern area_id create_area(const char *name, void **start_addr, uint32 addr_spec, 79 size_t size, uint32 lock, uint32 protection); 80 extern area_id clone_area(const char *name, void **dest_addr, uint32 addr_spec, 81 uint32 protection, area_id source); 82 extern area_id find_area(const char *name); 83 extern area_id area_for(void *address); 84 extern status_t delete_area(area_id id); 85 extern status_t resize_area(area_id id, size_t new_size); 86 extern status_t set_area_protection(area_id id, uint32 new_protection); 87 88 /* system private, use macros instead */ 89 extern status_t _get_area_info(area_id id, area_info *areaInfo, size_t size); 90 extern status_t _get_next_area_info(team_id team, int32 *cookie, area_info *areaInfo, size_t size); 91 92 #define get_area_info(id, ainfo) \ 93 _get_area_info((id), (ainfo),sizeof(*(ainfo))) 94 #define get_next_area_info(team, cookie, ainfo) \ 95 _get_next_area_info((team), (cookie), (ainfo), sizeof(*(ainfo))) 96 97 98 /*-------------------------------------------------------------*/ 99 /* Ports */ 100 101 typedef struct port_info { 102 port_id port; 103 team_id team; 104 char name[B_OS_NAME_LENGTH]; 105 int32 capacity; /* queue depth */ 106 int32 queue_count; /* # msgs waiting to be read */ 107 int32 total_count; /* total # msgs read so far */ 108 } port_info; 109 110 extern port_id create_port(int32 capacity, const char *name); 111 extern port_id find_port(const char *name); 112 extern ssize_t read_port(port_id port, int32 *code, void *buffer, size_t bufferSize); 113 extern ssize_t read_port_etc(port_id port, int32 *code, void *buffer, size_t bufferSize, 114 uint32 flags, bigtime_t timeout); 115 extern status_t write_port(port_id port, int32 code, const void *buffer, size_t bufferSize); 116 extern status_t write_port_etc(port_id port, int32 code, const void *buffer, size_t bufferSize, 117 uint32 flags, bigtime_t timeout); 118 extern status_t close_port(port_id port); 119 extern status_t delete_port(port_id port); 120 121 extern ssize_t port_buffer_size(port_id port); 122 extern ssize_t port_buffer_size_etc(port_id port, uint32 flags, bigtime_t timeout); 123 extern ssize_t port_count(port_id port); 124 extern status_t set_port_owner(port_id port, team_id team); 125 126 /* system private, use the macros instead */ 127 extern status_t _get_port_info(port_id port, port_info *portInfo, size_t portInfoSize); 128 extern status_t _get_next_port_info(team_id team, int32 *cookie, port_info *portInfo, 129 size_t portInfoSize); 130 131 #define get_port_info(port, info) \ 132 _get_port_info((port), (info), sizeof(*(info))) 133 #define get_next_port_info(team, cookie, info) \ 134 _get_next_port_info((team), (cookie), (info), sizeof(*(info))) 135 136 137 /*-------------------------------------------------------------*/ 138 /* Semaphores */ 139 140 typedef struct sem_info { 141 sem_id sem; 142 team_id team; 143 char name[B_OS_NAME_LENGTH]; 144 int32 count; 145 thread_id latest_holder; 146 } sem_info; 147 148 /* semaphore flags */ 149 enum { 150 B_CAN_INTERRUPT = 0x01, // acquisition of the semaphore can be 151 // interrupted (system use only) 152 B_CHECK_PERMISSION = 0x04, // ownership will be checked (system use 153 // only) 154 B_KILL_CAN_INTERRUPT = 0x20, // acquisition of the semaphore can be 155 // interrupted by SIGKILL[THR], even 156 // if not B_CAN_INTERRUPT (system use 157 // only) 158 159 /* release_sem_etc() only flags */ 160 B_DO_NOT_RESCHEDULE = 0x02, // thread is not rescheduled 161 B_RELEASE_ALL = 0x08, // all waiting threads will be woken up, 162 // count will be zeroed 163 B_RELEASE_IF_WAITING_ONLY = 0x10, // release count only if there are any 164 // threads waiting 165 }; 166 167 extern sem_id create_sem(int32 count, const char *name); 168 extern status_t delete_sem(sem_id id); 169 extern status_t acquire_sem(sem_id id); 170 extern status_t acquire_sem_etc(sem_id id, int32 count, uint32 flags, bigtime_t timeout); 171 extern status_t release_sem(sem_id id); 172 extern status_t release_sem_etc(sem_id id, int32 count, uint32 flags); 173 // ToDo: the following two calls are not part of the BeOS API, and might be 174 // changed or even removed for the final release of Haiku R1 175 extern status_t switch_sem(sem_id semToBeReleased, sem_id id); 176 extern status_t switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count, 177 uint32 flags, bigtime_t timeout); 178 extern status_t get_sem_count(sem_id id, int32 *threadCount); 179 extern status_t set_sem_owner(sem_id id, team_id team); 180 181 /* system private, use the macros instead */ 182 extern status_t _get_sem_info(sem_id id, struct sem_info *info, size_t infoSize); 183 extern status_t _get_next_sem_info(team_id team, int32 *cookie, struct sem_info *info, 184 size_t infoSize); 185 186 #define get_sem_info(sem, info) \ 187 _get_sem_info((sem), (info), sizeof(*(info))) 188 189 #define get_next_sem_info(team, cookie, info) \ 190 _get_next_sem_info((team), (cookie), (info), sizeof(*(info))) 191 192 193 /*-------------------------------------------------------------*/ 194 /* Teams */ 195 196 typedef struct { 197 team_id team; 198 int32 thread_count; 199 int32 image_count; 200 int32 area_count; 201 thread_id debugger_nub_thread; 202 port_id debugger_nub_port; 203 int32 argc; 204 char args[64]; 205 uid_t uid; 206 gid_t gid; 207 } team_info; 208 209 #define B_CURRENT_TEAM 0 210 #define B_SYSTEM_TEAM 2 211 212 extern status_t kill_team(team_id team); 213 /* see also: send_signal() */ 214 215 /* system private, use macros instead */ 216 extern status_t _get_team_info(team_id id, team_info *info, size_t size); 217 extern status_t _get_next_team_info(int32 *cookie, team_info *info, size_t size); 218 219 #define get_team_info(id, info) \ 220 _get_team_info((id), (info), sizeof(*(info))) 221 222 #define get_next_team_info(cookie, info) \ 223 _get_next_team_info((cookie), (info), sizeof(*(info))) 224 225 /* team usage info */ 226 227 typedef struct { 228 bigtime_t user_time; 229 bigtime_t kernel_time; 230 } team_usage_info; 231 232 enum { 233 /* compatible to sys/resource.h RUSAGE_SELF and RUSAGE_CHILDREN */ 234 B_TEAM_USAGE_SELF = 0, 235 B_TEAM_USAGE_CHILDREN = -1, 236 }; 237 238 /* system private, use macros instead */ 239 extern status_t _get_team_usage_info(team_id team, int32 who, team_usage_info *info, size_t size); 240 241 #define get_team_usage_info(team, who, info) \ 242 _get_team_usage_info((team), (who), (info), sizeof(*(info))) 243 244 /*-------------------------------------------------------------*/ 245 /* Threads */ 246 247 typedef enum { 248 B_THREAD_RUNNING = 1, 249 B_THREAD_READY, 250 B_THREAD_RECEIVING, 251 B_THREAD_ASLEEP, 252 B_THREAD_SUSPENDED, 253 B_THREAD_WAITING 254 } thread_state; 255 256 typedef struct { 257 thread_id thread; 258 team_id team; 259 char name[B_OS_NAME_LENGTH]; 260 thread_state state; 261 int32 priority; 262 sem_id sem; 263 bigtime_t user_time; 264 bigtime_t kernel_time; 265 void *stack_base; 266 void *stack_end; 267 } thread_info; 268 269 #define B_IDLE_PRIORITY 0 270 #define B_LOWEST_ACTIVE_PRIORITY 1 271 #define B_LOW_PRIORITY 5 272 #define B_NORMAL_PRIORITY 10 273 #define B_DISPLAY_PRIORITY 15 274 #define B_URGENT_DISPLAY_PRIORITY 20 275 #define B_REAL_TIME_DISPLAY_PRIORITY 100 276 #define B_URGENT_PRIORITY 110 277 #define B_REAL_TIME_PRIORITY 120 278 279 #define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY 280 #define B_MIN_PRIORITY B_IDLE_PRIORITY 281 #define B_MAX_PRIORITY B_REAL_TIME_PRIORITY 282 283 #define B_SYSTEM_TIMEBASE 0 284 285 typedef int32 (*thread_func) (void *); 286 #define thread_entry thread_func /* thread_entry is for backward compatibility only! Use thread_func */ 287 288 extern thread_id spawn_thread(thread_func, const char *name, int32 priority, void *data); 289 extern status_t kill_thread(thread_id thread); 290 extern status_t resume_thread(thread_id thread); 291 extern status_t suspend_thread(thread_id thread); 292 293 extern status_t rename_thread(thread_id thread, const char *newName); 294 extern status_t set_thread_priority (thread_id thread, int32 newPriority); 295 extern void exit_thread(status_t status); 296 extern status_t wait_for_thread (thread_id thread, status_t *threadReturnValue); 297 extern status_t on_exit_thread(void (*callback)(void *), void *data); 298 299 #if __INTEL__ && !_KERNEL_MODE && !_NO_INLINE_ASM 300 static inline thread_id 301 find_thread(const char *name) { 302 # ifndef __HAIKU__ 303 /* ToDo: this can be removed once we don't need BeOS compatibility of our source files */ 304 # define _kern_find_thread _kfind_thread_ 305 # endif 306 extern thread_id _kern_find_thread(const char *name); 307 if (!name) { 308 thread_id thread; 309 __asm__ __volatile__ ( 310 "movl %%fs:4, %%eax \n\t" 311 : "=a" (thread)); 312 return thread; 313 } 314 return _kern_find_thread(name); 315 # ifndef __HAIKU__ 316 # undef _kern_find_thread 317 # endif 318 } 319 #else 320 extern thread_id find_thread(const char *name); 321 #endif 322 323 extern status_t send_data(thread_id thread, int32 code, const void *buffer, 324 size_t bufferSize); 325 extern int32 receive_data(thread_id *sender, void *buffer, size_t bufferSize); 326 extern bool has_data(thread_id thread); 327 328 extern status_t snooze(bigtime_t amount); 329 extern status_t snooze_etc(bigtime_t amount, int timeBase, uint32 flags); 330 extern status_t snooze_until(bigtime_t time, int timeBase); 331 332 /* system private, use macros instead */ 333 extern status_t _get_thread_info(thread_id id, thread_info *info, size_t size); 334 extern status_t _get_next_thread_info(team_id team, int32 *cookie, 335 thread_info *info, size_t size); 336 337 #define get_thread_info(id, info) \ 338 _get_thread_info((id), (info), sizeof(*(info))) 339 340 #define get_next_thread_info(team, cookie, info) \ 341 _get_next_thread_info((team), (cookie), (info), sizeof(*(info))) 342 343 344 /*-------------------------------------------------------------*/ 345 /* Time */ 346 347 extern uint32 real_time_clock(void); 348 extern void set_real_time_clock(uint32 secs_since_jan1_1970); 349 extern bigtime_t real_time_clock_usecs(void); 350 extern status_t set_timezone(char *timezone); 351 extern bigtime_t system_time(void); /* time since booting in microseconds */ 352 353 354 /*-------------------------------------------------------------*/ 355 /* Alarm */ 356 357 enum { 358 B_ONE_SHOT_ABSOLUTE_ALARM = 1, 359 B_ONE_SHOT_RELATIVE_ALARM, 360 B_PERIODIC_ALARM /* "when" specifies the period */ 361 }; 362 363 extern bigtime_t set_alarm(bigtime_t when, uint32 flags); 364 365 366 /*-------------------------------------------------------------*/ 367 /* Debugger */ 368 369 extern void debugger(const char *message); 370 371 /* 372 calling this function with a non-zero value will cause your thread 373 to receive signals for any exceptional conditions that occur (i.e. 374 you'll get SIGSEGV for data access exceptions, SIGFPE for floating 375 point errors, SIGILL for illegal instructions, etc). 376 377 to re-enable the default debugger pass a zero. 378 */ 379 extern const int disable_debugger(int state); 380 381 // TODO: Remove. Temporary debug helper. 382 extern void debug_printf(const char *format, ...) 383 __attribute__ ((format (__printf__, 1, 2))); 384 extern void debug_vprintf(const char *format, va_list args); 385 386 387 /*-------------------------------------------------------------*/ 388 /* System information */ 389 390 #if __INTEL__ 391 # define B_MAX_CPU_COUNT 8 392 #elif __POWERPC__ 393 # define B_MAX_CPU_COUNT 8 394 #endif 395 396 #define OBOS_CPU_TYPES 397 398 typedef enum cpu_types { 399 // ToDo: add latest models 400 401 /* Motorola/IBM */ 402 B_CPU_PPC_601 = 1, 403 B_CPU_PPC_603 = 2, 404 B_CPU_PPC_603e = 3, 405 B_CPU_PPC_604 = 4, 406 B_CPU_PPC_604e = 5, 407 B_CPU_PPC_750 = 6, 408 B_CPU_PPC_686 = 13, 409 410 /* Intel */ 411 412 /* Updated according to Intel(R) Processor Identification and 413 * the CPUID instruction (Table 4) 414 * AP-485 Intel - 24161828.pdf 415 */ 416 B_CPU_INTEL_x86 = 0x1000, 417 B_CPU_INTEL_PENTIUM = 0x1051, 418 B_CPU_INTEL_PENTIUM75, 419 B_CPU_INTEL_PENTIUM_486_OVERDRIVE, 420 B_CPU_INTEL_PENTIUM_MMX, 421 B_CPU_INTEL_PENTIUM_MMX_MODEL_4 = B_CPU_INTEL_PENTIUM_MMX, 422 B_CPU_INTEL_PENTIUM_MMX_MODEL_8 = 0x1058, 423 B_CPU_INTEL_PENTIUM75_486_OVERDRIVE, 424 B_CPU_INTEL_PENTIUM_PRO = 0x1061, 425 B_CPU_INTEL_PENTIUM_II = 0x1063, 426 B_CPU_INTEL_PENTIUM_II_MODEL_3 = 0x1063, 427 B_CPU_INTEL_PENTIUM_II_MODEL_5 = 0x1065, 428 B_CPU_INTEL_CELERON = 0x1066, 429 B_CPU_INTEL_PENTIUM_III = 0x1067, 430 B_CPU_INTEL_PENTIUM_III_MODEL_8 = 0x1068, 431 B_CPU_INTEL_PENTIUM_M = 0x1069, 432 B_CPU_INTEL_PENTIUM_III_XEON = 0x106a, 433 B_CPU_INTEL_PENTIUM_III_MODEL_11 = 0x106b, 434 B_CPU_INTEL_PENTIUM_M_MODEL_13 = 0x106d, /* Dothan */ 435 B_CPU_INTEL_PENTIUM_IV = 0x10f0, 436 B_CPU_INTEL_PENTIUM_IV_MODEL_1, 437 B_CPU_INTEL_PENTIUM_IV_MODEL_2, 438 B_CPU_INTEL_PENTIUM_IV_MODEL_3, 439 B_CPU_INTEL_PENTIUM_IV_MODEL_4, 440 441 /* AMD */ 442 443 /* Checked with "AMD Processor Recognition Application Note" 444 * (Table 3) 445 * 20734.pdf 446 */ 447 B_CPU_AMD_x86 = 0x1100, 448 B_CPU_AMD_K5_MODEL_0 = 0x1150, 449 B_CPU_AMD_K5_MODEL_1, 450 B_CPU_AMD_K5_MODEL_2, 451 B_CPU_AMD_K5_MODEL_3, 452 B_CPU_AMD_K6_MODEL_6 = 0x1156, 453 B_CPU_AMD_K6_MODEL_7 = 0x1157, 454 B_CPU_AMD_K6_MODEL_8 = 0x1158, 455 B_CPU_AMD_K6_2 = 0x1158, 456 B_CPU_AMD_K6_MODEL_9 = 0x1159, 457 B_CPU_AMD_K6_III = 0x1159, 458 B_CPU_AMD_K6_III_MODEL_13 = 0x115d, 459 460 B_CPU_AMD_ATHLON_MODEL_1 = 0x1161, 461 B_CPU_AMD_ATHLON_MODEL_2 = 0x1162, 462 463 B_CPU_AMD_DURON = 0x1163, 464 465 B_CPU_AMD_ATHLON_THUNDERBIRD = 0x1164, 466 B_CPU_AMD_ATHLON_XP = 0x1166, 467 B_CPU_AMD_ATHLON_XP_MODEL_7, 468 B_CPU_AMD_ATHLON_XP_MODEL_8, 469 B_CPU_AMD_ATHLON_XP_MODEL_10 = 0x116a, /* Barton */ 470 471 B_CPU_AMD_SEMPRON_MODEL_8 = B_CPU_AMD_ATHLON_XP_MODEL_8, 472 B_CPU_AMD_SEMPRON_MODEL_10 = B_CPU_AMD_ATHLON_XP_MODEL_10, 473 474 /* According to "Revision guide for AMD Athlon 64 475 * and AMD Opteron Processors" (25759.pdf) 476 */ 477 B_CPU_AMD_ATHLON_64_MODEL_4 = 0x11f4, 478 B_CPU_AMD_ATHLON_64_MODEL_5, 479 B_CPU_AMD_OPTERON = B_CPU_AMD_ATHLON_64_MODEL_5, 480 B_CPU_AMD_ATHLON_64_FX = B_CPU_AMD_ATHLON_64_MODEL_5, 481 B_CPU_AMD_ATHLON_64_MODEL_7 = 0x11f7, 482 B_CPU_AMD_ATHLON_64_MODEL_8, 483 B_CPU_AMD_ATHLON_64_MODEL_11 = 0x11fb, 484 B_CPU_AMD_ATHLON_64_MODEL_12, 485 B_CPU_AMD_ATHLON_64_MODEL_14 = 0x11fe, 486 B_CPU_AMD_ATHLON_64_MODEL_15, 487 488 /* VIA/Cyrix */ 489 B_CPU_CYRIX_x86 = 0x1200, 490 B_CPU_VIA_CYRIX_x86 = 0x1200, 491 B_CPU_CYRIX_GXm = 0x1254, 492 B_CPU_CYRIX_6x86MX = 0x1260, 493 494 /* VIA/IDT */ 495 B_CPU_IDT_x86 = 0x1300, 496 B_CPU_VIA_IDT_x86 = 0x1300, 497 B_CPU_IDT_WINCHIP_C6 = 0x1354, 498 B_CPU_IDT_WINCHIP_2 = 0x1358, 499 B_CPU_IDT_WINCHIP_3, 500 B_CPU_VIA_EDEN = 0x1367, 501 B_CPU_VIA_EDEN_EZRA_T = 0x1368, 502 503 /* Transmeta */ 504 B_CPU_TRANSMETA_x86 = 0x1600, 505 B_CPU_TRANSMETA_CRUSOE = 0x1654, 506 507 /* Rise */ 508 B_CPU_RISE_x86 = 0x1400, 509 B_CPU_RISE_mP6 = 0x1450, 510 511 /* National Semiconductor */ 512 B_CPU_NATIONAL_x86 = 0x1500, 513 B_CPU_NATIONAL_GEODE_GX1 = 0x1554, 514 B_CPU_NATIONAL_GEODE_GX2, 515 516 /* For compatibility */ 517 B_CPU_AMD_29K = 14, 518 B_CPU_x86, 519 B_CPU_MC6502, 520 B_CPU_Z80, 521 B_CPU_ALPHA, 522 B_CPU_MIPS, 523 B_CPU_HPPA, 524 B_CPU_M68K, 525 B_CPU_ARM, 526 B_CPU_SH, 527 B_CPU_SPARC, 528 } cpu_type; 529 530 #define B_CPU_x86_VENDOR_MASK 0xff00 531 532 #ifdef __INTEL__ 533 typedef union { 534 struct { 535 uint32 max_eax; 536 char vendor_id[12]; 537 } eax_0; 538 539 struct { 540 uint32 stepping : 4; 541 uint32 model : 4; 542 uint32 family : 4; 543 uint32 type : 2; 544 uint32 reserved_0 : 2; 545 uint32 extended_model : 4; 546 uint32 extended_family : 8; 547 uint32 reserved_1 : 4; 548 549 uint32 reserved_2; 550 uint32 features; 551 uint32 reserved_3; 552 } eax_1; 553 554 struct { 555 uint8 call_num; 556 uint8 cache_descriptors[15]; 557 } eax_2; 558 559 struct { 560 uint32 reserved[2]; 561 uint32 serial_number_high; 562 uint32 serial_number_low; 563 } eax_3; 564 565 char as_chars[16]; 566 567 struct { 568 uint32 eax; 569 uint32 ebx; 570 uint32 edx; 571 uint32 ecx; 572 } regs; 573 } cpuid_info; 574 575 extern status_t get_cpuid(cpuid_info *info, uint32 eaxRegister, uint32 cpuNum); 576 #endif 577 578 579 typedef enum platform_types { 580 B_BEBOX_PLATFORM = 0, 581 B_MAC_PLATFORM, 582 B_AT_CLONE_PLATFORM, 583 B_ENIAC_PLATFORM, 584 B_APPLE_II_PLATFORM, 585 B_CRAY_PLATFORM, 586 B_LISA_PLATFORM, 587 B_TI_994A_PLATFORM, 588 B_TIMEX_SINCLAIR_PLATFORM, 589 B_ORAC_1_PLATFORM, 590 B_HAL_PLATFORM, 591 B_BESM_6_PLATFORM, 592 B_MK_61_PLATFORM, 593 B_NINTENDO_64_PLATFORM 594 } platform_type; 595 596 typedef struct { 597 bigtime_t active_time; /* usec of doing useful work since boot */ 598 } cpu_info; 599 600 601 typedef int32 machine_id[2]; /* unique machine ID */ 602 603 typedef struct { 604 machine_id id; /* unique machine ID */ 605 bigtime_t boot_time; /* time of boot (usecs since 1/1/1970) */ 606 607 int32 cpu_count; /* number of cpus */ 608 enum cpu_types cpu_type; /* type of cpu */ 609 int32 cpu_revision; /* revision # of cpu */ 610 cpu_info cpu_infos[B_MAX_CPU_COUNT]; /* info about individual cpus */ 611 int64 cpu_clock_speed; /* processor clock speed (Hz) */ 612 int64 bus_clock_speed; /* bus clock speed (Hz) */ 613 enum platform_types platform_type; /* type of machine we're on */ 614 615 int32 max_pages; /* total # physical pages */ 616 int32 used_pages; /* # physical pages in use */ 617 int32 page_faults; /* # of page faults */ 618 int32 max_sems; 619 int32 used_sems; 620 int32 max_ports; 621 int32 used_ports; 622 int32 max_threads; 623 int32 used_threads; 624 int32 max_teams; 625 int32 used_teams; 626 627 char kernel_name[B_FILE_NAME_LENGTH]; /* name of kernel */ 628 char kernel_build_date[B_OS_NAME_LENGTH]; /* date kernel built */ 629 char kernel_build_time[B_OS_NAME_LENGTH]; /* time kernel built */ 630 int64 kernel_version; /* version of this kernel */ 631 632 bigtime_t _busy_wait_time; /* reserved for whatever */ 633 int32 pad[4]; /* just in case... */ 634 } system_info; 635 636 /* system private, use macro instead */ 637 extern status_t _get_system_info(system_info *returned_info, size_t size); 638 639 #define get_system_info(info) \ 640 _get_system_info((info), sizeof(*(info))) 641 642 extern int32 is_computer_on(void); 643 extern double is_computer_on_fire(void); 644 645 #ifdef __cplusplus 646 } 647 #endif 648 649 #endif /* _OS_H */ 650