From f7a818f9806c4eadc8d0f5ad4e13d491a955c490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 21 Mar 2005 18:02:15 +0000 Subject: [PATCH] Has been moved to src/tests/kernel/boot_floppy. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11942 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/apps/Jamfile | 39 -- src/kernel/apps/cpuinfo/Jamfile | 20 - src/kernel/apps/cpuinfo/cpuinfo.h | 105 ---- src/kernel/apps/cpuinfo/flag_arrays.c | 178 ------- src/kernel/apps/cpuinfo/main.c | 663 ----------------------- src/kernel/apps/echo/Jamfile | 3 - src/kernel/apps/echo/main.c | 79 --- src/kernel/apps/envtest/Jamfile | 3 - src/kernel/apps/envtest/main.c | 66 --- src/kernel/apps/exec_test.c | 52 -- src/kernel/apps/false_main.c | 13 - src/kernel/apps/fibo_main.c | 72 --- src/kernel/apps/filetest/Jamfile | 3 - src/kernel/apps/filetest/main.c | 52 -- src/kernel/apps/fork_test.c | 33 -- src/kernel/apps/fortune/Jamfile | 7 - src/kernel/apps/fortune/fortunes | 9 - src/kernel/apps/fortune/main.c | 80 --- src/kernel/apps/hostname/Jamfile | 3 - src/kernel/apps/hostname/main.c | 42 -- src/kernel/apps/init.c | 52 -- src/kernel/apps/ls/Jamfile | 8 - src/kernel/apps/ls/main.c | 163 ------ src/kernel/apps/monitor_test.c | 44 -- src/kernel/apps/on_exit_thread.c | 43 -- src/kernel/apps/pipe_test.c | 97 ---- src/kernel/apps/ps/Jamfile | 3 - src/kernel/apps/ps/main.c | 72 --- src/kernel/apps/select_test.c | 48 -- src/kernel/apps/shell/Jamfile | 12 - src/kernel/apps/shell/args.c | 80 --- src/kernel/apps/shell/args.h | 10 - src/kernel/apps/shell/commands.c | 238 --------- src/kernel/apps/shell/commands.h | 22 - src/kernel/apps/shell/file_utils.c | 129 ----- src/kernel/apps/shell/file_utils.h | 10 - src/kernel/apps/shell/main.c | 117 ---- src/kernel/apps/shell/parse.c | 583 -------------------- src/kernel/apps/shell/parse.h | 22 - src/kernel/apps/shell/script.c | 124 ----- src/kernel/apps/shell/script.h | 27 - src/kernel/apps/shell/shell_defs.h | 71 --- src/kernel/apps/shell/shell_history.c | 69 --- src/kernel/apps/shell/shell_history.h | 16 - src/kernel/apps/shell/shell_vars.c | 372 ------------- src/kernel/apps/shell/shell_vars.h | 45 -- src/kernel/apps/shell/statements.c | 741 -------------------------- src/kernel/apps/shell/statements.h | 18 - src/kernel/apps/sig_test.c | 122 ----- src/kernel/apps/sockettest/Jamfile | 3 - src/kernel/apps/sockettest/main.c | 57 -- src/kernel/apps/symlink/Jamfile | 3 - src/kernel/apps/symlink/main.c | 22 - src/kernel/apps/testapp/Jamfile | 3 - src/kernel/apps/testapp/main.c | 521 ------------------ src/kernel/apps/testdigit/Jamfile | 3 - src/kernel/apps/testdigit/main.c | 47 -- src/kernel/apps/tests/Jamfile | 45 -- src/kernel/apps/tests/fops_test.c | 69 --- src/kernel/apps/tests/random_test.c | 43 -- src/kernel/apps/tests/thread_test.c | 136 ----- src/kernel/apps/tls_test.c | 97 ---- src/kernel/apps/true_main.c | 13 - src/kernel/apps/uname/Jamfile | 3 - src/kernel/apps/uname/main.c | 188 ------- 65 files changed, 6133 deletions(-) delete mode 100644 src/kernel/apps/Jamfile delete mode 100644 src/kernel/apps/cpuinfo/Jamfile delete mode 100644 src/kernel/apps/cpuinfo/cpuinfo.h delete mode 100644 src/kernel/apps/cpuinfo/flag_arrays.c delete mode 100644 src/kernel/apps/cpuinfo/main.c delete mode 100644 src/kernel/apps/echo/Jamfile delete mode 100644 src/kernel/apps/echo/main.c delete mode 100644 src/kernel/apps/envtest/Jamfile delete mode 100644 src/kernel/apps/envtest/main.c delete mode 100644 src/kernel/apps/exec_test.c delete mode 100644 src/kernel/apps/false_main.c delete mode 100644 src/kernel/apps/fibo_main.c delete mode 100644 src/kernel/apps/filetest/Jamfile delete mode 100644 src/kernel/apps/filetest/main.c delete mode 100644 src/kernel/apps/fork_test.c delete mode 100644 src/kernel/apps/fortune/Jamfile delete mode 100644 src/kernel/apps/fortune/fortunes delete mode 100644 src/kernel/apps/fortune/main.c delete mode 100644 src/kernel/apps/hostname/Jamfile delete mode 100644 src/kernel/apps/hostname/main.c delete mode 100644 src/kernel/apps/init.c delete mode 100644 src/kernel/apps/ls/Jamfile delete mode 100644 src/kernel/apps/ls/main.c delete mode 100644 src/kernel/apps/monitor_test.c delete mode 100644 src/kernel/apps/on_exit_thread.c delete mode 100644 src/kernel/apps/pipe_test.c delete mode 100644 src/kernel/apps/ps/Jamfile delete mode 100644 src/kernel/apps/ps/main.c delete mode 100644 src/kernel/apps/select_test.c delete mode 100644 src/kernel/apps/shell/Jamfile delete mode 100644 src/kernel/apps/shell/args.c delete mode 100644 src/kernel/apps/shell/args.h delete mode 100644 src/kernel/apps/shell/commands.c delete mode 100644 src/kernel/apps/shell/commands.h delete mode 100644 src/kernel/apps/shell/file_utils.c delete mode 100644 src/kernel/apps/shell/file_utils.h delete mode 100644 src/kernel/apps/shell/main.c delete mode 100644 src/kernel/apps/shell/parse.c delete mode 100644 src/kernel/apps/shell/parse.h delete mode 100644 src/kernel/apps/shell/script.c delete mode 100644 src/kernel/apps/shell/script.h delete mode 100644 src/kernel/apps/shell/shell_defs.h delete mode 100644 src/kernel/apps/shell/shell_history.c delete mode 100644 src/kernel/apps/shell/shell_history.h delete mode 100644 src/kernel/apps/shell/shell_vars.c delete mode 100644 src/kernel/apps/shell/shell_vars.h delete mode 100644 src/kernel/apps/shell/statements.c delete mode 100644 src/kernel/apps/shell/statements.h delete mode 100644 src/kernel/apps/sig_test.c delete mode 100644 src/kernel/apps/sockettest/Jamfile delete mode 100644 src/kernel/apps/sockettest/main.c delete mode 100644 src/kernel/apps/symlink/Jamfile delete mode 100644 src/kernel/apps/symlink/main.c delete mode 100644 src/kernel/apps/testapp/Jamfile delete mode 100644 src/kernel/apps/testapp/main.c delete mode 100644 src/kernel/apps/testdigit/Jamfile delete mode 100644 src/kernel/apps/testdigit/main.c delete mode 100644 src/kernel/apps/tests/Jamfile delete mode 100644 src/kernel/apps/tests/fops_test.c delete mode 100644 src/kernel/apps/tests/random_test.c delete mode 100644 src/kernel/apps/tests/thread_test.c delete mode 100644 src/kernel/apps/tls_test.c delete mode 100644 src/kernel/apps/true_main.c delete mode 100644 src/kernel/apps/uname/Jamfile delete mode 100644 src/kernel/apps/uname/main.c diff --git a/src/kernel/apps/Jamfile b/src/kernel/apps/Jamfile deleted file mode 100644 index aaf64c0e83..0000000000 --- a/src/kernel/apps/Jamfile +++ /dev/null @@ -1,39 +0,0 @@ -SubDir OBOS_TOP src kernel apps ; - -KernelObjects - exec_test.c - false_main.c - fibo_main.c - fork_test.c - init.c - monitor_test.c - pipe_test.c - true_main.c - sig_test.c - select_test.c - tls_test.c - on_exit_thread.c - ; - -UsePrivateHeaders kernel ; -# UsePrivateHeaders [ FDirName kernel arch ] ; -UsePrivateHeaders [ FDirName kernel arch $(OBOS_ARCH) ] ; -UsePrivateHeaders [ FDirName kernel boot platform $(OBOS_BOOT_PLATFORM) ] ; - -if $(OBOS_ARCH) = x86 { - SubInclude OBOS_TOP src kernel apps cpuinfo ; -} - -SubInclude OBOS_TOP src kernel apps echo ; -SubInclude OBOS_TOP src kernel apps filetest ; -SubInclude OBOS_TOP src kernel apps fortune ; -SubInclude OBOS_TOP src kernel apps hostname ; -SubInclude OBOS_TOP src kernel apps ls ; -SubInclude OBOS_TOP src kernel apps symlink ; -SubInclude OBOS_TOP src kernel apps ps ; -SubInclude OBOS_TOP src kernel apps shell ; -SubInclude OBOS_TOP src kernel apps envtest ; -#SubInclude OBOS_TOP src kernel apps sockettest ; -SubInclude OBOS_TOP src kernel apps testapp ; -SubInclude OBOS_TOP src kernel apps tests ; -SubInclude OBOS_TOP src kernel apps uname ; diff --git a/src/kernel/apps/cpuinfo/Jamfile b/src/kernel/apps/cpuinfo/Jamfile deleted file mode 100644 index 7f32bc0e8c..0000000000 --- a/src/kernel/apps/cpuinfo/Jamfile +++ /dev/null @@ -1,20 +0,0 @@ -SubDir OBOS_TOP src kernel apps cpuinfo ; - -KernelObjects - <$(SOURCE_GRIST)>main.c - : - -fpic - ; - -KernelLd cpuinfo : - libglue2.o - <$(SOURCE_GRIST)>main.o - libroot.so - : - $(OBOS_TOP)/src/kernel/ldscripts/$(OBOS_ARCH)/app.ld - : - : - : - bin/cpuinfo - ; - diff --git a/src/kernel/apps/cpuinfo/cpuinfo.h b/src/kernel/apps/cpuinfo/cpuinfo.h deleted file mode 100644 index 7691cc6baa..0000000000 --- a/src/kernel/apps/cpuinfo/cpuinfo.h +++ /dev/null @@ -1,105 +0,0 @@ - -// cache-type codes -enum cache_types { - Unused, - Inst_TLB, - Data_TLB, - L1_Inst_Cache, - L1_Data_Cache, - L2_Cache, - L3_Cache, - No_L2_Or_L3, - Trace_Cache -}; - - -// an entry in the TLB/Cache table -typedef struct { - uint8 descriptor; - uint8 cache_type; - char text[70]; -} tlbc_info; - - -// -// the global TLB/Cache table -// technical reference: -// "Intel Processor Identification and the CPUID instruction" -// (ftp://ftp.intel.com/docs/24161821.pdf) -// Page 18 - -static tlbc_info -Intel_TLB_Cache_Table[] = { - {0x0, 0, ""}, - {0x1, Inst_TLB, "4KB pages, 4-way set associative, 32 entries"}, - {0x2, Inst_TLB, "4MB pages, fully associative, 2 entries"}, - {0x50, Inst_TLB, "4KB, 2MB or 4MB pages, fully associative, 64 entries"}, - {0x51, Inst_TLB, "4KB, 2MB or 4MB pages, fully associative, 128 entries"}, - {0x52, Inst_TLB, "4KB, 2MB or 4MB pages, fully associative, 256 entries"}, - - {0x3, Data_TLB, "4KB pages, 4-way set associative, 64 entries"}, - {0x4, Data_TLB, "4MB pages, 4-way set associative, 8 entries"}, - {0x5b, Data_TLB, "4KB or 4MB pages, fully associative, 64 entries"}, - {0x5c, Data_TLB, "4KB or 4MB pages, fully associative, 128 entries"}, - {0x5d, Data_TLB, "4KB or 4MB pages, fully associative, 256 entries"}, - - {0x6, L1_Inst_Cache, "8KB pages, 4-way set associative, 32 byte line size"}, - {0x8, L1_Inst_Cache, "16KB pages, 4-way set associative, 32 byte line size"}, - - {0xa, L1_Data_Cache, "8KB pages, 2-way set associative, 32 byte line size"}, - {0xc, L1_Data_Cache, "16KB pages, 4-way set associative, 32 byte line size"}, - {0x66, L1_Data_Cache, "8KB pages, 4-way set associative, 64 byte line size"}, - {0x67, L1_Data_Cache, "16KB pages, 4-way set associative, 64 byte line size"}, - {0x68, L1_Data_Cache, "32KB pages, 4-way set associative, 64 byte line size"}, - - {0x39, L2_Cache, "128KB pages, 4-way set associative, sectored, 64 byte line size"}, - {0x3c, L2_Cache, "256KB pages, 4-way set associative, sectored, 64 byte line size"}, - {0x41, L2_Cache, "128KB pages, 4-way set associative, 32 byte line size"}, - {0x42, L2_Cache, "256KB pages, 4-way set associative, 32 byte line size"}, - {0x43, L2_Cache, "512KB pages, 4-way set associative, 32 byte line size"}, - {0x44, L2_Cache, "1MB pages, 4-way set associative, 32 byte line size"}, - {0x45, L2_Cache, "2MB pages, 4-way set associative, 32 byte line size"}, - {0x79, L2_Cache, "128KB pages, 8-way set associative, sectored, 64 byte line size"}, - {0x7a, L2_Cache, "256KB pages, 8-way set associative, sectored, 64 byte line size"}, - {0x7b, L2_Cache, "512KB pages, 8-way set associative, sectored, 64 byte line size"}, - {0x7c, L2_Cache, "1MB pages, 8-way set associative, sectored, 64 byte line size"}, - {0x82, L2_Cache, "256KB pages, 8-way set associative, 32 byte line size"}, - {0x83, L2_Cache, "512KB pages, 8-way set associative, 32 byte line size"}, - {0x84, L2_Cache, "1MB pages, 8-way set associative, 32 byte line size"}, - {0x85, L2_Cache, "2MB pages, 8-way set associative, 32 byte line size"}, - - {0x40, No_L2_Or_L3, "No 2nd-level cache, or if 2nd-level cache exists, no 3rd-level cache\n"}, - - {0x22, L3_Cache, "512KB pages, 4-way set associative, sectored, 64 byte line size"}, - {0x23, L3_Cache, "1MB pages, 8-way set associative, sectored, 64 byte line size"}, - {0x25, L3_Cache, "2MB pages, 8-way set associative, sectored, 64 byte line size"}, - {0x29, L3_Cache, "4MB pages, 8-way set associative, sectored, 64 byte line size"}, - - {0x70, Trace_Cache, "Trace cache: 12K-uops, 8-way set associative\n"}, - {0x71, Trace_Cache, "Trace cache: 16K-uops, 8-way set associative\n"}, - {0x72, Trace_Cache, "Trace cache: 32K-uops, 8-way set associative\n"}, -}; - - - - -void AMD_identify (cpuid_info *); -void AMD_features (cpuid_info *); -void AMD_TLB_cache (cpuid_info *); -void Cyrix_identify (cpuid_info *); -void Cyrix_features (cpuid_info *); -void Cyrix_TLB_cache (cpuid_info *); -void Intel_identify (cpuid_info *); -void Intel_features (cpuid_info *); -void Intel_TLB_cache (cpuid_info *); - -const char *Intel_brand_string (int, int); -void dump_regs (cpuid_info *, const char *, uint32, uint32); -char getoption (char *); -void insert (int *, int, int); -void opt_identify (cpuid_info *, int); -void opt_features (cpuid_info *, int); -void opt_TLB_cache (cpuid_info *, int); -void opt_dump_calls (cpuid_info *, uint32); -void print_regs (cpuid_info *); -void usage (void); diff --git a/src/kernel/apps/cpuinfo/flag_arrays.c b/src/kernel/apps/cpuinfo/flag_arrays.c deleted file mode 100644 index ff37c632a0..0000000000 --- a/src/kernel/apps/cpuinfo/flag_arrays.c +++ /dev/null @@ -1,178 +0,0 @@ - -static char *Intel_feature_flags[32] = { - "FPU Floating Point Unit", - "VME Virtual 8086 Mode Enhancements", - "DE Debugging Extensions", - "PSE Page Size Extensions", - "TSC Time Stamp Counter", - "MSR Model Specific Registers", - "PAE Physical Address Extension", - "MCE Machine Check Exception", - "CX8 COMPXCHG8B Instruction", - "APIC On-chip Advanced Programmable Interrupt Controller", - "10 Reserved", - "SEP Fast System Call", - "MTRR Memory Type Range Registers", - "PGE PTE Global Flag", - "MCA Machine Check Architecture", - "CMOV Conditional Move and Compare Instructions", - "FGPAT Page Attribute Table", - "PSE-36 36-bit Page Size Extension", - "PN Processor Serial Number present and enabled", - "CLFSH CFLUSH instruction", - "20 reserved", - "DS Debug store", - "ACPI Thermal Monitor and Clock Ctrl", - "MMX MMX instruction set", - "FXSR Fast FP/MMX Streaming SIMD Extensions save/restore", - "SSE Streaming SIMD Extensions instruction set", - "SSE2 SSE2 extensions", - "SS Self Snoop", - "HT Hyper Threading", - "TM Thermal monitor", - "30 reserved", - "31 reserved" -}; - -#if 0 -static char *AMD_feature_flags[32] = { - "Floating Point Unit", - "Virtual Mode Extensions", - "Debugging Extensions", - "Page Size Extensions", - "Time Stamp Counter (with RDTSC and CR4 disable bit)", - "Model Specific Registers with RDMSR & WRMSR", - "PAE - Page Address Extensions", - "Machine Check Exception", - "COMPXCHG8B Instruction", - "APIC", - "10 - Reserved", - "SYSCALL/SYSRET or SYSENTER/SYSEXIT instructions", - "MTRR - Memory Type Range Registers", - "Global paging extension", - "Machine Check Architecture", - "Conditional Move Instruction", - "PAT - Page Attribute Table", - "PSE-36 - Page Size Extensions", - "18 - reserved", - "19 - reserved", - "20 - reserved", - "21 - reserved", - "AMD MMX Instruction Extensions", - "MMX instructions", - "FXSAVE/FXRSTOR", - "25 - reserved", - "26 - reserved", - "27 - reserved", - "28 - reserved", - "29 - reserved", - "3DNow! Instruction Extensions", - "3DNow instructions" -}; - - -static char *Cyrix_standard_feature_flags_5[32] = { - "FPU Floating Point Unit", - "V86 Virtual Mode Extensions", - "Debug Extension", - "4MB Page Size", - "Time Stamp Counter", - "RDMSR/WRMSR (Model Specific Registers)", - "PAE", - "Machine Check Exception", - "COMPXCHG8B Instruction", - "APIC - On-chip Advanced Programmable Interrupt Controller", - "10 - Reserved", - "11 - Reserved", - "MTRR Memory Type Range Registers", - "13 - reserved", - "Machine Check", - "CMOV Conditional Move Instruction", - "16 - reserved", - "17 - reserved", - "18 - reserved", - "19 - reserved", - "20 - reserved", - "21 - reserved", - "22 - reserved", - "MMX instructions", - "24 - reserved", - "25 - reserved", - "26 - reserved", - "27 - reserved", - "28 - reserved", - "29 - reserved", - "30 - reserved" -}; - - -static char *Cyrix_standard_feature_flags_not5[32] = { - "FPU Floating Point Unit", - "V86 Virtual Mode Extensions", - "Debug Extension", - "4MB Page Size", - "Time Stamp Counter", - "RDMSR/WRMSR (Model Specific Registers)", - "PAE", - "Machine Check Exception", - "COMPXCHG8B Instruction", - "APIC - On-chip Advanced Programmable Interrupt Controller", - "10 - Reserved", - "11 - Reserved", - "MTRR Memory Type Range Registers", - "Global Paging Extension", - "Machine Check", - "CMOV Conditional Move Instruction", - "16 - reserved", - "17 - reserved", - "18 - reserved", - "19 - reserved", - "20 - reserved", - "21 - reserved", - "22 - reserved", - "MMX instructions", - "24 - reserved", - "25 - reserved", - "26 - reserved", - "27 - reserved", - "28 - reserved", - "29 - reserved", - "30 - reserved" -}; - - -static char *Cyrix_extended_feature_flags[32] = { - "FPU Floating Point Unit", - "V86 Virtual Mode Extensions", - "Debug Extension", - "Page Size Extensions", - "Time Stamp Counter", - "Cyrix MSR", - "PAE", - "MC Exception", - "COMPXCHG8B", - "APIC on chip", - "SYSCALL/SYSRET", - "11 - reserved", - "MTRR", - "Global bit", - "Machine Check", - "CMOV", - "FPU CMOV", - "17 - reserved", - "18 - reserved", - "19 - reserved", - "20 - reserved", - "21 - reserved", - "22 - reserved", - "MMX", - "Extended MMX", - "25 - reserved", - "26 - reserved", - "27 - reserved", - "28 - reserved", - "29 - reserved", - "30 - reserved", - "3DNow instructions" -}; -#endif diff --git a/src/kernel/apps/cpuinfo/main.c b/src/kernel/apps/cpuinfo/main.c deleted file mode 100644 index 27cfac32a9..0000000000 --- a/src/kernel/apps/cpuinfo/main.c +++ /dev/null @@ -1,663 +0,0 @@ -#include -#include -#include -#include - -#include "cpuinfo.h" -#include "flag_arrays.c" - - - -extern char *__progname; -static cpuid_info CPU_Data; - - -void -usage() -{ - printf("usage: %s [-option]\n\n" - "Prints information about your CPU.\n" - " -i CPU identification\n" - " -f supported processor features\n" - " -t TLB and cache info\n" - " -d dump registers from CPUID calls\n", __progname); - - exit(0); -} - - -char -getoption(char *optstr) -{ - if ((optstr[0] != '-') - || (strlen(optstr) > 2) - || (strchr("iftd", optstr[1]) == NULL)) - // invalid option - usage(); - - return optstr[1]; -} - - -int -main(int argc, char *argv[]) -{ - // this program prints out everything you would ever want to know about - // your computer's processor, or your money back, in full (30 days, no hassle) - // - // technical reference: - // "Intel Processor Identification and the CPUID Instruction" - // (ftp://download.intel.com/design/Xeon/applnots/24161821.pdf) - - const char *no_support = "Sorry, your processor does not support this feature\n"; - - char option = 0; - int vendor_tag; - uint32 max_level; - cpuid_info *info = &CPU_Data; - - if (argc == 2) - option = getoption(argv[1]); - else - usage(); - - // get initial info (max_level and vendor_tag) - get_cpuid(info, 0, 0); - max_level = info->eax_0.max_eax; - vendor_tag = info->regs.ebx; - - switch (option) { - case 'i': - printf("CPU identification:\n\n"); - if (max_level < 1) - printf(no_support); - else - opt_identify(info, vendor_tag); - break; - - case 'f': - printf("Supported processor features:\n\n"); - if (max_level < 1) - printf(no_support); - else - opt_features(info, vendor_tag); - break; - - case 't': - printf("TLB and cache information:\n\n"); - if (max_level < 2) - printf(no_support); - else - opt_TLB_cache(info, vendor_tag); - break; - - case 'd': - printf("CPUID instruction call dump:\n\n"); - opt_dump_calls(info, max_level); - break; - } - - return 0; -} - - -void -opt_identify(cpuid_info *info, int vendor_tag) -{ - // gosh, these CPU manufacturers have really outdone - // themselves on creating cutesy vendorID strings, no? - // (that was sarcasm, btw...) - - char vendorID[12+1] = {0}; - - // the 'vendorid' field of the info struct is not null terminated, - // so it is copied into a properly terminated local string buffer - memcpy(vendorID, info->eax_0.vendor_id, 12); - printf("%12s '%s'\n", "Vendor ID:", vendorID); - - switch (vendor_tag) { - case 'uneG': // "GenuineIntel" - Intel_identify(info); - break; - - case 'htuA': // "AuthenticAMD" - AMD_identify(info); - break; - - case 'iryC': // "CyrixInstead" - Cyrix_identify(info); - break; - } -} - - -void -opt_features(cpuid_info *info, int vendor_tag) -{ - switch (vendor_tag) { - case 'uneG': // "GenuineIntel" - Intel_features(info); - break; - - case 'htuA': // "AuthenticAMD" - AMD_features(info); - break; - - case 'iryC': // "CyrixInstead" - Cyrix_features(info); - break; - } -} - - -void -opt_TLB_cache(cpuid_info *info, int vendor_tag) -{ - switch (vendor_tag) { - case 'uneG': // "GenuineIntel" - Intel_TLB_cache(info); - break; - - case 'htuA': // "AuthenticAMD" - AMD_TLB_cache(info); - break; - - case 'iryC': // "CyrixInstead" - Cyrix_TLB_cache(info); - break; - } -} - - - - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Intel specs - -void -Intel_identify(cpuid_info *info) -{ - // the code for this function looks very boring and tedious - // (that's because it's very boring and tedious) - // but I think it's correct anyway (there's always that possibility!) - - int type, family, model, sig; - - get_cpuid(info, 1, 0); - type = info->eax_1.type; - family = info->eax_1.family; - model = info->eax_1.model; - - sig = info->regs.eax; - printf("%12s 0x%08X\n", "Signature:", sig); - - printf("%12s %2d '", "Type:", type); - if (type == 0) printf("Original OEM"); - else if (type == 1) printf("Overdrive"); - else if (type == 2) printf("Dual-capable"); - else if (type == 3) printf("Reserved"); - printf("'\n"); - - printf("%12s %2d '", "Family:", family); - if (family == 3) printf("i386"); - else if (family == 4) printf("i486"); - else if (family == 5) printf("Pentium"); - else if (family == 6) printf("Pentium Pro"); - else if (family == 15) printf("Pentium 4"); - printf("'\n"); - - if (family == 15) { - int efamily = (info->regs.eax >> 20) & 0xff; - printf("Extended family: %d\n", efamily); - } - - printf("%12s %2d '", "Model:", model); - switch (family) { - case 3: - break; - case 4: - if (model == 0) printf("DX"); - else if (model == 1) printf("DX"); - else if (model == 2) printf("SX"); - else if (model == 3) printf("487/DX2"); - else if (model == 4) printf("SL"); - else if (model == 5) printf("SX2"); - else if (model == 7) printf("write-back enhanced DX2"); - else if (model == 8) printf("DX4"); - break; - case 5: - if (model == 1) printf("60/66"); - else if (model == 2) printf("75-200"); - else if (model == 3) printf("for 486 system"); - else if (model == 4) printf("MMX"); - break; - case 6: - if (model == 1) printf("Pentium Pro"); - else if (model == 3) printf("Pentium II Model 3"); - else if (model == 5) printf("Pentium II Model 5/Xeon/Celeron"); - else if (model == 6) printf("Celeron"); - else if (model == 7) printf("Pentium III/Pentium III Xeon - external L2 cache"); - else if (model == 8) printf("Pentium III/Pentium III Xeon - internal L2 cache"); - break; - case 15: - break; - } - printf("'\n"); - - if (model == 15) { - int emodel = (info->regs.eax >> 16) & 0xf; - printf("Extended model: %d\n", emodel); - } - - printf("%12s 0x%08lX\n", "Features:", info->eax_1.features); - - { - int id = info->regs.ebx & 0xff; - printf("%12s %2d '%s'\n", "Brand ID:", id, Intel_brand_string(id, sig)); - } - - printf("%12s %2d\n", "Stepping:", info->eax_1.stepping); - printf("%12s %2d\n", "Reserved:", info->eax_1.reserved_0); - - get_cpuid(info, 0x80000000, 0); - if (info->regs.eax & 0x80000000) { - // extended feature/signature bits supported - if (info->regs.eax >= 0x80000004) { - uint32 i; - - printf("\nExtended brand string:\n'"); - for (i = 0x80000002; i <= 0x80000004; ++i) { - get_cpuid(info, i, 0); - print_regs(info); - } - printf("'\n"); - } - } -} - - -const char * -Intel_brand_string(int id, int processor_signature) -{ - int sig = processor_signature; - - switch (id) { - case 0x0: return "Unsupported"; - case 0x1: return "Intel(R) Celeron(R) processor"; - case 0x2: return "Intel(R) Pentium(R) III processor"; - case 0x3: return (sig == 0x6B1) ? "Intel(R) Celeron(R) processor" : "Intel(R) Pentium(R) III Xeon(TM) processor"; - case 0x4: return "Intel(R) Pentium(R) III processor"; - case 0x5: return ""; - case 0x6: return "Mobile Intel(R) Pentium(R) III Processor-M"; - case 0x7: return "Mobile Intel(R) Celeron(R) processor"; - case 0x8: return (sig >= 0xF13) ? "Intel(R) Genuine processor" : "Intel(R) Pentium(R) 4 processor"; - case 0x9: return "Intel(R) Pentium(R) 4 processor"; - case 0xA: return "Intel(R) Celeron(R) processor"; - case 0xB: return (sig < 0xF13) ? "Intel(R) Xeon(TM) processor MP" : "Intel(R) Xeon(TM) processor"; - case 0xC: return "Intel(R) Xeon(TM) processor MP"; - case 0xD: return ""; - case 0xE: return (sig < 0xF13) ? "Intel(R) Xeon(TM) processor" : "Mobile Intel(R) Pentium(R) 4 Processor-M"; - case 0xF: return "Mobile Intel(R) Celeron(R) processor"; - default: - return ""; - } -} - - -void -Intel_features(cpuid_info *info) -{ - // for each bit set in the features flag, print out the - // corresponding index in the flags array (too easy!) - - int i; - int fflags; - - get_cpuid(info, 1, 0); - fflags = info->eax_1.features; - - for (i = 0; i < 32; ++i) - if (fflags & (1< lo; --i) - a[i] = a[i-1]; - - // insert the new guy - a[lo] = elem; -} - - -void -Intel_TLB_cache(cpuid_info *info) -{ - // displays technical info for the CPU's various instruction and data pipeline caches - // and the TLBs (Translation Lookaside Buffers). - // - // The method for extracting and displaying this info might be less than obvious, - // so here's an explanation: - // - // The TLB/Cache info is stored in a global table. Each entry is uniquely identified - // by a descriptor byte. Additionally, each entry is catagorized according to the - // cache type. A textual string contains the information to display. - // - // To retrieve the CPUs capabilities, the pass loop repeatedly (maybe) calls - // get_cpuid() which fills the registers. Each register is a 4-byte datum, - // capable of holding up to 4 descriptor bytes. The descriptor bytes are extracted - // (thru shifting and masking) and then inserted into a slot array. The slot array - // stores indexes into the table. Since descriptor bytes are not indexes themselves, - // an index array is created and used to convert them. The slot array is filled so - // as to keep the indexes in sorted order -- this guarantees than all entries for - // a particular cache type will display together. - // - // After the pass loop is finished, the slot array contains the indexes of all the - // table entries that apply to the host processor. Displaying the info is merely a matter - // of spinning thru the slot array and printing the text. The output, however, is organized - // by the cache types -- this technique *only* works because the TLB/Cache table has been - // carefully arranged in that order. - - #define BIT_31_MASK (1 << 31) - - uint32 pass, matches; // counters - uint32 reg; // value of an individual register (eax, ebx, ecx, edx) - uint8 db; // descriptor byte - int indexOf[256] = {0}; // converts descriptor bytes to table indexes - int slot[256] = {0}; // indexes into the TLB/Cache table (for entries found) - - tlbc_info *tab = Intel_TLB_Cache_Table; - int tabsize = sizeof Intel_TLB_Cache_Table / sizeof(Intel_TLB_Cache_Table[0]); - - // fill the index conversion array - int i = 0; - int n = 0; - - while (n < tabsize) - indexOf[tab[n++].descriptor] = i++; - - // pass loop: insert relevant table indexes into the slot array - i = 0; - for (pass = 0; ; ++pass) { - get_cpuid(info, 2, 0); - - // low byte of eax register holds maximum iterations - reg = info->regs.eax; - if (pass >= (reg & 0xff)) - break; - - reg >>= 8; // skip low byte - for (; reg; reg >>= 8) - if ((db = (reg & 0xff))) - insert(slot, indexOf[db], i++); - - reg = info->regs.ebx; // ebx - if ((reg & BIT_31_MASK) == 0) - for (; reg; reg >>= 8) - if ((db = (reg & 0xff))) - insert(slot, indexOf[db], i++); - - reg = info->regs.ecx; // ecx - if ((reg & BIT_31_MASK) == 0) - for (; reg; reg >>= 8) - if ((db = (reg & 0xff))) - insert(slot, indexOf[db], i++); - - reg = info->regs.edx; // edx - if ((reg & BIT_31_MASK) == 0) - for (; reg; reg >>= 8) - if ((db = (reg & 0xff))) - insert(slot, indexOf[db], i++); - } - - // reset slot index for output loop - i = 0; - - // eeiuw! an icky macro (but it really does prevent much repetitive code) - #define display_matching_entries(type_name,type_code) \ - printf(type_name ":\n"); \ - matches = 0; \ - while (tab[n = slot[i]].cache_type == type_code) { \ - printf(" %s\n", tab[n].text); \ - ++matches; \ - ++i; \ - } \ - if (matches == 0) \ - printf(" None\n") - - // at long last... output the data - display_matching_entries("Instruction TLB", Inst_TLB); - display_matching_entries("Data TLB", Data_TLB); - display_matching_entries("L1 Instruction Cache", L1_Inst_Cache); - display_matching_entries("L1 Data Cache", L1_Data_Cache); - display_matching_entries("L2 Cache", L2_Cache); - - if (tab[slot[i]].cache_type == No_L2_Or_L3) - // no need to print the text on this one, just skip it - ++i; - - display_matching_entries("L3 Cache", L3_Cache); - display_matching_entries("Trace Cache", Trace_Cache); -} - - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// AMD specs - -// Brennan says: I'm just digging around and trying to find AMD documentation -// on product signatures and CPU types...not easy to find. This is a dirty hack -// until I can find proper docs... - -static const char * -AMD_brand_string(int family, int model, int processor_signature) -{ - int sig = processor_signature; - - switch (family) { - //K5 and K6 models - case 0x5: - if(model >= 0x0 && model <= 0x3) { - return "AMD K5"; - } - else if(model == 0x8){ - return "AMD K6-2"; - } - else if(model == 0x9) { - return "AMD K6-III"; - } - else { - return "AMD K6"; - } - //Athlon and Duron models, very general - case 0x6: - //Hack. I own one, so I know this is the processor signature! - if(sig == 1634) { - return "AMD Mobile Athlon"; - } - else if(model == 0x1 || model == 0x2 || model == 0x4) { - return "AMD Athlon"; - } - else if(model == 0x3 ||model == 0x7) { - return "AMD Duron"; - } - else if(model == 0x6){ - return "AMD Duron/AMD Athlon XP/AMD Athlon MP"; - } - case 0xf: - if(model == 0x5) { - return "AMD Athlon 64"; - } - if(model == 0x6) { - return "AMD Opteron"; - } - //This is the new 266FSB Duron model - else if(model == 0x8) { - return "AMD Duron (266 FSB)"; - } - default: - return "Unknown AMD Processor"; - } -} - - -void -AMD_identify(cpuid_info *info) -{ - int type, family, model, sig; - const char *id_string; - - get_cpuid(info, 1, 0); - type = info->eax_1.type; - family = info->eax_1.family; - model = info->eax_1.model; - sig = info->regs.eax; - - id_string = AMD_brand_string(family, model, sig); - - printf("%s, Model: %d\n", id_string, model); - printf("Family: %d\n", family); - printf("Signature: %d\n", sig); - -} - - -void -AMD_features(cpuid_info *info) -{ - printf("Sorry! Info about AMD CPU's not implemented yet :(\n"); -} - - -void -AMD_TLB_cache(cpuid_info *info) -{ - printf("Sorry! Info about AMD CPU's not implemented yet :(\n"); -} - - - - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Cyrix specs - - -void -Cyrix_identify(cpuid_info *info) -{ - printf("Sorry! Info about Cyrix CPU's not implemented yet :(\n"); -} - - -void -Cyrix_features(cpuid_info *info) -{ - printf("Sorry! Info about Cyrix CPU's not implemented yet :(\n"); -} - - -void -Cyrix_TLB_cache(cpuid_info *info) -{ - printf("Sorry! Info about Cyrix CPU's not implemented yet :(\n"); -} - - - - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// dumps - - -void -opt_dump_calls(cpuid_info *info, uint32 max_level) -{ - // dumps the registers for standard (and if supported) extended - // calls to the CPUID instruction - - uint32 max_extended; - - dump_regs(info, "Standard Calls", 0, max_level); - - get_cpuid(info, 0x80000000, 0); - max_extended = info->regs.eax; - - if (max_extended == 0) - printf("\nNo extended calls available for this CPU\n"); - else - dump_regs(info, "Extended Calls", 0x80000000, max_extended); -} - - -void -dump_regs(cpuid_info *info, const char *heading, uint32 min_level, uint32 max_level) -{ - // gosh, it's so perty (in a text-based output kind of way) - - uint32 i; - - printf("%s (max eax level = %lx)\n", heading, max_level); - printf("----------------------------------------------\n"); - printf(" Input | Output\n"); - printf("----------------------------------------------\n"); - printf(" eax | eax ebx ecx edx\n"); - - for (i = min_level; i <= max_level; ++i) { - get_cpuid(info, i, 0); - printf("%08lx | %08lx %08lx %08lx %08lx\n", - i, - info->regs.eax, - info->regs.ebx, - info->regs.ecx, - info->regs.edx); - } - printf("\n"); -} - - -void -print_regs(cpuid_info *info) -{ - // this function either prints the contents of all the - // registers as a single character string, or it does - // something else entirely (you decide) - - int i; - char s[17] = {0}; - - for (i = 0; i < 4; ++i) - s[i] = info->regs.eax >> (8*i), - s[i+4] = info->regs.ebx >> (8*i), - s[i+8] = info->regs.ecx >> (8*i), - s[i+12] = info->regs.edx >> (8*i); - - printf("%s", s); -} - diff --git a/src/kernel/apps/echo/Jamfile b/src/kernel/apps/echo/Jamfile deleted file mode 100644 index 8db262a729..0000000000 --- a/src/kernel/apps/echo/Jamfile +++ /dev/null @@ -1,3 +0,0 @@ -SubDir OBOS_TOP src kernel apps echo ; - -KernelObjects <$(SOURCE_GRIST)>main.c : -fpic -Wno-unused ; diff --git a/src/kernel/apps/echo/main.c b/src/kernel/apps/echo/main.c deleted file mode 100644 index 257dbb953d..0000000000 --- a/src/kernel/apps/echo/main.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - -#include -#include -#include - - -int -main(int argc , char *argv[]) -{ - int nflag; /* if not set, output a trailing newline. */ - - /* This utility may NOT do getopt(3) option parsing. */ - if (*++argv && !strcmp(*argv, "-n")) { - ++argv; - nflag = 1; - } else - nflag = 0; - - while (argv[0] != NULL) { - - /* - * If the next argument is NULL then this is this - * the last argument, therefore we need to check - * for a trailing \c. - */ - if (argv[1] == NULL) { - size_t len; - - len = strlen(argv[0]); - /* is there room for a '\c' and is there one? */ - if (len >= 2 && - argv[0][len - 2] == '\\' && - argv[0][len - 1] == 'c') { - /* chop it and set the no-newline flag. */ - argv[0][len - 2] = '\0'; - nflag = 1; - } - } - (void)printf("%s", argv[0]); - if (*++argv) - putchar(' '); - } - if (!nflag) - putchar('\n'); - return 0; -} diff --git a/src/kernel/apps/envtest/Jamfile b/src/kernel/apps/envtest/Jamfile deleted file mode 100644 index 9221a98e85..0000000000 --- a/src/kernel/apps/envtest/Jamfile +++ /dev/null @@ -1,3 +0,0 @@ -SubDir OBOS_TOP src kernel apps envtest ; - -KernelObjects <$(SOURCE_GRIST)>main.c : -fpic -Wno-unused ; diff --git a/src/kernel/apps/envtest/main.c b/src/kernel/apps/envtest/main.c deleted file mode 100644 index 9b15cc5556..0000000000 --- a/src/kernel/apps/envtest/main.c +++ /dev/null @@ -1,66 +0,0 @@ -/* -** Copyright 2003-2004, The Haiku Team. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ - - -#include - -#include -#include -#include - - -int -main(int argc, char **argv) -{ - int i; - thread_id pid; - status_t rc; - char temp[16]; - char *var; - - printf("Setting some env vars...\n"); - - if (setenv("TEST", "This is a test!", 0)) { - printf("setenv() error\n"); - return -1; - } - if (setenv("HOME", "/boot", 1)) { - printf("setenv() error\n"); - return -1; - } - - printf("Getting VAR_1: "); - var = getenv("VAR_1"); - if (var) - printf("found set to: \"%s\"\n", var); - else - printf("not found\n"); - - printf("List of env variables set:\n"); - for (i = 0; environ[i]; i++) - printf("%s\n", environ[i]); - - if (argc > 1) { - char buffer[16]; - const char *_argv[] = { argv[0], buffer, NULL }; - int val = atoi(argv[1]) - 1; - - sprintf(temp, "VAR_%d", val); - if (setenv(temp, "dummy", 0)) { - printf("setenv() error\n"); - return -1; - } - - if (val > 0) { - printf("Spawning test (%d left)\n", val); - sprintf(buffer, "%d", val); - pid = load_image(2, _argv, (const char **)environ); - wait_for_thread(pid, &rc); - } - } - return 0; -} - - diff --git a/src/kernel/apps/exec_test.c b/src/kernel/apps/exec_test.c deleted file mode 100644 index ce1409342b..0000000000 --- a/src/kernel/apps/exec_test.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ - - -#include - -#include -#include -#include -#include - - -static void -print_process_info(const char *text) -{ - puts(text); - - printf("\tsession_id = %ld\n", getsid(0)); - printf("\tgroup_id = %ld\n", getpgid(0)); - printf("\tprocess_id = %ld\n", getpid()); - printf("\tparent_id = %ld\n", getppid()); -} - - -int -main(int argc, char **argv) -{ - printf("exec_test: this is thread %ld\n", find_thread(NULL)); - - if (argc < 2) { - print_process_info("before exec():"); - puts("going to execl()..."); - - execl("/bin/exec_test", "/bin/exec_test", "argument 1", NULL); - printf("execl() returned: %s\n", strerror(errno)); - } else { - int i; - - print_process_info("after exec():"); - puts("got arguments:"); - for (i = 0; i < argc; i++) - printf("%d: \"%s\"\n", i, argv[i]); - - setsid(); - print_process_info("after setsid():"); - } - - return 0; -} - diff --git a/src/kernel/apps/false_main.c b/src/kernel/apps/false_main.c deleted file mode 100644 index 9128fb0be9..0000000000 --- a/src/kernel/apps/false_main.c +++ /dev/null @@ -1,13 +0,0 @@ -/* -** Copyright 2002, Manuel J. Petit. All rights reserved. -** Contains portions of: -** -** /boot/bin/true, Copyright 2001 Travis K. Geiselbrecht -** -** Distributed under the terms of the NewOS License. -*/ -int main(void) -{ - return 1; -} - diff --git a/src/kernel/apps/fibo_main.c b/src/kernel/apps/fibo_main.c deleted file mode 100644 index 2fd4a70113..0000000000 --- a/src/kernel/apps/fibo_main.c +++ /dev/null @@ -1,72 +0,0 @@ -/* -** Copyright 2002, Manuel J. Petit. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ - - -#include - -#include -#include -#include - - -static void -usage(char const *app) -{ - printf("usage: %s [-s] ###\n", app); - exit(-1); -} - - -int -main(int argc, char *argv[]) -{ - int num = 0; - int silent = 0; - int result; - - switch (argc) { - case 2: - num = atoi(argv[1]); - break; - case 3: - if (strcmp(argv[1], "-s") == 0) { - num = atoi(argv[2]); - silent = 1; - } else { - usage(argv[0]); - } - break; - default: - usage(argv[0]); - break; - } - - if (num < 2) { - result = 1; - } else { - thread_id pid; - status_t retcode; - char buffer[64]; - const char *aaargv[] = { "/boot/bin/fibo", "-s", buffer, NULL }; - int aaargc = 3; - - sprintf(buffer, "%d", num-1); - pid = load_image(aaargc, aaargv, (const char **)environ); - wait_for_thread(pid, &retcode); - result = retcode; - - sprintf(buffer, "%d", num-2); - pid = load_image(aaargc, aaargv, (const char **)environ); - wait_for_thread(pid, &retcode); - result += retcode; - } - - if (silent) { - return result; - } else { - printf("%d\n", result); - return 0; - } -} diff --git a/src/kernel/apps/filetest/Jamfile b/src/kernel/apps/filetest/Jamfile deleted file mode 100644 index d01295c6b4..0000000000 --- a/src/kernel/apps/filetest/Jamfile +++ /dev/null @@ -1,3 +0,0 @@ -SubDir OBOS_TOP src kernel apps filetest ; - -KernelObjects <$(SOURCE_GRIST)>main.c : -fpic -Wno-unused ; diff --git a/src/kernel/apps/filetest/main.c b/src/kernel/apps/filetest/main.c deleted file mode 100644 index 497a941514..0000000000 --- a/src/kernel/apps/filetest/main.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define FORTUNES "/boot/etc/fortunes" - -int main(int argc, char **argv) -{ - int rc = 0, fd[3]; - int cnt, i; - int on = 1; - - printf("File Test!!!\n"); - - for (i=0;i<3;i++) { - printf("%d : ", i + 1); - fd[i] = open(FORTUNES, O_RDONLY, 0); - printf("fd %d\n", fd[i]); - } - - printf("closing the 3 fd's\n"); - for (i=0;i<3;i++) { - close(fd[i]); - } - - printf("\nNow we have no open fd's so next socket should be 3\n"); - fd[0] = open(FORTUNES, O_RDONLY, 0); - printf("new fd %d\n", fd[0]); - - printf("Trying ioctl to set non-blocking: "); - rc = ioctl(fd[0], FIONBIO, &on, sizeof(on)); - if (rc == EINVAL) { - printf("OK\n"); - } else { - printf("failed\n"); - printf("error was %s\n", strerror(errno)); - } - - close(fd[0]); - - return 0; -} diff --git a/src/kernel/apps/fork_test.c b/src/kernel/apps/fork_test.c deleted file mode 100644 index 4252cef5aa..0000000000 --- a/src/kernel/apps/fork_test.c +++ /dev/null @@ -1,33 +0,0 @@ -/* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ - - -#include - -#include -#include -#include -#include -#include - - -int -main(int argc, char **argv) -{ - pid_t child = fork(); - - if (child == 0) { - printf("CHILD: we're the child!\n"); - snooze(500000); // .5 sec - printf("CHILD: exit!\n"); - } else if (child > 0) { - printf("PARENT: we're the parent, our child has pid %ld\n", child); - waitpid(-1, NULL, 0); - } else - fprintf(stderr, "fork() failed: %s\n", strerror(errno)); - - return 0; -} - diff --git a/src/kernel/apps/fortune/Jamfile b/src/kernel/apps/fortune/Jamfile deleted file mode 100644 index ca41fe0e4b..0000000000 --- a/src/kernel/apps/fortune/Jamfile +++ /dev/null @@ -1,7 +0,0 @@ -SubDir OBOS_TOP src kernel apps fortune ; - -KernelObjects - <$(SOURCE_GRIST)>main.c - : - -fpic - ; diff --git a/src/kernel/apps/fortune/fortunes b/src/kernel/apps/fortune/fortunes deleted file mode 100644 index 168166bd09..0000000000 --- a/src/kernel/apps/fortune/fortunes +++ /dev/null @@ -1,9 +0,0 @@ -#@# -Magic is real... unless declared integer. -#@# -System is up and running. -#@# -Open source thesis that thousand of eyes looking thu the code -increases software quality is completely wrong. The amount of -bugs per line of code is an universal constant. The bazaar -model only achieves a quick bug turnover. diff --git a/src/kernel/apps/fortune/main.c b/src/kernel/apps/fortune/main.c deleted file mode 100644 index 64dd6ea9c8..0000000000 --- a/src/kernel/apps/fortune/main.c +++ /dev/null @@ -1,80 +0,0 @@ -/* -** Copyright 2002-2004, The OpenBeOS Team. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define FORTUNES "/etc/fortunes" - -int -main(void) -{ - int fd; - int rc; - char *buf; - unsigned i; - unsigned found; - struct stat stat; - - fd = open(FORTUNES, O_RDONLY, 0); - if (fd < 0) { - printf("Couldn't open %s: %s\n", FORTUNES, strerror(errno)); - return -1; - } - - rc = fstat(fd, &stat); - if (rc < 0) { - printf("stat() failed: %s\n", strerror(errno)); - return -1; - } - - buf = malloc(stat.st_size + 1); - rc = read(fd, buf, stat.st_size); - if (rc < 0) { - printf("Could not read from fortune file: %s\n", strerror(errno)); - return -1; - } - - buf[stat.st_size] = 0; - close(fd); - - found = 0; - for (i = 0; i < stat.st_size; i++) { - if (!strncmp(buf + i, "#@#", 3)) - found += 1; - } - - if (found > 0) - found = 1 + ((system_time() + 3) % found); - else { - printf("Out of cookies...\n"); - return -1; - } - - for (i = 0; i < stat.st_size; i++) { - if (!strncmp(buf + i, "#@#", 3)) - found -= 1; - - if (found == 0) { - unsigned j; - - for (j = i + 1; j < stat.st_size; j++) { - if (!strncmp(buf + j, "#@#", 3)) - buf[j] = 0; - } - - printf("%s\n", buf + i + 3); - break; - } - } - - return 0; -} diff --git a/src/kernel/apps/hostname/Jamfile b/src/kernel/apps/hostname/Jamfile deleted file mode 100644 index d9e516d0c1..0000000000 --- a/src/kernel/apps/hostname/Jamfile +++ /dev/null @@ -1,3 +0,0 @@ -SubDir OBOS_TOP src kernel apps hostname ; - -KernelObjects <$(SOURCE_GRIST)>main.c : -fpic -Wno-unused ; diff --git a/src/kernel/apps/hostname/main.c b/src/kernel/apps/hostname/main.c deleted file mode 100644 index 2630de5369..0000000000 --- a/src/kernel/apps/hostname/main.c +++ /dev/null @@ -1,42 +0,0 @@ -/* naive implementation of hostname - * - * This mainly serves as a testbed for sysctl, part of the kernel - * just added. - */ - -#include -#include -#include -#include -#include - -#define MAXHOSTNAMELEN 256 - -int main(int argc, char *argv[]) -{ - char buffer[MAXHOSTNAMELEN]; - size_t buflen = MAXHOSTNAMELEN; - int mib[2]; - int rc = -1; - char *newname = NULL; - size_t newnamelen = 0; - - if (argc >= 2) { - newname = argv[1]; - newnamelen = strlen(newname); - } - - buffer[0] = '\0'; - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTNAME; - - rc = sysctl(mib, 2, &buffer, &buflen, newname, newnamelen); - - if (rc == 0 && !newname) { - printf("%s\n", buffer); - } - - return 0; -} - - diff --git a/src/kernel/apps/init.c b/src/kernel/apps/init.c deleted file mode 100644 index c45125820a..0000000000 --- a/src/kernel/apps/init.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Copyright 2001, Travis Geiselbrecht. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ - - -#include - -#include -#include -#include -#include - - -static void -setup_io(void) -{ - int i; - - for (i = 0; i< 256; i++) { - close(i); - } - - open("/dev/keyboard", O_RDONLY, 0); /* stdin */ - open("/dev/console", O_WRONLY, 0); /* stdout */ - open("/dev/console", O_WRONLY, 0); /* stderr */ -} - - -int -main(int argc, char **argv) -{ - setup_io(); - - printf("Welcome to Haiku!\r\n"); - - { - const char *args[] = {"consoled", NULL}; - thread_id thread; - - thread = load_image(1, args, (const char **)environ); - if (thread >= B_OK) { - status_t returnCode; - wait_for_thread(thread, &returnCode); - } else - printf("Failed to create a team for fortune.\n"); - } - - printf("init exiting\n"); - - return 0; -} diff --git a/src/kernel/apps/ls/Jamfile b/src/kernel/apps/ls/Jamfile deleted file mode 100644 index f5ddbae634..0000000000 --- a/src/kernel/apps/ls/Jamfile +++ /dev/null @@ -1,8 +0,0 @@ -SubDir OBOS_TOP src kernel apps ls ; - -KernelObjects - <$(SOURCE_GRIST)>main.c - : - -fpic -Wno-unused - ; - diff --git a/src/kernel/apps/ls/main.c b/src/kernel/apps/ls/main.c deleted file mode 100644 index 6ccf71377c..0000000000 --- a/src/kernel/apps/ls/main.c +++ /dev/null @@ -1,163 +0,0 @@ -/* -** Copyright 2002, Travis Geiselbrecht. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ -#include -#include -#include -#include -#include -#include -#include - -extern char *__progname; - -void (*disp_func)(const char *, const char *, struct stat *) = NULL; -static int show_all = 0; - -mode_t perms [9] = { - S_IRUSR, - S_IWUSR, - S_IXUSR, - S_IRGRP, - S_IWGRP, - S_IXGRP, - S_IROTH, - S_IWOTH, - S_IXOTH -}; - - -static void -display_l(const char *path, const char *filename, struct stat *stat) -{ - char perm[11]; - uint32 i; - memset(perm, '-', 10); - perm[10] = '\0'; - - for (i = 0; i < sizeof(perms) / sizeof(mode_t); i++) { - if (stat->st_mode & perms[i]) { - switch(i % 3) { - case 0: - perm[i + 1] = 'r'; - break; - case 1: - perm[i+1] = 'w'; - break; - case 2: - perm[i+1] = 'x'; - } - } - } - if (S_ISDIR(stat->st_mode)) - perm[0] = 'd'; - else if (S_ISLNK(stat->st_mode)) - perm[0] = 'l'; - else if (S_ISCHR(stat->st_mode)) - perm[0] = 'c'; - - printf("%10s %12lld %s" ,perm ,stat->st_size ,filename); - - if (S_ISLNK(stat->st_mode)) { - char buffer[1024]; - if (readlink(path, buffer, sizeof(buffer)) < 0) - strcpy(buffer, "???"); - printf(" (-> %s)\n", buffer); - } else - putchar('\n'); -} - - -static void -display(const char *path, const char *filename, struct stat *stat) -{ - printf("%s\n", filename); -} - - -int -main(int argc, char *argv[]) -{ - int rc; - int rc2; - int count = 0; - struct stat st; - char *arg; - int ch; - uint64 totbytes = 0; - - disp_func = display; - - while ((ch = getopt(argc, argv, "al")) != -1) { - switch (ch) { - case 'a': - show_all = 1; - break; - case 'l': - disp_func = display_l; - break; - } - } - argc -= optind; - argv += optind; - - if (*argv == NULL) - arg = "."; - else - arg = *argv; - - rc = stat(arg, &st); - if (rc < 0) { - printf("%s: %s: %s\n", __progname, - arg, strerror(rc)); - goto err_ls; - } - - if (S_ISDIR(st.st_mode)) { - DIR *thedir = opendir(arg); - - if (!thedir) { - printf("ls: %s: %s\n", arg, strerror(errno)); - } else { - if (show_all) { - /* process the '.' entry */ - rc = stat(arg, &st); - if (rc == 0) { - (*disp_func)(arg, ".", &st); - totbytes += st.st_size; - } - } - - for(;;) { - char buf2[1024]; - struct dirent *de = readdir(thedir); - - if (!de) - break; - - memset(buf2, 0, sizeof(buf2)); - if (strcmp(arg, ".") != 0) { - strlcpy(buf2, arg, sizeof(buf2)); - strlcat(buf2, "/", sizeof(buf2)); - } - strlcat(buf2, de->d_name, sizeof(buf2)); - - rc2 = lstat(buf2, &st); - if (rc2 == 0) { - (*disp_func)(buf2, de->d_name, &st); - totbytes += st.st_size; - } - count++; - } - closedir(thedir); - } - - printf("%lld bytes in %d files\n", totbytes, count); - } else { - (*disp_func)(arg, arg, &st); - } - -err_ls: - return 0; -} diff --git a/src/kernel/apps/monitor_test.c b/src/kernel/apps/monitor_test.c deleted file mode 100644 index 8e5f8bcfa2..0000000000 --- a/src/kernel/apps/monitor_test.c +++ /dev/null @@ -1,44 +0,0 @@ -/* tests node monitor functionality (very basic test!) */ - -/* -** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ - - -#include -#include -#include - -#include -#include -#include - - -int -main(int argc, char **argv) -{ - struct stat st; - if (stat("/", &st) < 0) { - fprintf(stderr, "Could not stat root!\n"); - return -1; - } - - printf("watch file: device = %ld, node = %Ld\n", st.st_dev, st.st_ino); - - if (_kern_start_watching(st.st_dev, st.st_ino, B_WATCH_DIRECTORY, 1, 2) < B_OK) { - fprintf(stderr, "Could not start watching!\n"); - return -1; - } - - mkdir("/temp_test", 0755); - rmdir("/temp_test"); - - if (_kern_stop_watching(st.st_dev, st.st_ino, 0, 1, 2) < B_OK) { - fprintf(stderr, "Could not stop watching!\n"); - return -1; - } - - return 0; -} - diff --git a/src/kernel/apps/on_exit_thread.c b/src/kernel/apps/on_exit_thread.c deleted file mode 100644 index 7ea9565512..0000000000 --- a/src/kernel/apps/on_exit_thread.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - - -static void -first(void *data) -{ - printf("first on_exit_thread(): %ld\n", (int32)data); -} - - -static void -second(void *data) -{ - printf("second on_exit_thread(): %ld\n", (int32)data); -} - - -static int32 -thread(void *data) -{ - puts("Nurse Stimpy for the rescue!"); - - on_exit_thread(first, (void *)11); - on_exit_thread(second, (void *)22); - - return 0; -} - - -int -main(int argc, char **argv) -{ - status_t status; - thread_id id; - - on_exit_thread(first, (void *)666); - id = spawn_thread(thread, "mythread", B_NORMAL_PRIORITY, (void *)42); - resume_thread(id); - - wait_for_thread(id, &status); - return 0; -} diff --git a/src/kernel/apps/pipe_test.c b/src/kernel/apps/pipe_test.c deleted file mode 100644 index 5947e59662..0000000000 --- a/src/kernel/apps/pipe_test.c +++ /dev/null @@ -1,97 +0,0 @@ -/* tests basic pipes functionality */ - -/* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ - - -#include - -#include -#include -#include - - -static int32 -reader_func(void *data) -{ - char buffer[1024]; - int input = (int)data; - int bytes; - - while ((bytes = read(input, buffer, sizeof(buffer) - 1)) > 0) { - buffer[bytes] = '\0'; - // null-terminate, just in case - printf("reader: (%d) %s\n", bytes, buffer); - - if (buffer[0] == '2') { - puts("reader: wait a second and let the writer lead (the pipe has to be buffered)"); - snooze(1000000); - } - if (strstr(buffer, "QUIT")) - break; - } - puts("reader quits"); - - return 0; -} - - -static int32 -writer_func(void *data) -{ - int output = (int)data; - int i; - - const char *strings[] = { - "1. If you read this ", - "2. the pipe implementation ", - "3. seems to work ", - "4. at least a bit ", - "5. QUIT", - NULL}; - - for (i = 0; strings[i] != NULL; i++) { - snooze(100000); - // make sure the reader is waiting for us... - // (needed by the current pipefs implementation :) - - printf("writer: (%ld)\n", write(output, strings[i], strlen(strings[i]))); - } - puts("writer quits"); - - return 0; -} - - -int -main(int argc, char **argv) -{ - thread_id reader, writer; - int stream[2]; - status_t returnCode; - - if (pipe(stream) < 0) { - fprintf(stderr, "pipe creation failed!\n"); - return -1; - } - - reader = spawn_thread(reader_func, "Reader" , B_NORMAL_PRIORITY, (void *)stream[0]); - resume_thread(reader); - - writer = spawn_thread(writer_func, "Writer" , B_NORMAL_PRIORITY, (void *)stream[1]); - resume_thread(writer); - - puts("reader & writer started."); - - // wait until they quit - wait_for_thread(reader, &returnCode); - wait_for_thread(writer, &returnCode); - - close(stream[0]); - close(stream[1]); - - return 0; -} - diff --git a/src/kernel/apps/ps/Jamfile b/src/kernel/apps/ps/Jamfile deleted file mode 100644 index 263838b2af..0000000000 --- a/src/kernel/apps/ps/Jamfile +++ /dev/null @@ -1,3 +0,0 @@ -SubDir OBOS_TOP src kernel apps ps ; - -KernelObjects <$(SOURCE_GRIST)>main.c ; diff --git a/src/kernel/apps/ps/main.c b/src/kernel/apps/ps/main.c deleted file mode 100644 index 393bd83c21..0000000000 --- a/src/kernel/apps/ps/main.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * PS command - * Rewritten for OpenBeOS by Angelo Mottola, Aug 2002. - */ - -#include -#include -#include -#include -#include -#include - - -const char *state(thread_state state); - - -const char *state(thread_state state) -{ - switch (state) { - case B_THREAD_RUNNING: - return "run"; - case B_THREAD_READY: - return "rdy"; - case B_THREAD_SUSPENDED: - return "sus"; - case B_THREAD_WAITING: - return "sem"; - case B_THREAD_ASLEEP: - return "zzz"; - case B_THREAD_RECEIVING: - return "msg"; - default: - return "???"; - } -} - - -int main(int argc, char **argv) -{ - int32 thread_num; - int32 team_num = 0; - thread_info thread; - team_info team; - sem_info sem; - char sem_name[B_OS_NAME_LENGTH * 2]; - char buffer[B_OS_NAME_LENGTH]; - - printf("\n thread name state prio user kernel semaphore\n"); - printf("-----------------------------------------------------------------------\n"); - - while (get_next_team_info(&team_num, &team) == B_OK) { - printf("%s (team %ld) (uid %d) (gid %d)\n", - team.args, team.team, team.uid, team.gid); - thread_num = 0; - while (get_next_thread_info(team.team, &thread_num, &thread) == B_OK) { - sem_name[0] = '\0'; - if (thread.state == B_THREAD_WAITING) { - if (get_sem_info(thread.sem, &sem) == B_OK) { - strcpy(sem_name, sem.name); - sprintf(buffer, "(%ld)", sem.sem); - strcat(sem_name, buffer); - } - } - printf(" %6ld %20s %s %3ld %7d %7d %s\n", - thread.thread, thread.name, state(thread.state), thread.priority, - (int)thread.user_time, (int)thread.kernel_time, sem_name); - } - } - printf("\n"); - - return 0; -} diff --git a/src/kernel/apps/select_test.c b/src/kernel/apps/select_test.c deleted file mode 100644 index 91588a5e03..0000000000 --- a/src/kernel/apps/select_test.c +++ /dev/null @@ -1,48 +0,0 @@ -/* tests basic select() and poll() functionality */ - -/* -** Copyright 2002, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ - - -#include -#include - -#include -#include -#include -#include - -#define FILE_NAME "/boot" - -int -main(int argc, char **argv) -{ - fd_set readSet; - struct pollfd pollfd; - int count; - int file = open(FILE_NAME, O_RDONLY); - if (file < 0) { - fprintf(stderr, "Could not open \"%s\": %s\n", FILE_NAME, strerror(file)); - return -1; - } - - FD_ZERO(&readSet); - FD_SET(file, &readSet); - - puts("selecting..."); - count = select(file + 1, &readSet, NULL, NULL, NULL); - printf("\tselect returned: %d (read set = %ld)\n", count, FD_ISSET(file, &readSet)); - - pollfd.fd = file; - pollfd.events = POLLOUT | POLLERR; - - puts("polling..."); - count = poll(&pollfd, 1, -1); - printf("\tpoll returned: %d (revents = 0x%x)\n", count, pollfd.revents); - - close(file); - return 0; -} - diff --git a/src/kernel/apps/shell/Jamfile b/src/kernel/apps/shell/Jamfile deleted file mode 100644 index d7f4ec4aeb..0000000000 --- a/src/kernel/apps/shell/Jamfile +++ /dev/null @@ -1,12 +0,0 @@ -SubDir OBOS_TOP src kernel apps shell ; - -KernelObjects <$(SOURCE_GRIST)>main.c - <$(SOURCE_GRIST)>args.c - <$(SOURCE_GRIST)>commands.c - <$(SOURCE_GRIST)>file_utils.c - <$(SOURCE_GRIST)>parse.c - <$(SOURCE_GRIST)>script.c - <$(SOURCE_GRIST)>shell_vars.c - <$(SOURCE_GRIST)>statements.c - <$(SOURCE_GRIST)>shell_history.c - : -fpic ; diff --git a/src/kernel/apps/shell/args.c b/src/kernel/apps/shell/args.c deleted file mode 100644 index 31fc81181c..0000000000 --- a/src/kernel/apps/shell/args.c +++ /dev/null @@ -1,80 +0,0 @@ -//#include -#include -#include -#include -#include -#include - -#include "args.h" -#include "shell_defs.h" -#include "shell_vars.h" - -bool af_exit_after_script; -char *af_script_file_name; -char *gCommandToExecute = NULL; - -static const char *kUsage = -"Usage: shell [ -s ] [ -c ] [