From bonefish at mail.berlios.de Sun Jun 1 04:25:03 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sun, 1 Jun 2008 04:25:03 +0200
Subject: [Haiku-commits] r25744 - in haiku/trunk: headers/private/kernel
src/system/kernel/debug
Message-ID: <200806010225.m512P3di025474@sheep.berlios.de>
Author: bonefish
Date: 2008-06-01 04:25:00 +0200 (Sun, 01 Jun 2008)
New Revision: 25744
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25744&view=rev
Added:
haiku/trunk/src/system/kernel/debug/debug_builtin_commands.cpp
haiku/trunk/src/system/kernel/debug/debug_builtin_commands.h
haiku/trunk/src/system/kernel/debug/debug_output_filter.h
Modified:
haiku/trunk/headers/private/kernel/debug.h
haiku/trunk/src/system/kernel/debug/Jamfile
haiku/trunk/src/system/kernel/debug/blue_screen.cpp
haiku/trunk/src/system/kernel/debug/debug.cpp
haiku/trunk/src/system/kernel/debug/debug_commands.cpp
haiku/trunk/src/system/kernel/debug/debug_commands.h
haiku/trunk/src/system/kernel/debug/debug_parser.cpp
Log:
* Introduced pipes in the kernel debugger. The syntax is similar to
pipes in the shell, though the semantics is a little different: The
second command is invoked whenever the first command has written a
complete line. The line is passed as last argument to the second
command. The new command flag B_KDEBUG_PIPE_FINAL_RERUN causes the
second command to be invoked again (with NULL argument) after the
first command is done.
* Added kprintf_unfiltered() and kputs_unfiltered() which bypass the
pipe mechanism and directly print to the bluescreen/serial output.
* Moved most commands from debug.cpp to the new
debug_builtin_commands.cpp.
* B_KDEBUG_DONT_PARSE_ARGUMENTS commands don't get an argument anymore,
if it would consist of white space only.
* Added new debugger command return value B_KDEBUG_ERROR, which
indicates that executing the command failed. This return code will
abort a complete pipe.
* Since debugger commands can nest (i.e. one command can invoke another
one) the setjmp()/longjmp() mechanism to restore the stack after a
page fault in a command needs more than one jump buffer.
* Added abort_debugger_command(), which longjmp()s out of the currently
executed command. This will also abort the current pipe.
* When pagination is enabled pressing "a" will abort the running command
(as opposed to "q" which only disables the blue screen output, but
lets the command continue).
* Added debugger commands:
- "grep" which can be used to filter output by pattern. Removed the
"filter" command and the underlying mechanism that did that before.
- "head" which prints only the first lines of output of another
command.
- "wc" counts lines, words, and characters of another command's
output.
Modified: haiku/trunk/headers/private/kernel/debug.h
===================================================================
--- haiku/trunk/headers/private/kernel/debug.h 2008-05-31 21:01:05 UTC (rev 25743)
+++ haiku/trunk/headers/private/kernel/debug.h 2008-06-01 02:25:00 UTC (rev 25744)
@@ -42,7 +42,12 @@
# define ASSERT_PRINT(x, format...) do { } while(0)
#endif
+// command return value
+#define B_KDEBUG_ERROR 4
+
+// command flags
#define B_KDEBUG_DONT_PARSE_ARGUMENTS (0x01)
+#define B_KDEBUG_PIPE_FINAL_RERUN (0x02)
struct debugger_module_info {
module_info info;
@@ -74,6 +79,9 @@
extern void debug_stop_screen_debug_output(void);
extern void kputs(const char *string);
+extern void kputs_unfiltered(const char *string);
+extern void kprintf_unfiltered(const char *format, ...)
+ __attribute__ ((format (__printf__, 1, 2)));
extern void dprintf_no_syslog(const char *format, ...)
__attribute__ ((format (__printf__, 1, 2)));
Modified: haiku/trunk/src/system/kernel/debug/Jamfile
===================================================================
--- haiku/trunk/src/system/kernel/debug/Jamfile 2008-05-31 21:01:05 UTC (rev 25743)
+++ haiku/trunk/src/system/kernel/debug/Jamfile 2008-06-01 02:25:00 UTC (rev 25744)
@@ -6,6 +6,7 @@
KernelMergeObject kernel_debug.o :
blue_screen.cpp
debug.cpp
+ debug_builtin_commands.cpp
debug_commands.cpp
debug_paranoia.cpp
debug_parser.cpp
Modified: haiku/trunk/src/system/kernel/debug/blue_screen.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/blue_screen.cpp 2008-05-31 21:01:05 UTC (rev 25743)
+++ haiku/trunk/src/system/kernel/debug/blue_screen.cpp 2008-06-01 02:25:00 UTC (rev 25744)
@@ -121,7 +121,7 @@
// Use the paging mechanism: either, we're in the debugger, and a
// command is being executed, or we're currently showing boot debug
// output
- const char *text = "Press key to continue, Q to quit";
+ const char *text = "Press key to continue, Q to quit, A to abort";
int32 length = strlen(text);
if (sScreen.x + length > sScreen.columns) {
// make sure we don't overwrite too much
@@ -136,8 +136,13 @@
}
char c = blue_screen_getchar();
- if (c == 'q')
+ if (c == 'q') {
sScreen.ignore_output = true;
+ } else if (c == 'a') {
+ abort_debugger_command();
+ // should not return
+ sScreen.ignore_output = true;
+ }
// remove on screen text again
sModule->fill_glyph(sScreen.columns - length, sScreen.y, length,
Modified: haiku/trunk/src/system/kernel/debug/debug.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/debug.cpp 2008-05-31 21:01:05 UTC (rev 25743)
+++ haiku/trunk/src/system/kernel/debug/debug.cpp 2008-06-01 02:25:00 UTC (rev 25744)
@@ -9,7 +9,6 @@
/*! This file contains the debugger and debug output facilities */
#include "blue_screen.h"
-#include "gdb.h"
#include
#include
@@ -35,7 +34,9 @@
#include
#include
+#include "debug_builtin_commands.h"
#include "debug_commands.h"
+#include "debug_output_filter.h"
#include "debug_variables.h"
@@ -67,6 +68,8 @@
#define OUTPUT_BUFFER_SIZE 1024
static char sOutputBuffer[OUTPUT_BUFFER_SIZE];
static char sLastOutputBuffer[OUTPUT_BUFFER_SIZE];
+static DebugOutputFilter* sDebugOutputFilter = NULL;
+DefaultDebugOutputFilter gDefaultDebugOutputFilter;
static void flush_pending_repeats(void);
static void check_pending_repeats(void *data, int iter);
@@ -84,22 +87,80 @@
static char sLineBuffer[HISTORY_SIZE][LINE_BUFFER_SIZE] = { "", };
static char sParseLine[LINE_BUFFER_SIZE];
-static char sFilter[64];
static int32 sCurrentLine = 0;
#define distance(a, b) ((a) < (b) ? (b) - (a) : (a) - (b))
+// #pragma mark - DebugOutputFilter
+
+
+DebugOutputFilter::DebugOutputFilter()
+{
+}
+
+
+DebugOutputFilter::~DebugOutputFilter()
+{
+}
+
+
+void
+DebugOutputFilter::PrintString(const char* string)
+{
+}
+
+
+void
+DebugOutputFilter::Print(const char* format, va_list args)
+{
+}
+
+
+void
+DefaultDebugOutputFilter::PrintString(const char* string)
+{
+ if (sSerialDebugEnabled)
+ arch_debug_serial_puts(string);
+ if (sBlueScreenEnabled || sDebugScreenEnabled)
+ blue_screen_puts(string);
+
+ for (uint32 i = 0; sSerialDebugEnabled && i < kMaxDebuggerModules; i++) {
+ if (sDebuggerModules[i] && sDebuggerModules[i]->debugger_puts)
+ sDebuggerModules[i]->debugger_puts(string, strlen(string));
+ }
+}
+
+
+void
+DefaultDebugOutputFilter::Print(const char* format, va_list args)
+{
+ vsnprintf(sOutputBuffer, OUTPUT_BUFFER_SIZE, format, args);
+ flush_pending_repeats();
+ PrintString(sOutputBuffer);
+}
+
+
+// #pragma mark -
+
+
+DebugOutputFilter*
+set_debug_output_filter(DebugOutputFilter* filter)
+{
+ DebugOutputFilter* oldFilter = sDebugOutputFilter;
+ sDebugOutputFilter = filter;
+ return oldFilter;
+}
+
+
static void
kputchar(char c)
{
- uint32 i;
-
if (sSerialDebugEnabled)
arch_debug_serial_putchar(c);
if (sBlueScreenEnabled || sDebugScreenEnabled)
blue_screen_putchar(c);
- for (i = 0; sSerialDebugEnabled && i < kMaxDebuggerModules; i++)
+ for (uint32 i = 0; sSerialDebugEnabled && i < kMaxDebuggerModules; i++)
if (sDebuggerModules[i] && sDebuggerModules[i]->debugger_puts)
sDebuggerModules[i]->debugger_puts(&c, sizeof(c));
}
@@ -108,15 +169,15 @@
void
kputs(const char *s)
{
- uint32 i;
+ if (sDebugOutputFilter != NULL)
+ sDebugOutputFilter->PrintString(s);
+}
- if (sSerialDebugEnabled)
- arch_debug_serial_puts(s);
- if (sBlueScreenEnabled || sDebugScreenEnabled)
- blue_screen_puts(s);
- for (i = 0; sSerialDebugEnabled && i < kMaxDebuggerModules; i++)
- if (sDebuggerModules[i] && sDebuggerModules[i]->debugger_puts)
- sDebuggerModules[i]->debugger_puts(s, strlen(s));
+
+void
+kputs_unfiltered(const char *s)
+{
+ gDefaultDebugOutputFilter.PrintString(s);
}
@@ -631,124 +692,17 @@
static int
-cmd_reboot(int argc, char **argv)
-{
- arch_cpu_shutdown(true);
- return 0;
- // I'll be really suprised if this line ever runs! ;-)
-}
-
-
-static int
-cmd_shutdown(int argc, char **argv)
-{
- arch_cpu_shutdown(false);
- return 0;
-}
-
-
-static int
-cmd_help(int argc, char **argv)
-{
- debugger_command *command, *specified = NULL;
- const char *start = NULL;
- int32 startLength = 0;
- bool ambiguous;
-
- if (argc > 1) {
- specified = find_debugger_command(argv[1], false, ambiguous);
- if (specified == NULL) {
- start = argv[1];
- startLength = strlen(start);
- }
- }
-
- if (specified != NULL) {
- // only print out the help of the specified command (and all of its aliases)
- kprintf("debugger command for \"%s\" and aliases:\n", specified->name);
- } else if (start != NULL)
- kprintf("debugger commands starting with \"%s\":\n", start);
- else
- kprintf("debugger commands:\n");
-
- for (command = get_debugger_commands(); command != NULL;
- command = command->next) {
- if (specified && command->func != specified->func)
- continue;
- if (start != NULL && strncmp(start, command->name, startLength))
- continue;
-
- kprintf(" %-20s\t\t%s\n", command->name, command->description ? command->description : "-");
- }
-
- return 0;
-}
-
-
-static int
-cmd_continue(int argc, char **argv)
-{
- return B_KDEBUG_QUIT;
-}
-
-
-static int
cmd_dump_kdl_message(int argc, char **argv)
{
if (sCurrentKernelDebuggerMessage) {
kputs(sCurrentKernelDebuggerMessage);
- kputchar('\n');
+ kputs("\n");
}
return 0;
}
-static int
-cmd_expr(int argc, char **argv)
-{
- if (argc != 2) {
- print_debugger_command_usage(argv[0]);
- return 0;
- }
- uint64 result;
- if (evaluate_debug_expression(argv[1], &result, false)) {
- kprintf("%llu (0x%llx)\n", result, result);
- set_debug_variable("_", result);
- }
-
- return 0;
-}
-
-
-static int
-cmd_filter(int argc, char **argv)
-{
- if (argc != 2) {
- sFilter[0] = '\0';
- return 0;
- }
-
- strlcpy(sFilter, argv[1], sizeof(sFilter));
- return 0;
-}
-
-
-static int
-cmd_error(int argc, char **argv)
-{
- if (argc != 2) {
- print_debugger_command_usage(argv[0]);
- return 0;
- }
-
- int32 error = parse_expression(argv[1]);
- kprintf("error 0x%lx: %s\n", error, strerror(error));
-
- return 0;
-}
-
-
static status_t
syslog_sender(void *data)
{
@@ -1000,6 +954,8 @@
status_t
debug_init(kernel_args *args)
{
+ new(&gDefaultDebugOutputFilter) DefaultDebugOutputFilter;
+
debug_paranoia_init();
return arch_debug_console_init(args);
}
@@ -1008,44 +964,13 @@
status_t
debug_init_post_vm(kernel_args *args)
{
- add_debugger_command_etc("help", &cmd_help, "List all debugger commands",
- "[name]\n"
- "Lists all debugger commands or those starting with \"name\".\n", 0);
- add_debugger_command_etc("reboot", &cmd_reboot, "Reboot the system",
- "\n"
- "Reboots the system.\n", 0);
- add_debugger_command_etc("shutdown", &cmd_shutdown, "Shut down the system",
- "\n"
- "Shuts down the system.\n", 0);
- add_debugger_command_etc("gdb", &cmd_gdb, "Connect to remote gdb",
- "\n"
- "Connects to a remote gdb connected to the serial port.\n", 0);
- add_debugger_command_etc("continue", &cmd_continue, "Leave kernel debugger",
- "\n"
- "Leaves kernel debugger.\n", 0);
- add_debugger_command_alias("exit", "continue", "Same as \"continue\"");
- add_debugger_command_alias("es", "continue", "Same as \"continue\"");
add_debugger_command_etc("message", &cmd_dump_kdl_message,
"Reprint the message printed when entering KDL",
"\n"
"Reprints the message printed when entering KDL.\n", 0);
- add_debugger_command_etc("expr", &cmd_expr,
- "Evaluates the given expression and prints the result",
- "\n"
- "Evaluates the given expression and prints the result.\n",
- B_KDEBUG_DONT_PARSE_ARGUMENTS);
- add_debugger_command_etc("filter", &cmd_filter,
- "Filters output of all debugger commands",
- "\n"
- "Filters out all debug output of commands that does not match the\n"
- "specified pattern. If no pattern is given, it is removed\n", 0);
- add_debugger_command_etc("error", &cmd_error,
- "Prints a human-readable description for an error code",
- "\n"
- "Prints a human-readable description for the given numeric error\n"
- "code.\n"
- " - The numeric error code.\n", 0);
+ debug_builtin_commands_init();
+
debug_variables_init();
frame_buffer_console_init(args);
arch_debug_console_init_settings(args);
@@ -1181,6 +1106,8 @@
sBlueScreenEnabled = true;
}
+ sDebugOutputFilter = &gDefaultDebugOutputFilter;
+
if (message)
kprintf("PANIC: %s\n", message);
@@ -1196,6 +1123,8 @@
call_modules_hook(false);
set_dprintf_enabled(dprintfState);
+ sDebugOutputFilter = NULL;
+
sBlueScreenEnabled = false;
atomic_add(&inDebugger, -1);
restore_interrupts(state);
@@ -1354,21 +1283,22 @@
void
kprintf(const char *format, ...)
{
- va_list args;
+ if (sDebugOutputFilter != NULL) {
+ va_list args;
+ va_start(args, format);
+ sDebugOutputFilter->Print(format, args);
+ va_end(args);
+ }
+}
- // ToDo: don't print anything if the debugger is not running!
+void
+kprintf_unfiltered(const char *format, ...)
+{
+ va_list args;
va_start(args, format);
- vsnprintf(sOutputBuffer, OUTPUT_BUFFER_SIZE, format, args);
+ gDefaultDebugOutputFilter.Print(format, args);
va_end(args);
-
- if (in_command_invocation() && sFilter[0]) {
- if (strstr(sOutputBuffer, sFilter) == NULL)
- return;
- }
-
- flush_pending_repeats();
- kputs(sOutputBuffer);
}
Added: haiku/trunk/src/system/kernel/debug/debug_builtin_commands.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/debug_builtin_commands.cpp 2008-05-31 21:01:05 UTC (rev 25743)
+++ haiku/trunk/src/system/kernel/debug/debug_builtin_commands.cpp 2008-06-01 02:25:00 UTC (rev 25744)
@@ -0,0 +1,318 @@
+/*
+ * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de
+ * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de
+ * Distributed under the terms of the MIT License.
+ *
+ * Copyright 2001, Travis Geiselbrecht. All rights reserved.
+ * Distributed under the terms of the NewOS License.
+ */
+
+#include "debug_builtin_commands.h"
+
+#include
+#include
+#include
+
+#include "debug_commands.h"
+#include "gdb.h"
+
+
+static int
+cmd_reboot(int argc, char **argv)
+{
+ arch_cpu_shutdown(true);
+ return 0;
+ // I'll be really suprised if this line ever runs! ;-)
+}
+
+
+static int
+cmd_shutdown(int argc, char **argv)
+{
+ arch_cpu_shutdown(false);
+ return 0;
+}
+
+
+static int
+cmd_help(int argc, char **argv)
+{
+ debugger_command *command, *specified = NULL;
+ const char *start = NULL;
+ int32 startLength = 0;
+ bool ambiguous;
+
+ if (argc > 1) {
+ specified = find_debugger_command(argv[1], false, ambiguous);
+ if (specified == NULL) {
+ start = argv[1];
+ startLength = strlen(start);
+ }
+ }
+
+ if (specified != NULL) {
+ // only print out the help of the specified command (and all of its aliases)
+ kprintf("debugger command for \"%s\" and aliases:\n", specified->name);
+ } else if (start != NULL)
+ kprintf("debugger commands starting with \"%s\":\n", start);
+ else
+ kprintf("debugger commands:\n");
+
+ for (command = get_debugger_commands(); command != NULL;
+ command = command->next) {
+ if (specified && command->func != specified->func)
+ continue;
+ if (start != NULL && strncmp(start, command->name, startLength))
+ continue;
+
+ kprintf(" %-20s\t\t%s\n", command->name, command->description ? command->description : "-");
+ }
+
+ return 0;
+}
+
+
+static int
+cmd_continue(int argc, char **argv)
+{
+ return B_KDEBUG_QUIT;
+}
+
+
+static int
+cmd_expr(int argc, char **argv)
+{
+ if (argc != 2) {
+ print_debugger_command_usage(argv[0]);
+ return 0;
+ }
+
+ uint64 result;
+ if (evaluate_debug_expression(argv[1], &result, false)) {
+ kprintf("%llu (0x%llx)\n", result, result);
+ set_debug_variable("_", result);
+ }
+
+ return 0;
+}
+
+
+static int
+cmd_error(int argc, char **argv)
+{
+ if (argc != 2) {
+ print_debugger_command_usage(argv[0]);
+ return 0;
+ }
+
+ int32 error = parse_expression(argv[1]);
+ kprintf("error 0x%lx: %s\n", error, strerror(error));
+
+ return 0;
+}
+
+
+static int
+cmd_head(int argc, char** argv)
+{
+ debugger_command_pipe_segment* segment
+ = get_current_debugger_command_pipe_segment();
+ if (segment == NULL) {
+ kprintf_unfiltered("%s can only be run as part of a pipe!\n", argv[0]);
+ return B_KDEBUG_ERROR;
+ }
+
+ struct user_data {
+ uint64 max_lines;
+ uint64 lines;
+ };
+ user_data* userData = (user_data*)segment->user_data;
+
+ if (segment->invocations == 0) {
+ if (argc != 3) {
+ print_debugger_command_usage(argv[0]);
+ return B_KDEBUG_ERROR;
+ }
+
+ if (!evaluate_debug_expression(argv[1], &userData->max_lines, false))
+ return B_KDEBUG_ERROR;
+ userData->lines = 0;
+ }
+
+ if (++userData->lines <= userData->max_lines) {
+ kputs(argv[2]);
+ kputs("\n");
+ }
+
+ return 0;
+}
+
+
+static int
+cmd_grep(int argc, char** argv)
+{
+ bool caseSensitive = true;
+ bool inverseMatch = false;
+
+ int argi = 1;
+ for (; argi < argc; argi++) {
+ const char* arg = argv[argi];
+ if (arg[0] != '-')
+ break;
+
+ for (int32 i = 1; arg[i] != '\0'; i++) {
+ if (arg[i] == 'i') {
+ caseSensitive = false;
+ } else if (arg[i] == 'v') {
+ inverseMatch = true;
+ } else {
+ print_debugger_command_usage(argv[0]);
+ return B_KDEBUG_ERROR;
+ }
+ }
+ }
+
+ if (argc - argi != 2) {
+ print_debugger_command_usage(argv[0]);
+ return B_KDEBUG_ERROR;
+ }
+
+ const char* pattern = argv[argi++];
+ const char* line = argv[argi++];
+
+ bool match;
+ if (caseSensitive) {
+ match = strstr(line, pattern) != NULL;
+ } else {
+ match = false;
+ int32 lineLen = strlen(line);
+ int32 patternLen = strlen(pattern);
+ for (int32 i = 0; i <= lineLen - patternLen; i++) {
+ // This is rather slow, but should be OK for our purposes.
+ if (strncasecmp(line + i, pattern, patternLen) == 0) {
+ match = true;
+ break;
+ }
+ }
+ }
+
+ if (match != inverseMatch) {
+ kputs(line);
+ kputs("\n");
+ }
+
+ return 0;
+}
+
+
+static int
+cmd_wc(int argc, char** argv)
+{
+ debugger_command_pipe_segment* segment
+ = get_current_debugger_command_pipe_segment();
+ if (segment == NULL) {
+ kprintf_unfiltered("%s can only be run as part of a pipe!\n", argv[0]);
+ return B_KDEBUG_ERROR;
+ }
+
+ struct user_data {
+ uint64 lines;
+ uint64 words;
+ uint64 chars;
+ };
+ user_data* userData = (user_data*)segment->user_data;
+
+ if (segment->invocations == 0) {
+ if (argc != 2) {
+ print_debugger_command_usage(argv[0]);
+ return B_KDEBUG_ERROR;
+ }
+
+ userData->lines = 0;
+ userData->words = 0;
+ userData->chars = 0;
+ }
+
+ const char* line = argv[1];
+ if (line == NULL) {
+ // last run -- print results
+ kprintf("%10lld %10lld %10lld\n", userData->lines, userData->words,
+ userData->chars);
+ return 0;
+ }
+
+ userData->lines++;
+ userData->chars++;
+ // newline
+
+ // count words and chars in this line
+ bool inWord = false;
+ for (; *line != '\0'; line++) {
+ userData->chars++;
+ if ((isspace(*line) != 0) == inWord) {
+ inWord = !inWord;
+ if (inWord)
+ userData->words++;
+ }
+ }
+
+ return 0;
+}
+
+
+// #pragma mark -
+
+
+void
+debug_builtin_commands_init()
+{
+ add_debugger_command_etc("help", &cmd_help, "List all debugger commands",
+ "[name]\n"
+ "Lists all debugger commands or those starting with \"name\".\n", 0);
+ add_debugger_command_etc("reboot", &cmd_reboot, "Reboot the system",
+ "\n"
+ "Reboots the system.\n", 0);
+ add_debugger_command_etc("shutdown", &cmd_shutdown, "Shut down the system",
+ "\n"
+ "Shuts down the system.\n", 0);
+ add_debugger_command_etc("gdb", &cmd_gdb, "Connect to remote gdb",
+ "\n"
+ "Connects to a remote gdb connected to the serial port.\n", 0);
+ add_debugger_command_etc("continue", &cmd_continue, "Leave kernel debugger",
+ "\n"
+ "Leaves kernel debugger.\n", 0);
+ add_debugger_command_alias("exit", "continue", "Same as \"continue\"");
+ add_debugger_command_alias("es", "continue", "Same as \"continue\"");
+ add_debugger_command_etc("expr", &cmd_expr,
+ "Evaluates the given expression and prints the result",
+ "\n"
+ "Evaluates the given expression and prints the result.\n",
+ B_KDEBUG_DONT_PARSE_ARGUMENTS);
+ add_debugger_command_etc("error", &cmd_error,
+ "Prints a human-readable description for an error code",
+ "\n"
+ "Prints a human-readable description for the given numeric error\n"
+ "code.\n"
+ " - The numeric error code.\n", 0);
+ add_debugger_command_etc("head", &cmd_head,
+ "Prints only the first lines of output from another command",
+ "\n"
+ "Should be used in a command pipe. It prints only the first\n"
+ " lines of output from the previous command in the pipe and\n"
+ "silently discards the rest of the output.\n", 0);
+ add_debugger_command_etc("grep", &cmd_grep,
+ "Filters output from another command",
+ "[ -i ] [ -v ] \n"
+ "Should be used in a command pipe. It filters all output from the\n"
+ "previous command in the pipe according to the given pattern.\n"
+ "When \"-v\" is specified, only those lines are printed that don't\n"
+ "match the given pattern, otherwise only those that do match. When\n"
+ "\"-i\" is specified, the pattern is matched case insensitive,\n"
+ "otherwise case sensitive.\n", 0);
+ add_debugger_command_etc("wc", &cmd_wc,
+ "Counts the lines, words, and characters of another command's output",
+ "\n"
+ "Should be used in a command pipe. It prints how many lines, words,\n"
+ "and characters the output of the previous command consists of.\n",
+ B_KDEBUG_PIPE_FINAL_RERUN);
+}
Added: haiku/trunk/src/system/kernel/debug/debug_builtin_commands.h
===================================================================
--- haiku/trunk/src/system/kernel/debug/debug_builtin_commands.h 2008-05-31 21:01:05 UTC (rev 25743)
+++ haiku/trunk/src/system/kernel/debug/debug_builtin_commands.h 2008-06-01 02:25:00 UTC (rev 25744)
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_DEBUG_BUILTIN_COMMANDS_H
+#define _KERNEL_DEBUG_BUILTIN_COMMANDS_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void debug_builtin_commands_init();
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+
+#endif // _KERNEL_DEBUG_BUILTIN_COMMANDS_H
Modified: haiku/trunk/src/system/kernel/debug/debug_commands.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/debug_commands.cpp 2008-05-31 21:01:05 UTC (rev 25743)
+++ haiku/trunk/src/system/kernel/debug/debug_commands.cpp 2008-06-01 02:25:00 UTC (rev 25744)
@@ -10,6 +10,7 @@
#include "debug_commands.h"
#include
+#include
#include
#include
@@ -19,18 +20,174 @@
#include
#include
+#include "debug_output_filter.h"
#include "debug_variables.h"
+#define INVOKE_COMMAND_FAULT 1
+#define INVOKE_COMMAND_ERROR 2
+
+static const int32 kMaxInvokeCommandDepth = 5;
+static const int32 kOutputBufferSize = 1024;
+
static spinlock sSpinlock = 0;
static struct debugger_command *sCommands;
-static jmp_buf sInvokeCommandEnv;
+static jmp_buf sInvokeCommandEnv[kMaxInvokeCommandDepth];
+static int32 sInvokeCommandLevel = 0;
static bool sInvokeCommandDirectly = false;
static bool sInCommand = false;
+static char sOutputBuffers[MAX_DEBUGGER_COMMAND_PIPE_LENGTH][kOutputBufferSize];
+static debugger_command_pipe* sCurrentPipe;
+static int32 sCurrentPipeSegment;
+static int invoke_pipe_segment(debugger_command_pipe* pipe, int32 index,
+ char* argument);
+
+
+class PipeDebugOutputFilter : public DebugOutputFilter {
+public:
+ PipeDebugOutputFilter()
+ {
+ }
+
+ PipeDebugOutputFilter(debugger_command_pipe* pipe, int32 segment,
+ char* buffer, size_t bufferSize)
+ :
+ fPipe(pipe),
+ fSegment(segment),
+ fBuffer(buffer),
+ fBufferCapacity(bufferSize - 1),
+ fBufferSize(0)
+ {
+ }
+
+ virtual void PrintString(const char* string)
+ {
+ if (fPipe->broken)
+ return;
+
+ size_t size = strlen(string);
+ while (const char* newLine = strchr(string, '\n')) {
+ size_t length = newLine - string;
+ _Append(string, length);
+
+ // invoke command
+ fBuffer[fBufferSize] = '\0';
+ invoke_pipe_segment(fPipe, fSegment + 1, fBuffer);
+
+ fBufferSize = 0;
+
+ string = newLine + 1;
+ size -= length + 1;
+ }
+
+ _Append(string, size);
+
+ if (fBufferSize == fBufferCapacity) {
+ // buffer is full, but contains no newline -- execute anyway
+ invoke_pipe_segment(fPipe, fSegment + 1, fBuffer);
+ fBufferSize = 0;
+ }
+ }
+
+ virtual void Print(const char* format, va_list args)
+ {
+ if (fPipe->broken)
+ return;
+
+ // print directly into the buffer
+ fBufferSize += vsnprintf(fBuffer + fBufferSize,
+ fBufferCapacity - fBufferSize, format, args);
+
+ // execute every complete line
+ fBuffer[fBufferSize] = '\0';
+ char* line = fBuffer;
+
+ while (char* newLine = strchr(line, '\n')) {
+ // invoke command
+ *newLine = '\0';
+ invoke_pipe_segment(fPipe, fSegment + 1, line);
+
+ line = newLine + 1;
+ }
+
+ size_t left = fBuffer + fBufferSize - line;
+
+ if (left == fBufferCapacity) {
+ // buffer is full, but contains no newline -- execute anyway
+ invoke_pipe_segment(fPipe, fSegment + 1, fBuffer);
+ left = 0;
+ }
+
+ if (left > 0)
+ memmove(fBuffer, line, left);
+
+ fBufferSize = left;
+ }
+
+private:
+ void _Append(const char* string, size_t length)
+ {
+ size_t toAppend = min_c(length, fBufferCapacity - fBufferSize);
+ memcpy(fBuffer + fBufferSize, string, toAppend);
+ fBufferSize += length;
+ }
+
+private:
+ debugger_command_pipe* fPipe;
+ int32 fSegment;
+ char* fBuffer;
+ size_t fBufferCapacity;
+ size_t fBufferSize;
+};
+
+
+static PipeDebugOutputFilter sPipeOutputFilters[
+ MAX_DEBUGGER_COMMAND_PIPE_LENGTH - 1];
+
+
+static int
+invoke_pipe_segment(debugger_command_pipe* pipe, int32 index, char* argument)
+{
+ // set debug output
+ DebugOutputFilter* oldFilter = set_debug_output_filter(
+ index == pipe->segment_count - 1
+ ? &gDefaultDebugOutputFilter : &sPipeOutputFilters[index]);
+
+ // set last command argument
+ debugger_command_pipe_segment& segment = pipe->segments[index];
+ if (index > 0)
+ segment.argv[segment.argc - 1] = argument;
+
+ // invoke command
+ int32 oldIndex = sCurrentPipeSegment;
+ sCurrentPipeSegment = index;
+
+ int result = invoke_debugger_command(segment.command, segment.argc,
+ segment.argv);
+ segment.invocations++;
+
+ sCurrentPipeSegment = oldIndex;
+
+ // reset debug output
+ set_debug_output_filter(oldFilter);
+
+ if (result == B_KDEBUG_ERROR) {
+ pipe->broken = true;
+
+ // Abort the previous pipe segment execution. The complete pipe is
+ // aborted iteratively this way.
+ if (index > 0)
+ abort_debugger_command();
+ }
+
+ return result;
+}
+
+
debugger_command*
next_debugger_command(debugger_command* command, const char* prefix, int prefixLen)
{
@@ -98,9 +255,10 @@
// intercept invocations with "--help" and directly print the usage text
// If we know the command's usage text, intercept "--help" invocations
// and print it directly.
- if (argc == 2 && strcmp(argv[1], "--help") == 0 && command->usage != NULL) {
- kprintf("usage: %s ", command->name);
- kputs(command->usage);
+ if (argc == 2 && argv[1] != NULL && strcmp(argv[1], "--help") == 0
+ && command->usage != NULL) {
+ kprintf_unfiltered("usage: %s ", command->name);
+ kputs_unfiltered(command->usage);
return 0;
}
@@ -117,33 +275,99 @@
sInCommand = true;
[... truncated: 458 lines follow ...]
From anevilyak at mail.berlios.de Sun Jun 1 04:36:47 2008
From: anevilyak at mail.berlios.de (anevilyak at BerliOS)
Date: Sun, 1 Jun 2008 04:36:47 +0200
Subject: [Haiku-commits] r25745 - haiku/trunk/src/system/kernel/debug
Message-ID: <200806010236.m512alRV026108@sheep.berlios.de>
Author: anevilyak
Date: 2008-06-01 04:36:47 +0200 (Sun, 01 Jun 2008)
New Revision: 25745
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25745&view=rev
Modified:
haiku/trunk/src/system/kernel/debug/debug_commands.cpp
Log:
gcc4 build fix.
Modified: haiku/trunk/src/system/kernel/debug/debug_commands.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/debug_commands.cpp 2008-06-01 02:25:00 UTC (rev 25744)
+++ haiku/trunk/src/system/kernel/debug/debug_commands.cpp 2008-06-01 02:36:47 UTC (rev 25745)
@@ -155,7 +155,7 @@
// set debug output
DebugOutputFilter* oldFilter = set_debug_output_filter(
index == pipe->segment_count - 1
- ? &gDefaultDebugOutputFilter : &sPipeOutputFilters[index]);
+ ? &gDefaultDebugOutputFilter : (DebugOutputFilter*)&sPipeOutputFilters[index]);
// set last command argument
debugger_command_pipe_segment& segment = pipe->segments[index];
From bonefish at mail.berlios.de Sun Jun 1 04:40:08 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sun, 1 Jun 2008 04:40:08 +0200
Subject: [Haiku-commits] r25746 - haiku/trunk/src/system/kernel/debug
Message-ID: <200806010240.m512e8vK026321@sheep.berlios.de>
Author: bonefish
Date: 2008-06-01 04:40:08 +0200 (Sun, 01 Jun 2008)
New Revision: 25746
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25746&view=rev
Modified:
haiku/trunk/src/system/kernel/debug/debug_commands.cpp
Log:
Enforce 80 columns maximum line length.
Modified: haiku/trunk/src/system/kernel/debug/debug_commands.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/debug_commands.cpp 2008-06-01 02:36:47 UTC (rev 25745)
+++ haiku/trunk/src/system/kernel/debug/debug_commands.cpp 2008-06-01 02:40:08 UTC (rev 25746)
@@ -155,7 +155,8 @@
// set debug output
DebugOutputFilter* oldFilter = set_debug_output_filter(
index == pipe->segment_count - 1
- ? &gDefaultDebugOutputFilter : (DebugOutputFilter*)&sPipeOutputFilters[index]);
+ ? &gDefaultDebugOutputFilter
+ : (DebugOutputFilter*)&sPipeOutputFilters[index]);
// set last command argument
debugger_command_pipe_segment& segment = pipe->segments[index];
@@ -189,7 +190,8 @@
debugger_command*
-next_debugger_command(debugger_command* command, const char* prefix, int prefixLen)
+next_debugger_command(debugger_command* command, const char* prefix,
+ int prefixLen)
{
if (command == NULL)
command = sCommands;
@@ -279,8 +281,8 @@
case 0:
int result;
thread->fault_handler = (addr_t)&&error;
- // Fake goto to trick the compiler not to optimize the code at the label
- // away.
+ // Fake goto to trick the compiler not to optimize the code at the
+ // label away.
if (!thread)
goto error;
From anevilyak at gmail.com Sun Jun 1 04:43:13 2008
From: anevilyak at gmail.com (Rene Gollent)
Date: Sat, 31 May 2008 21:43:13 -0500
Subject: [Haiku-commits] r25746 - haiku/trunk/src/system/kernel/debug
In-Reply-To: <200806010240.m512e8vK026321@sheep.berlios.de>
References: <200806010240.m512e8vK026321@sheep.berlios.de>
Message-ID:
On Sat, May 31, 2008 at 9:40 PM, bonefish at BerliOS
wrote:
> Author: bonefish
> Date: 2008-06-01 04:40:08 +0200 (Sun, 01 Jun 2008)
> New Revision: 25746
> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25746&view=rev
>
> Modified:
> haiku/trunk/src/system/kernel/debug/debug_commands.cpp
> Log:
> Enforce 80 columns maximum line length.
>
>
Whoops, forgot about that sorry.
Regards,
Rene
From axeld at mail.berlios.de Sun Jun 1 12:53:11 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Sun, 1 Jun 2008 12:53:11 +0200
Subject: [Haiku-commits] r25747 - haiku/trunk/src/system/kernel/vm
Message-ID: <200806011053.m51ArBcA015477@sheep.berlios.de>
Author: axeld
Date: 2008-06-01 12:53:10 +0200 (Sun, 01 Jun 2008)
New Revision: 25747
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25747&view=rev
Modified:
haiku/trunk/src/system/kernel/vm/vm_page.cpp
Log:
* vm_cache::virtual_size is not always a multiple of B_PAGE_SIZE for files.
In these cases, the last partial page would have never been written back.
* This fixes bug #2282, and eventually others.
Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp
===================================================================
--- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-06-01 02:40:08 UTC (rev 25746)
+++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-06-01 10:53:10 UTC (rev 25747)
@@ -1398,7 +1398,7 @@
vm_page_write_modified_pages(vm_cache *cache, bool fsReenter)
{
return vm_page_write_modified_page_range(cache, 0,
- cache->virtual_size >> PAGE_SHIFT, fsReenter);
+ (cache->virtual_size + B_PAGE_SIZE - 1) >> PAGE_SHIFT, fsReenter);
}
From korli at mail.berlios.de Sun Jun 1 17:27:01 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Sun, 1 Jun 2008 17:27:01 +0200
Subject: [Haiku-commits] r25748 -
haiku/trunk/src/system/kernel/device_manager
Message-ID: <200806011527.m51FR0h8026142@sheep.berlios.de>
Author: korli
Date: 2008-06-01 17:27:00 +0200 (Sun, 01 Jun 2008)
New Revision: 25748
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25748&view=rev
Modified:
haiku/trunk/src/system/kernel/device_manager/io_resources.cpp
Log:
when acquiring results in an error, the resource should be reset to avoid a crash on delete
Modified: haiku/trunk/src/system/kernel/device_manager/io_resources.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/io_resources.cpp 2008-06-01 10:53:10 UTC (rev 25747)
+++ haiku/trunk/src/system/kernel/device_manager/io_resources.cpp 2008-06-01 15:27:00 UTC (rev 25748)
@@ -89,6 +89,7 @@
// This range is already covered by someone else
// TODO: we might want to ignore resources that belong to
// a node that isn't used.
+ _Init();
return B_RESOURCE_UNAVAILABLE;
}
}
From anevilyak at mail.berlios.de Sun Jun 1 18:16:10 2008
From: anevilyak at mail.berlios.de (anevilyak at BerliOS)
Date: Sun, 1 Jun 2008 18:16:10 +0200
Subject: [Haiku-commits] r25749 - haiku/trunk/src/add-ons/accelerants/common
Message-ID: <200806011616.m51GGAh0030019@sheep.berlios.de>
Author: anevilyak
Date: 2008-06-01 18:16:10 +0200 (Sun, 01 Jun 2008)
New Revision: 25749
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25749&view=rev
Modified:
haiku/trunk/src/add-ons/accelerants/common/i2c.c
Log:
Fix I2C tracing, style cleanups.
Modified: haiku/trunk/src/add-ons/accelerants/common/i2c.c
===================================================================
--- haiku/trunk/src/add-ons/accelerants/common/i2c.c 2008-06-01 15:27:00 UTC (rev 25748)
+++ haiku/trunk/src/add-ons/accelerants/common/i2c.c 2008-06-01 16:16:10 UTC (rev 25749)
@@ -12,11 +12,14 @@
#include
#include
+#include
-
//#define TRACE_I2C
#ifdef TRACE_I2C
-extern "C" void _sPrintf(const char *format, ...);
+#ifdef __cplusplus
+extern "C"
+#endif
+void _sPrintf(const char *format, ...);
# define TRACE(x...) _sPrintf("I2C: " x)
#else
# define TRACE(x...) ;
@@ -25,45 +28,45 @@
//! Timining for 100kHz bus (fractional parts are rounded up)
const static i2c_timing kTiming100k = {
- buf : 5,
- hd_sta : 4,
- low : 5,
- high : 4,
- su_sta : 5,
- hd_dat : 0,
- su_dat : 1,
- r : 1,
- f : 1,
- su_sto : 4,
+ .buf = 5,
+ .hd_sta = 4,
+ .low = 5,
+ .high = 4,
+ .su_sta = 5,
+ .hd_dat = 0,
+ .su_dat = 1,
+ .r = 1,
+ .f = 1,
+ .su_sto = 4,
// as these are unspecified, we use half a clock cycle as a safe guess
- start_timeout : 5,
- byte_timeout : 5,
- bit_timeout : 5,
- ack_start_timeout : 5,
- ack_timeout : 5
+ .start_timeout = 5,
+ .byte_timeout = 5,
+ .bit_timeout = 5,
+ .ack_start_timeout = 5,
+ .ack_timeout = 5
};
// timing for 400 kHz bus
// (argh! heavy up-rounding here)
const static i2c_timing kTiming400k = {
- buf : 2,
- hd_sta : 1,
- low : 2,
- high : 1,
- su_sta : 1,
- hd_dat : 0,
- su_dat : 1,
- r : 1,
- f : 1,
- su_sto : 1,
+ .buf = 2,
+ .hd_sta = 1,
+ .low = 2,
+ .high = 1,
+ .su_sta = 1,
+ .hd_dat = 0,
+ .su_dat = 1,
+ .r = 1,
+ .f = 1,
+ .su_sto = 1,
// see kTiming100k
- start_timeout : 2,
- byte_timeout : 2,
- bit_timeout : 2,
- ack_start_timeout : 2,
- ack_timeout : 2
+ .start_timeout = 2,
+ .byte_timeout = 2,
+ .bit_timeout = 2,
+ .ack_start_timeout = 2,
+ .ack_timeout = 2
};
@@ -215,7 +218,8 @@
break;
if (system_time() - startTime > bus->timing.ack_timeout) {
- TRACE("send_acknowledge(): Slave didn't acknowledge byte\n");
+ TRACE("send_acknowledge(): Slave didn't acknowledge byte within ack_timeout: %ld\n",
+ bus->timing.ack_timeout);
return B_TIMEOUT;
}
@@ -372,7 +376,7 @@
static status_t
receive_bytes(const i2c_bus *bus, uint8 *readBuffer, ssize_t readLength)
{
- TRACE("receive_bytes(length = %ld)\n", writeLength);
+ TRACE("receive_bytes(length = %ld)\n", readLength);
for (; readLength > 0; --readLength, ++readBuffer) {
status_t status = receive_byte(bus, readBuffer, readLength > 1);
@@ -428,12 +432,12 @@
void
i2c_get100k_timing(i2c_timing *timing)
{
- *timing = kTiming100k;
+ memcpy(timing, &kTiming100k, sizeof(i2c_timing));
}
void
i2c_get400k_timing(i2c_timing *timing)
{
- *timing = kTiming400k;
+ memcpy(timing, &kTiming400k, sizeof(i2c_timing));
}
From axeld at mail.berlios.de Sun Jun 1 20:47:20 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Sun, 1 Jun 2008 20:47:20 +0200
Subject: [Haiku-commits] r25750 - haiku/trunk/src/system/kernel/fs
Message-ID: <200806011847.m51IlJ1h004034@sheep.berlios.de>
Author: axeld
Date: 2008-06-01 20:47:18 +0200 (Sun, 01 Jun 2008)
New Revision: 25750
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25750&view=rev
Modified:
haiku/trunk/src/system/kernel/fs/vfs.cpp
Log:
* Fixed an endless loop when using vfs_get_vnode_name() or the "wrong"
get_vnode_name() variant.
Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-06-01 16:16:10 UTC (rev 25749)
+++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-06-01 18:47:18 UTC (rev 25750)
@@ -2256,7 +2256,7 @@
char buffer[sizeof(struct dirent) + B_FILE_NAME_LENGTH];
struct dirent *dirent = (struct dirent *)buffer;
- status_t status = get_vnode_name(vnode, parent, buffer, sizeof(buffer),
+ status_t status = get_vnode_name(vnode, parent, dirent, sizeof(buffer),
get_current_io_context(kernel));
if (status != B_OK)
return status;
From stippi at mail.berlios.de Sun Jun 1 23:18:08 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Sun, 1 Jun 2008 23:18:08 +0200
Subject: [Haiku-commits] r25751 - haiku/trunk/build/jam
Message-ID: <200806012118.m51LI8rc014485@sheep.berlios.de>
Author: stippi
Date: 2008-06-01 23:18:08 +0200 (Sun, 01 Jun 2008)
New Revision: 25751
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25751&view=rev
Modified:
haiku/trunk/build/jam/OptionalPackages
Log:
Fix the link target for Beam. Note that the R5 version cannot retrieve mails
either, it just hangs there trying ot connect and eventually times out.
Modified: haiku/trunk/build/jam/OptionalPackages
===================================================================
--- haiku/trunk/build/jam/OptionalPackages 2008-06-01 18:47:18 UTC (rev 25750)
+++ haiku/trunk/build/jam/OptionalPackages 2008-06-01 21:18:08 UTC (rev 25751)
@@ -79,7 +79,8 @@
: apps
;
AddSymlinkToHaikuImage home config be Applications
- : /boot/apps/beam-1-1-bone-with-libs/Beam ;
+# : /boot/apps/beam-1-1-2-bone-with-libs/Beam ;
+ : /boot/apps/beam-1-1-2-r5-with-libs/Beam ;
}
}
From superstippi at gmx.de Sun Jun 1 23:28:17 2008
From: superstippi at gmx.de (Stephan Assmus)
Date: Sun, 01 Jun 2008 23:28:17 +0200
Subject: [Haiku-commits] r25704 - in haiku/trunk: headers/private/kernel
src/system/kernel
In-Reply-To: <200805291428.m4TESWbm013921@sheep.berlios.de>
References: <200805291428.m4TESWbm013921@sheep.berlios.de>
Message-ID: <20080601232817.3675.1@stippis2.1212350472.fake>
bonefish at BerliOS wrote:
> Author: bonefish
> Date: 2008-05-29 16:28:31 +0200 (Thu, 29 May 2008) New Revision: 25704
> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25704&view=rev
>
> Modified:
> haiku/trunk/headers/private/kernel/thread_types.h
> haiku/trunk/src/system/kernel/scheduler.cpp
> haiku/trunk/src/system/kernel/thread.cpp
> Log:
> Added new kernel thread "undertaker" which gets rid of dead thread
> remains. This replaces the previous mechanism of switching the thread to
> a dedicated death stack. We might consider moving more cleanup work to
> the undertaker, but that seems a little more involved.
This change seems ot exhibit some problems. Crashed or killed teams remain
in the kernel for much longer, it appears. I have one crashed app which
just sits there: I have just booted Haiku r25750 and saw the "black
interface in some apps" bug again with LaunchBox. Eventually I killed it,
but the pad window stayed on the screen. The LaunchBox team was gone. Just
when I examined this with ProcessController, the window suddenly
disappeared. Later I started Beam to check out whether the R5 version can
download mails, but unfortunately not. When I closed it, it crashed in some
liblayout stuff with corrupt memory (an allocator assert was triggered).
But after I quit the gdb, the Jobs window remained on screen. "Beam" is
still part of the kernel team now even after several minutes. Hope this
info is somehow useful.
Best regards,
-Stephan
From bonefish at mail.berlios.de Mon Jun 2 04:04:18 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Mon, 2 Jun 2008 04:04:18 +0200
Subject: [Haiku-commits] r25752 - in haiku/trunk: headers/os/drivers
headers/private/kernel headers/private/system
src/add-ons/kernel/bus_managers/ide
src/add-ons/kernel/bus_managers/pci/arch/x86
src/add-ons/kernel/bus_managers/ps2
src/add-ons/kernel/bus_managers/scsi
src/add-ons/kernel/busses/scsi/ahci src/add-ons/kernel/busses/usb
src/add-ons/kernel/drivers/audio/ac97/auich
src/add-ons/kernel/drivers/audio/ac97/auvia
src/add-ons/kernel/drivers/audio/emuxki
src/add-ons/kernel/drivers/graphics/radeon
src/add-ons/kernel/drivers/network/rtl8169
src/add-ons/kernel/generic/dpc src/add-ons/kernel/generic/mpu401
src/libs/compat/freebsd_network src/system/kernel
src/system/kernel/arch/m68k src/system/kernel/arch/x86
src/system/kernel/debug
Message-ID: <200806020204.m5224IeL027525@sheep.berlios.de>
Author: bonefish
Date: 2008-06-02 04:04:12 +0200 (Mon, 02 Jun 2008)
New Revision: 25752
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25752&view=rev
Added:
haiku/trunk/headers/private/system/spinlock_contention.h
Modified:
haiku/trunk/headers/os/drivers/KernelExport.h
haiku/trunk/headers/private/kernel/smp.h
haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.c
haiku/trunk/src/add-ons/kernel/bus_managers/pci/arch/x86/pci_controller.c
haiku/trunk/src/add-ons/kernel/bus_managers/ps2/packet_buffer.cpp
haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi_lock.h
haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp
haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp
haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp
haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c
haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/util.c
haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/util.c
haiku/trunk/src/add-ons/kernel/drivers/graphics/radeon/irq.c
haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c
haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/timer.c
haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c
haiku/trunk/src/add-ons/kernel/generic/mpu401/mpu401.c
haiku/trunk/src/libs/compat/freebsd_network/taskqueue.c
haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp
haiku/trunk/src/system/kernel/arch/x86/arch_debug_console.c
haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp
haiku/trunk/src/system/kernel/debug/debug.cpp
haiku/trunk/src/system/kernel/debug/debug_commands.cpp
haiku/trunk/src/system/kernel/debug/user_debugger.cpp
haiku/trunk/src/system/kernel/int.c
haiku/trunk/src/system/kernel/main.cpp
haiku/trunk/src/system/kernel/port.cpp
haiku/trunk/src/system/kernel/sem.cpp
haiku/trunk/src/system/kernel/smp.c
haiku/trunk/src/system/kernel/team.cpp
haiku/trunk/src/system/kernel/thread.cpp
Log:
* Added optional spinlock contention measurement feature. Enabled when
B_DEBUG_SPINLOCK_CONTENTION is defined to 1. It typedefs spinlock to a
structure (thus breaking BeOS binary compatibility), containing a
counter which is incremented whenever a thread has to wait for the
spinlock.
* Added macros for spinlock initialization and access and changed
code using spinlocks accordingly. This breaks compilation for BeOS --
the macros should be defined in the respective compatibility wrappers.
* Added generic syscall to get the spinlock counters for the thread and
the team spinlocks.
Modified: haiku/trunk/headers/os/drivers/KernelExport.h
===================================================================
--- haiku/trunk/headers/os/drivers/KernelExport.h 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/headers/os/drivers/KernelExport.h 2008-06-02 02:04:12 UTC (rev 25752)
@@ -13,8 +13,33 @@
/* interrupts and spinlocks */
typedef ulong cpu_status;
-typedef vint32 spinlock;
+// WARNING: For Haiku debugging only! This changes the spinlock type in a
+// binary incompatible way!
+//#define B_DEBUG_SPINLOCK_CONTENTION 1
+
+#if B_DEBUG_SPINLOCK_CONTENTION
+ typedef struct {
+ vint32 lock;
+ vint32 count_low;
+ vint32 count_high;
+ } spinlock;
+
+# define B_SPINLOCK_INITIALIZER { 0, 0, 0 }
+# define B_INITIALIZE_SPINLOCK(spinlock) do { \
+ (spinlock)->lock = 0; \
+ (spinlock)->count_low = 0; \
+ (spinlock)->count_high = 0; \
+ } while (false)
+# define B_SPINLOCK_IS_LOCKED(spinlock) ((spinlock)->lock > 0)
+#else
+ typedef vint32 spinlock;
+
+# define B_SPINLOCK_INITIALIZER 0
+# define B_INITIALIZE_SPINLOCK(lock) do { *(lock) = 0; } while (false)
+# define B_SPINLOCK_IS_LOCKED(lock) (*(lock) > 0)
+#endif
+
/* interrupt handling support for device drivers */
typedef int32 (*interrupt_handler)(void *data);
Modified: haiku/trunk/headers/private/kernel/smp.h
===================================================================
--- haiku/trunk/headers/private/kernel/smp.h 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/headers/private/kernel/smp.h 2008-06-02 02:04:12 UTC (rev 25752)
@@ -40,6 +40,7 @@
status_t smp_init(struct kernel_args *args);
status_t smp_per_cpu_init(struct kernel_args *args, int32 cpu);
+status_t smp_init_post_generic_syscalls(void);
bool smp_trap_non_boot_cpus(int32 cpu);
void smp_wake_up_non_boot_cpus(void);
void smp_cpu_rendezvous(volatile uint32 *var, int current_cpu);
Added: haiku/trunk/headers/private/system/spinlock_contention.h
===================================================================
--- haiku/trunk/headers/private/system/spinlock_contention.h 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/headers/private/system/spinlock_contention.h 2008-06-02 02:04:12 UTC (rev 25752)
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _SYSTEM_SPINLOCK_CONTENTION_H
+#define _SYSTEM_SPINLOCK_CONTENTION_H
+
+#include
+
+
+#define SPINLOCK_CONTENTION "spinlock contention"
+#define GET_SPINLOCK_CONTENTION_INFO 0x01
+
+
+typedef struct spinlock_contention_info {
+ uint64 thread_spinlock_counter;
+ uint64 team_spinlock_counter;
+} spinlock_contention_info;
+
+
+#endif /* _SYSTEM_SPINLOCK_CONTENTION_H */
Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -521,7 +521,7 @@
memset(bus, 0, sizeof(*bus));
bus->node = node;
- bus->lock = 0;
+ B_INITIALIZE_SPINLOCK(&bus->lock);
bus->num_running_reqs = 0;
bus->active_qrequest = NULL;
bus->disconnected = false;
Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/arch/x86/pci_controller.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/pci/arch/x86/pci_controller.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/arch/x86/pci_controller.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -32,7 +32,7 @@
restore_interrupts(cpu_status); \
}
-spinlock sConfigLock = 0;
+spinlock sConfigLock = B_SPINLOCK_INITIALIZER;
static status_t
pci_mech1_read_config(void *cookie, uint8 bus, uint8 device, uint8 function,
Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ps2/packet_buffer.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/ps2/packet_buffer.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/ps2/packet_buffer.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -40,7 +40,7 @@
free(buffer);
return NULL;
}
- buffer->lock = 0;
+ B_INITIALIZE_SPINLOCK(&buffer->lock);
return buffer;
}
Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi_lock.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi_lock.h 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi_lock.h 2008-06-02 02:04:12 UTC (rev 25752)
@@ -29,7 +29,7 @@
static inline void
spinlock_irq_init(spinlock_irq *lock)
{
- lock->lock = 0;
+ B_INITIALIZE_SPINLOCK(&lock->lock);
}
static inline void
Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -30,7 +30,6 @@
, fIndex(index)
, fRegs(&controller->fRegs->port[index])
, fArea(-1)
- , fSpinlock(0)
, fCommandsActive(0)
, fRequestSem(-1)
, fResponseSem(-1)
@@ -42,6 +41,7 @@
, fResetPort(false)
, fError(false)
{
+ B_INITIALIZE_SPINLOCK(&fSpinlock);
fRequestSem = create_sem(1, "ahci request");
fResponseSem = create_sem(0, "ahci response");
}
Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -782,7 +782,7 @@
int32
EHCI::Interrupt()
{
- static spinlock lock = 0;
+ static spinlock lock = B_SPINLOCK_INITIALIZER;
acquire_spinlock(&lock);
// check if any interrupt was generated
Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -694,7 +694,7 @@
int32
OHCI::_Interrupt()
{
- static spinlock lock = 0;
+ static spinlock lock = B_SPINLOCK_INITIALIZER;
acquire_spinlock(&lock);
uint32 status = 0;
Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -1531,7 +1531,7 @@
int32
UHCI::Interrupt()
{
- static spinlock lock = 0;
+ static spinlock lock = B_SPINLOCK_INITIALIZER;
acquire_spinlock(&lock);
// Check if we really had an interrupt
Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -34,7 +34,7 @@
#include "debug.h"
#include "util.h"
-spinlock slock = 0;
+spinlock slock = B_SPINLOCK_INITIALIZER;
uint32 round_to_pagesize(uint32 size);
Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/util.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/util.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/util.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -34,7 +34,7 @@
#include "debug.h"
#include "util.h"
-spinlock slock = 0;
+spinlock slock = B_SPINLOCK_INITIALIZER;
uint32 round_to_pagesize(uint32 size);
Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/util.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/util.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/util.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -34,7 +34,7 @@
#include "debug.h"
#include "util.h"
-spinlock slock = 0;
+spinlock slock = B_SPINLOCK_INITIALIZER;
uint32 round_to_pagesize(uint32 size);
Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/radeon/irq.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/graphics/radeon/irq.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/drivers/graphics/radeon/irq.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -237,7 +237,7 @@
goto err3;
}
- di->cap_spinlock = 0;
+ B_INITIALIZE_SPINLOCK(&di->cap_spinlock);
sprintf(buffer, "%04X_%04X_%02X%02X%02X DMA I",
di->pcii.vendor_id, di->pcii.device_id,
Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -467,7 +467,7 @@
read_settings(device);
device->rxBuf = (void **)malloc(sizeof(void *) * device->rxBufferCount);
- device->rxSpinlock = 0;
+ B_INITIALIZE_SPINLOCK(&device->rxSpinlock);
device->rxNextIndex = 0;
device->rxIntIndex = 0;
device->rxFree = device->rxBufferCount;
@@ -475,7 +475,7 @@
set_sem_owner(device->rxReadySem, B_SYSTEM_TEAM);
device->txBuf = (void **)malloc(sizeof(void *) * device->txBufferCount);
- device->txSpinlock = 0;
+ B_INITIALIZE_SPINLOCK(&device->txSpinlock);
device->txNextIndex = 0;
device->txIntIndex = 0;
device->txUsed = 0;
Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/timer.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/timer.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/timer.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -187,7 +187,7 @@
{
sTimerCount = 0;
sTimerNextId = 1;
- sTimerSpinlock = 0;
+ B_INITIALIZE_SPINLOCK(&sTimerSpinlock);
sTimerThread = spawn_kernel_thread(timer_thread, "rtl8169 timer", 80, 0);
sTimerSem = create_sem(0, "rtl8169 timer");
Modified: haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -91,7 +91,7 @@
queue->head = queue->tail = 0;
queue->size = DPC_QUEUE_SIZE;
queue->count = 0;
- queue->lock = 0; // Init the spinlock
+ B_INITIALIZE_SPINLOCK(&queue->lock); // Init the spinlock
#ifdef __HAIKU__
snprintf(str, sizeof(str), "%.*s_wakeup_sem",
Modified: haiku/trunk/src/add-ons/kernel/generic/mpu401/mpu401.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/generic/mpu401/mpu401.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/add-ons/kernel/generic/mpu401/mpu401.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -480,7 +480,7 @@
NULL
};
-spinlock locked = 0;
+spinlock locked = B_SPINLOCK_INITIALIZER;
cpu_status
lock(void)
{
Modified: haiku/trunk/src/libs/compat/freebsd_network/taskqueue.c
===================================================================
--- haiku/trunk/src/libs/compat/freebsd_network/taskqueue.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/libs/compat/freebsd_network/taskqueue.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -20,7 +20,7 @@
taskqueue_enqueue_fn tq_enqueue;
void *tq_arg;
int tq_fast;
- int32 tq_spinlock;
+ spinlock tq_spinlock;
sem_id tq_sem;
thread_id *tq_threads;
thread_id tq_thread_storage;
@@ -43,7 +43,7 @@
tq->tq_fast = fast;
if (fast) {
- tq->tq_spinlock = 0;
+ B_INITIALIZE_SPINLOCK(&tq->tq_spinlock);
} else {
mutex_init_etc(&tq->tq_mutex, name, MUTEX_FLAG_CLONE_NAME);
}
Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp
===================================================================
--- haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -1180,7 +1180,7 @@
sQueryDesc.type = DT_INVALID;
- tmap_list_lock = 0;
+ B_INITIALIZE_SPINLOCK(&tmap_list_lock);
tmap_list = NULL;
// allocate some space to hold physical page mapping info
Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug_console.c
===================================================================
--- haiku/trunk/src/system/kernel/arch/x86/arch_debug_console.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/arch/x86/arch_debug_console.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -99,7 +99,7 @@
static bool sBochsOutput = false;
#endif
-static spinlock sSerialOutputSpinlock = 0;
+static spinlock sSerialOutputSpinlock = B_SPINLOCK_INITIALIZER;
static void
Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp
===================================================================
--- haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -852,7 +852,7 @@
sKernelPhysicalPageDirectory = (page_directory_entry *)args->arch_args.phys_pgdir;
sKernelVirtualPageDirectory = (page_directory_entry *)args->arch_args.vir_pgdir;
- tmap_list_lock = 0;
+ B_INITIALIZE_SPINLOCK(&tmap_list_lock);
tmap_list = NULL;
// allocate some space to hold physical page mapping info
Modified: haiku/trunk/src/system/kernel/debug/debug.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/debug.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/debug/debug.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -54,7 +54,7 @@
// must always be false on startup
static bool sDebugScreenEnabled = false;
static bool sBlueScreenOutput = true;
-static spinlock sSpinlock = 0;
+static spinlock sSpinlock = B_SPINLOCK_INITIALIZER;
static int32 sDebuggerOnCPU = -1;
static sem_id sSyslogNotify = -1;
Modified: haiku/trunk/src/system/kernel/debug/debug_commands.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/debug_commands.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/debug/debug_commands.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -30,7 +30,7 @@
static const int32 kMaxInvokeCommandDepth = 5;
static const int32 kOutputBufferSize = 1024;
-static spinlock sSpinlock = 0;
+static spinlock sSpinlock = B_SPINLOCK_INITIALIZER;
static struct debugger_command *sCommands;
Modified: haiku/trunk/src/system/kernel/debug/user_debugger.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -219,7 +219,7 @@
info->debugger_write_lock = -1;
if (initLock)
- info->lock = 0;
+ B_INITIALIZE_SPINLOCK(&info->lock);
}
}
Modified: haiku/trunk/src/system/kernel/int.c
===================================================================
--- haiku/trunk/src/system/kernel/int.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/int.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -62,7 +62,7 @@
for (i = 0; i < NUM_IO_VECTORS; i++) {
struct io_handler *io;
- if (sVectors[i].vector_lock == 0
+ if (!B_SPINLOCK_IS_LOCKED(&sVectors[i].vector_lock)
&& sVectors[i].enable_count == 0
&& sVectors[i].handled_count == 0
&& sVectors[i].unhandled_count == 0
@@ -72,7 +72,7 @@
kprintf("int %3d, enabled %ld, handled %8lld, unhandled %8lld%s%s\n",
i, sVectors[i].enable_count, sVectors[i].handled_count,
sVectors[i].unhandled_count,
- sVectors[i].vector_lock != 0 ? ", ACTIVE" : "",
+ B_SPINLOCK_IS_LOCKED(&sVectors[i].vector_lock) ? ", ACTIVE" : "",
sVectors[i].handler_list.next == &sVectors[i].handler_list
? ", no handler" : "");
@@ -114,7 +114,7 @@
/* initialize the vector list */
for (i = 0; i < NUM_IO_VECTORS; i++) {
- sVectors[i].vector_lock = 0; /* initialize spinlock */
+ B_INITIALIZE_SPINLOCK(&sVectors[i].vector_lock);
sVectors[i].enable_count = 0;
sVectors[i].no_lock_vector = false;
#ifdef DEBUG_INT
Modified: haiku/trunk/src/system/kernel/main.cpp
===================================================================
--- haiku/trunk/src/system/kernel/main.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/main.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -160,6 +160,7 @@
driver_settings_init_post_sem(&sKernelArgs);
TRACE("init generic syscall\n");
generic_syscall_init();
+ smp_init_post_generic_syscalls();
TRACE("init cbuf\n");
cbuf_init();
TRACE("init teams\n");
Modified: haiku/trunk/src/system/kernel/port.cpp
===================================================================
--- haiku/trunk/src/system/kernel/port.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/port.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -72,7 +72,7 @@
static port_id sNextPort = 1;
static int32 sFirstFreeSlot = 1;
-static spinlock sPortSpinlock = 0;
+static spinlock sPortSpinlock = B_SPINLOCK_INITIALIZER;
#define GRAB_PORT_LIST_LOCK() acquire_spinlock(&sPortSpinlock)
#define RELEASE_PORT_LIST_LOCK() release_spinlock(&sPortSpinlock)
Modified: haiku/trunk/src/system/kernel/sem.cpp
===================================================================
--- haiku/trunk/src/system/kernel/sem.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/sem.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -108,7 +108,7 @@
static struct sem_entry *sFreeSemsHead = NULL;
static struct sem_entry *sFreeSemsTail = NULL;
-static spinlock sem_spinlock = 0;
+static spinlock sem_spinlock = B_SPINLOCK_INITIALIZER;
#define GRAB_SEM_LIST_LOCK() acquire_spinlock(&sem_spinlock)
#define RELEASE_SEM_LIST_LOCK() release_spinlock(&sem_spinlock)
#define GRAB_SEM_LOCK(s) acquire_spinlock(&(s).lock)
Modified: haiku/trunk/src/system/kernel/smp.c
===================================================================
--- haiku/trunk/src/system/kernel/smp.c 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/smp.c 2008-06-02 02:04:12 UTC (rev 25752)
@@ -8,18 +8,22 @@
/* Functionality for symetrical multi-processors */
-#include
-#include
#include
-#include
-#include
-#include
-#include
-#include
#include
#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
#define DEBUG_SPINLOCKS 1
//#define TRACE_SMP
@@ -53,17 +57,17 @@
#define MAILBOX_LOCAL 1
#define MAILBOX_BCAST 2
-static spinlock boot_cpu_spin[SMP_MAX_CPUS] = { 0, };
+static spinlock boot_cpu_spin[SMP_MAX_CPUS] = { };
static struct smp_msg *free_msgs = NULL;
static volatile int free_msg_count = 0;
-static spinlock free_msg_spinlock = 0;
+static spinlock free_msg_spinlock = B_SPINLOCK_INITIALIZER;
static struct smp_msg *smp_msgs[SMP_MAX_CPUS] = { NULL, };
-static spinlock cpu_msg_spinlock[SMP_MAX_CPUS] = { 0, };
+static spinlock cpu_msg_spinlock[SMP_MAX_CPUS];
static struct smp_msg *smp_broadcast_msgs = NULL;
-static spinlock broadcast_msg_spinlock = 0;
+static spinlock broadcast_msg_spinlock = B_SPINLOCK_INITIALIZER;
static bool sICIEnabled = false;
static int32 sNumCPUs = 1;
@@ -115,6 +119,10 @@
int currentCPU = smp_get_current_cpu();
if (are_interrupts_enabled())
panic("acquire_spinlock: attempt to acquire lock %p with interrupts enabled\n", lock);
+#if B_DEBUG_SPINLOCK_CONTENTION
+ while (atomic_add(&lock->lock, 1) != 0)
+ process_pending_ici(currentCPU);
+#else
while (1) {
while (*lock != 0) {
process_pending_ici(currentCPU);
@@ -123,6 +131,7 @@
if (atomic_set((int32 *)lock, 1) == 0)
break;
}
+#endif
} else {
#if DEBUG_SPINLOCKS
int32 oldValue;
@@ -148,12 +157,17 @@
if (are_interrupts_enabled())
panic("acquire_spinlock_nocheck: attempt to acquire lock %p with interrupts enabled\n", lock);
#endif
+#if B_DEBUG_SPINLOCK_CONTENTION
+ while (atomic_add(&lock->lock, 1) != 0) {
+ }
+#else
while (1) {
while(*lock != 0)
PAUSE();
if (atomic_set((int32 *)lock, 1) == 0)
break;
}
+#endif
} else {
#if DEBUG_SPINLOCKS
if (are_interrupts_enabled())
@@ -171,8 +185,23 @@
if (sNumCPUs > 1) {
if (are_interrupts_enabled())
panic("release_spinlock: attempt to release lock %p with interrupts enabled\n", lock);
+#if B_DEBUG_SPINLOCK_CONTENTION
+ {
+ int32 count = atomic_set(&lock->lock, 0) - 1;
+ if (count < 0) {
+ panic("release_spinlock: lock %p was already released\n", lock);
+ } else {
+ // add to the total count -- deal with carry manually
+ if ((uint32)atomic_add(&lock->count_low, count) + count
+ < (uint32)count) {
+ atomic_add(&lock->count_high, 1);
+ }
+ }
+ }
+#else
if (atomic_set((int32 *)lock, 0) != 1)
panic("release_spinlock: lock %p was already released\n", lock);
+#endif
} else {
#if DEBUG_SPINLOCKS
if (are_interrupts_enabled())
@@ -405,6 +434,48 @@
}
+#if B_DEBUG_SPINLOCK_CONTENTION
+
+static uint64
+get_spinlock_counter(spinlock* lock)
+{
+ uint32 high;
+ uint32 low;
+ do {
+ high = (uint32)atomic_get(&lock->count_high);
+ low = (uint32)atomic_get(&lock->count_low);
+ } while (high != atomic_get(&lock->count_high));
+
+ return ((uint64)high << 32) | low;
+}
+
+
+static status_t
+spinlock_contention_syscall(const char* subsystem, uint32 function,
+ void* buffer, size_t bufferSize)
+{
+ spinlock_contention_info info;
+
+ if (function != GET_SPINLOCK_CONTENTION_INFO)
+ return B_BAD_VALUE;
+
+ if (bufferSize < sizeof(spinlock_contention_info))
+ return B_BAD_VALUE;
+
+ info.thread_spinlock_counter = get_spinlock_counter(&thread_spinlock);
+ info.team_spinlock_counter = get_spinlock_counter(&team_spinlock);
+
+ if (!IS_USER_ADDRESS(buffer)
+ || user_memcpy(buffer, &info, sizeof(info)) != B_OK) {
+ return B_BAD_ADDRESS;
+ }
+
+ return B_OK;
+}
+
+#endif // B_DEBUG_SPINLOCK_CONTENTION
+
+
// #pragma mark -
@@ -553,7 +624,11 @@
smp_trap_non_boot_cpus(int32 cpu)
{
if (cpu > 0) {
+#if B_DEBUG_SPINLOCK_CONTENTION
+ boot_cpu_spin[cpu].lock = 1;
+#else
boot_cpu_spin[cpu] = 1;
+#endif
acquire_spinlock_nocheck(&boot_cpu_spin[cpu]);
return false;
}
@@ -624,6 +699,18 @@
}
+status_t
+smp_init_post_generic_syscalls(void)
+{
+#if B_DEBUG_SPINLOCK_CONTENTION
+ return register_generic_syscall(SPINLOCK_CONTENTION,
+ &spinlock_contention_syscall, 0, 0);
+#else
+ return B_OK;
+#endif
+}
+
+
void
smp_set_num_cpus(int32 numCPUs)
{
Modified: haiku/trunk/src/system/kernel/team.cpp
===================================================================
--- haiku/trunk/src/system/kernel/team.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/team.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -89,7 +89,7 @@
static int32 sMaxTeams = 2048;
static int32 sUsedTeams = 1;
-spinlock team_spinlock = 0;
+spinlock team_spinlock = B_SPINLOCK_INITIALIZER;
// #pragma mark - Tracing
Modified: haiku/trunk/src/system/kernel/thread.cpp
===================================================================
--- haiku/trunk/src/system/kernel/thread.cpp 2008-06-01 21:18:08 UTC (rev 25751)
+++ haiku/trunk/src/system/kernel/thread.cpp 2008-06-02 02:04:12 UTC (rev 25752)
@@ -60,7 +60,7 @@
};
// global
-spinlock thread_spinlock = 0;
+spinlock thread_spinlock = B_SPINLOCK_INITIALIZER;
// thread list
static struct thread sIdleThreads[B_MAX_CPU_COUNT];
From bonefish at mail.berlios.de Mon Jun 2 04:07:27 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Mon, 2 Jun 2008 04:07:27 +0200
Subject: [Haiku-commits] r25753 - haiku/trunk/src/tests/system/kernel
Message-ID: <200806020207.m5227Rhe027740@sheep.berlios.de>
Author: bonefish
Date: 2008-06-02 04:07:26 +0200 (Mon, 02 Jun 2008)
New Revision: 25753
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25753&view=rev
Added:
haiku/trunk/src/tests/system/kernel/spinlock_contention.cpp
Modified:
haiku/trunk/src/tests/system/kernel/Jamfile
Log:
Added test that runs another program and analyzes the contention of the
thread and team spinlocks during that time.
Modified: haiku/trunk/src/tests/system/kernel/Jamfile
===================================================================
--- haiku/trunk/src/tests/system/kernel/Jamfile 2008-06-02 02:04:12 UTC (rev 25752)
+++ haiku/trunk/src/tests/system/kernel/Jamfile 2008-06-02 02:07:26 UTC (rev 25753)
@@ -1,7 +1,6 @@
SubDir HAIKU_TOP src tests system kernel ;
-UsePrivateHeaders kernel ;
-UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ;
+UsePrivateKernelHeaders ;
SimpleTest advisory_locking_test : advisory_locking_test.cpp ;
@@ -36,6 +35,8 @@
SimpleTest sem_acquire_test1 : sem_acquire_test1.cpp : be ;
+SimpleTest spinlock_contention : spinlock_contention.cpp ;
+
SimpleTest syscall_restart_test : syscall_restart_test.cpp : network ;
SetSupportedPlatformsForTarget syscall_time
Added: haiku/trunk/src/tests/system/kernel/spinlock_contention.cpp
===================================================================
--- haiku/trunk/src/tests/system/kernel/spinlock_contention.cpp 2008-06-02 02:04:12 UTC (rev 25752)
+++ haiku/trunk/src/tests/system/kernel/spinlock_contention.cpp 2008-06-02 02:07:26 UTC (rev 25753)
@@ -0,0 +1,267 @@
+/*
+ * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+
+
+#define panic printf
+
+
+struct dummy_spinlock {
+ vint32 lock;
+ vint32 count_low;
+ vint32 count_high;
+};
+
+
+struct dummy_smp_msg {
+ dummy_smp_msg* next;
+};
+
+
+static int sNumCPUs = 2;
+static bool sICIEnabled = true;
+static dummy_spinlock cpu_msg_spinlock[B_MAX_CPU_COUNT];
+static dummy_smp_msg* smp_msgs[B_MAX_CPU_COUNT];
+static dummy_spinlock broadcast_msg_spinlock;
+static dummy_smp_msg* smp_broadcast_msgs;
+
+
+bool
+dummy_are_interrupts_enabled()
+{
+ return false;
+}
+
+
+void
+dummy_acquire_spinlock_nocheck(dummy_spinlock* lock)
+{
+ if (sNumCPUs > 1) {
+ if (dummy_are_interrupts_enabled())
+ panic("acquire_spinlock_nocheck: attempt to acquire lock %p with interrupts enabled\n", lock);
+
+ while (atomic_add(&lock->lock, 1) != 0) {
+ }
+ } else {
+ if (dummy_are_interrupts_enabled())
+ panic("acquire_spinlock_nocheck: attempt to acquire lock %p with interrupts enabled\n", lock);
+ if (atomic_set((int32 *)lock, 1) != 0)
+ panic("acquire_spinlock_nocheck: attempt to acquire lock %p twice on non-SMP system\n", lock);
+ }
+}
+
+
+void
+dummy_release_spinlock(dummy_spinlock* lock)
+{
+ if (sNumCPUs > 1) {
+ if (dummy_are_interrupts_enabled())
+ panic("release_spinlock: attempt to release lock %p with interrupts enabled\n", lock);
+
+ {
+ int32 count = atomic_set(&lock->lock, 0) - 1;
+ if (count < 0) {
+ panic("release_spinlock: lock %p was already released\n", lock);
+ } else {
+ // add to the total count -- deal with carry manually
+ if ((uint32)atomic_add(&lock->count_low, count) + count
+ < (uint32)count) {
+ atomic_add(&lock->count_high, 1);
+ }
+ }
+ }
+ } else {
+ if (dummy_are_interrupts_enabled())
+ panic("release_spinlock: attempt to release lock %p with interrupts enabled\n", lock);
+ if (atomic_set((int32 *)lock, 0) != 1)
+ panic("release_spinlock: lock %p was already released\n", lock);
+ }
+}
+
+
+struct dummy_smp_msg *
+dummy_check_for_message(int currentCPU, int *source_mailbox)
+{
+ struct dummy_smp_msg *msg;
+
+ if (!sICIEnabled)
+ return NULL;
+
+ dummy_acquire_spinlock_nocheck(&cpu_msg_spinlock[currentCPU]);
+ msg = smp_msgs[currentCPU];
+ if (msg != NULL) {
+ printf("yeah\n");
+ dummy_release_spinlock(&cpu_msg_spinlock[currentCPU]);
+ *source_mailbox = 1;
+ } else {
+ // try getting one from the broadcast mailbox
+
+ dummy_release_spinlock(&cpu_msg_spinlock[currentCPU]);
+ dummy_acquire_spinlock_nocheck(&broadcast_msg_spinlock);
+
+ msg = smp_broadcast_msgs;
+ while (msg != NULL) {
+ printf("yeah\n");
+ msg = msg->next;
+ }
+ dummy_release_spinlock(&broadcast_msg_spinlock);
+ }
+ return msg;
+}
+
+
+int32
+dummy_process_pending_ici(int32 currentCPU)
+{
+ int retval = 42;
+ int sourceMailbox = 0;
+
+ dummy_smp_msg* msg = dummy_check_for_message(currentCPU, &sourceMailbox);
+ if (msg == NULL)
+ return retval;
+
+ switch ((addr_t)msg) {
+ case 0:
+ printf("foo\n");
+ break;
+ case 1:
+ printf("foo\n");
+ break;
+ case 2:
+ printf("foo\n");
+ break;
+ }
+
+ return 9;
+}
+
+
+static void
+test_spinlock(dummy_spinlock* lock)
+{
+ while (atomic_add(&lock->lock, -1) != 0)
+ dummy_process_pending_ici(0);
+}
+
+
+static double
+estimate_spinlock_tick_time()
+{
+ // time the spinlock
+ int32 count = (INT_MAX >> 16) + 1;
+ while (true) {
+ bigtime_t startTime = system_time();
+
+ dummy_spinlock lock;
+ lock.lock = count;
+ test_spinlock(&lock);
+
+ bigtime_t totalTime = system_time() - startTime;
+ double tickTime = (double)totalTime / count;
+
+ if (totalTime > 1000000 || INT_MAX >> 2 < count)
+ return tickTime;
+
+ count <<= 1;
+ }
+}
+
+
+static const char*
+time_string(double timeInUsecs, char* buffer)
+{
+ static const char* const kUnits[] = { "us", "ms", "s ", NULL };
+
+ double time = timeInUsecs;
+
+ int32 i = 0;
+ while (time > 1000 && kUnits[i + 1] != NULL) {
+ time /= 1000;
+ i++;
+ }
+
+ sprintf(buffer, "%.3f %s", time, kUnits[i]);
+
+ return buffer;
+}
+
+
+int
+main(int argc, char** argv)
+{
+ // get the initial contention info
+ spinlock_contention_info startInfo;
+ status_t error = _kern_generic_syscall(SPINLOCK_CONTENTION,
+ GET_SPINLOCK_CONTENTION_INFO, &startInfo, sizeof(startInfo));
+ if (error != B_OK) {
+ fprintf(stderr, "Error: Failed to get spinlock contention info: %s\n",
+ strerror(error));
+ exit(1);
+ }
+ bigtime_t startTime = system_time();
+
+ pid_t child = fork();
+ if (child < 0) {
+ fprintf(stderr, "Error: fork() failed: %s\n", strerror(errno));
+ exit(1);
+ }
+
+ if (child == 0) {
+ execvp(argv[1], argv + 1);
+ fprintf(stderr, "Error: exec() failed: %s\n", strerror(errno));
+ exit(1);
+ } else {
+ int status;
+ wait(&status);
+ }
+
+ // get the final contention info
+ spinlock_contention_info endInfo;
+ error = _kern_generic_syscall(SPINLOCK_CONTENTION,
+ GET_SPINLOCK_CONTENTION_INFO, &endInfo, sizeof(endInfo));
+ if (error != B_OK) {
+ fprintf(stderr, "Error: Failed to get spinlock contention info: %s\n",
+ strerror(error));
+ exit(1);
+ }
+ bigtime_t totalTime = system_time() - startTime;
+
+ char buffer[128];
+ printf("\ntotal run time: %s\n", time_string(totalTime, buffer));
+
+ // estimate spinlock tick time
+ printf("estimating time per spinlock tick...\n");
+ double tickTime = estimate_spinlock_tick_time();
+ printf("time per spinlock tick: %s\n",
+ time_string(tickTime, buffer));
+
+ // print results
+ static const char* const kLockNames[] = { "thread", "team", NULL };
+ uint64 lockCounts[] = {
+ endInfo.thread_spinlock_counter - startInfo.thread_spinlock_counter,
+ endInfo.team_spinlock_counter - startInfo.team_spinlock_counter
+ };
+
+ printf("\nlock counter time wasted %% CPU\n");
+ printf("-------------------------------------------------------\n");
+ for (int32 i = 0; kLockNames[i] != NULL; i++) {
+ double wastedUsecs = lockCounts[i] * tickTime;
+ printf("%-10s %12llu %14s %12.4f\n", kLockNames[i], lockCounts[i],
+ time_string(wastedUsecs, buffer), wastedUsecs / totalTime * 100);
+ }
+
+ return 0;
+}
From bonefish at mail.berlios.de Mon Jun 2 06:34:15 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Mon, 2 Jun 2008 06:34:15 +0200
Subject: [Haiku-commits] r25754 - haiku/trunk/src/system/kernel
Message-ID: <200806020434.m524YFGg007153@sheep.berlios.de>
Author: bonefish
Date: 2008-06-02 06:34:09 +0200 (Mon, 02 Jun 2008)
New Revision: 25754
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25754&view=rev
Modified:
haiku/trunk/src/system/kernel/thread.cpp
Log:
Before starting to wait the undertaker does now check whether there's
already a dead thread available. Fixes a race condition.
Modified: haiku/trunk/src/system/kernel/thread.cpp
===================================================================
--- haiku/trunk/src/system/kernel/thread.cpp 2008-06-02 02:07:26 UTC (rev 25753)
+++ haiku/trunk/src/system/kernel/thread.cpp 2008-06-02 04:34:09 UTC (rev 25754)
@@ -540,21 +540,21 @@
{
while (true) {
// wait for a thread to bury
- ConditionVariableEntry conditionEntry;
-
InterruptsSpinLocker locker(thread_spinlock);
- sUndertakerCondition.Add(&conditionEntry);
- locker.Unlock();
- conditionEntry.Wait();
+ while (sUndertakerEntries.IsEmpty()) {
+ ConditionVariableEntry conditionEntry;
+ sUndertakerCondition.Add(&conditionEntry);
+ locker.Unlock();
- locker.Lock();
+ conditionEntry.Wait();
+
+ locker.Lock();
+ }
+
UndertakerEntry* _entry = sUndertakerEntries.RemoveHead();
locker.Unlock();
- if (_entry == NULL)
- continue;
-
UndertakerEntry entry = *_entry;
// we need a copy, since the original entry is on the thread's stack
From axeld at mail.berlios.de Mon Jun 2 12:38:01 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Mon, 2 Jun 2008 12:38:01 +0200
Subject: [Haiku-commits] r25755 - in haiku/trunk: build/jam
src/add-ons/kernel/busses/ide/generic_ide_pci
src/add-ons/kernel/busses/ide/ide_isa
Message-ID: <200806021038.m52Ac1MM008059@sheep.berlios.de>
Author: axeld
Date: 2008-06-02 12:37:58 +0200 (Mon, 02 Jun 2008)
New Revision: 25755
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25755&view=rev
Removed:
haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/wrapper.h
haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/wrapper.h
Modified:
haiku/trunk/build/jam/HaikuImage
haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/generic_ide_pci.c
haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c
Log:
* Ported ide_isa module to the new driver architecture.
* Minor cleanup of ide_isa, and generic_ide_pci (removed wrapper.h).
* Added ide_isa back to the image.
Modified: haiku/trunk/build/jam/HaikuImage
===================================================================
--- haiku/trunk/build/jam/HaikuImage 2008-06-02 04:34:09 UTC (rev 25754)
+++ haiku/trunk/build/jam/HaikuImage 2008-06-02 10:37:58 UTC (rev 25755)
@@ -145,7 +145,7 @@
AddFilesToHaikuImage beos system add-ons kernel busses agp_gart
: $(X86_ONLY)intel ;
AddFilesToHaikuImage beos system add-ons kernel busses ide
- : generic_ide_pci silicon_image_3112 legacy_sata ; #$(X86_ONLY)ide_isa ;
+ : generic_ide_pci silicon_image_3112 legacy_sata $(X86_ONLY)ide_isa ;
AddFilesToHaikuImage beos system add-ons kernel busses scsi
: ahci ;
AddFilesToHaikuImage beos system add-ons kernel busses usb
@@ -359,7 +359,7 @@
pci $(X86_ONLY)isa config_manager ide scsi
$(PPC_ONLY)openpic
block_io ide_adapter locked_pool scsi_periph
- generic_ide_pci ahci legacy_sata silicon_image_3112 # $(X86_ONLY)ide_isa
+ generic_ide_pci ahci legacy_sata silicon_image_3112 $(X86_ONLY)ide_isa
scsi_cd scsi_disk
intel
bfs
Modified: haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/generic_ide_pci.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/generic_ide_pci.c 2008-06-02 04:34:09 UTC (rev 25754)
+++ haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/generic_ide_pci.c 2008-06-02 10:37:58 UTC (rev 25755)
@@ -3,26 +3,14 @@
* Distributed under the terms of the MIT License.
*/
-/*
- Generic IDE PCI controller driver
+/*! Generic PCI bus mastering IDE driver. */
- Generic PCI bus mastering IDE driver.
-*/
-
#include
#include
#include
#include
-#define debug_level_flow 0
-#define debug_level_error 3
-#define debug_level_info 3
-
-#define DEBUG_MSG_PREFIX "GENERIC IDE PCI -- "
-
-#include "wrapper.h"
-
#define GENERIC_IDE_PCI_CONTROLLER_MODULE_NAME "busses/ide/generic_ide_pci/driver_v1"
#define GENERIC_IDE_PCI_CHANNEL_MODULE_NAME "busses/ide/generic_ide_pci/channel/v1"
@@ -186,20 +174,6 @@
}
-static status_t
-module_std_ops(int32 op, ...)
-{
- switch (op) {
- case B_MODULE_INIT:
- case B_MODULE_UNINIT:
- return B_OK;
-
- default:
- return B_ERROR;
- }
-}
-
-
module_dependency module_dependencies[] = {
{ IDE_FOR_CONTROLLER_MODULE_NAME, (module_info **)&ide },
{ B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&pnp },
@@ -214,12 +188,12 @@
{
GENERIC_IDE_PCI_CHANNEL_MODULE_NAME,
0,
- module_std_ops
+ NULL
},
NULL, // supports device
NULL, // register device
- (status_t (*)(device_node *, void **))init_channel,
+ init_channel,
uninit_channel,
NULL, // register child devices
NULL, // rescan
@@ -247,7 +221,7 @@
{
GENERIC_IDE_PCI_CONTROLLER_MODULE_NAME,
0,
- module_std_ops
+ NULL
},
supports_device,
Deleted: haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/wrapper.h
Modified: haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c 2008-06-02 04:34:09 UTC (rev 25754)
+++ haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c 2008-06-02 10:37:58 UTC (rev 25755)
@@ -22,18 +22,17 @@
#include
#include
-#define debug_level_flow 0
-#define debug_level_error 1
-#define debug_level_info 2
-#define DEBUG_MSG_PREFIX "IDE ISA -- "
-#define TRACE dprintf
+//#define TRACE_IDE_ISA
+#ifdef TRACE_IDE_ISA
+# define TRACE(x...) dprintf("ide_isa: " x)
+#else
+# define TRACE(x...) ;
+#endif
-#include "wrapper.h"
+#define IDE_ISA_MODULE_NAME "busses/ide/ide_isa/driver_v1"
-#define IDE_ISA_MODULE_NAME "busses/ide/ide_isa/device_v1"
-
// private node item:
// io address of command block
#define IDE_ISA_COMMAND_BLOCK_BASE "ide_isa/command_block_base"
@@ -42,7 +41,7 @@
// interrupt number
#define IDE_ISA_INTNUM "ide_isa/irq"
-//isa2_module_info *isa;
+
ide_for_controller_interface *ide;
device_manager_info *pnp;
@@ -52,44 +51,97 @@
isa2_module_info *isa;
uint16 command_block_base; // io address command block
uint16 control_block_base; // io address control block
- int intnum; // interrupt number
-
+ int intnum; // interrupt number
+
uint32 lost; // != 0 if device got removed, i.e. if it must not
// be accessed anymore
-
+
ide_channel ide_channel;
- device_node_handle node;
+ device_node *node;
} channel_info;
+/*! publish node of an ide channel */
static status_t
-write_command_block_regs(void *channel_cookie, ide_task_file *tf, ide_reg_mask mask)
+publish_channel(device_node *parent, uint16 command_block_base,
+ uint16 control_block_base, uint8 intnum, const char *name)
{
+ device_attr attrs[] = {
+ { B_DEVICE_FIXED_CHILD, B_STRING_TYPE, { string: IDE_FOR_CONTROLLER_MODULE_NAME }},
+
+ // properties of this controller for ide bus manager
+ { IDE_CONTROLLER_MAX_DEVICES_ITEM, B_UINT8_TYPE, { ui8: 2 }},
+ { IDE_CONTROLLER_CAN_DMA_ITEM, B_UINT8_TYPE, { ui8: 0 }},
+ { IDE_CONTROLLER_CAN_CQ_ITEM, B_UINT8_TYPE, { ui8: 1 }},
+ { IDE_CONTROLLER_CONTROLLER_NAME_ITEM, B_STRING_TYPE, { string: name }},
+
+ // DMA properties; the 16 bit alignment is not necessary as
+ // the ide bus manager handles that very efficiently, but why
+ // not use the block device manager for doing that?
+ { B_BLOCK_DEVICE_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: 1 }},
+
+ // private data to identify device
+ { IDE_ISA_COMMAND_BLOCK_BASE, B_UINT16_TYPE, { ui16: command_block_base }},
+ { IDE_ISA_CONTROL_BLOCK_BASE, B_UINT16_TYPE, { ui16: control_block_base }},
+ { IDE_ISA_INTNUM, B_UINT8_TYPE, { ui8: intnum }},
+ { NULL }
+ };
+ io_resource resources[3] = {
+ { B_IO_PORT, command_block_base, 8 },
+ { B_IO_PORT, control_block_base, 1 },
+ {}
+ };
+
+ TRACE("publishing %s, resources %#x %#x %d\n",
+ name, command_block_base, control_block_base, intnum);
+
+ return pnp->register_node(parent, IDE_ISA_MODULE_NAME, attrs, resources,
+ NULL);
+}
+
+
+// #pragma mark -
+
+
+static void
+set_channel(void *cookie, ide_channel ideChannel)
+{
+ channel_info *channel = cookie;
+ channel->ide_channel = ideChannel;
+}
+
+
+static status_t
+write_command_block_regs(void *channel_cookie, ide_task_file *tf,
+ ide_reg_mask mask)
+{
channel_info *channel = channel_cookie;
uint16 ioaddr = channel->command_block_base;
int i;
-
+
if (channel->lost)
return B_ERROR;
for (i = 0; i < 7; i++) {
if (((1 << (i-7)) & mask) != 0) {
- SHOW_FLOW(3, "%x->HI(%x)", tf->raw.r[i + 7], i);
+ TRACE("write_command_block_regs(): %x->HI(%x)\n",
+ tf->raw.r[i + 7], i);
channel->isa->write_io_8(ioaddr + 1 + i, tf->raw.r[i + 7]);
}
if (((1 << i) & mask) != 0 ) {
- SHOW_FLOW(3, "%x->LO(%x)", tf->raw.r[i], i);
+ TRACE("write_comamnd_block_regs(): %x->LO(%x)\n", tf->raw.r[i], i);
channel->isa->write_io_8(ioaddr + 1 + i, tf->raw.r[i]);
}
}
-
+
return B_OK;
}
static status_t
-read_command_block_regs(void *channel_cookie, ide_task_file *tf, ide_reg_mask mask)
+read_command_block_regs(void *channel_cookie, ide_task_file *tf,
+ ide_reg_mask mask)
{
channel_info *channel = channel_cookie;
uint16 ioaddr = channel->command_block_base;
@@ -101,10 +153,10 @@
for (i = 0; i < 7; i++) {
if (((1 << i) & mask) != 0) {
tf->raw.r[i] = channel->isa->read_io_8(ioaddr + 1 + i);
- SHOW_FLOW(3, "%x: %x", i, (int)tf->raw.r[i]);
+ TRACE("read_command_block_regs(%x): %x\n", i, (int)tf->raw.r[i]);
}
}
-
+
return B_OK;
}
@@ -128,7 +180,7 @@
channel_info *channel = channel_cookie;
uint16 device_control_addr = channel->control_block_base;
- SHOW_FLOW(3, "%x", (int)val);
+ TRACE("write_device_control(%x)\n", (int)val);
if (channel->lost)
return B_ERROR;
@@ -148,7 +200,7 @@
if (channel->lost)
return B_ERROR;
- // Bochs doesn't support 32 bit accesses;
+ // Bochs doesn't support 32 bit accesses;
// no real performance impact as this driver is for Bochs only anyway
force_16bit = true;
@@ -197,7 +249,7 @@
channel_info *channel = (channel_info *)arg;
uint8 status;
- SHOW_FLOW0(3, "");
+ TRACE("interrupt handler()\n");
if (channel->lost)
return B_UNHANDLED_INTERRUPT;
@@ -210,9 +262,8 @@
static status_t
-prepare_dma(void *channel_cookie,
- const physical_entry *sg_list, size_t sg_list_count,
- bool write)
+prepare_dma(void *channel_cookie, const physical_entry *sg_list,
+ size_t sg_list_count, bool write)
{
return B_NOT_ALLOWED;
}
@@ -232,53 +283,54 @@
}
+// #pragma mark -
+
+
static float
-supports_device(device_node_handle parent, bool *_noConnection)
+supports_device(device_node *parent)
{
- char *bus;
+ const char *bus;
// make sure parent is really the ISA bus manager
- if (pnp->get_attr_string(parent, B_DRIVER_BUS, &bus, false))
+ if (pnp->get_attr_string(parent, B_DEVICE_BUS, &bus, false))
return B_ERROR;
- if (strcmp(bus, "isa")) {
- free(bus);
+ if (strcmp(bus, "isa"))
return 0.0;
- }
- // ToDo: check I/O resources for availability?
+ // we assume that every modern PC has an IDE controller, so no
+ // further testing is done (well - I don't really know how to detect the
+ // controller, but who cares ;)
- free(bus);
return 0.6;
}
static status_t
-init_channel(device_node_handle node, ide_channel ide_channel, channel_info **cookie)
+init_channel(device_node *node, void **_cookie)
{
channel_info *channel;
+ device_node *parent;
isa2_module_info *isa;
- void *dummy;
uint16 command_block_base, control_block_base;
uint8 irq;
status_t res;
TRACE("ISA-IDE: channel init\n");
- // get device data
+ // get device data
if (pnp->get_attr_uint16(node, IDE_ISA_COMMAND_BLOCK_BASE, &command_block_base, false) != B_OK
|| pnp->get_attr_uint16(node, IDE_ISA_CONTROL_BLOCK_BASE, &control_block_base, false) != B_OK
|| pnp->get_attr_uint8(node, IDE_ISA_INTNUM, &irq, false) != B_OK)
return B_ERROR;
- if (pnp->init_driver(pnp->get_parent(node), NULL, (driver_module_info **)&isa, &dummy) != B_OK)
- return B_ERROR;
+ parent = pnp->get_parent_node(node);
+ pnp->get_driver(parent, (driver_module_info **)&isa, NULL);
+ pnp->put_node(parent);
channel = (channel_info *)malloc(sizeof(channel_info));
- if (channel == NULL) {
- res = B_NO_MEMORY;
- goto err0;
- }
+ if (channel == NULL)
+ return B_NO_MEMORY;
TRACE("ISA-IDE: channel init, resources %#x %#x %d\n",
command_block_base, control_block_base, irq);
@@ -289,9 +341,9 @@
channel->command_block_base = command_block_base;
channel->control_block_base = control_block_base;
channel->intnum = irq;
- channel->ide_channel = ide_channel;
+ channel->ide_channel = NULL;
- res = install_io_interrupt_handler(channel->intnum,
+ res = install_io_interrupt_handler(channel->intnum,
inthand, channel, 0);
if (res < 0) {
@@ -302,20 +354,16 @@
// enable interrupts so the channel is ready to run
write_device_control(channel, ide_devctrl_bit3);
- *cookie = channel;
-
+ *_cookie = channel;
return B_OK;
err:
free(channel);
-
-err0:
- pnp->uninit_driver(pnp->get_parent(node));
return res;
}
-static status_t
+static void
uninit_channel(void *channel_cookie)
{
channel_info *channel = channel_cookie;
@@ -329,142 +377,45 @@
// (some controllers generate an IRQ when you _disable_ interrupts,
// they are delayed by less then 40 ?s, so 1 ms is safe)
snooze(1000);
-
+
remove_io_interrupt_handler(channel->intnum, inthand, channel);
- pnp->uninit_driver(pnp->get_parent(channel->node));
-
free(channel);
-
- return B_OK;
}
-/** publish node of an ide channel */
-
static status_t
-publish_channel(device_node_handle parent, io_resource_handle *resources,
- uint16 command_block_base, uint16 control_block_base, uint8 intnum,
- const char *name)
+register_device(device_node *parent)
{
- device_attr attrs[] = {
- // info about ourself and our consumer
- { B_DRIVER_MODULE, B_STRING_TYPE, { string: IDE_ISA_MODULE_NAME }},
- { B_DRIVER_FIXED_CHILD, B_STRING_TYPE, { string: IDE_FOR_CONTROLLER_MODULE_NAME }},
- { PNP_DRIVER_CONNECTION, B_STRING_TYPE, { string: name }},
+ status_t primaryStatus;
+ status_t secondaryStatus;
+ TRACE("register_device()\n");
- // properties of this controller for ide bus manager
- { IDE_CONTROLLER_MAX_DEVICES_ITEM, B_UINT8_TYPE, { ui8: 2 }},
- { IDE_CONTROLLER_CAN_DMA_ITEM, B_UINT8_TYPE, { ui8: 0 }},
- { IDE_CONTROLLER_CAN_CQ_ITEM, B_UINT8_TYPE, { ui8: 1 }},
- { IDE_CONTROLLER_CONTROLLER_NAME_ITEM, B_STRING_TYPE, { string: name }},
-
- // DMA properties; the 16 bit alignment is not necessary as
- // the ide bus manager handles that very efficiently, but why
- // not use the block device manager for doing that?
- { B_BLOCK_DEVICE_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: 1 }},
-
- // private data to identify device
- { IDE_ISA_COMMAND_BLOCK_BASE, B_UINT16_TYPE, { ui16: command_block_base }},
- { IDE_ISA_CONTROL_BLOCK_BASE, B_UINT16_TYPE, { ui16: control_block_base }},
- { IDE_ISA_INTNUM, B_UINT8_TYPE, { ui8: intnum }},
- { NULL }
- };
- device_node_handle node;
-
- SHOW_FLOW0(2, "");
-
- TRACE("ISA-IDE: publishing %s, resources %#x %#x %d\n",
- name, command_block_base, control_block_base, intnum);
-
- return pnp->register_device(parent, attrs, resources, &node);
-}
-
-
-// detect IDE channel
-static status_t
-probe_channel(device_node_handle parent,
- uint16 command_block_base, uint16 control_block_base,
- int intnum, const char *name)
-{
- io_resource resources[3] = {
- { IO_PORT, command_block_base, 8 },
- { IO_PORT, control_block_base, 1 },
- {}
- };
- io_resource_handle resource_handles[3];
-
- SHOW_FLOW(3, "name = \"%s\"", name);
-
- // we aren't upset if io-ports are in use already - only
- // the PCI IDE driver can own them, and if it does, we exit silently
- if (pnp->acquire_io_resources(resources, resource_handles) != B_OK) {
- TRACE("ISA-IDE: can't acquire resources %#x and %#x\n",
- command_block_base, control_block_base);
- return B_OK;
- }
-
- // we assume that every modern PC has an IDE controller, so no
- // further testing is done (well - I don't really know how to detect the
- // controller, but who cares ;)
- return publish_channel(parent, resource_handles, command_block_base,
- control_block_base, intnum, name);
-}
-
-
-static status_t
-register_device(device_node_handle node)
-{
- SHOW_FLOW0(3, "");
-
// our parent device is the isa bus and all device drivers are Universal,
// so the pnp_manager tries each ISA driver in turn
- probe_channel(node, 0x1f0, 0x3f6, 14, "primary IDE channel");
- probe_channel(node, 0x170, 0x376, 15, "secondary IDE channel");
+ primaryStatus = publish_channel(parent, 0x1f0, 0x3f6, 14,
+ "primary IDE channel");
+ secondaryStatus = publish_channel(parent, 0x170, 0x376, 15,
+ "secondary IDE channel");
- return B_OK;
-}
+ if (primaryStatus == B_OK || secondaryStatus == B_OK)
+ return B_OK;
-
-static void
-channel_removed(device_node_handle node, void *channel_cookie)
-{
- channel_info *channel = channel_cookie;
- SHOW_FLOW0(3, "");
-
- if (channel != NULL)
- // disable access instantly
- atomic_or(&channel->lost, 1);
-
- return;
+ return primaryStatus;
}
static void
-get_paths(const char ***_bus, const char ***_device)
+channel_removed(void *cookie)
{
- static const char *kBus[] = {"isa", NULL};
- static const char *kDevice[] = {"drivers/dev/disk/ide", NULL};
+ channel_info *channel = cookie;
+ TRACE("channel_removed()\n");
- *_bus = kBus;
- *_device = kDevice;
+ // disable access instantly
+ atomic_or(&channel->lost, 1);
}
-static status_t
-std_ops(int32 op, ...)
-{
- switch (op) {
- case B_MODULE_INIT:
- case B_MODULE_UNINIT:
- return B_OK;
-
- default:
- return B_ERROR;
- }
-}
-
-
module_dependency module_dependencies[] = {
{ IDE_FOR_CONTROLLER_MODULE_NAME, (module_info **)&ide },
{ B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&pnp },
@@ -472,23 +423,25 @@
};
// exported interface
-ide_controller_interface isa_controller_interface = {
+static ide_controller_interface sISAControllerInterface = {
{
{
IDE_ISA_MODULE_NAME,
0,
- std_ops
+ NULL
},
supports_device,
register_device,
- (status_t (*)(device_node_handle, void *, void **)) init_channel,
+ init_channel,
uninit_channel,
+ NULL, // register child devices
+ NULL, // rescan
channel_removed,
- NULL, // cleanup
- get_paths
},
+ &set_channel,
+
&write_command_block_regs,
&read_command_block_regs,
@@ -504,6 +457,6 @@
};
module_info *modules[] = {
- (module_info *)&isa_controller_interface,
+ (module_info *)&sISAControllerInterface,
NULL
};
Deleted: haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/wrapper.h
From axeld at mail.berlios.de Mon Jun 2 13:01:46 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Mon, 2 Jun 2008 13:01:46 +0200
Subject: [Haiku-commits] r25756 -
haiku/trunk/src/libs/compat/freebsd_network/compat/sys
Message-ID: <200806021101.m52B1kOc006047@sheep.berlios.de>
Author: axeld
Date: 2008-06-02 13:01:44 +0200 (Mon, 02 Jun 2008)
New Revision: 25756
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25756&view=rev
Modified:
haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h
Log:
Patch by Vasilis Kaoutsis:
* Removed duplicate PAGE_SIZE definition (now defined in limits.h).
Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h
===================================================================
--- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h 2008-06-02 10:37:58 UTC (rev 25755)
+++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h 2008-06-02 11:01:44 UTC (rev 25756)
@@ -16,7 +16,6 @@
#define MAXBSIZE 0x10000
#define PAGE_SHIFT 12
-#define PAGE_SIZE B_PAGE_SIZE
#define PAGE_MASK (PAGE_SIZE - 1)
From axeld at mail.berlios.de Mon Jun 2 13:04:48 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Mon, 2 Jun 2008 13:04:48 +0200
Subject: [Haiku-commits] r25757 - haiku/trunk/src/build/libbe/storage
Message-ID: <200806021104.m52B4mZP009081@sheep.berlios.de>
Author: axeld
Date: 2008-06-02 13:04:46 +0200 (Mon, 02 Jun 2008)
New Revision: 25757
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25757&view=rev
Modified:
haiku/trunk/src/build/libbe/storage/Volume.cpp
Log:
Patch by Vasilis Kaoutsis:
* Update license and author information.
* Simplified operator==().
* Removed obsolete OpenBeOS namespace.
* Some style cleanup.
Modified: haiku/trunk/src/build/libbe/storage/Volume.cpp
===================================================================
--- haiku/trunk/src/build/libbe/storage/Volume.cpp 2008-06-02 11:01:44 UTC (rev 25756)
+++ haiku/trunk/src/build/libbe/storage/Volume.cpp 2008-06-02 11:04:46 UTC (rev 25757)
@@ -1,16 +1,21 @@
-// ----------------------------------------------------------------------
-// This software is part of the OpenBeOS distribution and is covered
-// by the OpenBeOS license.
-//
-// File Name: Volume.cpp
-//
-// Description: BVolume class
-// ----------------------------------------------------------------------
+/*
+ * Copyright 2002-2008, Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Tyler Dauwalder, tyler at dauwalder.net
+ * Erik Jakowatz
+ * shadow303
+ * Ingo Weinhold, ingo_weinhold at gmx.de
+ */
+
/*!
\file Volume.h
BVolume implementation.
*/
+#include
+
#include
#include
@@ -18,14 +23,10 @@
#include
#include
#include
-#include
#include
#include
-#ifdef USE_OPENBEOS_NAMESPACE
-namespace OpenBeOS {
-#endif
/*!
\class BVolume
@@ -51,18 +52,19 @@
\brief The object's initialization status.
*/
-// constructor
+
/*! \brief Creates an uninitialized BVolume.
InitCheck() will return \c B_NO_INIT.
*/
BVolume::BVolume()
- : fDevice((dev_t)-1),
- fCStatus(B_NO_INIT)
+ :
+ fDevice((dev_t)-1),
+ fCStatus(B_NO_INIT)
{
}
-// constructor
+
/*! \brief Creates a BVolume and initializes it to the volume specified
by the supplied device ID.
@@ -72,13 +74,14 @@
\param device The device ID of the volume.
*/
BVolume::BVolume(dev_t device)
- : fDevice((dev_t)-1),
- fCStatus(B_NO_INIT)
+ :
+ fDevice((dev_t)-1),
+ fCStatus(B_NO_INIT)
{
SetTo(device);
}
-// copy constructor
+
/*! \brief Creates a BVolume and makes it a clone of the supplied one.
Afterwards the object refers to the same device the supplied object
@@ -88,12 +91,13 @@
\param volume The volume object to be cloned.
*/
BVolume::BVolume(const BVolume &volume)
- : fDevice(volume.fDevice),
- fCStatus(volume.fCStatus)
+ :
+ fDevice(volume.fDevice),
+ fCStatus(volume.fCStatus)
{
}
-// destructor
+
/*! \brief Frees all resources associated with the object.
Does nothing.
@@ -102,7 +106,7 @@
{
}
-// InitCheck
+
/*! \brief Returns the result of the last initialization.
\return
- \c B_OK: The object is properly initialized.
@@ -114,7 +118,7 @@
return fCStatus;
}
-// SetTo
+
/*! \brief Re-initializes the object to refer to the volume specified by
the supplied device ID.
\param device The device ID of the volume.
@@ -142,7 +146,7 @@
return fCStatus;
}
-// Unset
+
/*! \brief Uninitialized the BVolume.
*/
void
@@ -152,7 +156,7 @@
fCStatus = B_NO_INIT;
}
-// Device
+
/*! \brief Returns the device ID of the volume the object refers to.
\return Returns the device ID of the volume the object refers to
or -1, if the object is not properly initialized.
@@ -163,7 +167,7 @@
return fDevice;
}
-// ==
+
/*! \brief Returns whether two BVolume objects are equal.
Two volume objects are said to be equal, if they either are both
@@ -176,11 +180,10 @@
bool
BVolume::operator==(const BVolume &volume) const
{
- return (InitCheck() != B_OK && volume.InitCheck() != B_OK
- || fDevice == volume.fDevice);
+ return fDevice == volume.fDevice;
}
-// !=
+
/*! \brief Returns whether two BVolume objects are unequal.
Two volume objects are said to be equal, if they either are both
@@ -196,7 +199,7 @@
return !(*this == volume);
}
-// =
+
/*! \brief Assigns another BVolume object to this one.
This object is made an exact clone of the supplied one.
@@ -215,7 +218,6 @@
}
-// FBC
void BVolume::_TurnUpTheVolume1() {}
void BVolume::_TurnUpTheVolume2() {}
void BVolume::_TurnUpTheVolume3() {}
@@ -224,7 +226,3 @@
void BVolume::_TurnUpTheVolume6() {}
void BVolume::_TurnUpTheVolume7() {}
void BVolume::_TurnUpTheVolume8() {}
-
-#ifdef USE_OPENBEOS_NAMESPACE
-}
-#endif
From axeld at mail.berlios.de Mon Jun 2 13:10:36 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Mon, 2 Jun 2008 13:10:36 +0200
Subject: [Haiku-commits] r25758 -
haiku/trunk/src/add-ons/kernel/network/protocols/ipv4
Message-ID: <200806021110.m52BAaNl015762@sheep.berlios.de>
Author: axeld
Date: 2008-06-02 13:10:35 +0200 (Mon, 02 Jun 2008)
New Revision: 25758
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25758&view=rev
Modified:
haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp
Log:
Patch by Vasilis Kaoutsis:
* FragmentPacket::Reassemble() would return NULL instead of an error when the
packet was not yet complete.
* This didn't have any actual consequences, though, as Reassemble() was only
called for a complete fragment set.
Modified: haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp 2008-06-02 11:04:46 UTC (rev 25757)
+++ haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp 2008-06-02 11:10:35 UTC (rev 25758)
@@ -368,15 +368,14 @@
}
-/*!
- Reassembles the fragments to the specified buffer \a to.
+/*! Reassembles the fragments to the specified buffer \a to.
This buffer must have been added via AddFragment() before.
*/
status_t
FragmentPacket::Reassemble(net_buffer *to)
{
if (!IsComplete())
- return NULL;
+ return B_ERROR;
net_buffer *buffer = NULL;
From axeld at mail.berlios.de Mon Jun 2 13:24:13 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Mon, 2 Jun 2008 13:24:13 +0200
Subject: [Haiku-commits] r25759 - haiku/trunk/src/build/libbe/interface
Message-ID: <200806021124.m52BODbr001217@sheep.berlios.de>
Author: axeld
Date: 2008-06-02 13:24:11 +0200 (Mon, 02 Jun 2008)
New Revision: 25759
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25759&view=rev
Modified:
haiku/trunk/src/build/libbe/interface/Bitmap.cpp
Log:
* Patch by Vasilis Kaoutsis to fix a warning in PaletteConverter::IndexForRGB16().
* Further cleanup by myself.
Modified: haiku/trunk/src/build/libbe/interface/Bitmap.cpp
===================================================================
--- haiku/trunk/src/build/libbe/interface/Bitmap.cpp 2008-06-02 11:10:35 UTC (rev 25758)
+++ haiku/trunk/src/build/libbe/interface/Bitmap.cpp 2008-06-02 11:24:11 UTC (rev 25759)
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2005, Haiku Inc.
+ * Copyright 2001-2008, Haiku Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -8,9 +8,7 @@
* Stephan A?mus
*/
-/** BBitmap objects represent off-screen windows that
- * contain bitmap data.
- */
+/*! BBitmap objects represent off-screen windows that contain bitmap data. */
#include
#include
@@ -24,99 +22,149 @@
#include
+// structures defining the pixel layout
+
+struct rgb32_pixel {
+ uint8 blue;
+ uint8 green;
+ uint8 red;
+ uint8 alpha;
+};
+
+struct rgb32_big_pixel {
+ uint8 red;
+ uint8 green;
+ uint8 blue;
+ uint8 alpha;
+};
+
+struct rgb24_pixel {
+ uint8 blue;
+ uint8 green;
+ uint8 red;
+};
+
+struct rgb24_big_pixel {
+ uint8 red;
+ uint8 green;
+ uint8 blue;
+};
+
+struct rgb16_pixel {
+ uint8 gb; // G[2:0],B[4:0]
+ uint8 rg; // 16: R[4:0],G[5:3]
+ // 15: -[0],R[4:0],G[4:3]
+};
+
+struct rgb16_big_pixel {
+ uint8 rg; // 16: R[4:0],G[5:3]
+ // 15: -[0],R[4:0],G[4:3]
+ uint8 gb; // G[2:0],B[4:0]
+};
+
+// types defining what is needed to store a color value
+
+struct rgb_color_value {
+ uint8 red;
+ uint8 green;
+ uint8 blue;
+ uint8 alpha;
+};
+
+typedef uint8 gray_color_value;
+
// TODO: system palette -- hard-coded for now, when the app server is ready
// we should use system_colors() or BScreen::ColorMap().
const rgb_color kSystemPalette[] = {
- { 0, 0, 0, 255 }, { 8, 8, 8, 255 }, { 16, 16, 16, 255 },
- { 24, 24, 24, 255 }, { 32, 32, 32, 255 }, { 40, 40, 40, 255 },
- { 48, 48, 48, 255 }, { 56, 56, 56, 255 }, { 64, 64, 64, 255 },
- { 72, 72, 72, 255 }, { 80, 80, 80, 255 }, { 88, 88, 88, 255 },
- { 96, 96, 96, 255 }, { 104, 104, 104, 255 }, { 112, 112, 112, 255 },
- { 120, 120, 120, 255 }, { 128, 128, 128, 255 }, { 136, 136, 136, 255 },
- { 144, 144, 144, 255 }, { 152, 152, 152, 255 }, { 160, 160, 160, 255 },
- { 168, 168, 168, 255 }, { 176, 176, 176, 255 }, { 184, 184, 184, 255 },
- { 192, 192, 192, 255 }, { 200, 200, 200, 255 }, { 208, 208, 208, 255 },
- { 216, 216, 216, 255 }, { 224, 224, 224, 255 }, { 232, 232, 232, 255 },
- { 240, 240, 240, 255 }, { 248, 248, 248, 255 }, { 0, 0, 255, 255 },
- { 0, 0, 229, 255 }, { 0, 0, 204, 255 }, { 0, 0, 179, 255 },
- { 0, 0, 154, 255 }, { 0, 0, 129, 255 }, { 0, 0, 105, 255 },
- { 0, 0, 80, 255 }, { 0, 0, 55, 255 }, { 0, 0, 30, 255 },
- { 255, 0, 0, 255 }, { 228, 0, 0, 255 }, { 203, 0, 0, 255 },
- { 178, 0, 0, 255 }, { 153, 0, 0, 255 }, { 128, 0, 0, 255 },
- { 105, 0, 0, 255 }, { 80, 0, 0, 255 }, { 55, 0, 0, 255 },
- { 30, 0, 0, 255 }, { 0, 255, 0, 255 }, { 0, 228, 0, 255 },
- { 0, 203, 0, 255 }, { 0, 178, 0, 255 }, { 0, 153, 0, 255 },
- { 0, 128, 0, 255 }, { 0, 105, 0, 255 }, { 0, 80, 0, 255 },
- { 0, 55, 0, 255 }, { 0, 30, 0, 255 }, { 0, 152, 51, 255 },
- { 255, 255, 255, 255 }, { 203, 255, 255, 255 }, { 203, 255, 203, 255 },
- { 203, 255, 152, 255 }, { 203, 255, 102, 255 }, { 203, 255, 51, 255 },
- { 203, 255, 0, 255 }, { 152, 255, 255, 255 }, { 152, 255, 203, 255 },
- { 152, 255, 152, 255 }, { 152, 255, 102, 255 }, { 152, 255, 51, 255 },
- { 152, 255, 0, 255 }, { 102, 255, 255, 255 }, { 102, 255, 203, 255 },
- { 102, 255, 152, 255 }, { 102, 255, 102, 255 }, { 102, 255, 51, 255 },
- { 102, 255, 0, 255 }, { 51, 255, 255, 255 }, { 51, 255, 203, 255 },
- { 51, 255, 152, 255 }, { 51, 255, 102, 255 }, { 51, 255, 51, 255 },
- { 51, 255, 0, 255 }, { 255, 152, 255, 255 }, { 255, 152, 203, 255 },
- { 255, 152, 152, 255 }, { 255, 152, 102, 255 }, { 255, 152, 51, 255 },
- { 255, 152, 0, 255 }, { 0, 102, 255, 255 }, { 0, 102, 203, 255 },
- { 203, 203, 255, 255 }, { 203, 203, 203, 255 }, { 203, 203, 152, 255 },
- { 203, 203, 102, 255 }, { 203, 203, 51, 255 }, { 203, 203, 0, 255 },
- { 152, 203, 255, 255 }, { 152, 203, 203, 255 }, { 152, 203, 152, 255 },
- { 152, 203, 102, 255 }, { 152, 203, 51, 255 }, { 152, 203, 0, 255 },
- { 102, 203, 255, 255 }, { 102, 203, 203, 255 }, { 102, 203, 152, 255 },
- { 102, 203, 102, 255 }, { 102, 203, 51, 255 }, { 102, 203, 0, 255 },
- { 51, 203, 255, 255 }, { 51, 203, 203, 255 }, { 51, 203, 152, 255 },
- { 51, 203, 102, 255 }, { 51, 203, 51, 255 }, { 51, 203, 0, 255 },
- { 255, 102, 255, 255 }, { 255, 102, 203, 255 }, { 255, 102, 152, 255 },
- { 255, 102, 102, 255 }, { 255, 102, 51, 255 }, { 255, 102, 0, 255 },
- { 0, 102, 152, 255 }, { 0, 102, 102, 255 }, { 203, 152, 255, 255 },
- { 203, 152, 203, 255 }, { 203, 152, 152, 255 }, { 203, 152, 102, 255 },
- { 203, 152, 51, 255 }, { 203, 152, 0, 255 }, { 152, 152, 255, 255 },
- { 152, 152, 203, 255 }, { 152, 152, 152, 255 }, { 152, 152, 102, 255 },
- { 152, 152, 51, 255 }, { 152, 152, 0, 255 }, { 102, 152, 255, 255 },
- { 102, 152, 203, 255 }, { 102, 152, 152, 255 }, { 102, 152, 102, 255 },
- { 102, 152, 51, 255 }, { 102, 152, 0, 255 }, { 51, 152, 255, 255 },
- { 51, 152, 203, 255 }, { 51, 152, 152, 255 }, { 51, 152, 102, 255 },
- { 51, 152, 51, 255 }, { 51, 152, 0, 255 }, { 230, 134, 0, 255 },
- { 255, 51, 203, 255 }, { 255, 51, 152, 255 }, { 255, 51, 102, 255 },
- { 255, 51, 51, 255 }, { 255, 51, 0, 255 }, { 0, 102, 51, 255 },
- { 0, 102, 0, 255 }, { 203, 102, 255, 255 }, { 203, 102, 203, 255 },
- { 203, 102, 152, 255 }, { 203, 102, 102, 255 }, { 203, 102, 51, 255 },
- { 203, 102, 0, 255 }, { 152, 102, 255, 255 }, { 152, 102, 203, 255 },
- { 152, 102, 152, 255 }, { 152, 102, 102, 255 }, { 152, 102, 51, 255 },
- { 152, 102, 0, 255 }, { 102, 102, 255, 255 }, { 102, 102, 203, 255 },
- { 102, 102, 152, 255 }, { 102, 102, 102, 255 }, { 102, 102, 51, 255 },
- { 102, 102, 0, 255 }, { 51, 102, 255, 255 }, { 51, 102, 203, 255 },
- { 51, 102, 152, 255 }, { 51, 102, 102, 255 }, { 51, 102, 51, 255 },
- { 51, 102, 0, 255 }, { 255, 0, 255, 255 }, { 255, 0, 203, 255 },
- { 255, 0, 152, 255 }, { 255, 0, 102, 255 }, { 255, 0, 51, 255 },
- { 255, 175, 19, 255 }, { 0, 51, 255, 255 }, { 0, 51, 203, 255 },
- { 203, 51, 255, 255 }, { 203, 51, 203, 255 }, { 203, 51, 152, 255 },
- { 203, 51, 102, 255 }, { 203, 51, 51, 255 }, { 203, 51, 0, 255 },
- { 152, 51, 255, 255 }, { 152, 51, 203, 255 }, { 152, 51, 152, 255 },
- { 152, 51, 102, 255 }, { 152, 51, 51, 255 }, { 152, 51, 0, 255 },
- { 102, 51, 255, 255 }, { 102, 51, 203, 255 }, { 102, 51, 152, 255 },
- { 102, 51, 102, 255 }, { 102, 51, 51, 255 }, { 102, 51, 0, 255 },
- { 51, 51, 255, 255 }, { 51, 51, 203, 255 }, { 51, 51, 152, 255 },
- { 51, 51, 102, 255 }, { 51, 51, 51, 255 }, { 51, 51, 0, 255 },
- { 255, 203, 102, 255 }, { 255, 203, 152, 255 }, { 255, 203, 203, 255 },
- { 255, 203, 255, 255 }, { 0, 51, 152, 255 }, { 0, 51, 102, 255 },
- { 0, 51, 51, 255 }, { 0, 51, 0, 255 }, { 203, 0, 255, 255 },
- { 203, 0, 203, 255 }, { 203, 0, 152, 255 }, { 203, 0, 102, 255 },
- { 203, 0, 51, 255 }, { 255, 227, 70, 255 }, { 152, 0, 255, 255 },
- { 152, 0, 203, 255 }, { 152, 0, 152, 255 }, { 152, 0, 102, 255 },
- { 152, 0, 51, 255 }, { 152, 0, 0, 255 }, { 102, 0, 255, 255 },
- { 102, 0, 203, 255 }, { 102, 0, 152, 255 }, { 102, 0, 102, 255 },
- { 102, 0, 51, 255 }, { 102, 0, 0, 255 }, { 51, 0, 255, 255 },
- { 51, 0, 203, 255 }, { 51, 0, 152, 255 }, { 51, 0, 102, 255 },
- { 51, 0, 51, 255 }, { 51, 0, 0, 255 }, { 255, 203, 51, 255 },
- { 255, 203, 0, 255 }, { 255, 255, 0, 255 }, { 255, 255, 51, 255 },
- { 255, 255, 102, 255 }, { 255, 255, 152, 255 }, { 255, 255, 203, 255 },
- { 255, 255, 255, 0 } // B_TRANSPARENT_MAGIC_CMAP8
+ { 0, 0, 0, 255 }, { 8, 8, 8, 255 }, { 16, 16, 16, 255 },
+ { 24, 24, 24, 255 }, { 32, 32, 32, 255 }, { 40, 40, 40, 255 },
+ { 48, 48, 48, 255 }, { 56, 56, 56, 255 }, { 64, 64, 64, 255 },
+ { 72, 72, 72, 255 }, { 80, 80, 80, 255 }, { 88, 88, 88, 255 },
+ { 96, 96, 96, 255 }, { 104, 104, 104, 255 }, { 112, 112, 112, 255 },
+ { 120, 120, 120, 255 }, { 128, 128, 128, 255 }, { 136, 136, 136, 255 },
+ { 144, 144, 144, 255 }, { 152, 152, 152, 255 }, { 160, 160, 160, 255 },
+ { 168, 168, 168, 255 }, { 176, 176, 176, 255 }, { 184, 184, 184, 255 },
+ { 192, 192, 192, 255 }, { 200, 200, 200, 255 }, { 208, 208, 208, 255 },
+ { 216, 216, 216, 255 }, { 224, 224, 224, 255 }, { 232, 232, 232, 255 },
+ { 240, 240, 240, 255 }, { 248, 248, 248, 255 }, { 0, 0, 255, 255 },
+ { 0, 0, 229, 255 }, { 0, 0, 204, 255 }, { 0, 0, 179, 255 },
+ { 0, 0, 154, 255 }, { 0, 0, 129, 255 }, { 0, 0, 105, 255 },
+ { 0, 0, 80, 255 }, { 0, 0, 55, 255 }, { 0, 0, 30, 255 },
+ { 255, 0, 0, 255 }, { 228, 0, 0, 255 }, { 203, 0, 0, 255 },
+ { 178, 0, 0, 255 }, { 153, 0, 0, 255 }, { 128, 0, 0, 255 },
+ { 105, 0, 0, 255 }, { 80, 0, 0, 255 }, { 55, 0, 0, 255 },
+ { 30, 0, 0, 255 }, { 0, 255, 0, 255 }, { 0, 228, 0, 255 },
+ { 0, 203, 0, 255 }, { 0, 178, 0, 255 }, { 0, 153, 0, 255 },
+ { 0, 128, 0, 255 }, { 0, 105, 0, 255 }, { 0, 80, 0, 255 },
+ { 0, 55, 0, 255 }, { 0, 30, 0, 255 }, { 0, 152, 51, 255 },
+ { 255, 255, 255, 255 }, { 203, 255, 255, 255 }, { 203, 255, 203, 255 },
+ { 203, 255, 152, 255 }, { 203, 255, 102, 255 }, { 203, 255, 51, 255 },
+ { 203, 255, 0, 255 }, { 152, 255, 255, 255 }, { 152, 255, 203, 255 },
+ { 152, 255, 152, 255 }, { 152, 255, 102, 255 }, { 152, 255, 51, 255 },
+ { 152, 255, 0, 255 }, { 102, 255, 255, 255 }, { 102, 255, 203, 255 },
+ { 102, 255, 152, 255 }, { 102, 255, 102, 255 }, { 102, 255, 51, 255 },
+ { 102, 255, 0, 255 }, { 51, 255, 255, 255 }, { 51, 255, 203, 255 },
+ { 51, 255, 152, 255 }, { 51, 255, 102, 255 }, { 51, 255, 51, 255 },
+ { 51, 255, 0, 255 }, { 255, 152, 255, 255 }, { 255, 152, 203, 255 },
+ { 255, 152, 152, 255 }, { 255, 152, 102, 255 }, { 255, 152, 51, 255 },
+ { 255, 152, 0, 255 }, { 0, 102, 255, 255 }, { 0, 102, 203, 255 },
+ { 203, 203, 255, 255 }, { 203, 203, 203, 255 }, { 203, 203, 152, 255 },
+ { 203, 203, 102, 255 }, { 203, 203, 51, 255 }, { 203, 203, 0, 255 },
+ { 152, 203, 255, 255 }, { 152, 203, 203, 255 }, { 152, 203, 152, 255 },
+ { 152, 203, 102, 255 }, { 152, 203, 51, 255 }, { 152, 203, 0, 255 },
+ { 102, 203, 255, 255 }, { 102, 203, 203, 255 }, { 102, 203, 152, 255 },
+ { 102, 203, 102, 255 }, { 102, 203, 51, 255 }, { 102, 203, 0, 255 },
+ { 51, 203, 255, 255 }, { 51, 203, 203, 255 }, { 51, 203, 152, 255 },
+ { 51, 203, 102, 255 }, { 51, 203, 51, 255 }, { 51, 203, 0, 255 },
+ { 255, 102, 255, 255 }, { 255, 102, 203, 255 }, { 255, 102, 152, 255 },
+ { 255, 102, 102, 255 }, { 255, 102, 51, 255 }, { 255, 102, 0, 255 },
+ { 0, 102, 152, 255 }, { 0, 102, 102, 255 }, { 203, 152, 255, 255 },
+ { 203, 152, 203, 255 }, { 203, 152, 152, 255 }, { 203, 152, 102, 255 },
+ { 203, 152, 51, 255 }, { 203, 152, 0, 255 }, { 152, 152, 255, 255 },
+ { 152, 152, 203, 255 }, { 152, 152, 152, 255 }, { 152, 152, 102, 255 },
+ { 152, 152, 51, 255 }, { 152, 152, 0, 255 }, { 102, 152, 255, 255 },
+ { 102, 152, 203, 255 }, { 102, 152, 152, 255 }, { 102, 152, 102, 255 },
+ { 102, 152, 51, 255 }, { 102, 152, 0, 255 }, { 51, 152, 255, 255 },
+ { 51, 152, 203, 255 }, { 51, 152, 152, 255 }, { 51, 152, 102, 255 },
+ { 51, 152, 51, 255 }, { 51, 152, 0, 255 }, { 230, 134, 0, 255 },
+ { 255, 51, 203, 255 }, { 255, 51, 152, 255 }, { 255, 51, 102, 255 },
+ { 255, 51, 51, 255 }, { 255, 51, 0, 255 }, { 0, 102, 51, 255 },
+ { 0, 102, 0, 255 }, { 203, 102, 255, 255 }, { 203, 102, 203, 255 },
+ { 203, 102, 152, 255 }, { 203, 102, 102, 255 }, { 203, 102, 51, 255 },
+ { 203, 102, 0, 255 }, { 152, 102, 255, 255 }, { 152, 102, 203, 255 },
+ { 152, 102, 152, 255 }, { 152, 102, 102, 255 }, { 152, 102, 51, 255 },
+ { 152, 102, 0, 255 }, { 102, 102, 255, 255 }, { 102, 102, 203, 255 },
+ { 102, 102, 152, 255 }, { 102, 102, 102, 255 }, { 102, 102, 51, 255 },
+ { 102, 102, 0, 255 }, { 51, 102, 255, 255 }, { 51, 102, 203, 255 },
+ { 51, 102, 152, 255 }, { 51, 102, 102, 255 }, { 51, 102, 51, 255 },
+ { 51, 102, 0, 255 }, { 255, 0, 255, 255 }, { 255, 0, 203, 255 },
+ { 255, 0, 152, 255 }, { 255, 0, 102, 255 }, { 255, 0, 51, 255 },
+ { 255, 175, 19, 255 }, { 0, 51, 255, 255 }, { 0, 51, 203, 255 },
+ { 203, 51, 255, 255 }, { 203, 51, 203, 255 }, { 203, 51, 152, 255 },
+ { 203, 51, 102, 255 }, { 203, 51, 51, 255 }, { 203, 51, 0, 255 },
+ { 152, 51, 255, 255 }, { 152, 51, 203, 255 }, { 152, 51, 152, 255 },
+ { 152, 51, 102, 255 }, { 152, 51, 51, 255 }, { 152, 51, 0, 255 },
+ { 102, 51, 255, 255 }, { 102, 51, 203, 255 }, { 102, 51, 152, 255 },
+ { 102, 51, 102, 255 }, { 102, 51, 51, 255 }, { 102, 51, 0, 255 },
+ { 51, 51, 255, 255 }, { 51, 51, 203, 255 }, { 51, 51, 152, 255 },
+ { 51, 51, 102, 255 }, { 51, 51, 51, 255 }, { 51, 51, 0, 255 },
+ { 255, 203, 102, 255 }, { 255, 203, 152, 255 }, { 255, 203, 203, 255 },
+ { 255, 203, 255, 255 }, { 0, 51, 152, 255 }, { 0, 51, 102, 255 },
+ { 0, 51, 51, 255 }, { 0, 51, 0, 255 }, { 203, 0, 255, 255 },
+ { 203, 0, 203, 255 }, { 203, 0, 152, 255 }, { 203, 0, 102, 255 },
+ { 203, 0, 51, 255 }, { 255, 227, 70, 255 }, { 152, 0, 255, 255 },
+ { 152, 0, 203, 255 }, { 152, 0, 152, 255 }, { 152, 0, 102, 255 },
+ { 152, 0, 51, 255 }, { 152, 0, 0, 255 }, { 102, 0, 255, 255 },
+ { 102, 0, 203, 255 }, { 102, 0, 152, 255 }, { 102, 0, 102, 255 },
+ { 102, 0, 51, 255 }, { 102, 0, 0, 255 }, { 51, 0, 255, 255 },
+ { 51, 0, 203, 255 }, { 51, 0, 152, 255 }, { 51, 0, 102, 255 },
+ { 51, 0, 51, 255 }, { 51, 0, 0, 255 }, { 255, 203, 51, 255 },
+ { 255, 203, 0, 255 }, { 255, 255, 0, 255 }, { 255, 255, 51, 255 },
+ { 255, 255, 102, 255 }, { 255, 255, 152, 255 }, { 255, 255, 203, 255 },
+ { 255, 255, 255, 0 } // B_TRANSPARENT_MAGIC_CMAP8
};
-// get_raw_bytes_per_row
/*! \brief Returns the number of bytes per row needed to store the actual
bitmap data (not including any padding) given a color space and a
row width.
@@ -125,8 +173,7 @@
\return The number of bytes per row needed to store data for a row, or
0, if the color space is not supported.
*/
-static inline
-int32
+static inline int32
get_raw_bytes_per_row(color_space colorSpace, int32 width)
{
int32 bpr = 0;
@@ -177,7 +224,7 @@
return bpr;
}
-// get_bytes_per_row
+
/*! \brief Returns the number of bytes per row needed to store the bitmap
data (including any padding) given a color space and a row width.
\param colorSpace The color space.
@@ -185,8 +232,7 @@
\return The number of bytes per row needed to store data for a row, or
0, if the color space is not supported.
*/
-static inline
-int32
+static inline int32
get_bytes_per_row(color_space colorSpace, int32 width)
{
int32 bpr = get_raw_bytes_per_row(colorSpace, width);
@@ -195,7 +241,7 @@
return bpr;
}
-// brightness_for
+
/*! \brief Returns the brightness of an RGB 24 color.
\param red Value of the red component.
\param green Value of the green component.
@@ -203,8 +249,7 @@
\return The brightness for the supplied RGB color as a value between 0
and 255.
*/
-static inline
-uint8
+static inline uint8
brightness_for(uint8 red, uint8 green, uint8 blue)
{
// brightness = 0.301 * red + 0.586 * green + 0.113 * blue
@@ -213,7 +258,7 @@
return uint8((308 * red + 600 * green + 116 * blue) / 1024);
}
-// color_distance
+
/*! \brief Returns the "distance" between two RGB colors.
This functions defines an metric on the RGB color space. The distance
@@ -227,10 +272,9 @@
\param blue2 Blue component of the second color.
\return The distance between the given colors.
*/
-static inline
-unsigned
-color_distance(uint8 red1, uint8 green1, uint8 blue1,
- uint8 red2, uint8 green2, uint8 blue2)
+static inline unsigned
+color_distance(uint8 red1, uint8 green1, uint8 blue1, uint8 red2, uint8 green2,
+ uint8 blue2)
{
// euklidian distance (its square actually)
int rd = (int)red1 - (int)red2;
@@ -240,20 +284,28 @@
// distance according to psycho-visual tests
int rmean = ((int)red1 + (int)red2) / 2;
- return (((512 + rmean) * rd * rd) >> 8)
- + 4 * gd * gd
- + (((767 - rmean) * bd * bd) >> 8);
+ return (((512 + rmean) * rd * rd) >> 8) + 4 * gd * gd
+ + (((767 - rmean) * bd * bd) >> 8);
}
-// bit_mask, inverse_bit_mask
-static inline int32 bit_mask(int32 bit) { return (1 << bit); }
-static inline int32 inverse_bit_mask(int32 bit) { return ~bit_mask(bit); }
+static inline int32
+bit_mask(int32 bit)
+{
+ return 1 << bit;
+}
-//////////////////////
-// PaletteConverter //
-//////////////////////
+static inline int32
+inverse_bit_mask(int32 bit)
+{
+ return ~bit_mask(bit);
+}
+
+
+// #pragma mark - PaletteConverter
+
+
namespace BPrivate {
/*! \brief Helper class for conversion between RGB and palette colors.
@@ -282,7 +334,7 @@
inline uint16 RGB16ColorForIndex(uint8 index) const;
inline uint32 RGB24ColorForIndex(uint8 index) const;
inline void RGB24ColorForIndex(uint8 index, uint8 &red, uint8 &green,
- uint8 &blue, uint8 &alpha) const;
+ uint8 &blue, uint8 &alpha) const;
inline uint8 GrayColorForIndex(uint8 index) const;
private:
@@ -296,7 +348,7 @@
using BPrivate::PaletteConverter;
using namespace std;
-// constructor
+
/*! \brief Creates an uninitialized PaletteConverter.
*/
PaletteConverter::PaletteConverter()
@@ -306,7 +358,7 @@
{
}
-// constructor
+
/*! \brief Creates a PaletteConverter and initializes it to the supplied
palette.
\param palette The palette being a 256 entry rgb_color array.
@@ -319,7 +371,7 @@
SetTo(palette);
}
-// constructor
+
/*! \brief Creates a PaletteConverter and initializes it to the supplied
color map.
\param colorMap The completely initialized color map.
@@ -332,7 +384,7 @@
SetTo(colorMap);
}
-// destructor
+
/*! \brief Frees all resources associated with this object.
*/
PaletteConverter::~PaletteConverter()
@@ -340,7 +392,7 @@
delete fOwnColorMap;
}
-// SetTo
+
/*! \brief Initializes the converter to the supplied palette.
\param palette The palette being a 256 entry rgb_color array.
\return \c B_OK, if everything went fine, an error code otherwise.
@@ -391,7 +443,7 @@
return error;
}
-// SetTo
+
/*! \brief Initializes the converter to the supplied color map.
\param colorMap The completely initialized color map.
\return \c B_OK, if everything went fine, an error code otherwise.
@@ -406,11 +458,11 @@
}
// set
fColorMap = colorMap;
- fCStatus = (fColorMap ? B_OK : B_BAD_VALUE);
+ fCStatus = fColorMap ? B_OK : B_BAD_VALUE;
return fCStatus;
}
-// InitCheck
+
/*! \brief Returns the result of the last initialization via constructor or
SetTo().
\return \c B_OK, if the converter is properly initialized, an error code
@@ -422,7 +474,7 @@
return fCStatus;
}
-// IndexForRGB15
+
/*! \brief Returns the palette color index closest to a given RGB 15 color.
The object must be properly initialized.
@@ -430,14 +482,13 @@
\param rgb The RGB 15 color value (R[14:10]G[9:5]B[4:0]).
\return The palette color index for the supplied color.
*/
-inline
-uint8
+inline uint8
PaletteConverter::IndexForRGB15(uint16 rgb) const
{
return fColorMap->index_map[rgb];
}
-// IndexForRGB15
+
/*! \brief Returns the palette color index closest to a given RGB 15 color.
The object must be properly initialized.
@@ -447,15 +498,14 @@
\param blue Blue component of the color (B[4:0]).
\return The palette color index for the supplied color.
*/
-inline
-uint8
+inline uint8
PaletteConverter::IndexForRGB15(uint8 red, uint8 green, uint8 blue) const
{
// the 5 least significant bits are used
return fColorMap->index_map[(red << 10) | (green << 5) | blue];
}
-// IndexForRGB16
+
/*! \brief Returns the palette color index closest to a given RGB 16 color.
The object must be properly initialized.
@@ -463,14 +513,13 @@
\param rgb The RGB 16 color value (R[15:11]G[10:5]B[4:0]).
\return The palette color index for the supplied color.
*/
-inline
-uint8
+inline uint8
PaletteConverter::IndexForRGB16(uint16 rgb) const
{
- return fColorMap->index_map[(rgb >> 1) & 0x7fe0 | rgb & 0x1f];
+ return fColorMap->index_map[((rgb >> 1) & 0x7fe0) | (rgb & 0x1f)];
}
-// IndexForRGB16
+
/*! \brief Returns the palette color index closest to a given RGB 16 color.
The object must be properly initialized.
@@ -480,15 +529,14 @@
\param blue Blue component of the color (B[4:0]).
\return The palette color index for the supplied color.
*/
-inline
-uint8
+inline uint8
PaletteConverter::IndexForRGB16(uint8 red, uint8 green, uint8 blue) const
{
// the 5 (for red, blue) / 6 (for green) least significant bits are used
return fColorMap->index_map[(red << 10) | ((green & 0x3e) << 4) | blue];
}
-// IndexForRGB24
+
/*! \brief Returns the palette color index closest to a given RGB 32 color.
The object must be properly initialized.
@@ -496,16 +544,14 @@
\param rgb The RGB 32 color value (R[31:24]G[23:16]B[15:8]).
\return The palette color index for the supplied color.
*/
-inline
-uint8
+inline uint8
PaletteConverter::IndexForRGB24(uint32 rgb) const
{
return fColorMap->index_map[((rgb & 0xf8000000) >> 17)
- | ((rgb & 0xf80000) >> 14)
- | ((rgb & 0xf800) >> 11)];
+ | ((rgb & 0xf80000) >> 14) | ((rgb & 0xf800) >> 11)];
}
-// IndexForRGB24
+
/*! \brief Returns the palette color index closest to a given RGB 24 color.
The object must be properly initialized.
@@ -515,16 +561,14 @@
\param blue Blue component of the color.
\return The palette color index for the supplied color.
*/
-inline
-uint8
+inline uint8
PaletteConverter::IndexForRGB24(uint8 red, uint8 green, uint8 blue) const
{
- return fColorMap->index_map[((red & 0xf8) << 7)
- | ((green & 0xf8) << 2)
- | (blue >> 3)];
+ return fColorMap->index_map[((red & 0xf8) << 7) | ((green & 0xf8) << 2)
+ | (blue >> 3)];
}
-// IndexForGray
+
/*! \brief Returns the palette color index closest to a given Gray 8 color.
The object must be properly initialized.
@@ -532,14 +576,13 @@
\param gray The Gray 8 color value.
\return The palette color index for the supplied color.
*/
-inline
-uint8
+inline uint8
PaletteConverter::IndexForGray(uint8 gray) const
{
return IndexForRGB24(gray, gray, gray);
}
-// RGBColorForIndex
+
/*! \brief Returns the RGB color for a given palette color index.
The object must be properly initialized.
@@ -547,14 +590,13 @@
\param index The palette color index.
\return The color for the supplied palette color index.
*/
-inline
-const rgb_color &
+inline const rgb_color &
PaletteConverter::RGBColorForIndex(uint8 index) const
{
return fColorMap->color_list[index];
}
-// RGB15ColorForIndex
+
/*! \brief Returns the RGB 15 color for a given palette color index.
The object must be properly initialized.
@@ -563,17 +605,15 @@
\return The color for the supplied palette color index
(R[14:10]G[9:5]B[4:0]).
*/
-inline
-uint16
+inline uint16
PaletteConverter::RGB15ColorForIndex(uint8 index) const
{
const rgb_color &color = fColorMap->color_list[index];
- return ((color.red & 0xf8) << 7)
- | ((color.green & 0xf8) << 2)
- | (color.blue >> 3);
+ return ((color.red & 0xf8) << 7) | ((color.green & 0xf8) << 2)
+ | (color.blue >> 3);
}
-// RGB16ColorForIndex
+
/*! \brief Returns the RGB 16 color for a given palette color index.
The object must be properly initialized.
@@ -582,17 +622,15 @@
\return The color for the supplied palette color index
(R[15:11]G[10:5]B[4:0]).
*/
-inline
-uint16
+inline uint16
PaletteConverter::RGB16ColorForIndex(uint8 index) const
{
const rgb_color &color = fColorMap->color_list[index];
- return ((color.red & 0xf8) << 8)
- | ((color.green & 0xfc) << 3)
- | (color.blue >> 3);
+ return ((color.red & 0xf8) << 8) | ((color.green & 0xfc) << 3)
+ | (color.blue >> 3);
}
-// RGB24ColorForIndex
+
/*! \brief Returns the RGB 24 color for a given palette color index.
The object must be properly initialized.
@@ -601,15 +639,15 @@
\return The color for the supplied palette color index
(R[31:24]G[23:16]B[15:8]).
*/
-inline
-uint32
+inline uint32
PaletteConverter::RGB24ColorForIndex(uint8 index) const
{
const rgb_color &color = fColorMap->color_list[index];
- return (color.blue << 24) | (color.red << 8) | (color.green << 16) | color.alpha;
+ return (color.blue << 24) | (color.red << 8) | (color.green << 16)
+ | color.alpha;
}
-// RGB24ColorForIndex
+
/*! \brief Returns the RGB 24 color for a given palette color index.
The object must be properly initialized.
@@ -622,10 +660,9 @@
\param blue Reference to the variable the blue component shall be stored
into.
*/
-inline
-void
+inline void
PaletteConverter::RGB24ColorForIndex(uint8 index, uint8 &red, uint8 &green,
- uint8 &blue, uint8 &alpha) const
+ uint8 &blue, uint8 &alpha) const
{
const rgb_color &color = fColorMap->color_list[index];
red = color.red;
@@ -634,7 +671,7 @@
alpha = color.alpha;
}
-// GrayColorForIndex
+
/*! \brief Returns the Gray 8 color for a given palette color index.
The object must be properly initialized.
@@ -642,8 +679,7 @@
\param index The palette color index.
\return The color for the supplied palette color index.
*/
-inline
-uint8
+inline uint8
PaletteConverter::GrayColorForIndex(uint8 index) const
{
const rgb_color &color = fColorMap->color_list[index];
@@ -651,15 +687,14 @@
}
// TODO: Remove these and palette_converter() when BScreen is available.
-static BLocker gPaletteConverterLock;
+static BLocker gPaletteConverterLock;
static PaletteConverter gPaletteConverter;
-// palette_converter
+
/*! \brief Returns a PaletteConverter using the system color palette.
\return A PaletteConverter.
*/
-static
-const PaletteConverter*
+static const PaletteConverter*
palette_converter()
{
if (gPaletteConverterLock.Lock()) {
@@ -671,370 +706,9 @@
}
-/////////////
-// BBitmap //
-/////////////
+// #pragma mark - Reader classes
-// constructor
-/*! \brief Creates and initializes a BBitmap.
- \param bounds The bitmap dimensions.
- \param flags Creation flags.
- \param colorSpace The bitmap's color space.
- \param bytesPerRow The number of bytes per row the bitmap should use.
- \c B_ANY_BYTES_PER_ROW to let the constructor choose an appropriate
- value.
- \param screenID ???
-*/
-BBitmap::BBitmap(BRect bounds, uint32 flags, color_space colorSpace,
- int32 bytesPerRow, screen_id screenID)
- : fBasePtr(NULL),
- fSize(0),
- fColorSpace(B_NO_COLOR_SPACE),
- fBounds(0, 0, -1, -1),
- fBytesPerRow(0),
- fServerToken(-1),
- fToken(-1),
- fArea(-1),
- fOrigArea(-1),
- fFlags(0),
- fInitError(B_NO_INIT)
-{
- InitObject(bounds, colorSpace, flags, bytesPerRow, screenID);
-}
-// constructor
-/*! \brief Creates and initializes a BBitmap.
- \param bounds The bitmap dimensions.
- \param colorSpace The bitmap's color space.
- \param acceptsViews \c true, if the bitmap shall accept BViews, i.e. if
- it shall be possible to attach BView to the bitmap and draw into
- it.
- \param needsContiguous If \c true a physically contiguous chunk of memory
- will be allocated.
-*/
-BBitmap::BBitmap(BRect bounds, color_space colorSpace, bool acceptsViews,
- bool needsContiguous)
- : fBasePtr(NULL),
- fSize(0),
- fColorSpace(B_NO_COLOR_SPACE),
- fBounds(0, 0, -1, -1),
- fBytesPerRow(0),
- fServerToken(-1),
- fToken(-1),
- fArea(-1),
- fOrigArea(-1),
- fFlags(0),
- fInitError(B_NO_INIT)
-{
- int32 flags = (acceptsViews ? B_BITMAP_ACCEPTS_VIEWS : 0)
- | (needsContiguous ? B_BITMAP_IS_CONTIGUOUS : 0);
- InitObject(bounds, colorSpace, flags, B_ANY_BYTES_PER_ROW,
- B_MAIN_SCREEN_ID);
-
-}
-
-// constructor
-/*! \brief Creates a BBitmap as a clone of another bitmap.
- \param source The source bitmap.
- \param acceptsViews \c true, if the bitmap shall accept BViews, i.e. if
- it shall be possible to attach BView to the bitmap and draw into
- it.
- \param needsContiguous If \c true a physically contiguous chunk of memory
- will be allocated.
-*/
-BBitmap::BBitmap(const BBitmap *source, bool acceptsViews,
- bool needsContiguous)
- : fBasePtr(NULL),
- fSize(0),
- fColorSpace(B_NO_COLOR_SPACE),
- fBounds(0, 0, -1, -1),
- fBytesPerRow(0),
- fServerToken(-1),
- fToken(-1),
- fArea(-1),
- fOrigArea(-1),
- fFlags(0),
- fInitError(B_NO_INIT)
-{
- if (source && source->IsValid()) {
- int32 flags = (acceptsViews ? B_BITMAP_ACCEPTS_VIEWS : 0)
- | (needsContiguous ? B_BITMAP_IS_CONTIGUOUS : 0);
- InitObject(source->Bounds(), source->ColorSpace(), flags,
- source->BytesPerRow(), B_MAIN_SCREEN_ID);
- if (InitCheck() == B_OK)
- memcpy(Bits(), source->Bits(), BytesPerRow());
- }
-}
-
-// destructor
-/*! \brief Frees all resources associated with this object.
-*/
-BBitmap::~BBitmap()
-{
- CleanUp();
-}
-
-// unarchiving constructor
-/*! \brief Unarchives a bitmap from a BMessage.
- \param data The archive.
-*/
-BBitmap::BBitmap(BMessage *data)
- : BArchivable(data),
- fBasePtr(NULL),
- fSize(0),
- fColorSpace(B_NO_COLOR_SPACE),
- fBounds(0, 0, -1, -1),
- fBytesPerRow(0),
- fServerToken(-1),
- fToken(-1),
- fArea(-1),
- fOrigArea(-1),
- fFlags(0),
- fInitError(B_NO_INIT)
-{
- BRect bounds;
- data->FindRect("_frame", &bounds);
-
- color_space cspace;
- data->FindInt32("_cspace", (int32 *)&cspace);
-
- int32 flags = 0;
- data->FindInt32("_bmflags", &flags);
-
- int32 rowbytes = 0;
- data->FindInt32("_rowbytes", &rowbytes);
-
-flags |= B_BITMAP_NO_SERVER_LINK;
-flags &= ~B_BITMAP_ACCEPTS_VIEWS;
- InitObject(bounds, cspace, flags, rowbytes, B_MAIN_SCREEN_ID);
-
- if (data->HasData("_data", B_RAW_TYPE) && InitCheck() == B_OK) {
- ssize_t size = 0;
- const void *buffer;
- if (data->FindData("_data", B_RAW_TYPE, &buffer, &size) == B_OK)
- memcpy(fBasePtr, buffer, size);
- }
-
- if (fFlags & B_BITMAP_ACCEPTS_VIEWS) {
-// BArchivable *obj;
-// BMessage message;
-// int i = 0;
-//
-// while (data->FindMessage("_view", i++, &message) == B_OK) {
-// obj = instantiate_object(&message);
-// BView *view = dynamic_cast(obj);
-//
-// if (view)
-// AddChild(view);
-// }
- }
-}
-
-// Instantiate
-/*! \brief Instantiates a BBitmap from an archive.
- \param data The archive.
- \return A bitmap reconstructed from the archive or \c NULL, if an error
- occured.
-*/
-BArchivable *
-BBitmap::Instantiate(BMessage *data)
-{
- if (validate_instantiation(data, "BBitmap"))
- return new BBitmap(data);
-
- return NULL;
-}
-
-// Archive
-/*! \brief Archives the BBitmap object.
- \param data The archive.
- \param deep \c true, if child object shall be archived as well, \c false
- otherwise.
- \return \c B_OK, if everything went fine, an error code otherwise.
-*/
-status_t
-BBitmap::Archive(BMessage *data, bool deep) const
-{
- BArchivable::Archive(data, deep);
-
- data->AddRect("_frame", fBounds);
- data->AddInt32("_cspace", (int32)fColorSpace);
- data->AddInt32("_bmflags", fFlags);
- data->AddInt32("_rowbytes", fBytesPerRow);
-
- if (deep) {
- if (fFlags & B_BITMAP_ACCEPTS_VIEWS) {
-// BMessage views;
-// for (int32 i = 0; i < CountChildren(); i++) {
-// if (ChildAt(i)->Archive(&views, deep))
-// data->AddMessage("_views", &views);
-// }
- }
- // Note: R5 does not archive the data if B_BITMAP_IS_CONTIGNUOUS is
- // true and it does save all formats as B_RAW_TYPE and it does save
- // the data even if B_BITMAP_ACCEPTS_VIEWS is set (as opposed to
- // the BeBook)
-
- data->AddData("_data", B_RAW_TYPE, fBasePtr, fSize);
- }
-
- return B_OK;
-}
-
-// InitCheck
-/*! \brief Returns the result from the construction.
- \return \c B_OK, if the object is properly initialized, an error code
- otherwise.
-*/
-status_t
-BBitmap::InitCheck() const
-{
- return fInitError;
-}
-
-// IsValid
-/*! \brief Returns whether or not the BBitmap object is valid.
- \return \c true, if the object is properly initialized, \c false otherwise.
-*/
-bool
-BBitmap::IsValid() const
-{
- return (InitCheck() == B_OK);
-}
-
-// LockBits
-/*! \brief ???
-*/
-status_t
-BBitmap::LockBits(uint32 *state)
-{
- return B_ERROR;
-}
-
-// UnlockBits
-/*! \brief ???
-*/
-void
-BBitmap::UnlockBits()
-{
-}
-
-// Area
-/*! \brief Returns the ID of the area the bitmap data reside in.
- \return The ID of the area the bitmap data reside in.
-*/
-area_id
-BBitmap::Area() const
-{
- return fArea;
-}
-
-// Bits
-/*! \brief Returns the pointer to the bitmap data.
- \return The pointer to the bitmap data.
-*/
-void *
-BBitmap::Bits() const
-{
- return fBasePtr;
-}
-
-// BitsLength
-/*! \brief Returns the size of the bitmap data.
- \return The size of the bitmap data.
-*/
-int32
-BBitmap::BitsLength() const
-{
- return fSize;
-}
-
-// BytesPerRow
-/*! \brief Returns the number of bytes used to store a row of bitmap data.
[... truncated: 555 lines follow ...]
From axeld at mail.berlios.de Mon Jun 2 17:45:23 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Mon, 2 Jun 2008 17:45:23 +0200
Subject: [Haiku-commits] r25760 - haiku/trunk/docs/develop/kernel
Message-ID: <200806021545.m52FjNC9018181@sheep.berlios.de>
Author: axeld
Date: 2008-06-02 17:45:22 +0200 (Mon, 02 Jun 2008)
New Revision: 25760
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25760&view=rev
Added:
haiku/trunk/docs/develop/kernel/device_manager_introduction.html
Log:
An early version of an introduction to the new device manager. Will be expanded
more over the following days, and published on the website.
Comments welcome!
Added: haiku/trunk/docs/develop/kernel/device_manager_introduction.html
===================================================================
--- haiku/trunk/docs/develop/kernel/device_manager_introduction.html 2008-06-02 11:24:11 UTC (rev 25759)
+++ haiku/trunk/docs/develop/kernel/device_manager_introduction.html 2008-06-02 15:45:22 UTC (rev 25760)
@@ -0,0 +1,249 @@
+
+
+
+Introduction to Haiku's Device Driver Architecture
+
+This document tries to give you a short introduction into the new device
+manager, and how to write drivers for it. Haiku still supports the legacy
+device driver architecture introduced with BeOS.
+
+The new device driver architecture of Haiku is still a moving target,
+although most of its details are already specificed.
+
+
+1. The Basics
+
+The device manager functionality builds upon device_node objects.
+Every driver in the system publishes one or more of such nodes, building a
+tree of device nodes. This tree is in theory a dynamic representation of the
+current hardware devices in the system, but in practice will also contain
+implementation specific details; since every node comes with an API specific
+to that node, you'll find device nodes that only come with a number of support
+functions for a certain class of drivers.
+
+Structurally, a device_node is a set of a module, attributes,
+and resources, as well as a parent and children. At a minimum, a node must
+have a module, all other components are optional.
+
+TODO: picture of the device node tree
+
+When the system starts, there is only a root node registered. Only primary
+hardware busses register with the root node, such as PCI, and ISA on x86.
+Since the PCI bus is an intelligent bus, it knows what hardware is installed,
+and registers a child node for each device on the bus.
+
+Every driver can also publish a device in /dev for communication with
+userland applications. All drivers and devices are kernel modules.
+
+
+2. Exploring the Device Tree
+
+So how does it all work? When building the initial device tree, the system only
+explores a minimum of device drivers only, resulting in a tree that basically
+only shows the hardware found in the computer.
+
+Now, if the system requires disk access, it will scan the device file system
+for a driver that provides such functionality, in this case, it will look for
+drivers under "/dev/disk/". The device manager has a set of built-in rules for
+how to translate a device path into a device node, and vice versa: every node
+representing a device of an intelligent bus (such as PCI) will also contain
+device type information following the PCI definitions. In this case, the "disk"
+sub-path will translate into the PCI_mass_storage type, and hence, the
+device manager will then completely explore all device nodes of that type.
+
+It will also use that path information to only ask drivers that actually
+are in a matching module directory. In the above example of a disk driver, this
+would be either in "busses/scsi", "busses/ide", "drivers/disk", ...
+
+TODO: untyped/generic busses are not yet supported!
+
+
+3. Writing a Driver
+
+The device manager assumes the following API from a driver module:
+
+- supports_device()
+ Determines wether or not the driver supports a given parent device node,
+ that is the hardware device it represents (if any), and the API the node
+ exports.
+- register_device()
+ The driver should register its device node here. The parent driver is
+ always initialized at this point. When registering the node, the driver
+ can also attach certain I/O resources (like I/O ports, or memory ranges)
+ to the node -- the device manager will make sure that only one node can
+ claim these resources.
+- init_driver()
+ Any initialization necessary to get the driver going. For most drivers,
+ this will be reduced to the creation of a private data structure that is
+ going to be used for all of the following functions.
+- uninit_driver()
+ Uninitializes resources acquired by init_driver().
+- register_child_devices()
+ If the driver wants to register any child device nodes or to publish
+ any devices, it should do so here. This function is called only during
+ the initial registration process of the device node.
+- rescan_child_devices()
+ Is called whenever a manual rescan is triggered.
+- device_removed()
+ Is called when the device node is about to be unregistered when its
+ device is gone, for example when a USB device is unplugged.
+- suspend()
+ Enters different sleep modes.
+- resume()
+ Resumes a device from a previous sleep mode.
+
+To ensure that a module exports this API, it must end its module name
+with "driver_v1" to denote the version of the API it supports. Note that
+suspend() and resume() are currently never called, as Haiku has
+no power management implemented yet.
+
+If your driver can give the device it is attached to a nice name that can be
+presented to the user, it should add the B_DEVICE_PRETTY_NAME attribute
+to the device node.
+
The B_DEVICE_UNIQUE_ID should be used in case the device has a unique
+ID that can be used to identify it, and also differentiate it from other devices
+of the same model and vendor. This information will be added to the file system
+attributes of all devices published by your driver, so that user applications
+can identify, say, a USB printer no matter what USB slot it is attached to, and
+assign it additional data, like paper configuration, or recognize it as the
+default printer.
+If your driver implements an API that is used by a support or bus module, you
+will usually use the B_DEVICE_FIXED_CHILD attribute to specify exactly
+which child device node you will be talking to. If you support several child
+nodes, you may want to have a closer look at the section explaining
+how to write a bus driver.
+
+
+4. Publishing a Device
+
+To publish a device entry in the device file system under /dev, all your
+driver has to do is to call the
+
+ publish_device(device_node *node, const char *path,
+ const char *deviceModuleName);
+
+function the device manager module exports. The path is the path
+component that follows "/dev", for example "net/ipro1000/0". The
+deviceModuleName is the module exporting the device functionality.
+It should end with "device_v1" to show the device manager which protocol it
+supports. If the device node your device belongs to is removed, your device
+is removed automatically with it. On the other hand, you are allowed to
+unpublish the device at any point using the unpublish_device() function
+the device manager delivers for this.
+
+A device module must export the following API:
+
+- init_device()
+ This is called when the open() is called on this device for the first
+ time. You may want to create a private data structure that is passed on
+ to all subsequent calls of the open() function that your device
+ exports.
+- uninit_device()
+ Is called when the last file descriptor to the device had been closed.
+- device_removed()
+ When the device node your device belongs to is going to be removed,
+ you're notified about this in this function.
+- open()
+ Called whenever your device is opened.
+- close()
+
+- free()
+ Free the private data structure you allocated in open().
+- read()
+
+- write()
+
+- io()
+ This is a replacement for the read(), and write() calls,
+ and allows, among other things, for asynchronous I/O. This functionality
+ has not yet been implemented, though (see below).
+- control()
+
+- select()
+
+- deselect()
+
+
+
+
+
+
+A bus driver is a driver that represents a bus where one or more arbitrary
+devices can be attached to.
+
+There are two basic types of busses: intelligent busses like PCI or USB that
+know a lot about the devices attached to it, like a generic device type, as
+well as device and vendor ID information, and simple untyped/generic busses that
+either have not all the information (like device type) or don't even know what
+and if any devices are attached. The device manager has been written in such a
+way that device exploration makes use of additional information the bus can
+provide in order to find a responsible device driver faster, and with less
+overhead.
+
+5.1. Writing an Intelligent Bus Driver
+
+If your bus knows what type of device is attached to, and also has vendor and
+device ID information about that device, it is considered to be an intelligent
+bus. The bus driver is supposed to have one parent node representing the bus,
+and to create a child node for each device attached to the bus.
+
+The additional information you have about the devices are attached to the
+device node in the following attributes:
+
+- B_DEVICE_VENDOR_ID
+ The vendor ID - this ID has only to be valid in the namespace of your
+ bus.
+- B_DEVICE_ID
+ The device ID.
+- B_DEVICE_TYPE
+ The device type as defined by the PCI class base information.
+- B_DEVICE_SUB_TYPE
+ The device sub type as defined by the PCI sub class information.
+- B_DEVICE_INTERFACE
+ The device interface type as defined by the PCI class API information.
+
+
+You can use the B_DEVICE_FLAGS attribute to define how the device
+manager finds the children of the devices you exported. For this kind of bus
+drivers, you will usually only want to specify B_FIND_CHILD_ON_DEMAND
+here, which causes the driver only to be searched when the system asks for it.
+
+
+5.2. Writing a Simple Bus Driver
+
+TODO: support for these drivers is still missing!
+
+
+6. Open Issues
+
+While most of the new device manager is fledged out, there are some areas that
+could use improvements or are problematic under certain requirements. Also, some
+parts just haven't been written yet.
+
+6.1. generic/simple busses
+
+6.2. Unpublishing
+
+6.3. listdev functionality
+
+The "listdev" command has been removed from the image, and it is currently not
+functional anymore.
+
+6.4. Versioning
+
+The way the device manager works, it makes versioning of modules (which are
+supposed to be one of the strong points of the module system) much harder or
+even impossible. While the device manager could introduce a new API and could
+translate between a "driver_v1", and a "driver_v2" API on the fly, it's not
+yet possible for a PCI sub module to do the same thing.
+
+Proposed Solution: Add attribute B_DEVICE_ALTERNATE_VERSION
+that specifies alternate versions of the module API this device node supports.
+We would then need a request_version() or set_version() function
+(to be called from supports_device()) that allows to specify the version
+of the parent node this device node wants to talk to.
+
+6.5. Unregistering Nodes
+
+
+
From aldeck at mail.berlios.de Mon Jun 2 19:08:44 2008
From: aldeck at mail.berlios.de (aldeck at BerliOS)
Date: Mon, 2 Jun 2008 19:08:44 +0200
Subject: [Haiku-commits] r25761 - haiku/trunk/src/preferences/screensaver
Message-ID: <200806021708.m52H8ipP019364@sheep.berlios.de>
Author: aldeck
Date: 2008-06-02 19:08:42 +0200 (Mon, 02 Jun 2008)
New Revision: 25761
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25761&view=rev
Modified:
haiku/trunk/src/preferences/screensaver/ScreenSaverWindow.cpp
Log:
- Decouple ModulesView::SaveState() from ModulesView::_CloseSaver() and thus ModulesView::DetachedFromWindow(). When called by BWindow destructor,
the needed derived member fSettings was already destroyed by the derived ScreenSaverWindow destructor. See backtrace in #2287
Fixes #2287
Modified: haiku/trunk/src/preferences/screensaver/ScreenSaverWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/screensaver/ScreenSaverWindow.cpp 2008-06-02 15:45:22 UTC (rev 25760)
+++ haiku/trunk/src/preferences/screensaver/ScreenSaverWindow.cpp 2008-06-02 17:08:42 UTC (rev 25761)
@@ -351,6 +351,7 @@
else
fSettings.SetModuleName(item->Text());
+ SaveState();
_CloseSaver();
_OpenSaver();
break;
@@ -469,9 +470,7 @@
fSaverRunner->Quit();
if (saver != NULL)
saver->StopConfig();
-
- SaveState();
-
+
delete view;
delete fSettingsView;
delete fSaverRunner;
From stippi at mail.berlios.de Mon Jun 2 20:18:56 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Mon, 2 Jun 2008 20:18:56 +0200
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
Message-ID: <200806021818.m52IIuoZ028545@sheep.berlios.de>
Author: stippi
Date: 2008-06-02 20:18:56 +0200 (Mon, 02 Jun 2008)
New Revision: 25762
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25762&view=rev
Modified:
haiku/trunk/src/kits/interface/GraphicsDefs.cpp
Log:
Resolved TODO and set the flags for the kind of additional
bitmap support (bitmaps support child views or BViews can
draw them)
Modified: haiku/trunk/src/kits/interface/GraphicsDefs.cpp
===================================================================
--- haiku/trunk/src/kits/interface/GraphicsDefs.cpp 2008-06-02 17:08:42 UTC (rev 25761)
+++ haiku/trunk/src/kits/interface/GraphicsDefs.cpp 2008-06-02 18:18:56 UTC (rev 25762)
@@ -144,17 +144,21 @@
bool
bitmaps_support_space(color_space space, uint32 *supportFlags)
{
- // TODO: fill supportFlags with the supported flags:
- // - B_VIEWS_SUPPORT_DRAW_BITMAP
- // - B_BITMAPS_SUPPORT_ATTACHED_VIEWS
- bool result = false;
+ bool result = true;
switch (space) {
- // supported
+ // supported, also for drawing and for attaching BViews
case B_RGB32: case B_RGBA32: case B_RGB24:
case B_RGB32_BIG: case B_RGBA32_BIG: case B_RGB24_BIG:
case B_RGB16: case B_RGB15: case B_RGBA15:
case B_RGB16_BIG: case B_RGB15_BIG: case B_RGBA15_BIG:
case B_CMAP8: case B_GRAY8: case B_GRAY1:
+ if (supportFlags) {
+ *supportFlags = 0;
+ *supportFlags |= B_VIEWS_SUPPORT_DRAW_BITMAP;
+ *supportFlags |= B_BITMAPS_SUPPORT_ATTACHED_VIEWS;
+ }
+ break;
+ // supported, but cannot draw
case B_YCbCr422: case B_YCbCr411: case B_YCbCr444: case B_YCbCr420:
case B_YUV422: case B_YUV411: case B_YUV444: case B_YUV420:
case B_UVL24: case B_UVL32: case B_UVLA32:
@@ -163,11 +167,11 @@
case B_HSV24: case B_HSV32: case B_HSVA32:
case B_HLS24: case B_HLS32: case B_HLSA32:
case B_CMY24: case B_CMY32: case B_CMYA32: case B_CMYK32:
- result = true;
break;
// unsupported
case B_NO_COLOR_SPACE:
case B_YUV9: case B_YUV12:
+ result = false;
break;
}
return result;
From stippi at mail.berlios.de Mon Jun 2 20:21:55 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Mon, 2 Jun 2008 20:21:55 +0200
Subject: [Haiku-commits] r25763 - in
haiku/trunk/src/apps/mediaplayer/media_node_framework: . audio
Message-ID: <200806021821.m52ILt9N028952@sheep.berlios.de>
Author: stippi
Date: 2008-06-02 20:21:55 +0200 (Mon, 02 Jun 2008)
New Revision: 25763
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25763&view=rev
Modified:
haiku/trunk/src/apps/mediaplayer/media_node_framework/PlaybackManager.cpp
haiku/trunk/src/apps/mediaplayer/media_node_framework/audio/AudioProducer.cpp
Log:
Small code cleanups.
Modified: haiku/trunk/src/apps/mediaplayer/media_node_framework/PlaybackManager.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/media_node_framework/PlaybackManager.cpp 2008-06-02 18:18:56 UTC (rev 25762)
+++ haiku/trunk/src/apps/mediaplayer/media_node_framework/PlaybackManager.cpp 2008-06-02 18:21:55 UTC (rev 25763)
@@ -713,10 +713,12 @@
int64 xEndFrame;
int32 playingDirection;
GetPlaylistFrameInterval(startFrame, endFrame, xStartFrame, xEndFrame,
- playingDirection);
+ playingDirection);
// Calculate the performance time interval end/length.
- endTime = min(endTime, TimeForFrame(endFrame));
+ bigtime_t endTimeForFrame = TimeForFrame(endFrame);
+ endTime = min(endTime, endTimeForFrame);
bigtime_t intervalLength = endTime - startTime;
+
// Finally determine the time bounds for the Playlist interval (depending
// on the playing direction).
switch (playingDirection) {
@@ -780,8 +782,8 @@
return 0;
}
int64 frame = (int64)(((double)time - info->activation_time)
- * (double)fFrameRate * info->speed / 1000000.0)
- + info->activation_frame;
+ * (double)fFrameRate * info->speed / 1000000.0)
+ + info->activation_frame;
if (TimeForFrame(frame) > time)
frame--;
else if (TimeForFrame(frame + 1) <= time)
Modified: haiku/trunk/src/apps/mediaplayer/media_node_framework/audio/AudioProducer.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/media_node_framework/audio/AudioProducer.cpp 2008-06-02 18:18:56 UTC (rev 25762)
+++ haiku/trunk/src/apps/mediaplayer/media_node_framework/audio/AudioProducer.cpp 2008-06-02 18:21:55 UTC (rev 25763)
@@ -711,10 +711,10 @@
* 1000000.0 / double(fOutput.format.u.raw_audio.frame_rate));
// fill in data from audio supplier
- size_t frameCount = numSamples / fOutput.format.u.raw_audio.channel_count;
+ int64 frameCount = numSamples / fOutput.format.u.raw_audio.channel_count;
bigtime_t startTime = performanceTime;
bigtime_t endTime = bigtime_t(double(fFramesSent + frameCount)
- * 1000000.0 / double(fOutput.format.u.raw_audio.frame_rate));
+ * 1000000.0 / fOutput.format.u.raw_audio.frame_rate);
if (!fSupplier || fSupplier->InitCheck() != B_OK
|| fSupplier->GetFrames(buffer->Data(), frameCount, startTime,
From stippi at mail.berlios.de Mon Jun 2 20:25:31 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Mon, 2 Jun 2008 20:25:31 +0200
Subject: [Haiku-commits] r25764 - in
haiku/trunk/src/apps/mediaplayer/media_node_framework: . video
Message-ID: <200806021825.m52IPVv9029235@sheep.berlios.de>
Author: stippi
Date: 2008-06-02 20:25:31 +0200 (Mon, 02 Jun 2008)
New Revision: 25764
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25764&view=rev
Modified:
haiku/trunk/src/apps/mediaplayer/media_node_framework/NodeManager.cpp
haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp
haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.h
Log:
Do not reference bitmap color spaces directly anymore, but use
bitmaps_support_space() interface kit function. First try to
use overlays, if that fails, try again without overlays. The
NodeManager makes sure to fall back to B_RGB32 if the given
mode is not supported for drawing bitmaps in by BViews. Thanks,
Axel, for the suggestion!
Modified: haiku/trunk/src/apps/mediaplayer/media_node_framework/NodeManager.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/media_node_framework/NodeManager.cpp 2008-06-02 18:21:55 UTC (rev 25763)
+++ haiku/trunk/src/apps/mediaplayer/media_node_framework/NodeManager.cpp 2008-06-02 18:25:31 UTC (rev 25764)
@@ -358,15 +358,29 @@
};
format.u.raw_video = videoFormat;
- // connect video producer to consumer (B_YCbCr422)
+ // connect video producer to consumer (hopefully using overlays)
+ fVideoConsumer->SetTryOverlay(true);
fStatus = fMediaRoster->Connect(videoOutput.source, videoInput.destination,
&format, &videoOutput, &videoInput);
- if (fStatus != B_OK && preferredVideoFormat != B_RGB32) {
+ if (fStatus != B_OK) {
print_error("Can't connect the video source to the video window... "
- "trying B_RGB32", fStatus);
- format.u.raw_video.display.format = B_RGB32;
- // connect video producer to consumer (B_RGB32)
+ "trying without overlays", fStatus);
+
+ uint32 flags = 0;
+ bool supported = bitmaps_support_space(
+ format.u.raw_video.display.format, &flags);
+ if (!supported || (flags & B_VIEWS_SUPPORT_DRAW_BITMAP) == 0) {
+ // cannot create bitmaps with such a color space
+ // or BViews don't support drawing it, fallback to B_RGB32
+ format.u.raw_video.display.format = B_RGB32;
+ printf("NodeManager::_SetupVideoNodes() - falling back to "
+ "B_RGB32\n");
+ }
+
+ fVideoConsumer->SetTryOverlay(false);
+ // connect video producer to consumer (not using overlays and using
+ // a colorspace that BViews support drawing)
fStatus = fMediaRoster->Connect(videoOutput.source,
videoInput.destination, &format, &videoOutput, &videoInput);
}
Modified: haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp 2008-06-02 18:21:55 UTC (rev 25763)
+++ haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp 2008-06-02 18:25:31 UTC (rev 25764)
@@ -7,20 +7,19 @@
*/
#include "VideoConsumer.h"
+#include
#include
-#include
+#include
+#include
+
#include
-#include
-#include
+#include
#include
-#include
#include
#include
-#include
#include
#include
#include
-#include
#include "NodeManager.h"
#include "VideoTarget.h"
@@ -61,7 +60,8 @@
fManager(manager),
fTargetLock(),
fTarget(target),
- fTargetBufferIndex(-1)
+ fTargetBufferIndex(-1),
+ fTryOverlay(true)
{
FUNCTION("VideoConsumer::VideoConsumer\n");
@@ -219,14 +219,13 @@
ERROR("VideoConsumer::CreateBuffers - ERROR CREATING BUFFER GROUP\n");
return status;
}
-
+
// and attach the bitmaps to the buffer group
BRect bounds(0, 0, width - 1, height - 1);
for (uint32 i = 0; i < kBufferCount; i++) {
// figure out the bitmap creation flags
uint32 bitmapFlags = 0;
- if (colorSpace == B_YCbCr420 || colorSpace == B_YCbCr411
- || colorSpace == B_YCbCr422 || colorSpace == B_YCbCr444) {
+ if (fTryOverlay) {
// try to use hardware overlay
bitmapFlags |= B_BITMAP_WILL_OVERLAY;
if (i == 0)
@@ -338,6 +337,13 @@
}
+void
+VideoConsumer::SetTryOverlay(bool tryOverlay)
+{
+ fTryOverlay = tryOverlay;
+}
+
+
status_t
VideoConsumer::Connected(const media_source& producer,
const media_destination& where, const media_format& format,
@@ -429,23 +435,31 @@
return B_MEDIA_BAD_FORMAT;
}
- if (format->u.raw_video.display.format != B_YCbCr444 &&
- format->u.raw_video.display.format != B_YCbCr422 &&
- format->u.raw_video.display.format != B_RGB32 &&
- format->u.raw_video.display.format != B_RGB16 &&
- format->u.raw_video.display.format != B_RGB15 &&
- format->u.raw_video.display.format != B_GRAY8 &&
- format->u.raw_video.display.format
+ if (format->u.raw_video.display.format
!= media_raw_video_format::wildcard.display.format) {
- ERROR("AcceptFormat - not a format we know about!\n");
- return B_MEDIA_BAD_FORMAT;
+ uint32 flags = 0;
+ bool supported = bitmaps_support_space(
+ format->u.raw_video.display.format, &flags);
+ if (!supported) {
+ // cannot create bitmaps with such a color space
+ ERROR("AcceptFormat - unsupported color space for BBitmaps!\n");
+ return B_MEDIA_BAD_FORMAT;
+ }
+ if (!fTryOverlay && (flags & B_VIEWS_SUPPORT_DRAW_BITMAP) == 0) {
+ // BViews do not support drawing such a bitmap
+ ERROR("AcceptFormat - BViews cannot draw bitmaps in given "
+ "colorspace!\n");
+ return B_MEDIA_BAD_FORMAT;
+ }
}
-
- char string[256];
- string[0] = 0;
- string_for_format(*format, string, 256);
- FUNCTION("VideoConsumer::AcceptFormat: %s\n", string);
+ #ifdef TRACE_VIDEO_CONSUMER
+ char string[256];
+ string[0] = 0;
+ string_for_format(*format, string, 256);
+ FUNCTION("VideoConsumer::AcceptFormat: %s\n", string);
+ #endif
+
return B_OK;
}
Modified: haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.h
===================================================================
--- haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.h 2008-06-02 18:21:55 UTC (rev 25763)
+++ haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.h 2008-06-02 18:25:31 UTC (rev 25764)
@@ -100,7 +100,8 @@
void DeleteBuffers();
void SetTarget(VideoTarget* target);
-
+ void SetTryOverlay(bool tryOverlay);
+
private:
uint32 fInternalID;
BMediaAddOn* fAddOn;
@@ -119,6 +120,8 @@
BLocker fTargetLock; // locks the following variable
VideoTarget* volatile fTarget;
int32 fTargetBufferIndex;
+
+ bool fTryOverlay;
};
#endif // VIDEO_CONSUMER_H
From stippi at mail.berlios.de Mon Jun 2 20:28:31 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Mon, 2 Jun 2008 20:28:31 +0200
Subject: [Haiku-commits] r25765 - in haiku/trunk/src/apps/mediaplayer: .
supplier
Message-ID: <200806021828.m52ISVdk029489@sheep.berlios.de>
Author: stippi
Date: 2008-06-02 20:28:31 +0200 (Mon, 02 Jun 2008)
New Revision: 25765
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25765&view=rev
Modified:
haiku/trunk/src/apps/mediaplayer/Controller.cpp
haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp
haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.h
haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp
Log:
I tracked down a problem with a specific clip I have here.
In the end, the problem was that no codec was installed
for it, but I fixed a bunch of issues on the way to find
out. Now the controller will not rely on the number
of audio and video tracks, but on the fact that it could
instantiate suppliers at all. Made the MediaTrackVideoSupplier
return an init error. Should be replicated for the
MediaTrackAudioSupplier.
Modified: haiku/trunk/src/apps/mediaplayer/Controller.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/Controller.cpp 2008-06-02 18:25:31 UTC (rev 25764)
+++ haiku/trunk/src/apps/mediaplayer/Controller.cpp 2008-06-02 18:28:31 UTC (rev 25765)
@@ -230,12 +230,6 @@
}
}
- if (AudioTrackCount() == 0 && VideoTrackCount() == 0) {
- printf("Controller::SetTo: no audio or video tracks found\n");
- _NotifyFileChanged();
- return B_MEDIA_NO_HANDLER;
- }
-
printf("Controller::SetTo: %d audio track, %d video track\n",
AudioTrackCount(), VideoTrackCount());
@@ -245,6 +239,15 @@
SelectAudioTrack(0);
SelectVideoTrack(0);
+ if (fAudioTrackSupplier == NULL && fVideoTrackSupplier == NULL) {
+ printf("Controller::SetTo: no audio or video tracks found or "
+ "no decoders\n");
+ _NotifyFileChanged();
+ delete fMediaFile;
+ fMediaFile = NULL;
+ return B_MEDIA_NO_HANDLER;
+ }
+
// prevent blocking the creation of new overlay buffers
fVideoView->DisableOverlay();
@@ -350,13 +353,25 @@
if (!track)
return B_ERROR;
+ status_t initStatus;
ObjectDeleter deleter(fVideoTrackSupplier);
- fVideoTrackSupplier = new MediaTrackVideoSupplier(track);
+ fVideoTrackSupplier = new MediaTrackVideoSupplier(track, initStatus);
+ if (initStatus < B_OK) {
+ delete fVideoTrackSupplier;
+ fVideoTrackSupplier = NULL;
+ return initStatus;
+ }
bigtime_t a = fAudioTrackSupplier ? fAudioTrackSupplier->Duration() : 0;
bigtime_t v = fVideoTrackSupplier->Duration();
fDuration = max_c(a, v);
fVideoFrameRate = fVideoTrackSupplier->Format().u.raw_video.field_rate;
+ if (fVideoFrameRate <= 0.0) {
+ printf("Controller::SelectVideoTrack(%d) - invalid video frame rate: %.1f\n", n,
+ fVideoFrameRate);
+ fVideoFrameRate = 25.0;
+ }
+
DurationChanged();
// TODO: notify duration changed!
Modified: haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp 2008-06-02 18:25:31 UTC (rev 25764)
+++ haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp 2008-06-02 18:28:31 UTC (rev 25765)
@@ -27,7 +27,8 @@
// constructor
-MediaTrackVideoSupplier::MediaTrackVideoSupplier(BMediaTrack* track)
+MediaTrackVideoSupplier::MediaTrackVideoSupplier(BMediaTrack* track,
+ status_t& initStatus)
: VideoTrackSupplier()
, fVideoTrack(track)
@@ -40,7 +41,7 @@
return;
}
- _SwitchFormat(B_NO_COLOR_SPACE, 0);
+ initStatus = _SwitchFormat(B_NO_COLOR_SPACE, 0);
fDuration = fVideoTrack->Duration();
@@ -354,7 +355,19 @@
if (ret < B_OK) {
printf("MediaTrackVideoSupplier::_SwitchFormat() - "
- "fVideoTrack->DecodedFormat(): %s\n", strerror(ret));
+ "fVideoTrack->DecodedFormat(): %s - retrying with B_RGB32\n",
+ strerror(ret));
+ fFormat.u.raw_video.display.format = format;
+ minBytesPerRow = width * 4;
+ fFormat.u.raw_video.display.bytes_per_row = max_c(minBytesPerRow,
+ bytesPerRow);
+
+ ret = fVideoTrack->DecodedFormat(&fFormat);
+ if (ret < B_OK) {
+ printf("MediaTrackVideoSupplier::_SwitchFormat() - "
+ "fVideoTrack->DecodedFormat(): %s - giving up\n",
+ strerror(ret));
+ }
return ret;
}
Modified: haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.h
===================================================================
--- haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.h 2008-06-02 18:25:31 UTC (rev 25764)
+++ haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.h 2008-06-02 18:28:31 UTC (rev 25765)
@@ -16,7 +16,8 @@
class MediaTrackVideoSupplier : public VideoTrackSupplier {
public:
- MediaTrackVideoSupplier(BMediaTrack* track);
+ MediaTrackVideoSupplier(BMediaTrack* track,
+ status_t& initStatus);
virtual ~MediaTrackVideoSupplier();
virtual const media_format& Format() const;
Modified: haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp 2008-06-02 18:25:31 UTC (rev 25764)
+++ haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp 2008-06-02 18:28:31 UTC (rev 25765)
@@ -12,18 +12,20 @@
#include
#include
+#include "AudioTrackSupplier.h"
#include "AudioAdapter.h"
-#include "AudioTrackSupplier.h"
#include "PlaybackManager.h"
using std::nothrow;
-//#define TRACE_PROXY_AUDIO_SUPPLIER
+#define TRACE_PROXY_AUDIO_SUPPLIER
#ifdef TRACE_PROXY_AUDIO_SUPPLIER
# define TRACE(x...) printf("ProxyAudioSupplier::"); printf(x)
+# define ERROR(x...) fprintf(stderr, "ProxyAudioSupplier::"); fprintf(stderr, x)
#else
# define TRACE(x...)
+# define ERROR(x...) fprintf(stderr, "ProxyAudioSupplier::"); fprintf(stderr, x)
#endif
@@ -87,9 +89,18 @@
interval->start_time, interval->end_time,
interval->x_start_time, interval->x_end_time,
interval->speed);
+ if (intervalStartTime == interval->end_time) {
+ delete interval;
+ error = B_ERROR;
+ sLastInvalidStartTime = intervalStartTime;
+ ERROR("GetFrames() - zero duration audio interval! start "
+ "time: %lld\n", intervalStartTime);
+ break;
+ }
if (!playingIntervals.AddItem(interval)) {
delete interval;
error = B_NO_MEMORY;
+ ERROR("GetFrames() - Out of memory\n");
break;
}
intervalStartTime = interval->end_time;
@@ -102,6 +113,9 @@
BAutolock _(fSupplierLock);
+ if (!fSupplier)
+ return B_ERROR;
+
// retrieve the audio data for each interval.
int64 framesRead = 0;
while (!playingIntervals.IsEmpty()) {
From anevilyak at gmail.com Mon Jun 2 20:40:28 2008
From: anevilyak at gmail.com (Rene Gollent)
Date: Mon, 2 Jun 2008 13:40:28 -0500
Subject: [Haiku-commits] r25765 - in haiku/trunk/src/apps/mediaplayer: .
supplier
In-Reply-To: <200806021828.m52ISVdk029489@sheep.berlios.de>
References: <200806021828.m52ISVdk029489@sheep.berlios.de>
Message-ID:
Hi Stephan,
Was the line about sLastInvalidStartTime intended to be there? It
throws an error about being undeclared, and I see no other use of that
variable in the file.
Regards,
Rene
On Mon, Jun 2, 2008 at 1:28 PM, stippi at BerliOS
wrote:
> Author: stippi
> Date: 2008-06-02 20:28:31 +0200 (Mon, 02 Jun 2008)
> New Revision: 25765
> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25765&view=rev
>
> Modified:
> haiku/trunk/src/apps/mediaplayer/Controller.cpp
> haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp
> haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.h
> haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp
> Log:
> I tracked down a problem with a specific clip I have here.
> In the end, the problem was that no codec was installed
> for it, but I fixed a bunch of issues on the way to find
> out. Now the controller will not rely on the number
> of audio and video tracks, but on the fact that it could
> instantiate suppliers at all. Made the MediaTrackVideoSupplier
> return an init error. Should be replicated for the
> MediaTrackAudioSupplier.
>
>
> Modified: haiku/trunk/src/apps/mediaplayer/Controller.cpp
> ===================================================================
> --- haiku/trunk/src/apps/mediaplayer/Controller.cpp 2008-06-02 18:25:31 UTC (rev 25764)
> +++ haiku/trunk/src/apps/mediaplayer/Controller.cpp 2008-06-02 18:28:31 UTC (rev 25765)
> @@ -230,12 +230,6 @@
> }
> }
>
> - if (AudioTrackCount() == 0 && VideoTrackCount() == 0) {
> - printf("Controller::SetTo: no audio or video tracks found\n");
> - _NotifyFileChanged();
> - return B_MEDIA_NO_HANDLER;
> - }
> -
> printf("Controller::SetTo: %d audio track, %d video track\n",
> AudioTrackCount(), VideoTrackCount());
>
> @@ -245,6 +239,15 @@
> SelectAudioTrack(0);
> SelectVideoTrack(0);
>
> + if (fAudioTrackSupplier == NULL && fVideoTrackSupplier == NULL) {
> + printf("Controller::SetTo: no audio or video tracks found or "
> + "no decoders\n");
> + _NotifyFileChanged();
> + delete fMediaFile;
> + fMediaFile = NULL;
> + return B_MEDIA_NO_HANDLER;
> + }
> +
> // prevent blocking the creation of new overlay buffers
> fVideoView->DisableOverlay();
>
> @@ -350,13 +353,25 @@
> if (!track)
> return B_ERROR;
>
> + status_t initStatus;
> ObjectDeleter deleter(fVideoTrackSupplier);
> - fVideoTrackSupplier = new MediaTrackVideoSupplier(track);
> + fVideoTrackSupplier = new MediaTrackVideoSupplier(track, initStatus);
> + if (initStatus < B_OK) {
> + delete fVideoTrackSupplier;
> + fVideoTrackSupplier = NULL;
> + return initStatus;
> + }
>
> bigtime_t a = fAudioTrackSupplier ? fAudioTrackSupplier->Duration() : 0;
> bigtime_t v = fVideoTrackSupplier->Duration();
> fDuration = max_c(a, v);
> fVideoFrameRate = fVideoTrackSupplier->Format().u.raw_video.field_rate;
> + if (fVideoFrameRate <= 0.0) {
> + printf("Controller::SelectVideoTrack(%d) - invalid video frame rate: %.1f\n", n,
> + fVideoFrameRate);
> + fVideoFrameRate = 25.0;
> + }
> +
> DurationChanged();
> // TODO: notify duration changed!
>
>
> Modified: haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp
> ===================================================================
> --- haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp 2008-06-02 18:25:31 UTC (rev 25764)
> +++ haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp 2008-06-02 18:28:31 UTC (rev 25765)
> @@ -27,7 +27,8 @@
>
>
> // constructor
> -MediaTrackVideoSupplier::MediaTrackVideoSupplier(BMediaTrack* track)
> +MediaTrackVideoSupplier::MediaTrackVideoSupplier(BMediaTrack* track,
> + status_t& initStatus)
> : VideoTrackSupplier()
> , fVideoTrack(track)
>
> @@ -40,7 +41,7 @@
> return;
> }
>
> - _SwitchFormat(B_NO_COLOR_SPACE, 0);
> + initStatus = _SwitchFormat(B_NO_COLOR_SPACE, 0);
>
> fDuration = fVideoTrack->Duration();
>
> @@ -354,7 +355,19 @@
>
> if (ret < B_OK) {
> printf("MediaTrackVideoSupplier::_SwitchFormat() - "
> - "fVideoTrack->DecodedFormat(): %s\n", strerror(ret));
> + "fVideoTrack->DecodedFormat(): %s - retrying with B_RGB32\n",
> + strerror(ret));
> + fFormat.u.raw_video.display.format = format;
> + minBytesPerRow = width * 4;
> + fFormat.u.raw_video.display.bytes_per_row = max_c(minBytesPerRow,
> + bytesPerRow);
> +
> + ret = fVideoTrack->DecodedFormat(&fFormat);
> + if (ret < B_OK) {
> + printf("MediaTrackVideoSupplier::_SwitchFormat() - "
> + "fVideoTrack->DecodedFormat(): %s - giving up\n",
> + strerror(ret));
> + }
> return ret;
> }
>
>
> Modified: haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.h
> ===================================================================
> --- haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.h 2008-06-02 18:25:31 UTC (rev 25764)
> +++ haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.h 2008-06-02 18:28:31 UTC (rev 25765)
> @@ -16,7 +16,8 @@
>
> class MediaTrackVideoSupplier : public VideoTrackSupplier {
> public:
> - MediaTrackVideoSupplier(BMediaTrack* track);
> + MediaTrackVideoSupplier(BMediaTrack* track,
> + status_t& initStatus);
> virtual ~MediaTrackVideoSupplier();
>
> virtual const media_format& Format() const;
>
> Modified: haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp
> ===================================================================
> --- haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp 2008-06-02 18:25:31 UTC (rev 25764)
> +++ haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp 2008-06-02 18:28:31 UTC (rev 25765)
> @@ -12,18 +12,20 @@
> #include
> #include
>
> +#include "AudioTrackSupplier.h"
> #include "AudioAdapter.h"
> -#include "AudioTrackSupplier.h"
> #include "PlaybackManager.h"
>
> using std::nothrow;
>
>
> -//#define TRACE_PROXY_AUDIO_SUPPLIER
> +#define TRACE_PROXY_AUDIO_SUPPLIER
> #ifdef TRACE_PROXY_AUDIO_SUPPLIER
> # define TRACE(x...) printf("ProxyAudioSupplier::"); printf(x)
> +# define ERROR(x...) fprintf(stderr, "ProxyAudioSupplier::"); fprintf(stderr, x)
> #else
> # define TRACE(x...)
> +# define ERROR(x...) fprintf(stderr, "ProxyAudioSupplier::"); fprintf(stderr, x)
> #endif
>
>
> @@ -87,9 +89,18 @@
> interval->start_time, interval->end_time,
> interval->x_start_time, interval->x_end_time,
> interval->speed);
> + if (intervalStartTime == interval->end_time) {
> + delete interval;
> + error = B_ERROR;
> + sLastInvalidStartTime = intervalStartTime;
> + ERROR("GetFrames() - zero duration audio interval! start "
> + "time: %lld\n", intervalStartTime);
> + break;
> + }
> if (!playingIntervals.AddItem(interval)) {
> delete interval;
> error = B_NO_MEMORY;
> + ERROR("GetFrames() - Out of memory\n");
> break;
> }
> intervalStartTime = interval->end_time;
> @@ -102,6 +113,9 @@
>
> BAutolock _(fSupplierLock);
>
> + if (!fSupplier)
> + return B_ERROR;
> +
> // retrieve the audio data for each interval.
> int64 framesRead = 0;
> while (!playingIntervals.IsEmpty()) {
>
> _______________________________________________
> Haiku-commits mailing list
> Haiku-commits at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/haiku-commits
>
From stippi at mail.berlios.de Mon Jun 2 20:46:39 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Mon, 2 Jun 2008 20:46:39 +0200
Subject: [Haiku-commits] r25766 - haiku/trunk/src/apps/mediaplayer/supplier
Message-ID: <200806021846.m52Ikdc8031357@sheep.berlios.de>
Author: stippi
Date: 2008-06-02 20:46:38 +0200 (Mon, 02 Jun 2008)
New Revision: 25766
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25766&view=rev
Modified:
haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp
Log:
Accidentally left tracing on...
Modified: haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp 2008-06-02 18:28:31 UTC (rev 25765)
+++ haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp 2008-06-02 18:46:38 UTC (rev 25766)
@@ -19,7 +19,7 @@
using std::nothrow;
-#define TRACE_PROXY_AUDIO_SUPPLIER
+//#define TRACE_PROXY_AUDIO_SUPPLIER
#ifdef TRACE_PROXY_AUDIO_SUPPLIER
# define TRACE(x...) printf("ProxyAudioSupplier::"); printf(x)
# define ERROR(x...) fprintf(stderr, "ProxyAudioSupplier::"); fprintf(stderr, x)
From stippi at mail.berlios.de Mon Jun 2 20:50:42 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Mon, 2 Jun 2008 20:50:42 +0200
Subject: [Haiku-commits] r25767 - haiku/trunk/src/apps/mediaplayer/supplier
Message-ID: <200806021850.m52IogkT031994@sheep.berlios.de>
Author: stippi
Date: 2008-06-02 20:50:42 +0200 (Mon, 02 Jun 2008)
New Revision: 25767
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25767&view=rev
Modified:
haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp
Log:
And now it should even compile again! Sorry about that, forgot to
remove the debug output completely.
Modified: haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp 2008-06-02 18:46:38 UTC (rev 25766)
+++ haiku/trunk/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp 2008-06-02 18:50:42 UTC (rev 25767)
@@ -92,7 +92,6 @@
if (intervalStartTime == interval->end_time) {
delete interval;
error = B_ERROR;
- sLastInvalidStartTime = intervalStartTime;
ERROR("GetFrames() - zero duration audio interval! start "
"time: %lld\n", intervalStartTime);
break;
From superstippi at gmx.de Mon Jun 2 20:51:21 2008
From: superstippi at gmx.de (Stephan Assmus)
Date: Mon, 02 Jun 2008 20:51:21 +0200
Subject: [Haiku-commits] r25765 - in haiku/trunk/src/apps/mediaplayer:
. supplier
In-Reply-To:
References: <200806021828.m52ISVdk029489@sheep.berlios.de>
Message-ID: <20080602185121.33540@gmx.net>
-------- Original-Nachricht --------
> Datum: Mon, 2 Jun 2008 13:40:28 -0500
> Von: "Rene Gollent"
> An: "SVN commits to the Haiku source repository"
> Betreff: Re: [Haiku-commits] r25765 - in haiku/trunk/src/apps/mediaplayer: . supplier
> Hi Stephan,
>
> Was the line about sLastInvalidStartTime intended to be there? It
> throws an error about being undeclared, and I see no other use of that
> variable in the file.
Sorry about that... :-\
Best regards,
-Stephan
From mmlr at mlotz.ch Mon Jun 2 20:57:40 2008
From: mmlr at mlotz.ch (Michael Lotz)
Date: Mon, 02 Jun 2008 20:57:40 +0200
Subject: [Haiku-commits]
=?windows-1252?q?r25752_-_in_haiku/trunk=3A_heade?=
=?windows-1252?q?rs/os/drivers_headers/private/kernel__headers/private/sy?=
=?windows-1252?q?stem_src/add-ons/kernel/bus=5Fmanagers/ide_src/add-ons/k?=
=?windows-1252?q?ernel/bus=5Fmanagers/pci/arch/x86_src/add-ons/kernel/bus?=
=?windows-1252?q?=5Fmanagers/ps2_src/add-ons/kernel/bus=5Fmanagers/scsi_s?=
=?windows-1252?q?rc/add-ons/kernel/busses/scsi/ahci__src/add-ons/kernel/b?=
=?windows-1252?q?usses/usb_src/add-ons/kernel/drivers/audio/ac97/auich_sr?=
=?windows-1252?q?c/add-ons/kernel/drivers/audio/ac97/auvia_src/add-ons/ke?=
=?windows-1252?q?rnel/drivers/audio/emuxki_src/add-ons/kernel/drivers/gra?=
=?windows-1252?q?phics/radeon_src/add-ons/kernel/drivers/network/rtl8169_?=
=?windows-1252?q?src/add-ons/kernel/generic/dpc__src/add-ons/kernel/gener?=
=?windows-1252?q?ic/mpu401_src/libs/compat/freebsd=5Fnetwork_src/system/k?=
=?windows-1252?q?ernel_src/system/kernel/arch/m68k_src/system/kernel/arch?=
=?windows-1252?q?/x86_src/system/kernel/debug?=
In-Reply-To: <200806020204.m5224IeL027525@sheep.berlios.de>
Message-ID: <1163535131-BeMail@primary>
> Author: bonefish
> Date: 2008-06-02 04:04:12 +0200 (Mon, 02 Jun 2008)
> New Revision: 25752
> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25752&view=rev
> Log:
> * Added macros for spinlock initialization and access and changed
> code using spinlocks accordingly. This breaks compilation for BeOS
> --
> the macros should be defined in the respective compatibility
> wrappers.
Well at least for the USB parts this still compiles just fine (with the
bone target in my case). The Haiku KernelExport.h is included there and
not the host one, so the initializers you provide are picked up and
everything compiles.
Regards
Michael
From korli at users.berlios.de Mon Jun 2 21:15:35 2008
From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=)
Date: Mon, 2 Jun 2008 21:15:35 +0200
Subject: [Haiku-commits] r25752 - in haiku/trunk: headers/os/drivers
headers/private/kernel headers/private/system
src/add-ons/kernel/bus_managers/ide
src/add-ons/kernel/bus_managers/pci/arch/x86
src/add-ons/kernel/bus_managers/ps2 src/add-ons/kernel/bus_
Message-ID:
Hi Ingo,
2008/6/2 bonefish at BerliOS :
> * Added macros for spinlock initialization and access and changed
> code using spinlocks accordingly. This breaks compilation for BeOS --
> the macros should be defined in the respective compatibility wrappers.
Shouldn't B_SPINLOCK_INITIALIZER be added to Haiku compatibility header ?
Bye,
J?r?me
From oruizdorantes at mail.berlios.de Mon Jun 2 22:16:09 2008
From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS)
Date: Mon, 2 Jun 2008 22:16:09 +0200
Subject: [Haiku-commits] r25768 - in haiku/trunk: headers/os/bluetooth
headers/os/bluetooth/L2CAP src/add-ons/kernel/network/protocols
src/add-ons/kernel/network/protocols/l2cap
Message-ID: <200806022016.m52KG9Wv009880@sheep.berlios.de>
Author: oruizdorantes
Date: 2008-06-02 22:16:00 +0200 (Mon, 02 Jun 2008)
New Revision: 25768
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25768&view=rev
Added:
haiku/trunk/headers/os/bluetooth/L2CAP/
haiku/trunk/headers/os/bluetooth/L2CAP/btL2CAP.h
haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/
haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/Jamfile
haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap.cpp
haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_address.cpp
haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_address.h
Log:
L2CAP, without functionality, for the moment my playground in the netstack
Added: haiku/trunk/headers/os/bluetooth/L2CAP/btL2CAP.h
===================================================================
--- haiku/trunk/headers/os/bluetooth/L2CAP/btL2CAP.h 2008-06-02 18:50:42 UTC (rev 25767)
+++ haiku/trunk/headers/os/bluetooth/L2CAP/btL2CAP.h 2008-06-02 20:16:00 UTC (rev 25768)
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
+ *
+ * All rights reserved. Distributed under the terms of the MIT License.
+ *
+ */
+
+#ifndef _BTL2CAP_H_
+#define _BTL2CAP_H_
+
+#include
+
+struct sockaddr_l2cap {
+ uint8 l2cap_len; /* total length */
+ uint8 l2cap_family; /* address family */
+ uint16 l2cap_psm; /* PSM (Protocol/Service Multiplexor) */
+ bdaddr_t l2cap_bdaddr; /* address */
+};
+
+
+#endif
\ No newline at end of file
Added: haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/Jamfile
===================================================================
--- haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/Jamfile 2008-06-02 18:50:42 UTC (rev 25767)
+++ haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/Jamfile 2008-06-02 20:16:00 UTC (rev 25768)
@@ -0,0 +1,26 @@
+SubDir HAIKU_TOP src add-ons kernel network protocols l2cap ;
+
+SetSubDirSupportedPlatformsBeOSCompatible ;
+
+if $(TARGET_PLATFORM) != haiku {
+ UseHeaders [ FStandardOSHeaders ] : true ;
+ # Needed for and maybe other stuff.
+ UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
+ # We need the public network headers also when not compiling for Haiku.
+ # Unfortunately we get more than we want, namely all POSIX headers.
+}
+
+UsePrivateHeaders kernel net bluetooth ;
+
+KernelAddon l2cap :
+ l2cap.cpp
+ l2cap_address.cpp
+;
+
+# Installation
+HaikuInstall install-networking : /boot/home/config/add-ons/kernel/haiku_network/protocols
+ : l2cap ;
+
+Package haiku-networkingkit-cvs :
+ haiku :
+ boot home config add-ons kernel haiku_network protocols ;
Added: haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap.cpp 2008-06-02 18:50:42 UTC (rev 25767)
+++ haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap.cpp 2008-06-02 20:16:00 UTC (rev 25768)
@@ -0,0 +1,304 @@
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+
+typedef NetBufferField ICMPChecksumField;
+
+#define ICMP_TYPE_ECHO_REPLY 0
+#define ICMP_TYPE_UNREACH 3
+#define ICMP_TYPE_REDIRECT 5
+#define ICMP_TYPE_ECHO_REQUEST 8
+
+// type unreach codes
+#define ICMP_CODE_UNREACH_NEED_FRAGMENT 4 // this is used for path MTU discovery
+
+struct l2cap_protocol : net_protocol {
+};
+
+
+net_buffer_module_info *gBufferModule;
+static net_stack_module_info *sStackModule;
+
+
+net_protocol *
+l2cap_init_protocol(net_socket *socket)
+{
+ l2cap_protocol *protocol = new (std::nothrow) l2cap_protocol;
+ if (protocol == NULL)
+ return NULL;
+
+ return protocol;
+}
+
+
+status_t
+l2cap_uninit_protocol(net_protocol *protocol)
+{
+ delete protocol;
+ return B_OK;
+}
+
+
+status_t
+l2cap_open(net_protocol *protocol)
+{
+ return B_OK;
+}
+
+
+status_t
+l2cap_close(net_protocol *protocol)
+{
+ return B_OK;
+}
+
+
+status_t
+l2cap_free(net_protocol *protocol)
+{
+ return B_OK;
+}
+
+
+status_t
+l2cap_connect(net_protocol *protocol, const struct sockaddr *address)
+{
+ return B_ERROR;
+}
+
+
+status_t
+l2cap_accept(net_protocol *protocol, struct net_socket **_acceptedSocket)
+{
+ return EOPNOTSUPP;
+}
+
+
+status_t
+l2cap_control(net_protocol *protocol, int level, int option, void *value,
+ size_t *_length)
+{
+ return protocol->next->module->control(protocol->next, level, option,
+ value, _length);
+}
+
+
+status_t
+l2cap_getsockopt(net_protocol *protocol, int level, int option,
+ void *value, int *length)
+{
+ return protocol->next->module->getsockopt(protocol->next, level, option,
+ value, length);
+}
+
+
+status_t
+l2cap_setsockopt(net_protocol *protocol, int level, int option,
+ const void *value, int length)
+{
+ return protocol->next->module->setsockopt(protocol->next, level, option,
+ value, length);
+}
+
+
+status_t
+l2cap_bind(net_protocol *protocol, const struct sockaddr *address)
+{
+ return B_ERROR;
+}
+
+
+status_t
+l2cap_unbind(net_protocol *protocol, struct sockaddr *address)
+{
+ return B_ERROR;
+}
+
+
+status_t
+l2cap_listen(net_protocol *protocol, int count)
+{
+ return EOPNOTSUPP;
+}
+
+
+status_t
+l2cap_shutdown(net_protocol *protocol, int direction)
+{
+ return EOPNOTSUPP;
+}
+
+
+status_t
+l2cap_send_data(net_protocol *protocol, net_buffer *buffer)
+{
+ return protocol->next->module->send_data(protocol->next, buffer);
+}
+
+
+status_t
+l2cap_send_routed_data(net_protocol *protocol, struct net_route *route,
+ net_buffer *buffer)
+{
+ return protocol->next->module->send_routed_data(protocol->next, route, buffer);
+}
+
+
+ssize_t
+l2cap_send_avail(net_protocol *protocol)
+{
+ return B_ERROR;
+}
+
+
+status_t
+l2cap_read_data(net_protocol *protocol, size_t numBytes, uint32 flags,
+ net_buffer **_buffer)
+{
+ return B_ERROR;
+}
+
+
+ssize_t
+l2cap_read_avail(net_protocol *protocol)
+{
+ return B_ERROR;
+}
+
+
+struct net_domain *
+l2cap_get_domain(net_protocol *protocol)
+{
+ return protocol->next->module->get_domain(protocol->next);
+}
+
+
+size_t
+l2cap_get_mtu(net_protocol *protocol, const struct sockaddr *address)
+{
+ return protocol->next->module->get_mtu(protocol->next, address);
+}
+
+
+status_t
+l2cap_receive_data(net_buffer *buffer)
+{
+ debugf("ICMP received some data, buffer length %lu\n", buffer->size);
+
+ NetBufferHeaderReader bufferHeader(buffer);
+ if (bufferHeader.Status() < B_OK)
+ return bufferHeader.Status();
+
+ hci_acl_header &header = bufferHeader.Data();
+
+ debugf(" got type %u, code %u, checksum %u\n", header.type, header.code, ntohs(header.checksum));
+ debugf(" computed checksum: %ld\n", gBufferModule->checksum(buffer, 0, buffer->size, true));
+
+ if (gBufferModule->checksum(buffer, 0, buffer->size, true) != 0)
+ return B_BAD_DATA;
+
+ gBufferModule->free(buffer);
+ return B_OK;
+}
+
+
+status_t
+l2cap_error(uint32 code, net_buffer *data)
+{
+ return B_ERROR;
+}
+
+
+status_t
+l2cap_error_reply(net_protocol *protocol, net_buffer *causedError, uint32 code,
+ void *errorData)
+{
+ return B_ERROR;
+}
+
+
+// #pragma mark -
+
+
+static status_t
+l2cap_std_ops(int32 op, ...)
+{
+ switch (op) {
+ case B_MODULE_INIT:
+ {
+ sStackModule->register_domain_protocols(AF_INET, SOCK_DGRAM, IPPROTO_ICMP,
+ "network/protocols/l2cap/v1",
+ NULL);
+
+ sStackModule->register_domain_receiving_protocol(AF_INET, IPPROTO_ICMP,
+ "network/protocols/l2cap/v1");
+ return B_OK;
+ }
+
+ case B_MODULE_UNINIT:
+ return B_OK;
+
+ default:
+ return B_ERROR;
+ }
+}
+
+
+net_protocol_module_info sL2CAPModule = {
+ {
+ "network/protocols/l2cap/v1",
+ 0,
+ l2cap_std_ops
+ },
+ NET_PROTOCOL_ATOMIC_MESSAGES,
+
+ l2cap_init_protocol,
+ l2cap_uninit_protocol,
+ l2cap_open,
+ l2cap_close,
+ l2cap_free,
+ l2cap_connect,
+ l2cap_accept,
+ l2cap_control,
+ l2cap_getsockopt,
+ l2cap_setsockopt,
+ l2cap_bind,
+ l2cap_unbind,
+ l2cap_listen,
+ l2cap_shutdown,
+ l2cap_send_data,
+ l2cap_send_routed_data,
+ l2cap_send_avail,
+ l2cap_read_data,
+ l2cap_read_avail,
+ l2cap_get_domain,
+ l2cap_get_mtu,
+ l2cap_receive_data,
+ NULL,
+ l2cap_error,
+ l2cap_error_reply,
+};
+
+module_dependency module_dependencies[] = {
+ {NET_STACK_MODULE_NAME, (module_info **)&sStackModule},
+ {NET_BUFFER_MODULE_NAME, (module_info **)&gBufferModule},
+ {}
+};
+
+module_info *modules[] = {
+ (module_info *)&sL2CAPModule,
+ NULL
+};
Added: haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_address.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_address.cpp 2008-06-02 18:50:42 UTC (rev 25767)
+++ haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_address.cpp 2008-06-02 20:16:00 UTC (rev 25768)
@@ -0,0 +1,416 @@
+/*
+ * Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Oliver Ruiz Dorantes, oliver-ruiz.dorantes_at_gmail.com
+ */
+
+
+#include
+
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+
+#include
+
+#define L2CAP_CHECKSUM(address) (address.b[0]+\
+ address.b[1]+\
+ address.b[2]+\
+ address.b[3]+\
+ address.b[4]+\
+ address.b[5])
+
+/*!
+ Routing utility function: copies address \a from into a new address
+ that is put into \a to.
+ If \a replaceWithZeros is set \a from will be replaced by an empty
+ address.
+ If a \a mask is given it is applied to \a from (such that \a to is the
+ result of \a from & \a mask).
+ \return B_OK if the address could be copied
+ \return B_NO_MEMORY if the new address could not be allocated
+ \return B_MISMATCHED_VALUES if \a address does not match family AF_INET
+*/
+static status_t
+l2cap_copy_address(const sockaddr *from, sockaddr **to,
+ bool replaceWithZeros = false, const sockaddr *mask = NULL)
+{
+ if (replaceWithZeros) {
+ *to = (sockaddr *)malloc(sizeof(sockaddr_in));
+ if (*to == NULL)
+ return B_NO_MEMORY;
+
+ memset(*to, 0, sizeof(sockaddr_in));
+ (*to)->sa_family = AF_INET;
+ (*to)->sa_len = sizeof(sockaddr_in);
+ } else {
+ if (from == NULL)
+ return B_OK;
+ if (from->sa_family != AF_INET)
+ return B_MISMATCHED_VALUES;
+
+ *to = (sockaddr *)malloc(sizeof(sockaddr_in));
+ if (*to == NULL)
+ return B_NO_MEMORY;
+
+ memcpy(*to, from, sizeof(sockaddr_l2cap));
+
+ }
+ return B_OK;
+}
+
+
+/*!
+ Routing utility function: applies \a mask to given \a address and puts
+ the resulting address into \a result.
+ \return B_OK if the mask has been applied
+ \return B_BAD_VALUE if \a address or \a mask is NULL
+*/
+static status_t
+l2cap_mask_address(const sockaddr *address, const sockaddr *mask, sockaddr *result)
+{
+ if (address == NULL || result == NULL)
+ return B_BAD_VALUE;
+
+ return B_OK;
+}
+
+
+/*!
+ Checks if the given \a address is the empty address. By default, the port
+ is checked, too, but you can avoid that by passing \a checkPort = false.
+ \return true if \a address is NULL, uninitialized or the empty address,
+ false if not
+*/
+static bool
+l2cap_is_empty_address(const sockaddr *address, bool checkPort)
+{
+ if (address == NULL || address->sa_len == 0)
+ return true;
+
+ return ((bacmp(&((sockaddr_l2cap *)address)->l2cap_bdaddr, BDADDR_NULL)==0)
+ && (!checkPort || ((sockaddr_l2cap *)address)->l2cap_psm == 0) );
+}
+
+
+/*!
+ Compares the IP-addresses of the two given address structures \a a and \a b.
+ \return true if IP-addresses of \a a and \a b are equal, false if not
+*/
+static bool
+l2cap_equal_addresses(const sockaddr *a, const sockaddr *b)
+{
+ if (a == NULL && b == NULL)
+ return true;
+ if (a != NULL && b == NULL)
+ return l2cap_is_empty_address(a, false);
+ if (a == NULL && b != NULL)
+ return l2cap_is_empty_address(b, false);
+
+ return (bacmp(&((sockaddr_l2cap*)a)->l2cap_bdaddr,
+ &((sockaddr_l2cap*)b)->l2cap_bdaddr)==0);
+}
+
+
+/*!
+ Compares the ports of the two given address structures \a a and \a b.
+ \return true if ports of \a a and \a b are equal, false if not
+*/
+static bool
+l2cap_equal_ports(const sockaddr *a, const sockaddr *b)
+{
+ uint16 portA = a ? ((sockaddr_l2cap *)a)->l2cap_psm : 0;
+ uint16 portB = b ? ((sockaddr_l2cap *)b)->l2cap_psm : 0;
+ return portA == portB;
+}
+
+
+/*!
+ Compares the IP-addresses and ports of the two given address structures
+ \a a and \a b.
+ \return true if IP-addresses and ports of \a a and \a b are equal, false if not
+*/
+static bool
+l2cap_equal_addresses_and_ports(const sockaddr *a, const sockaddr *b)
+{
+ if (a == NULL && b == NULL)
+ return true;
+ if (a != NULL && b == NULL)
+ return l2cap_is_empty_address(a, true);
+ if (a == NULL && b != NULL)
+ return l2cap_is_empty_address(b, true);
+
+ return (bacmp(&((sockaddr_l2cap*)a)->l2cap_bdaddr,&((sockaddr_l2cap *)b)->l2cap_bdaddr)==0)
+ && ((sockaddr_l2cap *)a)->l2cap_psm == ((sockaddr_l2cap *)b)->l2cap_psm;
+}
+
+
+/*!
+ Applies the given \a mask two \a a and \a b and then checks whether
+ the masked addresses match.
+ \return true if \a a matches \a b after masking both, false if not
+*/
+static bool
+l2cap_equal_masked_addresses(const sockaddr *a, const sockaddr *b,
+ const sockaddr *mask)
+{
+ if (a == NULL && b == NULL)
+ return true;
+
+ return false;
+}
+
+
+/*!
+ Routing utility function: determines the least significant bit that is set
+ in the given \a mask.
+ \return the number of the first bit that is set (0-32, where 32 means
+ that there's no bit set in the mask).
+*/
+static int32
+l2cap_first_mask_bit(const sockaddr *_mask)
+{
+ if (_mask == NULL)
+ return 0;
+
+ return 0;
+}
+
+
+/*!
+ Routing utility function: checks the given \a mask for correctness (which
+ means that (starting with LSB) consists zero or more unset bits, followed
+ by bits that are all set).
+ \return true if \a mask is ok, false if not
+*/
+static bool
+l2cap_check_mask(const sockaddr *_mask)
+{
+
+ return true;
+}
+
+
+/*!
+ Creates a buffer for the given \a address and prints the address into
+ it (hexadecimal representation in host byte order or '').
+ If \a printPort is set, the port is printed, too.
+ \return B_OK if the address could be printed, \a buffer will point to
+ the resulting string
+ \return B_BAD_VALUE if no buffer has been given
+ \return B_NO_MEMORY if the buffer could not be allocated
+*/
+static status_t
+l2cap_print_address_buffer(const sockaddr *_address, char *buffer,
+ size_t bufferSize, bool printPort)
+{
+ const sockaddr_l2cap *address = (const sockaddr_l2cap *)_address;
+
+ if (buffer == NULL)
+ return B_BAD_VALUE;
+
+ if (address == NULL)
+ strlcpy(buffer, "", bufferSize);
+ else {
+ bdaddr_t addr = address->l2cap_bdaddr;
+ if (printPort) {
+ snprintf(buffer, bufferSize, "%2X:%2X:%2X:%2X:%2X:%2X|%u", addr.b[0],
+ addr.b[1],addr.b[2],addr.b[3],addr.b[4],addr.b[5],address->l2cap_psm);
+ }
+ else {
+ snprintf(buffer, bufferSize, "%2X:%2X:%2X:%2X:%2X:%2X",addr.b[0],
+ addr.b[1],addr.b[2],addr.b[3],addr.b[4],addr.b[5]);
+ }
+ }
+
+ return B_OK;
+}
+
+
+static status_t
+l2cap_print_address(const sockaddr *_address, char **_buffer, bool printPort)
+{
+ if (_buffer == NULL)
+ return B_BAD_VALUE;
+
+ char tmp[32];
+ l2cap_print_address_buffer(_address, tmp, sizeof(tmp), printPort);
+
+ *_buffer = strdup(tmp);
+ if (*_buffer == NULL)
+ return B_NO_MEMORY;
+
+ return B_OK;
+}
+
+
+/*!
+ Determines the port of the given \a address.
+ \return uint16 representing the port-nr
+*/
+static uint16
+l2cap_get_port(const sockaddr *address)
+{
+ if (address == NULL)
+ return 0;
+
+ return ((sockaddr_l2cap *)address)->l2cap_psm;
+}
+
+
+/*!
+ Sets the port of the given \a address to \a port.
+ \return B_OK if the port has been set
+ \return B_BAD_VALUE if \a address is NULL
+*/
+static status_t
+l2cap_set_port(sockaddr *address, uint16 port)
+{
+ if (address == NULL)
+ return B_BAD_VALUE;
+
+ ((sockaddr_l2cap *)address)->l2cap_psm = port;
+ return B_OK;
+}
+
+
+/*!
+ Sets \a address to \a from.
+ \return B_OK if \a from has been copied into \a address
+ \return B_BAD_VALUE if either \a address or \a from is NULL
+ \return B_MISMATCHED_VALUES if from is not of family AF_INET
+*/
+static status_t
+l2cap_set_to(sockaddr *address, const sockaddr *from)
+{
+ if (address == NULL || from == NULL)
+ return B_BAD_VALUE;
+
+ if (from->sa_family != AF_BLUETOOTH)
+ return B_MISMATCHED_VALUES;
+
+ memcpy(address, from, sizeof(sockaddr_l2cap));
+ address->sa_len = sizeof(sockaddr_l2cap);
+ return B_OK;
+}
+
+
+static status_t
+l2cap_update_to(sockaddr *_address, const sockaddr *_from)
+{
+ sockaddr_l2cap *address = (sockaddr_l2cap *)_address;
+ const sockaddr_l2cap *from = (const sockaddr_l2cap *)_from;
+
+ if (address == NULL || from == NULL)
+ return B_BAD_VALUE;
+
+ if (from->l2cap_family != AF_BLUETOOTH)
+ return B_BAD_VALUE;
+
+ address->l2cap_family = AF_INET;
+ address->l2cap_len = sizeof(sockaddr_l2cap);
+
+ if (address->l2cap_psm == 0)
+ address->l2cap_psm = from->l2cap_psm;
+
+ if (bacmp(&address->l2cap_bdaddr, BDADDR_BROADCAST)==0)
+ address->l2cap_bdaddr = from->l2cap_bdaddr;
+
+ return B_OK;
+}
+
+
+/*!
+ Sets \a address to the empty address (0.0.0.0).
+ \return B_OK if \a address has been set
+ \return B_BAD_VALUE if \a address is NULL
+*/
+static status_t
+l2cap_set_to_empty_address(sockaddr *address)
+{
+ if (address == NULL)
+ return B_BAD_VALUE;
+
+ memset(address, 0, sizeof(sockaddr_l2cap));
+ address->sa_len = sizeof(sockaddr_l2cap);
+ address->sa_family = AF_BLUETOOTH;
+ return B_OK;
+}
+
+
+static status_t
+l2cap_set_to_defaults(sockaddr *_defaultMask, sockaddr *_defaultBroadcast,
+ sockaddr *_address, sockaddr *_mask)
+{
+
+ return B_OK;
+}
+
+/*!
+ Computes a hash-value of the given addresses \a ourAddress
+ and \a peerAddress.
+ \return uint32 representing the hash-value
+*/
+static uint32
+l2cap_hash_address_pair(const sockaddr *ourAddress, const sockaddr *peerAddress)
+{
+ const sockaddr_l2cap *our = (const sockaddr_l2cap *)ourAddress;
+ const sockaddr_l2cap *peer = (const sockaddr_l2cap *)peerAddress;
+
+ return ((our ? our->l2cap_psm : 0) | ((peer ? peer->l2cap_psm : 0) << 16))
+ ^ (our ? L2CAP_CHECKSUM(our->l2cap_bdaddr) : 0) ^ (peer ? L2CAP_CHECKSUM(peer->l2cap_bdaddr) : 0);
+}
+
+
+/*!
+ Adds the given \a address to the IP-checksum \a checksum.
+ \return B_OK if \a address has been added to the checksum
+ \return B_BAD_VALUE if either \a address or \a checksum is NULL
+*/
+static status_t
+l2cap_checksum_address(struct Checksum *checksum, const sockaddr *address)
+{
+ if (checksum == NULL || address == NULL)
+ return B_BAD_VALUE;
+
+ for (uint i = 0; i < sizeof(bdaddr_t); i++)
+ (*checksum) << ((sockaddr_l2cap*)address)->l2cap_bdaddr.b[i];
+
+ return B_OK;
+}
+
+
+net_address_module_info gL2cap4AddressModule = {
+ {
+ NULL,
+ 0,
+ NULL
+ },
+ l2cap_copy_address,
+ l2cap_mask_address,
+ l2cap_equal_addresses,
+ l2cap_equal_ports,
+ l2cap_equal_addresses_and_ports,
+ l2cap_equal_masked_addresses,
+ l2cap_is_empty_address,
+ l2cap_first_mask_bit,
+ l2cap_check_mask,
+ l2cap_print_address,
+ l2cap_print_address_buffer,
+ l2cap_get_port,
+ l2cap_set_port,
+ l2cap_set_to,
+ l2cap_set_to_empty_address,
+ l2cap_set_to_defaults,
+ l2cap_update_to,
+ l2cap_hash_address_pair,
+ l2cap_checksum_address,
+ NULL // l2cap_matches_broadcast_address,
+};
Added: haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_address.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_address.h 2008-06-02 18:50:42 UTC (rev 25767)
+++ haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_address.h 2008-06-02 20:16:00 UTC (rev 25768)
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2006, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Oliver Ruiz Dorantes, oliver-ruiz.dorantes_at_gmail.com
+ */
+
+
+#ifndef L2CAP_ADDRESS_H
+#define L2CAP_ADDRESS_H
+
+extern struct net_address_module_info gL2cap4AddressModule;
+
+#endif // L2CAP_ADDRESS_H
From julun at mail.berlios.de Mon Jun 2 22:21:40 2008
From: julun at mail.berlios.de (julun at BerliOS)
Date: Mon, 2 Jun 2008 22:21:40 +0200
Subject: [Haiku-commits] r25769 - haiku/trunk/src/kits/interface
Message-ID: <200806022021.m52KLeId010425@sheep.berlios.de>
Author: julun
Date: 2008-06-02 22:21:40 +0200 (Mon, 02 Jun 2008)
New Revision: 25769
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25769&view=rev
Modified:
haiku/trunk/src/kits/interface/PrintJob.cpp
Log:
* don't print child views with invalid rect, this makes printing e.g.
from Scooby nearly the same as on R5 (still misses the gray header color)
Modified: haiku/trunk/src/kits/interface/PrintJob.cpp
===================================================================
--- haiku/trunk/src/kits/interface/PrintJob.cpp 2008-06-02 20:16:00 UTC (rev 25768)
+++ haiku/trunk/src/kits/interface/PrintJob.cpp 2008-06-02 20:21:40 UTC (rev 25769)
@@ -673,13 +673,12 @@
BView *child = view->ChildAt(0);
while (child != NULL) {
if ((child->Flags() & B_WILL_DRAW) && !child->IsHidden()) {
- BRect bounds(child->Bounds());
- BPoint childLeftTop = view->Bounds().LeftTop()
- + (child->Frame().LeftTop() - bounds.LeftTop());
- _RecurseView(child, origin + childLeftTop, picture,
- bounds & rect.OffsetToCopy(rect.LeftTop() - childLeftTop));
- child = child->NextSibling();
+ BPoint leftTop(view->Bounds().LeftTop() + child->Frame().LeftTop());
+ BRect printRect(rect.OffsetToCopy(rect.LeftTop() - leftTop) & child->Bounds());
+ if (printRect.IsValid())
+ _RecurseView(child, origin + leftTop, picture, printRect);
}
+ child = child->NextSibling();
}
if (view->Flags() & B_DRAW_ON_CHILDREN) {
From korli at mail.berlios.de Mon Jun 2 22:53:47 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Mon, 2 Jun 2008 22:53:47 +0200
Subject: [Haiku-commits] r25770 - haiku/trunk/src/apps/workspaces
Message-ID: <200806022053.m52KrlPu013975@sheep.berlios.de>
Author: korli
Date: 2008-06-02 22:53:46 +0200 (Mon, 02 Jun 2008)
New Revision: 25770
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25770&view=rev
Modified:
haiku/trunk/src/apps/workspaces/Workspaces.cpp
Log:
HasBorder and HasTitle are exclusive, fix bug #2325
Modified: haiku/trunk/src/apps/workspaces/Workspaces.cpp
===================================================================
--- haiku/trunk/src/apps/workspaces/Workspaces.cpp 2008-06-02 20:21:40 UTC (rev 25769)
+++ haiku/trunk/src/apps/workspaces/Workspaces.cpp 2008-06-02 20:53:46 UTC (rev 25770)
@@ -554,8 +554,10 @@
if (enable)
SetLook(B_TITLED_WINDOW_LOOK);
- else
+ else {
SetLook(B_NO_BORDER_WINDOW_LOOK);
+ fSettings->SetHasTitle(true);
+ }
fSettings->SetHasBorder(enable);
break;
@@ -569,8 +571,10 @@
if (enable)
SetLook(B_TITLED_WINDOW_LOOK);
- else
+ else {
SetLook(B_MODAL_WINDOW_LOOK);
+ fSettings->SetHasBorder(true);
+ }
fSettings->SetHasTitle(enable);
break;
From axeld at pinc-software.de Mon Jun 2 23:28:49 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Mon, 02 Jun 2008 23:28:49 +0200 CEST
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To: <200806021818.m52IIuoZ028545@sheep.berlios.de>
Message-ID: <47430005181-BeMail@zon>
stippi at BerliOS wrote:
> Log:
> Resolved TODO and set the flags for the kind of additional
> bitmap support (bitmaps support child views or BViews can
> draw them)
Wasn't aware of this function - so we can just add a
B_BITMAP_SUPPORTS_OVERLAY there and that's it?
Bye,
Axel.
From korli at mail.berlios.de Tue Jun 3 00:29:15 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Tue, 3 Jun 2008 00:29:15 +0200
Subject: [Haiku-commits] r25771 - haiku/trunk/src/apps/installer
Message-ID: <200806022229.m52MTFEV022956@sheep.berlios.de>
Author: korli
Date: 2008-06-03 00:29:15 +0200 (Tue, 03 Jun 2008)
New Revision: 25771
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25771&view=rev
Modified:
haiku/trunk/src/apps/installer/FSUtils.cpp
Log:
ported back a change from Tracker FSUtils.cpp
Modified: haiku/trunk/src/apps/installer/FSUtils.cpp
===================================================================
--- haiku/trunk/src/apps/installer/FSUtils.cpp 2008-06-02 20:53:46 UTC (rev 25770)
+++ haiku/trunk/src/apps/installer/FSUtils.cpp 2008-06-02 22:29:15 UTC (rev 25771)
@@ -1146,6 +1146,11 @@
continue;
}
+ // Special case for a size 0 attribute. It wouldn't be written at all
+ // otherwise.
+ if (info.size == 0)
+ destNode->WriteAttr(name, info.type, 0, buffer, 0);
+
ssize_t bytes;
ssize_t numToRead = (ssize_t)info.size;
for (off_t offset = 0; numToRead > 0; offset += bytes) {
From korli at mail.berlios.de Tue Jun 3 00:34:49 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Tue, 3 Jun 2008 00:34:49 +0200
Subject: [Haiku-commits] r25772 - haiku/trunk/src/apps/installer
Message-ID: <200806022234.m52MYnbP030051@sheep.berlios.de>
Author: korli
Date: 2008-06-03 00:34:48 +0200 (Tue, 03 Jun 2008)
New Revision: 25772
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25772&view=rev
Modified:
haiku/trunk/src/apps/installer/CopyEngine.cpp
haiku/trunk/src/apps/installer/CopyEngine.h
haiku/trunk/src/apps/installer/InstallerWindow.cpp
Log:
better handles error and cancellation when copying
Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp
===================================================================
--- haiku/trunk/src/apps/installer/CopyEngine.cpp 2008-06-02 22:29:15 UTC (rev 25771)
+++ haiku/trunk/src/apps/installer/CopyEngine.cpp 2008-06-02 22:34:48 UTC (rev 25772)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006, J?r?me DUVAL. All rights reserved.
+ * Copyright 2005-2008, J?r?me DUVAL. All rights reserved.
* Distributed under the terms of the MIT License.
*/
@@ -76,7 +76,10 @@
fWindow->GetTargetMenu());
if (err != B_OK) {
ERR("Start failed");
+ SetStatusMessage("Installation aborted.");
BMessenger(fWindow).SendMessage(RESET_INSTALL);
+ } else {
+ BMessenger(fWindow).SendMessage(INSTALL_FINISHED);
}
break;
}
@@ -229,8 +232,11 @@
// copy source volume
BDirectory targetDir(targetDirectory.Path());
BDirectory srcDir(srcDirectory.Path());
- CopyFolder(srcDir, targetDir);
+ err = CopyFolder(srcDir, targetDir);
+ if (err != B_OK)
+ return err;
+
// copy selected packages
if (fPackages) {
srcDirectory.Append(PACKAGES_DIRECTORY);
@@ -239,25 +245,28 @@
int32 count = fPackages->CountItems();
for (int32 i = 0; i < count; i++) {
if (fControl->CheckUserCanceled())
- return B_OK;
+ return B_CANCELED;
Package *p = static_cast(fPackages->ItemAt(i));
packageDir.SetTo(&srcDir, p->Folder());
- CopyFolder(packageDir, targetDir);
+ err = CopyFolder(packageDir, targetDir);
+ if (err != B_OK)
+ break;
}
}
- if (!fControl->CheckUserCanceled()) {
- LaunchFinishScript(targetDirectory);
+ if (err != B_OK)
+ return err;
- BMessage msg(INSTALL_FINISHED);
- BMessenger(fWindow).SendMessage(&msg);
- }
+ if (fControl->CheckUserCanceled())
+ return B_CANCELED;
+
+ LaunchFinishScript(targetDirectory);
return B_OK;
}
-void
+status_t
CopyEngine::CopyFolder(BDirectory &srcDir, BDirectory &targetDir)
{
BEntry entry;
@@ -283,8 +292,11 @@
BPath path;
entry.GetPath(&path);
ERR2("error while copying %s", path.Path());
+ return err;
}
}
+
+ return B_OK;
}
Modified: haiku/trunk/src/apps/installer/CopyEngine.h
===================================================================
--- haiku/trunk/src/apps/installer/CopyEngine.h 2008-06-02 22:29:15 UTC (rev 25771)
+++ haiku/trunk/src/apps/installer/CopyEngine.h 2008-06-02 22:34:48 UTC (rev 25772)
@@ -32,7 +32,7 @@
private:
void LaunchInitScript(BPath &path);
void LaunchFinishScript(BPath &path);
- void CopyFolder(BDirectory &srcDir, BDirectory &targetDir);
+ status_t CopyFolder(BDirectory &srcDir, BDirectory &targetDir);
InstallerWindow *fWindow;
BDiskDeviceRoster fDDRoster;
Modified: haiku/trunk/src/apps/installer/InstallerWindow.cpp
===================================================================
--- haiku/trunk/src/apps/installer/InstallerWindow.cpp 2008-06-02 22:29:15 UTC (rev 25771)
+++ haiku/trunk/src/apps/installer/InstallerWindow.cpp 2008-06-02 22:34:48 UTC (rev 25772)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005, J?r?me DUVAL. All rights reserved.
+ * Copyright 2005-2008, J?r?me DUVAL. All rights reserved.
* Distributed under the terms of the MIT License.
*/
@@ -213,7 +213,6 @@
if (fCopyEngine->Cancel()) {
fInstallStatus = kCancelled;
SetStatusMessage("Installation cancelled.");
- PostMessage(RESET_INSTALL);
}
break;
case kFinished:
@@ -263,6 +262,7 @@
}
case INSTALL_FINISHED:
fBeginButton->SetLabel("Quit");
+ SetStatusMessage("Installation completed.");
fInstallStatus = kFinished;
DisableInterface(false);
break;
From ingo_weinhold at gmx.de Tue Jun 3 01:11:56 2008
From: ingo_weinhold at gmx.de (Ingo Weinhold)
Date: Tue, 03 Jun 2008 01:11:56 +0200
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To: <200806021818.m52IIuoZ028545@sheep.berlios.de>
References: <200806021818.m52IIuoZ028545@sheep.berlios.de>
Message-ID: <20080603011156.631.2@knochen-vm.1212446751.fake>
On 2008-06-02 at 20:18:56 [+0200], stippi at BerliOS
wrote:
> Author: stippi
> Date: 2008-06-02 20:18:56 +0200 (Mon, 02 Jun 2008)
> New Revision: 25762
> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25762&view=rev
>
> Modified:
> haiku/trunk/src/kits/interface/GraphicsDefs.cpp
> Log:
> Resolved TODO and set the flags for the kind of additional
> bitmap support (bitmaps support child views or BViews can
> draw them)
>
>
> Modified: haiku/trunk/src/kits/interface/GraphicsDefs.cpp
> ===================================================================
> --- haiku/trunk/src/kits/interface/GraphicsDefs.cpp 2008-06-02 17:08:42
> UTC (rev 25761)
> +++ haiku/trunk/src/kits/interface/GraphicsDefs.cpp 2008-06-02 18:18:56
> UTC (rev 25762)
> @@ -144,17 +144,21 @@
> bool
> bitmaps_support_space(color_space space, uint32 *supportFlags)
> {
> - // TODO: fill supportFlags with the supported flags:
> - // - B_VIEWS_SUPPORT_DRAW_BITMAP
> - // - B_BITMAPS_SUPPORT_ATTACHED_VIEWS
> - bool result = false;
> + bool result = true;
> switch (space) {
> - // supported
> + // supported, also for drawing and for attaching BViews
> case B_RGB32: case B_RGBA32: case B_RGB24:
> case B_RGB32_BIG: case B_RGBA32_BIG: case B_RGB24_BIG:
> case B_RGB16: case B_RGB15: case B_RGBA15:
> case B_RGB16_BIG: case B_RGB15_BIG: case B_RGBA15_BIG:
> case B_CMAP8: case B_GRAY8: case B_GRAY1:
> + if (supportFlags) {
> + *supportFlags = 0;
> + *supportFlags |= B_VIEWS_SUPPORT_DRAW_BITMAP;
> + *supportFlags |= B_BITMAPS_SUPPORT_ATTACHED_VIEWS;
I don't really see why this isn't a single statement. Not that this is
particularly important...
CU, Ingo
From ingo_weinhold at gmx.de Tue Jun 3 01:12:44 2008
From: ingo_weinhold at gmx.de (Ingo Weinhold)
Date: Tue, 03 Jun 2008 01:12:44 +0200
Subject: [Haiku-commits] r25752 - in haiku/trunk: headers/os/drivers
headers/private/kernel headers/private/system
src/add-ons/kernel/bus_managers/ide
src/add-ons/kernel/bus_managers/pci/arch/x86
src/add-ons/kernel/bus_managers/ps2 src/add-ons/kernel/bus_managers/scsi
src/add-ons/kernel/busses/scsi/ahci src/add-ons/kernel/busses/usb
src/add-ons/kernel/drivers/audio/ac97/auich
src/add-ons/kernel/drivers/audio/ac97/auvia
src/add-ons/kernel/drivers/audio/emuxki
src/add-ons/kernel/drivers/graphics/radeon
src/add-ons/kernel/drivers/network/rtl8169 src/add-ons/kernel/generic/dpc
src/add-ons/kernel/generic/mpu401 src/libs/compat/freebsd_network
src/system/kernel src/system/kernel/arch/m68k src/system/kernel/arch/x86
src/system/kernel/debug
In-Reply-To: <1163535131-BeMail@primary>
References: <1163535131-BeMail@primary>
Message-ID: <20080603011244.661.3@knochen-vm.1212446751.fake>
On 2008-06-02 at 20:57:40 [+0200], Michael Lotz wrote:
> > Author: bonefish
> > Date: 2008-06-02 04:04:12 +0200 (Mon, 02 Jun 2008)
> > New Revision: 25752
> > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25752&view=rev
> > Log:
> > * Added macros for spinlock initialization and access and changed
> > code using spinlocks accordingly. This breaks compilation for BeOS
> > --
> > the macros should be defined in the respective compatibility
> > wrappers.
>
> Well at least for the USB parts this still compiles just fine (with the
> bone target in my case). The Haiku KernelExport.h is included there and
> not the host one, so the initializers you provide are picked up and
> everything compiles.
OK, sounds a bit hacky, but I suppose there's a reason for not using the
target platform's KernelExport.h.
CU, Ingo
From ingo_weinhold at gmx.de Tue Jun 3 01:14:27 2008
From: ingo_weinhold at gmx.de (Ingo Weinhold)
Date: Tue, 03 Jun 2008 01:14:27 +0200
Subject: [Haiku-commits] r25752 - in haiku/trunk: headers/os/drivers
headers/private/kernel headers/private/system
src/add-ons/kernel/bus_managers/ide
src/add-ons/kernel/bus_managers/pci/arch/x86
src/add-ons/kernel/bus_managers/ps2 src/add-ons/kernel/bus_
In-Reply-To:
References:
Message-ID: <20080603011427.704.4@knochen-vm.1212446751.fake>
On 2008-06-02 at 21:15:35 [+0200], J?r?me Duval
wrote:
> 2008/6/2 bonefish at BerliOS :
> > * Added macros for spinlock initialization and access and changed
> > code using spinlocks accordingly. This breaks compilation for BeOS --
> > the macros should be defined in the respective compatibility wrappers.
>
> Shouldn't B_SPINLOCK_INITIALIZER be added to Haiku compatibility header ?
If you mean HaikuBuildCompatibility.h, I don't think this is included from
any kernel code. It's original purpose was for building the build tools,
anyway.
CU, Ingo
From jackburton at mail.berlios.de Tue Jun 3 06:37:20 2008
From: jackburton at mail.berlios.de (jackburton at BerliOS)
Date: Tue, 3 Jun 2008 06:37:20 +0200
Subject: [Haiku-commits] r25773 - in haiku/trunk:
headers/private/kernel/arch/x86 src/system/kernel/arch/x86
Message-ID: <200806030437.m534bKgT017729@sheep.berlios.de>
Author: jackburton
Date: 2008-06-03 06:37:18 +0200 (Tue, 03 Jun 2008)
New Revision: 25773
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25773&view=rev
Added:
haiku/trunk/headers/private/kernel/arch/x86/arch_hpet.h
haiku/trunk/src/system/kernel/arch/x86/arch_hpet.c
Modified:
haiku/trunk/src/system/kernel/arch/x86/Jamfile
Log:
Added patch by Dustin Howett: header with HPET definitions and (empty)
file for hpet implementation. Not yet added to the build.
Added: haiku/trunk/headers/private/kernel/arch/x86/arch_hpet.h
===================================================================
--- haiku/trunk/headers/private/kernel/arch/x86/arch_hpet.h 2008-06-02 22:34:48 UTC (rev 25772)
+++ haiku/trunk/headers/private/kernel/arch/x86/arch_hpet.h 2008-06-03 04:37:18 UTC (rev 25773)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2008, Dustin Howett, dustin.howett at gmail.com. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_x86_HPET_H
+#define _KERNEL_ARCH_x86_HPET_H
+
+/* All masks are 64 bits wide to represent bit locations;
+ the HPET registers are 64 bits wide. */
+
+/* Global Capability Register Masks */
+#define HPET_CAP_MASK_ID 0x00000000000000FF
+#define HPET_CAP_MASK_NUMTIMERS 0x0000000000001F00
+#define HPET_CAP_MASK_WIDTH 0x0000000000002000
+#define HPET_CAP_MASK_LEGACY 0x0000000000008000
+#define HPET_CAP_MASK_VENDOR_ID 0x00000000FFFF0000
+#define HPET_CAP_MASK_PERIOD 0xFFFFFFFF00000000
+
+/* Retrieve Global Capabilities */
+#define HPET_GET_ID(regs) ((regs)->caps & HPET_CAP_MASK_ID)
+#define HPET_GET_NUM_TIMERS(regs) (((regs)->caps & HPET_CAP_MASK_NUMTIMERS) >> 8)
+#define HPET_IS_64BIT_CAPABLE(regs) (((regs)->caps & HPET_CAP_MASK_WIDTH) >> 13)
+#define HPET_IS_LEGACY_CAPABLE(regs) (((regs)->caps & HPET_CAP_MASK_LEGACY) >> 15)
+#define HPET_GET_VENDOR_ID(regs) (((regs)->caps & HPET_CAP_MASK_VENDOR_ID) >> 16)
+#define HPET_GET_PERIOD(regs) (((regs)->caps & HPET_CAP_MASK_PERIOD) >> 32)
+
+struct hpet_timer {
+ uint64 config, /* Timer configuration and capabilities */
+ uint64 comparator, /* Comparator value */
+ uint64 introute, /* FSB Interrupt Routing */
+ uint64 reserved
+};
+
+struct hpet_regs {
+ uint64 caps, /* HPET Capabilities and ID */
+ uint64 reserved1,
+ uint64 config, /* General Configuration */
+ uint64 reserved2,
+ uint64 intstatus, /* General Interrupt Status */
+ uint8 reserved3[200],
+ uint64 mainvalue, /* Main Counter Value */
+ uint64 reserved3,
+ struct hpet_timer timers[1] /* Timers */
+};
+
+#endif
Modified: haiku/trunk/src/system/kernel/arch/x86/Jamfile
===================================================================
--- haiku/trunk/src/system/kernel/arch/x86/Jamfile 2008-06-02 22:34:48 UTC (rev 25772)
+++ haiku/trunk/src/system/kernel/arch/x86/Jamfile 2008-06-03 04:37:18 UTC (rev 25773)
@@ -15,6 +15,7 @@
arch_debug.cpp
arch_debug_console.c
arch_elf.c
+# arch_hpet.c
arch_int.c
arch_platform.c
# arch_selector.c
Added: haiku/trunk/src/system/kernel/arch/x86/arch_hpet.c
===================================================================
--- haiku/trunk/src/system/kernel/arch/x86/arch_hpet.c 2008-06-02 22:34:48 UTC (rev 25772)
+++ haiku/trunk/src/system/kernel/arch/x86/arch_hpet.c 2008-06-03 04:37:18 UTC (rev 25773)
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2008, Dustin Howett, dustin.howett at gmail.com. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include
From jackburton at mail.berlios.de Tue Jun 3 07:03:01 2008
From: jackburton at mail.berlios.de (jackburton at BerliOS)
Date: Tue, 3 Jun 2008 07:03:01 +0200
Subject: [Haiku-commits] r25774 - in haiku/trunk:
headers/private/kernel/arch/x86 src/system/kernel/arch/x86
Message-ID: <200806030503.m53531Na017101@sheep.berlios.de>
Author: jackburton
Date: 2008-06-03 07:02:59 +0200 (Tue, 03 Jun 2008)
New Revision: 25774
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25774&view=rev
Modified:
haiku/trunk/headers/private/kernel/arch/x86/arch_hpet.h
haiku/trunk/src/system/kernel/arch/x86/Jamfile
Log:
took the liberty to add this to the buiild and fix compilation :)
Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_hpet.h
===================================================================
--- haiku/trunk/headers/private/kernel/arch/x86/arch_hpet.h 2008-06-03 04:37:18 UTC (rev 25773)
+++ haiku/trunk/headers/private/kernel/arch/x86/arch_hpet.h 2008-06-03 05:02:59 UTC (rev 25774)
@@ -5,6 +5,8 @@
#ifndef _KERNEL_ARCH_x86_HPET_H
#define _KERNEL_ARCH_x86_HPET_H
+#include
+
/* All masks are 64 bits wide to represent bit locations;
the HPET registers are 64 bits wide. */
@@ -25,22 +27,23 @@
#define HPET_GET_PERIOD(regs) (((regs)->caps & HPET_CAP_MASK_PERIOD) >> 32)
struct hpet_timer {
- uint64 config, /* Timer configuration and capabilities */
- uint64 comparator, /* Comparator value */
- uint64 introute, /* FSB Interrupt Routing */
- uint64 reserved
+ uint64 config; /* Timer configuration and capabilities */
+ uint64 comparator; /* Comparator value */
+ uint64 introute; /* FSB Interrupt Routing */
+ uint64 reserved;
};
+
struct hpet_regs {
- uint64 caps, /* HPET Capabilities and ID */
- uint64 reserved1,
- uint64 config, /* General Configuration */
- uint64 reserved2,
- uint64 intstatus, /* General Interrupt Status */
- uint8 reserved3[200],
- uint64 mainvalue, /* Main Counter Value */
- uint64 reserved3,
- struct hpet_timer timers[1] /* Timers */
+ uint64 caps; /* HPET Capabilities and ID */
+ uint64 reserved1;
+ uint64 config; /* General Configuration */
+ uint64 reserved2;
+ uint64 intstatus; /* General Interrupt Status */
+ uint8 reserved3[200];
+ uint64 mainvalue; /* Main Counter Value */
+ uint64 reserved4;
+ struct hpet_timer timers[1]; /* Timers */
};
#endif
Modified: haiku/trunk/src/system/kernel/arch/x86/Jamfile
===================================================================
--- haiku/trunk/src/system/kernel/arch/x86/Jamfile 2008-06-03 04:37:18 UTC (rev 25773)
+++ haiku/trunk/src/system/kernel/arch/x86/Jamfile 2008-06-03 05:02:59 UTC (rev 25774)
@@ -15,7 +15,7 @@
arch_debug.cpp
arch_debug_console.c
arch_elf.c
-# arch_hpet.c
+ arch_hpet.c
arch_int.c
arch_platform.c
# arch_selector.c
From mmlr at mail.berlios.de Tue Jun 3 08:53:58 2008
From: mmlr at mail.berlios.de (mmlr at BerliOS)
Date: Tue, 3 Jun 2008 08:53:58 +0200
Subject: [Haiku-commits] r25775 -
haiku/trunk/src/system/kernel/device_manager
Message-ID: <200806030653.m536rw4R011049@sheep.berlios.de>
Author: mmlr
Date: 2008-06-03 08:53:57 +0200 (Tue, 03 Jun 2008)
New Revision: 25775
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25775&view=rev
Modified:
haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp
Log:
Move the device deletion after the unpublish call. Fixes crashes where a
device is still referenced through the devfs and used right between deleting
and unpublishing.
Modified: haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp 2008-06-03 05:02:59 UTC (rev 25774)
+++ haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp 2008-06-03 06:53:57 UTC (rev 25775)
@@ -312,12 +312,11 @@
TRACE(("devfs: unpublishing no more present \"%s\"\n", entry->path));
LegacyDevice* device = get_device_for_path(driver, entry->path);
- if (device != NULL) {
+ if (device != NULL)
driver->devices.Remove(device);
- delete device;
- }
devfs_unpublish_device(entry->path, true);
+ delete device;
delete entry;
}
From mmlr at mail.berlios.de Tue Jun 3 08:56:24 2008
From: mmlr at mail.berlios.de (mmlr at BerliOS)
Date: Tue, 3 Jun 2008 08:56:24 +0200
Subject: [Haiku-commits] r25776 - haiku/trunk/src/system/kernel
Message-ID: <200806030656.m536uO52011220@sheep.berlios.de>
Author: mmlr
Date: 2008-06-03 08:56:24 +0200 (Tue, 03 Jun 2008)
New Revision: 25776
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25776&view=rev
Modified:
haiku/trunk/src/system/kernel/heap.cpp
Log:
Directly use memalign instead of malloc to safe one indirection.
Modified: haiku/trunk/src/system/kernel/heap.cpp
===================================================================
--- haiku/trunk/src/system/kernel/heap.cpp 2008-06-03 06:53:57 UTC (rev 25775)
+++ haiku/trunk/src/system/kernel/heap.cpp 2008-06-03 06:56:24 UTC (rev 25776)
@@ -1419,7 +1419,7 @@
}
if (address == NULL)
- return malloc(newSize);
+ return memalign(0, newSize);
if (newSize == 0) {
free(address);
From axeld at pinc-software.de Tue Jun 3 09:02:20 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Tue, 03 Jun 2008 09:02:20 +0200 CEST
Subject: [Haiku-commits]
=?utf-8?q?r25773_-_in_haiku/trunk=3A_headers/priv?=
=?utf-8?q?ate/kernel/arch/x86__src/system/kernel/arch/x86?=
In-Reply-To: <200806030437.m534bKgT017729@sheep.berlios.de>
Message-ID: <569727871-BeMail@zon>
jackburton at BerliOS wrote:
> + uint64 introute, /* FSB Interrupt Routing */
> + uint64 reserved
> +};
> +
> +struct hpet_regs {
> + uint64 caps, /* HPET Capabilities and ID */
> + uint64 reserved1,
> + uint64 config, /* General Configuration */
> + uint64 reserved2,
> + uint64 intstatus, /* General Interrupt Status */
> + uint8 reserved3[200],
> + uint64 mainvalue, /* Main Counter Value */
How about using interrupt_route, interrupt_status, and
main_counter_value and remove the then superfluous comments (or make
them more specific to change that)?
We should always use expressive names rather than ones you'll have to
look up before understanding their purpose. Also, concatenations (like
"mainvalue") are separated by '_' in C structures.
And finally, since HPET is an x86 specific thing (unless there will be
an arch/hpet.h header), so the header should just be called hpet.h in
that directory (just like apm.h, vesa.h, ...).
Looking forward to the implementation :-)
Bye,
Axel.
From axeld at mail.berlios.de Tue Jun 3 09:28:05 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 09:28:05 +0200
Subject: [Haiku-commits] r25777 -
haiku/trunk/src/system/kernel/device_manager
Message-ID: <200806030728.m537S5Of013567@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 09:28:04 +0200 (Tue, 03 Jun 2008)
New Revision: 25777
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25777&view=rev
Modified:
haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
Log:
Patch by Vasilis Kaoutsis:
* Added a missing close_module_list().
Modified: haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-03 06:56:24 UTC (rev 25776)
+++ haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-03 07:28:04 UTC (rev 25777)
@@ -305,6 +305,7 @@
devfs_publish_directory(path.Path());
}
+ close_module_list(list);
} else {
// TODO: implement module directory traversal!
}
From axeld at mail.berlios.de Tue Jun 3 11:13:04 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 11:13:04 +0200
Subject: [Haiku-commits] r25778 -
haiku/trunk/src/system/kernel/device_manager
Message-ID: <200806030913.m539D4cV026950@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 11:13:04 +0200 (Tue, 03 Jun 2008)
New Revision: 25778
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25778&view=rev
Modified:
haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
Log:
* As Korli pointed out, I got a bit confused with Rescan() vs. Probe().
* Therefore, device_manager::rescan_node() now actually causes the
driver::rescan_child_devices() function to be called, instead of probing
again.
* Added a device_node::Reprobe() method that does what Rescan() did previously.
* Probe() should now also work with "dumb" busses that don't support type
information - it will now probe all of these nodes.
Modified: haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-03 07:28:04 UTC (rev 25777)
+++ haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-03 09:13:04 UTC (rev 25778)
@@ -117,6 +117,7 @@
status_t Register(device_node* parent);
status_t Probe(const char* devicePath, uint32 updateCycle);
+ status_t Reprobe();
status_t Rescan();
bool IsRegistered() const { return fRegistered; }
@@ -153,7 +154,7 @@
status_t _RegisterDynamic(device_node* previous = NULL);
status_t _RemoveChildren();
device_node* _FindCurrentChild();
- status_t _Rescan();
+ status_t _Probe();
void _ReleaseWaiting();
device_node* fParent;
@@ -1695,7 +1696,7 @@
status_t
-device_node::_Rescan()
+device_node::_Probe()
{
device_node* previous = NULL;
@@ -1733,31 +1734,37 @@
MethodDeleter uninit(this,
&device_node::UninitDriver);
- uint16 type = 0;
- uint16 subType = 0;
- if (get_attr_uint16(this, B_DEVICE_TYPE, &type, false) == B_OK
- && get_attr_uint16(this, B_DEVICE_SUB_TYPE, &subType, false) == B_OK) {
- // Check if this node matches the device path
- // TODO: maybe make this extendible via settings file?
+ if ((fFlags & B_FIND_CHILD_ON_DEMAND) != 0) {
bool matches = false;
- if (!strcmp(devicePath, "disk")) {
- matches = type == PCI_mass_storage;
- } else if (!strcmp(devicePath, "audio")) {
- matches = type == PCI_multimedia
- && (subType == PCI_audio || subType == PCI_hd_audio);
- } else if (!strcmp(devicePath, "net")) {
- matches = type == PCI_network;
- } else if (!strcmp(devicePath, "graphics")) {
- matches = type == PCI_display;
- } else if (!strcmp(devicePath, "video")) {
- matches = type == PCI_multimedia && subType == PCI_video;
+ uint16 type = 0;
+ uint16 subType = 0;
+ if (get_attr_uint16(this, B_DEVICE_SUB_TYPE, &subType, false) == B_OK
+ && get_attr_uint16(this, B_DEVICE_TYPE, &type, false) == B_OK) {
+ // Check if this node matches the device path
+ // TODO: maybe make this extendible via settings file?
+ if (!strcmp(devicePath, "disk")) {
+ matches = type == PCI_mass_storage;
+ } else if (!strcmp(devicePath, "audio")) {
+ matches = type == PCI_multimedia
+ && (subType == PCI_audio || subType == PCI_hd_audio);
+ } else if (!strcmp(devicePath, "net")) {
+ matches = type == PCI_network;
+ } else if (!strcmp(devicePath, "graphics")) {
+ matches = type == PCI_display;
+ } else if (!strcmp(devicePath, "video")) {
+ matches = type == PCI_multimedia && subType == PCI_video;
+ }
+ } else {
+ // This driver does not support types, but still wants to its
+ // children explored on demand only.
+ matches = true;
}
if (matches) {
fLastUpdateCycle = updateCycle;
// This node will be probed in this update cycle
- return _Rescan();
+ return _Probe();
}
return B_OK;
@@ -1777,10 +1784,17 @@
status_t
-device_node::Rescan()
+device_node::Reprobe()
{
+ status_t status = InitDriver();
+ if (status < B_OK)
+ return status;
+
+ MethodDeleter uninit(this,
+ &device_node::UninitDriver);
+
// If this child has been probed already, probe it again
- status_t status = _Rescan();
+ status = _Probe();
if (status != B_OK)
return status;
@@ -1788,6 +1802,35 @@
while (iterator.HasNext()) {
device_node* child = iterator.Next();
+ status = child->Reprobe();
+ if (status != B_OK)
+ return status;
+ }
+
+ return B_OK;
+}
+
+
+status_t
+device_node::Rescan()
+{
+ status_t status = InitDriver();
+ if (status < B_OK)
+ return status;
+
+ MethodDeleter uninit(this,
+ &device_node::UninitDriver);
+
+ if (DriverModule()->rescan_child_devices != NULL) {
+ status = DriverModule()->rescan_child_devices(DriverData());
+ if (status != B_OK)
+ return status;
+ }
+
+ NodeList::Iterator iterator = fChildren.GetIterator();
+ while (iterator.HasNext()) {
+ device_node* child = iterator.Next();
+
status = child->Rescan();
if (status != B_OK)
return status;
@@ -2062,6 +2105,7 @@
status_t
device_manager_init_post_modules(struct kernel_args* args)
{
- return sRootNode->Rescan();
+ RecursiveLocker _(sLock);
+ return sRootNode->Reprobe();
}
From axeld at mail.berlios.de Tue Jun 3 15:22:25 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 15:22:25 +0200
Subject: [Haiku-commits] r25779 - in haiku/trunk/src:
add-ons/kernel/bus_managers/isa system/kernel/device_manager
Message-ID: <200806031322.m53DMPY5021302@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 15:22:24 +0200 (Tue, 03 Jun 2008)
New Revision: 25779
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25779&view=rev
Modified:
haiku/trunk/src/add-ons/kernel/bus_managers/isa/isa.c
haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
Log:
* device_nodes now have a priority that is used to sort them when they are
added to their parent. Currently, only the existence of B_FIND_MULTIPLE_CHILDREN
influences the priority.
* This makes it possible to register/probe intelligent busses earlier than
simple/generic busses.
* Reenabled the ISA bus manager using the new device architecture; the
ide_isa driver can and will now actually work.
* device_node::Probe() now sets the global sGenericContextPath for generic
nodes. This causes a special handling in _GetNextDriverPath().
Modified: haiku/trunk/src/add-ons/kernel/bus_managers/isa/isa.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/isa/isa.c 2008-06-03 09:13:04 UTC (rev 25778)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/isa/isa.c 2008-06-03 13:22:24 UTC (rev 25779)
@@ -34,7 +34,7 @@
// (for example, the Pegasos (PPC based) also has an ISA bus)
-#define ISA_MODULE_NAME "bus_managers/isa/root/device_v1"
+#define ISA_MODULE_NAME "bus_managers/isa/root/driver_v1"
device_manager_info *pnp;
@@ -73,75 +73,54 @@
}
-#if 0
+// #pragma mark - driver module API
+
+
static status_t
-isa_init_driver(device_node_handle node, void *user_cookie, void **cookie)
+isa_init_driver(device_node *node, void **cookie)
{
- *cookie = NULL;
+ *cookie = node;
return B_OK;
}
-static status_t
+static void
isa_uninit_driver(void *cookie)
{
- return B_OK;
}
static float
-isa_supports_device(device_node_handle parent, bool *_noConnection)
+isa_supports_device(device_node *parent)
{
- char *bus;
+ const char *bus;
// make sure parent is really pnp root
- if (pnp->get_attr_string(parent, B_DRIVER_BUS, &bus, false))
+ if (pnp->get_attr_string(parent, B_DEVICE_BUS, &bus, false))
return B_ERROR;
- if (strcmp(bus, "root")) {
- free(bus);
+ if (strcmp(bus, "root"))
return 0.0;
- }
- free(bus);
return 1.0;
}
static status_t
-isa_register_device(device_node_handle parent)
+isa_register_device(device_node *parent)
{
static const device_attr attrs[] = {
- // info about ourself
- { B_DRIVER_MODULE, B_STRING_TYPE, { string: ISA_MODULE_NAME }},
- // unique connection
- { PNP_DRIVER_CONNECTION, B_STRING_TYPE, { string: "ISA" }},
-
- // mark as being a bus
- { PNP_BUS_IS_BUS, B_UINT8_TYPE, { ui8: 1 }},
-
// tell where to look for child devices
- { B_DRIVER_BUS, B_STRING_TYPE, { string: "isa" }},
- { B_DRIVER_FIND_DEVICES_ON_DEMAND, B_UINT8_TYPE, { ui8: 1 }},
- { B_DRIVER_EXPLORE_LAST, B_UINT8_TYPE, { ui8: 1 }},
- { NULL }
+ {B_DEVICE_BUS, B_STRING_TYPE, {string: "isa" }},
+ {B_DEVICE_FLAGS, B_UINT32_TYPE,
+ {ui32: B_FIND_CHILD_ON_DEMAND | B_FIND_MULTIPLE_CHILDREN}},
+ {}
};
- return pnp->register_device(parent, attrs, NULL, NULL);
+ return pnp->register_node(parent, ISA_MODULE_NAME, attrs, NULL, NULL);
}
-static void
-isa_get_paths(const char ***_bus, const char ***_device)
-{
- static const char *kBus[] = {"root", NULL};
-
- *_bus = kBus;
- *_device = NULL;
-}
-#endif
-
-
static status_t
std_ops(int32 op, ...)
{
@@ -185,27 +164,19 @@
&unlock_isa_dma_channel
};
-#if 0
static isa2_module_info isa2_module = {
{
{
- {
- ISA_MODULE_NAME,
- 0,
- std_ops
- },
-
- isa_supports_device,
- isa_register_device,
- isa_init_driver,
- isa_uninit_driver,
- NULL, // removed device
- NULL, // cleanup device
- isa_get_paths,
+ ISA_MODULE_NAME,
+ 0,
+ std_ops
},
- // as ISA relies on device drivers to detect their devices themselves,
- // we don't have an universal rescan method
+ isa_supports_device,
+ isa_register_device,
+ isa_init_driver,
+ isa_uninit_driver,
+ NULL, // removed device
NULL, // register child devices
NULL, // rescan bus
},
@@ -218,10 +189,9 @@
arch_start_isa_dma,
};
-#endif
module_info *modules[] = {
(module_info *)&isa_module,
-// (module_info *)&isa2_module,
+ (module_info *)&isa2_module,
NULL
};
Modified: haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-03 09:13:04 UTC (rev 25778)
+++ haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-03 13:22:24 UTC (rev 25779)
@@ -136,6 +136,8 @@
device_node* FindChild(const device_attr* attributes) const;
device_node* FindChild(const char* moduleName) const;
+ int32 Priority();
+
void Dump(int32 level = 0);
private:
@@ -189,6 +191,7 @@
static device_node *sRootNode;
static recursive_lock sLock;
+static const char* sGenericContextPath;
static uint32 sDriverUpdateCycle = 1;
@@ -1260,7 +1263,22 @@
// we must not be destroyed as long as we have children
Acquire();
node->fParent = this;
- fChildren.Add(node);
+
+ int32 priority = node->Priority();
+
+ // Enforce an order in which the children are traversed - from most
+ // specific to least specific child.
+ NodeList::Iterator iterator = fChildren.GetIterator();
+ device_node* before = NULL;
+ while (iterator.HasNext()) {
+ device_node* child = iterator.Next();
+ if (child->Priority() <= priority) {
+ before = child;
+ break;
+ }
+ }
+
+ fChildren.Insert(before, node);
}
@@ -1411,11 +1429,16 @@
return B_NO_MEMORY;
StackDeleter stackDeleter(stack);
+
+ bool generic = false;
uint16 type = 0;
uint16 subType = 0;
uint16 interface = 0;
- get_attr_uint16(this, B_DEVICE_TYPE, &type, false);
- get_attr_uint16(this, B_DEVICE_SUB_TYPE, &subType, false);
+ if (get_attr_uint16(this, B_DEVICE_TYPE, &type, false) != B_OK
+ || get_attr_uint16(this, B_DEVICE_SUB_TYPE, &subType, false)
+ != B_OK)
+ generic = true;
+
get_attr_uint16(this, B_DEVICE_INTERFACE, &interface, false);
// TODO: maybe make this extendible via settings file?
@@ -1475,8 +1498,19 @@
if (sRootNode == this) {
_AddPath(*stack, "busses/pci");
_AddPath(*stack, "bus_managers");
- } else
+ } else if (!generic) {
_AddPath(*stack, "drivers");
+ } else {
+ // For generic drivers, we only allow busses when the
+ // request is more specified
+ if (sGenericContextPath != NULL
+ && (!strcmp(sGenericContextPath, "disk")
+ || !strcmp(sGenericContextPath, "ports")
+ || !strcmp(sGenericContextPath, "bus"))) {
+ _AddPath(*stack, "busses");
+ }
+ _AddPath(*stack, "drivers", sGenericContextPath);
+ }
break;
}
@@ -1758,13 +1792,17 @@
// This driver does not support types, but still wants to its
// children explored on demand only.
matches = true;
+ sGenericContextPath = devicePath;
}
if (matches) {
fLastUpdateCycle = updateCycle;
// This node will be probed in this update cycle
- return _Probe();
+ status = _Probe();
+
+ sGenericContextPath = NULL;
+ return status;
}
return B_OK;
@@ -2005,6 +2043,19 @@
}
+/*! This returns the priority or importance of this node. Nodes with higher
+ priority are registered/probed first.
+ Currently, only the B_FIND_MULITPLE_CHILDREN flag alters the priority;
+ it might make sense to be able to directly set the priority via an
+ attribute.
+*/
+int32
+device_node::Priority()
+{
+ return (fFlags & B_FIND_MULTIPLE_CHILDREN) != 0 ? 0 : 100;
+}
+
+
void
device_node::Dump(int32 level)
{
From axeld at mail.berlios.de Tue Jun 3 15:30:45 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 15:30:45 +0200
Subject: [Haiku-commits] r25780 -
haiku/trunk/src/system/kernel/device_manager
Message-ID: <200806031330.m53DUjEE024251@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 15:30:45 +0200 (Tue, 03 Jun 2008)
New Revision: 25780
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25780&view=rev
Modified:
haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
Log:
* Added a bit more debug output when enabled.
Modified: haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-03 13:22:24 UTC (rev 25779)
+++ haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-03 13:30:45 UTC (rev 25780)
@@ -1410,6 +1410,8 @@
if (status == B_OK)
status = stack.Push(path);
+ TRACE((" add path: \"%s\", %ld\n", path->Path(), status));
+
if (status != B_OK)
delete path;
From superstippi at gmx.de Tue Jun 3 16:12:43 2008
From: superstippi at gmx.de (Stephan Assmus)
Date: Tue, 03 Jun 2008 16:12:43 +0200
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To: <47430005181-BeMail@zon>
References: <47430005181-BeMail@zon>
Message-ID: <20080603141243.239490@gmx.net>
-------- Original-Nachricht --------
> Datum: Mon, 02 Jun 2008 23:28:49 +0200 CEST
> Von: "Axel D?rfler"
> An: "SVN commits to the Haiku sourcerepository=?utf-8?q?" =haiku-commits at lists.berlios.de>
> Betreff: Re: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
> stippi at BerliOS wrote:
> > Log:
> > Resolved TODO and set the flags for the kind of additional
> > bitmap support (bitmaps support child views or BViews can
> > draw them)
>
> Wasn't aware of this function - so we can just add a
> B_BITMAP_SUPPORTS_OVERLAY there and that's it?
Ah yeah, didn't even think of that, but yes! We could also add flags whether or not BBitmap can convert from/to the format (from B_RGBA32 as intermediate). Would be a nice, unintrucive way to extend existing API.
Best regards,
-Stephan
From axeld at mail.berlios.de Tue Jun 3 16:31:47 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 16:31:47 +0200
Subject: [Haiku-commits] r25781 - haiku/trunk/src/servers/app/drawing
Message-ID: <200806031431.m53EVlXG005375@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 16:31:47 +0200 (Tue, 03 Jun 2008)
New Revision: 25781
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25781&view=rev
Modified:
haiku/trunk/src/servers/app/drawing/drawing_support.h
Log:
Minor cleanup.
Modified: haiku/trunk/src/servers/app/drawing/drawing_support.h
===================================================================
--- haiku/trunk/src/servers/app/drawing/drawing_support.h 2008-06-03 13:30:45 UTC (rev 25780)
+++ haiku/trunk/src/servers/app/drawing/drawing_support.h 2008-06-03 14:31:47 UTC (rev 25781)
@@ -5,8 +5,8 @@
* Authors:
* Stephan A?mus
*/
-#ifndef SUPPORT_H
-#define SUPPORT_H
+#ifndef DRAWING_SUPPORT_H
+#define DRAWING_SUPPORT_H
#include
@@ -42,7 +42,7 @@
dst += numBytesBegin - numBytes;
src += numBytesBegin - numBytes;
numBytesBegin = numBytes;
-
+
uint32* d32 = (uint32*)dst;
uint32* s32 = (uint32*)src;
while (numBytes >= 4) {
@@ -52,7 +52,7 @@
// update original pointers
dst += numBytesBegin - numBytes;
src += numBytesBegin - numBytes;
-
+
while (numBytes > 0) {
*dst++ = *src++;
numBytes--;
@@ -142,9 +142,6 @@
gfxcpy32(buffer, tempBuffer, pixels * 4);
}
-void
-align_rect_to_pixels(BRect* rect);
+void align_rect_to_pixels(BRect* rect);
-#endif // SUPPORT_H
-
-
+#endif // DRAWING_SUPPORT_H
From axeld at mail.berlios.de Tue Jun 3 16:35:32 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 16:35:32 +0200
Subject: [Haiku-commits] r25782 - haiku/trunk/src/servers/app
Message-ID: <200806031435.m53EZWf3006155@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 16:35:31 +0200 (Tue, 03 Jun 2008)
New Revision: 25782
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25782&view=rev
Modified:
haiku/trunk/src/servers/app/Screen.cpp
haiku/trunk/src/servers/app/Screen.h
haiku/trunk/src/servers/app/VirtualScreen.cpp
Log:
* Renamed the "simple" mode setter Screen::SetMode() variant to SetBestMode();
it can also no longer create a default mode.
* This SetBestMode() function now follows a similar logic than the boot loader,
that is, only the width must not deviate, all other values are chosen as
close to the original as possible.
* VirtualScreen::AddScreen() now follows the same logic as the boot loader in
case no configuration was found, and the current screen has no preferred mode
(for example via EDID). That is, it will first try 1024x768, and then 800x600.
* This means there is no mode change anymore when switching from the boot
loader to the app_server in Qemu and VMware.
Modified: haiku/trunk/src/servers/app/Screen.cpp
===================================================================
--- haiku/trunk/src/servers/app/Screen.cpp 2008-06-03 14:31:47 UTC (rev 25781)
+++ haiku/trunk/src/servers/app/Screen.cpp 2008-06-03 14:35:31 UTC (rev 25782)
@@ -64,6 +64,9 @@
delete fHWInterface;
}
+/*! Finds the mode in the mode list that is closest to the mode specified.
+ As long as the mode list is not empty, this method will always succeed.
+*/
status_t
Screen::Initialize()
@@ -120,35 +123,47 @@
status_t
-Screen::SetMode(uint16 width, uint16 height, uint32 colorSpace,
- float frequency, bool makeDefault)
+Screen::SetBestMode(uint16 width, uint16 height, uint32 colorSpace,
+ float frequency)
{
// search for a matching mode
- display_mode mode;
- status_t status = _FindMode(width, height, colorSpace, frequency, &mode);
+ display_mode* modes = NULL;
+ uint32 count;
+ status_t status = fHWInterface->GetModeList(&modes, &count);
if (status < B_OK)
return status;
+ if (count <= 0)
+ return B_ERROR;
- if (status >= B_OK) {
- float modeFrequency = get_mode_frequency(mode);
- display_mode originalMode = mode;
- bool adjusted = false;
+ int32 index = _FindBestMode(modes, count, width, height, colorSpace,
+ frequency);
+ if (index < 0) {
+ debug_printf("Finding best mode failed");
+ delete[] modes;
+ return B_ERROR;
+ }
- if (modeFrequency != frequency) {
- // adjust timing to fit the requested frequency if needed
- // (taken from Screen preferences application)
- mode.timing.pixel_clock = ((uint32)mode.timing.h_total
- * mode.timing.v_total / 10 * int32(frequency * 10)) / 1000;
- adjusted = true;
- }
+ display_mode mode = modes[index];
+ delete[] modes;
- status = SetMode(mode, makeDefault);
- if (status < B_OK) {
- // try again with the unchanged mode
- status = SetMode(originalMode, makeDefault);
- }
+ float modeFrequency = get_mode_frequency(mode);
+ display_mode originalMode = mode;
+ bool adjusted = false;
+
+ if (modeFrequency != frequency) {
+ // adjust timing to fit the requested frequency if needed
+ // (taken from Screen preferences application)
+ mode.timing.pixel_clock = ((uint32)mode.timing.h_total
+ * mode.timing.v_total / 10 * int32(frequency * 10)) / 1000;
+ adjusted = true;
}
+ status = SetMode(mode, false);
+ if (status < B_OK && adjusted) {
+ // try again with the unchanged mode
+ status = SetMode(originalMode, false);
+ }
+
return status;
}
@@ -199,7 +214,7 @@
display_mode mode;
fHWInterface->GetMode(&mode);
- return BRect(0, 0, mode.virtual_width - 1, mode.virtual_height - 1);
+ return BRect(0, 0, mode.virtual_width - 1, mode.virtual_height - 1);
}
@@ -213,75 +228,32 @@
}
-status_t
-Screen::_FindMode(uint16 width, uint16 height, uint32 colorspace,
- float frequency, display_mode* mode) const
-{
- display_mode* modes = NULL;
- uint32 count;
-
- status_t status = fHWInterface->GetModeList(&modes, &count);
- if (status < B_OK || count <= 0) {
- // We've run into quite a problem here! This is a function which is a requirement
- // for a graphics module. The best thing that we can hope for is 640x480x8 without
- // knowing anything else. While even this seems like insanity to assume that we
- // can support this, the only lower mode supported is 640x400, but we shouldn't even
- // bother with such a pathetic possibility.
- if (width == 640 && height == 480 && colorspace == B_CMAP8)
- return B_OK;
-
- return status;
- }
-
- int32 index = _FindMode(modes, count, width, height, colorspace, frequency);
- if (index < 0) {
- fprintf(stderr, "mode not found (%d, %d, %f) -> using first mode from list!\n",
- width, height, frequency);
- // fallback to first mode from list - TODO: ?!?
- // NOTE: count > 0 is checked above
- *mode = modes[0];
- } else {
- *mode = modes[index];
- }
-
- delete[] modes;
-
- return B_OK;
-}
-
-
-/*!
- \brief Returns the mode that matches the given criteria. The frequency
- doesn't have to match, though - the closest one found is used.
+/*! \brief Returns the mode that matches the given criteria best.
+ The "width" argument is the only hard argument, the rest will be adapted
+ as needed.
*/
int32
-Screen::_FindMode(const display_mode* modes, uint32 count,
- uint16 width, uint16 height, uint32 colorspace,
- float frequency) const
+Screen::_FindBestMode(const display_mode* modes, uint32 count,
+ uint16 width, uint16 height, uint32 colorSpace, float frequency) const
{
- // we always try to choose the mode with the closest frequency
- float bestFrequencyDiff = 0.0f;
- int32 index = -1;
-
+ int32 bestDiff = 0;
+ int32 bestIndex = -1;
for (uint32 i = 0; i < count; i++) {
- if (modes[i].virtual_width == width
- && modes[i].virtual_height == height
- && modes[i].space == colorspace) {
- // we have found a mode with the correct width, height and format
- // now see if the frequency matches
- float modeFrequency = get_mode_frequency(modes[i]);
- float frequencyDiff = fabs(modeFrequency - frequency);
+ const display_mode& mode = modes[i];
+ if (mode.virtual_width != width)
+ continue;
- if (index == -1 || bestFrequencyDiff > frequencyDiff) {
- index = i;
- if (frequencyDiff == 0.0f)
- break;
+ // compute some random equality score
+ // TODO: check if these scores make sense
+ int32 diff = 1000 * abs(mode.timing.v_display - height)
+ + int32(fabs(get_mode_frequency(mode) - frequency) * 10)
+ + 100 * abs(mode.space - colorSpace);
- bestFrequencyDiff = frequencyDiff;
- }
+ if (bestIndex == -1 || diff < bestDiff) {
+ bestDiff = diff;
+ bestIndex = i;
}
}
- return index;
+ return bestIndex;
}
-
Modified: haiku/trunk/src/servers/app/Screen.h
===================================================================
--- haiku/trunk/src/servers/app/Screen.h 2008-06-03 14:31:47 UTC (rev 25781)
+++ haiku/trunk/src/servers/app/Screen.h 2008-06-03 14:35:31 UTC (rev 25782)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001-2007, Haiku, Inc.
+ * Copyright (c) 2001-2008, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
@@ -34,13 +34,12 @@
status_t SetMode(const display_mode& mode,
bool makeDefault);
status_t SetMode(uint16 width, uint16 height,
- uint32 colorspace, float frequency,
- bool makeDefault);
- status_t SetMode(uint16 width, uint16 height,
uint32 colorspace,
const display_timing& timing,
bool makeDefault);
status_t SetPreferredMode();
+ status_t SetBestMode(uint16 width, uint16 height,
+ uint32 colorspace, float frequency);
void GetMode(display_mode* mode) const;
void GetMode(uint16 &width, uint16 &height,
@@ -56,11 +55,7 @@
{ return fHWInterface; }
private:
- status_t _FindMode(uint16 width, uint16 height,
- uint32 colorspace, float frequency,
- display_mode* mode) const;
-
- int32 _FindMode(const display_mode* modeList,
+ int32 _FindBestMode(const display_mode* modeList,
uint32 count, uint16 width, uint16 height,
uint32 colorspace, float frequency) const;
Modified: haiku/trunk/src/servers/app/VirtualScreen.cpp
===================================================================
--- haiku/trunk/src/servers/app/VirtualScreen.cpp 2008-06-03 14:31:47 UTC (rev 25781)
+++ haiku/trunk/src/servers/app/VirtualScreen.cpp 2008-06-03 14:35:31 UTC (rev 25782)
@@ -156,8 +156,11 @@
}
if (status < B_OK) {
// TODO: more intelligent standard mode (monitor preference, desktop default, ...)
- if (screen->SetPreferredMode() != B_OK)
- screen->SetMode(800, 600, B_RGB32, 60.f, false);
+ status_t status = screen->SetPreferredMode();
+ if (status != B_OK)
+ status = screen->SetBestMode(1024, 768, B_RGB32, 60.f);
+ if (status != B_OK)
+ screen->SetBestMode(800, 600, B_RGB32, 60.f);
}
// TODO: this works only for single screen configurations
From bonefish at mail.berlios.de Tue Jun 3 17:04:10 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Tue, 3 Jun 2008 17:04:10 +0200
Subject: [Haiku-commits] r25783 - haiku/trunk/src/system/kernel/debug
Message-ID: <200806031504.m53F4A6M009123@sheep.berlios.de>
Author: bonefish
Date: 2008-06-03 17:04:09 +0200 (Tue, 03 Jun 2008)
New Revision: 25783
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25783&view=rev
Modified:
haiku/trunk/src/system/kernel/debug/debug.cpp
Log:
_user_debug_output() used kputs() and thus wouldn't print anything
anymore.
Modified: haiku/trunk/src/system/kernel/debug/debug.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/debug.cpp 2008-06-03 14:35:31 UTC (rev 25782)
+++ haiku/trunk/src/system/kernel/debug/debug.cpp 2008-06-03 15:04:09 UTC (rev 25783)
@@ -920,6 +920,7 @@
if (length >= OUTPUT_BUFFER_SIZE)
length = OUTPUT_BUFFER_SIZE - 1;
+ // TODO: Code duplication! Cf. dprintf_args()!
if (length > 1 && string[length - 1] == '\n'
&& strncmp(string, sLastOutputBuffer, length) == 0) {
sMessageRepeatCount++;
@@ -928,12 +929,16 @@
sMessageRepeatFirstTime = sMessageRepeatLastTime;
} else {
flush_pending_repeats();
- kputs(string);
- // kputs() doesn't output to syslog (as it's only used
- // from the kernel debugger elsewhere)
+ if (sSerialDebugEnabled)
+ arch_debug_serial_puts(string);
if (sSyslogOutputEnabled)
syslog_write(string, length);
+ if (sBlueScreenEnabled || sDebugScreenEnabled)
+ blue_screen_puts(string);
+ for (uint32 i = 0; sSerialDebugEnabled && i < kMaxDebuggerModules; i++)
+ if (sDebuggerModules[i] && sDebuggerModules[i]->debugger_puts)
+ sDebuggerModules[i]->debugger_puts(string, length);
memcpy(sLastOutputBuffer, string, length);
sLastOutputBuffer[length] = 0;
From bonefish at mail.berlios.de Tue Jun 3 17:05:18 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Tue, 3 Jun 2008 17:05:18 +0200
Subject: [Haiku-commits] r25784 - haiku/trunk/src/system/runtime_loader
Message-ID: <200806031505.m53F5I8m009248@sheep.berlios.de>
Author: bonefish
Date: 2008-06-03 17:05:16 +0200 (Tue, 03 Jun 2008)
New Revision: 25784
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25784&view=rev
Modified:
haiku/trunk/src/system/runtime_loader/elf.cpp
Log:
Don't spam to the standard output when not finding a symbol.
Modified: haiku/trunk/src/system/runtime_loader/elf.cpp
===================================================================
--- haiku/trunk/src/system/runtime_loader/elf.cpp 2008-06-03 15:04:09 UTC (rev 25783)
+++ haiku/trunk/src/system/runtime_loader/elf.cpp 2008-06-03 15:05:16 UTC (rev 25784)
@@ -1078,20 +1078,23 @@
// it's undefined, must be outside this image, try the other images
sym2 = find_undefined_symbol(rootImage, image, symname, &shimg);
if (!sym2) {
- printf("elf_resolve_symbol: could not resolve symbol '%s'\n", symname);
+ FATAL("elf_resolve_symbol: could not resolve symbol '%s'\n",
+ symname);
return B_MISSING_SYMBOL;
}
// make sure they're the same type
if (ELF32_ST_TYPE(sym->st_info) != STT_NOTYPE
&& ELF32_ST_TYPE(sym->st_info) != ELF32_ST_TYPE(sym2->st_info)) {
- printf("elf_resolve_symbol: found symbol '%s' in shared image but wrong type\n", symname);
+ FATAL("elf_resolve_symbol: found symbol '%s' in shared image "
+ "but wrong type\n", symname);
return B_MISSING_SYMBOL;
}
if (ELF32_ST_BIND(sym2->st_info) != STB_GLOBAL
&& ELF32_ST_BIND(sym2->st_info) != STB_WEAK) {
- printf("elf_resolve_symbol: found symbol '%s' but not exported\n", symname);
+ FATAL("elf_resolve_symbol: found symbol '%s' but not "
+ "exported\n", symname);
return B_MISSING_SYMBOL;
}
@@ -1104,7 +1107,7 @@
case SHN_COMMON:
// ToDo: finish this
- printf("elf_resolve_symbol: COMMON symbol, finish me!\n");
+ FATAL("elf_resolve_symbol: COMMON symbol, finish me!\n");
return B_ERROR; //ERR_NOT_IMPLEMENTED_YET;
default:
From revol at free.fr Tue Jun 3 17:08:16 2008
From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol)
Date: Tue, 03 Jun 2008 17:08:16 +0200 CEST
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To: <47430005181-BeMail@zon>
Message-ID: <473118456-BeMail@laptop>
> stippi at BerliOS wrote:
> > Log:
> > Resolved TODO and set the flags for the kind of additional
> > bitmap support (bitmaps support child views or BViews can
> > draw them)
>
> Wasn't aware of this function - so we can just add a
> B_BITMAP_SUPPORTS_OVERLAY there and that's it?
Hmm overlay support depends on the gfx card usually...
So it should be tied to BScreen I think.
Anyway most cards have a limited number (1 but sometimes 2 or 3) of
available overlays, so apps should fall back in that case.
Fran?ois.
From anevilyak at gmail.com Tue Jun 3 17:13:02 2008
From: anevilyak at gmail.com (Rene Gollent)
Date: Tue, 3 Jun 2008 10:13:02 -0500
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To: <473118456-BeMail@laptop>
References: <47430005181-BeMail@zon> <473118456-BeMail@laptop>
Message-ID:
On Tue, Jun 3, 2008 at 10:08 AM, Fran?ois Revol wrote:
> Anyway most cards have a limited number (1 but sometimes 2 or 3) of
> available overlays, so apps should fall back in that case.
Really? I haven't heard of a card that had more than one BES, at least
not in the consumer space. Happen to know one offhand? Or does
double/triple buffer overlay count as multiple as well?
Regards,
Rene
From bonefish at mail.berlios.de Tue Jun 3 17:13:34 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Tue, 3 Jun 2008 17:13:34 +0200
Subject: [Haiku-commits] r25785 - haiku/trunk/build/jam
Message-ID: <200806031513.m53FDYem010238@sheep.berlios.de>
Author: bonefish
Date: 2008-06-03 17:13:33 +0200 (Tue, 03 Jun 2008)
New Revision: 25785
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25785&view=rev
Modified:
haiku/trunk/build/jam/MainBuildRules
Log:
The Executable and Addon rules also use --no-undefined, now. Apparently
-nostdlib disables that for executables although it should be enabled by
default.
Modified: haiku/trunk/build/jam/MainBuildRules
===================================================================
--- haiku/trunk/build/jam/MainBuildRules 2008-06-03 15:05:16 UTC (rev 25784)
+++ haiku/trunk/build/jam/MainBuildRules 2008-06-03 15:13:33 UTC (rev 25785)
@@ -52,7 +52,7 @@
Main $(1) : $(2) ;
LinkAgainst $(1) : $(3) ;
LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ]
- -Xlinker -soname=_APP_ ;
+ -Xlinker --no-undefined -Xlinker -soname=_APP_ ;
# we link with -nostdlib and add the required libs manually, when building
# for Haiku
@@ -112,7 +112,8 @@
Main $(target) : $(sources) ;
- local linkFlags = -Xlinker -soname=\"$(target:G=)\" ;
+ local linkFlags = -Xlinker --no-undefined
+ -Xlinker -soname=\"$(target:G=)\" ;
if $(isExecutable) != true {
linkFlags = -nostart $(linkFlags) ;
}
From axeld at mail.berlios.de Tue Jun 3 17:18:00 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 17:18:00 +0200
Subject: [Haiku-commits] r25786 - in haiku/trunk:
headers/private/graphics/vesa headers/private/kernel/boot
src/add-ons/accelerants/vesa
src/add-ons/kernel/drivers/graphics/vesa
src/system/boot/platform/bios_ia32 src/system/kernel/debug
Message-ID: <200806031518.m53FI0le010517@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 17:17:59 +0200 (Tue, 03 Jun 2008)
New Revision: 25786
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25786&view=rev
Modified:
haiku/trunk/headers/private/graphics/vesa/vesa_info.h
haiku/trunk/headers/private/kernel/boot/kernel_args.h
haiku/trunk/src/add-ons/accelerants/vesa/accelerant_protos.h
haiku/trunk/src/add-ons/accelerants/vesa/hooks.cpp
haiku/trunk/src/add-ons/accelerants/vesa/mode.cpp
haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/Jamfile
haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp
haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp
haiku/trunk/src/system/kernel/debug/Jamfile
haiku/trunk/src/system/kernel/debug/frame_buffer_console.cpp
Log:
* The boot loader now passes on its EDID info to the kernel, and that will
be put into a boot_item in frame_buffer_console_init().
* The VESA driver now supports gettings the EDID information as well; this
is necessary now, since the app_server no longer takes over the mode the
boot loader had chosen.
* Note, we might want to do this via vm86 instead in the future, and remove
the kernel part again.
Modified: haiku/trunk/headers/private/graphics/vesa/vesa_info.h
===================================================================
--- haiku/trunk/headers/private/graphics/vesa/vesa_info.h 2008-06-03 15:13:33 UTC (rev 25785)
+++ haiku/trunk/headers/private/graphics/vesa/vesa_info.h 2008-06-03 15:17:59 UTC (rev 25786)
@@ -10,7 +10,10 @@
#include
#include
+#include
+
+#define VESA_EDID_BOOT_INFO "vesa_edid/v1"
#define VESA_MODES_BOOT_INFO "vesa_modes/v1"
struct vesa_mode {
@@ -34,6 +37,9 @@
uint32 vesa_mode_offset;
uint32 vesa_mode_count;
+
+ edid1_info edid_info;
+ bool has_edid;
};
//----------------- ioctl() interface ----------------
Modified: haiku/trunk/headers/private/kernel/boot/kernel_args.h
===================================================================
--- haiku/trunk/headers/private/kernel/boot/kernel_args.h 2008-06-03 15:13:33 UTC (rev 25785)
+++ haiku/trunk/headers/private/kernel/boot/kernel_args.h 2008-06-03 15:17:59 UTC (rev 25786)
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de.
* Distributed under the terms of the MIT License.
*
@@ -73,6 +73,7 @@
void *vesa_modes;
uint32 vesa_modes_size;
+ void *edid_info;
void *debug_output;
uint32 debug_size;
Modified: haiku/trunk/src/add-ons/accelerants/vesa/accelerant_protos.h
===================================================================
--- haiku/trunk/src/add-ons/accelerants/vesa/accelerant_protos.h 2008-06-03 15:13:33 UTC (rev 25785)
+++ haiku/trunk/src/add-ons/accelerants/vesa/accelerant_protos.h 2008-06-03 15:17:59 UTC (rev 25786)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
+ * Copyright 2005-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _ACCELERANT_PROTOS_H
@@ -26,14 +26,18 @@
// modes & constraints
uint32 vesa_accelerant_mode_count(void);
status_t vesa_get_mode_list(display_mode *dm);
-status_t vesa_propose_display_mode(display_mode *target, const display_mode *low, const display_mode *high);
+status_t vesa_propose_display_mode(display_mode *target,
+ const display_mode *low, const display_mode *high);
status_t vesa_set_display_mode(display_mode *mode_to_set);
status_t vesa_get_display_mode(display_mode *current_mode);
+status_t vesa_get_edid_info(void *info, size_t size, uint32 *_version);
status_t vesa_get_frame_buffer_config(frame_buffer_config *config);
-status_t vesa_get_pixel_clock_limits(display_mode *dm, uint32 *low, uint32 *high);
+status_t vesa_get_pixel_clock_limits(display_mode *dm, uint32 *low,
+ uint32 *high);
status_t vesa_move_display(uint16 h_display_start, uint16 v_display_start);
status_t vesa_get_timing_constraints(display_timing_constraints *dtc);
-void vesa_set_indexed_colors(uint count, uint8 first, uint8 *color_data, uint32 flags);
+void vesa_set_indexed_colors(uint count, uint8 first, uint8 *color_data,
+ uint32 flags);
// DPMS
uint32 vesa_dpms_capabilities(void);
@@ -41,34 +45,42 @@
status_t vesa_set_dpms_mode(uint32 dpms_flags);
// cursor
-status_t vesa_set_cursor_shape(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y, uint8 *andMask, uint8 *xorMask);
+status_t vesa_set_cursor_shape(uint16 width, uint16 height, uint16 hot_x,
+ uint16 hot_y, uint8 *andMask, uint8 *xorMask);
void vesa_move_cursor(uint16 x, uint16 y);
void vesa_show_cursor(bool is_visible);
// accelerant engine
uint32 vesa_accelerant_engine_count(void);
-status_t vesa_acquire_engine(uint32 capabilities, uint32 max_wait, sync_token *st, engine_token **et);
+status_t vesa_acquire_engine(uint32 capabilities, uint32 max_wait,
+ sync_token *st, engine_token **et);
status_t vesa_release_engine(engine_token *et, sync_token *st);
void vesa_wait_engine_idle(void);
status_t vesa_get_sync_token(engine_token *et, sync_token *st);
status_t vesa_sync_to_token(sync_token *st);
// 2D acceleration
-void vesa_screen_to_screen_blit(engine_token *et, blit_params *list, uint32 count);
-void vesa_fill_rectangle(engine_token *et, uint32 color, fill_rect_params *list, uint32 count);
-void vesa_invert_rectangle(engine_token *et, fill_rect_params *list, uint32 count);
+void vesa_screen_to_screen_blit(engine_token *et, blit_params *list,
+ uint32 count);
+void vesa_fill_rectangle(engine_token *et, uint32 color, fill_rect_params *list,
+ uint32 count);
+void vesa_invert_rectangle(engine_token *et, fill_rect_params *list,
+ uint32 count);
void vesa_fill_span(engine_token *et, uint32 color, uint16 *list, uint32 count);
// overlay
uint32 vesa_overlay_count(const display_mode *dm);
const uint32 *vesa_overlay_supported_spaces(const display_mode *dm);
uint32 vesa_overlay_supported_features(uint32 a_color_space);
-const overlay_buffer *vesa_allocate_overlay_buffer(color_space cs, uint16 width, uint16 height);
+const overlay_buffer *vesa_allocate_overlay_buffer(color_space cs, uint16 width,
+ uint16 height);
status_t vesa_release_overlay_buffer(const overlay_buffer *ob);
-status_t vesa_get_overlay_constraints(const display_mode *dm, const overlay_buffer *ob, overlay_constraints *oc);
+status_t vesa_get_overlay_constraints(const display_mode *dm,
+ const overlay_buffer *ob, overlay_constraints *oc);
overlay_token vesa_allocate_overlay(void);
status_t vesa_release_overlay(overlay_token ot);
-status_t vesa_configure_overlay(overlay_token ot, const overlay_buffer *ob, const overlay_window *ow, const overlay_view *ov);
+status_t vesa_configure_overlay(overlay_token ot, const overlay_buffer *ob,
+ const overlay_window *ow, const overlay_view *ov);
#ifdef __cplusplus
}
Modified: haiku/trunk/src/add-ons/accelerants/vesa/hooks.cpp
===================================================================
--- haiku/trunk/src/add-ons/accelerants/vesa/hooks.cpp 2008-06-03 15:13:33 UTC (rev 25785)
+++ haiku/trunk/src/add-ons/accelerants/vesa/hooks.cpp 2008-06-03 15:17:59 UTC (rev 25786)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
+ * Copyright 2005-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
@@ -16,13 +16,13 @@
}
-void
+void
vesa_move_cursor(uint16 x, uint16 y)
{
}
-void
+void
vesa_show_cursor(bool is_visible)
{
}
@@ -59,6 +59,8 @@
return (void*)vesa_set_display_mode;
case B_GET_DISPLAY_MODE:
return (void*)vesa_get_display_mode;
+ case B_GET_EDID_INFO:
+ return (void*)vesa_get_edid_info;
case B_GET_FRAME_BUFFER_CONFIG:
return (void*)vesa_get_frame_buffer_config;
case B_GET_PIXEL_CLOCK_LIMITS:
Modified: haiku/trunk/src/add-ons/accelerants/vesa/mode.cpp
===================================================================
--- haiku/trunk/src/add-ons/accelerants/vesa/mode.cpp 2008-06-03 15:13:33 UTC (rev 25785)
+++ haiku/trunk/src/add-ons/accelerants/vesa/mode.cpp 2008-06-03 15:17:59 UTC (rev 25786)
@@ -112,7 +112,7 @@
TRACE(("vesa_propose_display_mode()\n"));
// just search for the specified mode in the list
-
+
for (uint32 i = 0; i < gInfo->shared_info->mode_count; i++) {
display_mode *current = &gInfo->mode_list[i];
@@ -162,6 +162,22 @@
status_t
+vesa_get_edid_info(void *info, size_t size, uint32 *_version)
+{
+ TRACE(("intel_get_edid_info()\n"));
+
+ if (!gInfo->shared_info->has_edid)
+ return B_ERROR;
+ if (size < sizeof(struct edid1_info))
+ return B_BUFFER_OVERFLOW;
+
+ memcpy(info, &gInfo->shared_info->edid_info, sizeof(struct edid1_info));
+ *_version = EDID_VERSION_1;
+ return B_OK;
+}
+
+
+status_t
vesa_get_frame_buffer_config(frame_buffer_config *config)
{
TRACE(("vesa_get_frame_buffer_config()\n"));
@@ -185,7 +201,7 @@
/* lower limit of about 48Hz vertical refresh */
*low = (total_pix * 48L) / 1000L;
- if (*low > clock_limit)
+ if (*low > clock_limit)
return B_ERROR;
*high = clock_limit;
Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/Jamfile
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/Jamfile 2008-06-03 15:13:33 UTC (rev 25785)
+++ haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/Jamfile 2008-06-03 15:17:59 UTC (rev 25786)
@@ -1,5 +1,6 @@
SubDir HAIKU_TOP src add-ons kernel drivers graphics vesa ;
+UsePrivateHeaders kernel graphics [ FDirName graphics common ] ;
UsePrivateHeaders kernel graphics [ FDirName graphics vesa ] ;
KernelAddon vesa :
Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp 2008-06-03 15:13:33 UTC (rev 25785)
+++ haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp 2008-06-03 15:17:59 UTC (rev 25786)
@@ -138,6 +138,14 @@
bufferInfo->depth);
sharedInfo.bytes_per_row = bufferInfo->bytes_per_row;
+ // TODO: we might want to do this via vm86 instead
+ edid1_info *edidInfo = (edid1_info *)get_boot_item(VESA_EDID_BOOT_INFO,
+ NULL);
+ if (edidInfo != NULL) {
+ sharedInfo.has_edid = true;
+ memcpy(&sharedInfo.edid_info, edidInfo, sizeof(edid1_info));
+ }
+
physical_entry mapping;
get_memory_map((void *)sharedInfo.frame_buffer, B_PAGE_SIZE,
&mapping, 1);
Modified: haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp
===================================================================
--- haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp 2008-06-03 15:13:33 UTC (rev 25785)
+++ haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp 2008-06-03 15:17:59 UTC (rev 25786)
@@ -29,7 +29,7 @@
#include
-//#define TRACE_VIDEO
+#define TRACE_VIDEO
#ifdef TRACE_VIDEO
# define TRACE(x) dprintf x
#else
@@ -1030,6 +1030,10 @@
// We found a new default mode to use!
sDefaultMode = defaultMode;
}
+
+ gKernelArgs.edid_info = kernel_args_malloc(sizeof(edid1_info));
+ if (gKernelArgs.edid_info != NULL)
+ memcpy(gKernelArgs.edid_info, &info, sizeof(edid1_info));
}
sMode = sDefaultMode;
Modified: haiku/trunk/src/system/kernel/debug/Jamfile
===================================================================
--- haiku/trunk/src/system/kernel/debug/Jamfile 2008-06-03 15:13:33 UTC (rev 25785)
+++ haiku/trunk/src/system/kernel/debug/Jamfile 2008-06-03 15:17:59 UTC (rev 25786)
@@ -1,6 +1,7 @@
SubDir HAIKU_TOP src system kernel debug ;
UsePrivateHeaders [ FDirName kernel debug ] syslog_daemon ;
+UsePrivateHeaders [ FDirName graphics common ] ;
UsePrivateHeaders [ FDirName graphics vesa ] ;
KernelMergeObject kernel_debug.o :
Modified: haiku/trunk/src/system/kernel/debug/frame_buffer_console.cpp
===================================================================
--- haiku/trunk/src/system/kernel/debug/frame_buffer_console.cpp 2008-06-03 15:13:33 UTC (rev 25785)
+++ haiku/trunk/src/system/kernel/debug/frame_buffer_console.cpp 2008-06-03 15:17:59 UTC (rev 25786)
@@ -4,6 +4,13 @@
*/
+#include
+
+#include
+#include
+#include
+#include
+
#include
#include
#include
@@ -13,15 +20,11 @@
#include
#include
-#include
+#include
+
#include "font.h"
-#include
-#include
-#include
-#include
-
//#define TRACE_FB_CONSOLE
#ifdef TRACE_FB_CONSOLE
# define TRACE(x) dprintf x
@@ -56,11 +59,11 @@
};
static uint16 sPalette15[] = {
// 0bbbbbgggggrrrrr (5-5-5)
- 0x7fff, 0x001f, 0x03e0, 0x03ff, 0x7c00, 0x7c1f, 0x7fe0, 0x0000,
+ 0x7fff, 0x001f, 0x03e0, 0x03ff, 0x7c00, 0x7c1f, 0x7fe0, 0x0000,
};
static uint16 sPalette16[] = {
// bbbbbggggggrrrrr (5-6-5)
- 0xffff, 0x001f, 0x07e0, 0x07ff, 0xf800, 0xf81f, 0xffe0, 0x0000,
+ 0xffff, 0x001f, 0x07e0, 0x07ff, 0xf800, 0xf81f, 0xffe0, 0x0000,
};
static uint32 sPalette32[] = {
// is also used by 24 bit modes
@@ -119,7 +122,7 @@
uint8 bits = FONT[CHAR_HEIGHT * glyph + y];
for (x = 0; x < CHAR_WIDTH; x++) {
for (int32 i = 0; i < sConsole.bytes_per_pixel; i++) {
- if (bits & 1)
+ if (bits & 1)
base[x * sConsole.bytes_per_pixel + i] = color[i];
else
base[x * sConsole.bytes_per_pixel + i] = backgroundColor[i];
@@ -206,7 +209,7 @@
draw_cursor(sConsole.cursor_x, sConsole.cursor_y);
draw_cursor(x, y);
-
+
sConsole.cursor_x = x;
sConsole.cursor_y = y;
}
@@ -425,6 +428,14 @@
add_boot_item(VESA_MODES_BOOT_INFO, sVesaModes, args->vesa_modes_size);
}
+ if (args->edid_info != NULL) {
+ edid1_info *info = (edid1_info *)malloc(sizeof(edid1_info));
+ if (info != NULL) {
+ memcpy(info, args->edid_info, sizeof(edid1_info));
+ add_boot_item(VESA_EDID_BOOT_INFO, info, sizeof(edid1_info));
+ }
+ }
+
return B_OK;
}
From bonefish at mail.berlios.de Tue Jun 3 17:29:11 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Tue, 3 Jun 2008 17:29:11 +0200
Subject: [Haiku-commits] r25787 - haiku/trunk/src/apps/terminal
Message-ID: <200806031529.m53FTBbN012218@sheep.berlios.de>
Author: bonefish
Date: 2008-06-03 17:29:10 +0200 (Tue, 03 Jun 2008)
New Revision: 25787
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25787&view=rev
Added:
haiku/trunk/src/apps/terminal/TerminalBuffer.cpp
haiku/trunk/src/apps/terminal/TerminalBuffer.h
Modified:
haiku/trunk/src/apps/terminal/Jamfile
haiku/trunk/src/apps/terminal/Shell.cpp
haiku/trunk/src/apps/terminal/Shell.h
haiku/trunk/src/apps/terminal/TermParse.cpp
haiku/trunk/src/apps/terminal/TermParse.h
haiku/trunk/src/apps/terminal/TermView.h
Log:
Pulled the TermView interface used by TermParse into a new interface
class TerminalBuffer, which will evolve into a TermBuffer replacement
and decouple the parse thread from the window.
Modified: haiku/trunk/src/apps/terminal/Jamfile
===================================================================
--- haiku/trunk/src/apps/terminal/Jamfile 2008-06-03 15:17:59 UTC (rev 25786)
+++ haiku/trunk/src/apps/terminal/Jamfile 2008-06-03 15:29:10 UTC (rev 25787)
@@ -20,6 +20,7 @@
SmartTabView.cpp
TermApp.cpp
TermBuffer.cpp
+ TerminalBuffer.cpp
TermParse.cpp
TermView.cpp
TermWindow.cpp
@@ -29,4 +30,4 @@
VTPrsTbl.c
: be game tracker textencoding
: Terminal.rdef Terminal.icons.rdef
- ;
+;
Modified: haiku/trunk/src/apps/terminal/Shell.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/Shell.cpp 2008-06-03 15:17:59 UTC (rev 25786)
+++ haiku/trunk/src/apps/terminal/Shell.cpp 2008-06-03 15:29:10 UTC (rev 25787)
@@ -10,11 +10,6 @@
#include "Shell.h"
-#include "TermConst.h"
-#include "TermParse.h"
-
-#include
-
#include
#include
#include
@@ -31,7 +26,14 @@
#include
#include
+#include
+#include "TermConst.h"
+#include "TermParse.h"
+#include "TermView.h"
+ // TODO: Fix dependency!
+
+
#ifndef CEOF
#define CEOF ('D'&037)
#endif
@@ -225,6 +227,7 @@
}
+// TODO: Fix this dependency!
void
Shell::ViewAttached(TermView *view)
{
Modified: haiku/trunk/src/apps/terminal/Shell.h
===================================================================
--- haiku/trunk/src/apps/terminal/Shell.h 2008-06-03 15:17:59 UTC (rev 25786)
+++ haiku/trunk/src/apps/terminal/Shell.h 2008-06-03 15:29:10 UTC (rev 25787)
@@ -18,6 +18,7 @@
// TODO: Maybe merge TermParse and Shell classes ?
class TermParse;
class TermView;
+
class Shell {
public:
Shell();
Modified: haiku/trunk/src/apps/terminal/TermParse.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermParse.cpp 2008-06-03 15:17:59 UTC (rev 25786)
+++ haiku/trunk/src/apps/terminal/TermParse.cpp 2008-06-03 15:29:10 UTC (rev 25787)
@@ -6,11 +6,6 @@
*/
#include "TermParse.h"
-#include "CodeConv.h"
-#include "TermConst.h"
-#include "TermView.h"
-#include "VTparse.h"
-
#include
#include
#include
@@ -20,7 +15,12 @@
#include
#include
+#include "CodeConv.h"
+#include "TermConst.h"
+#include "TerminalBuffer.h"
+#include "VTparse.h"
+
//////////////////////////////////////////////////////////////////////////////
// EscParse ... Escape sequence parse and character encoding.
//
@@ -56,7 +56,7 @@
fReaderLocker(-1),
fBufferPosition(0),
fLockFlag(0),
- fView(NULL),
+ fBuffer(NULL),
fQuitting(true)
{
}
@@ -69,24 +69,24 @@
status_t
-TermParse::StartThreads(TermView *view)
+TermParse::StartThreads(TerminalBuffer *buffer)
{
- if (fView != NULL)
+ if (fBuffer != NULL)
return B_ERROR;
fQuitting = false;
- fView = view;
+ fBuffer = buffer;
status_t status = InitPtyReader();
if (status < B_OK) {
- fView = NULL;
+ fBuffer = NULL;
return status;
}
status = InitTermParse();
if (status < B_OK) {
StopPtyReader();
- fView = NULL;
+ fBuffer = NULL;
return status;
}
@@ -97,7 +97,7 @@
status_t
TermParse::StopThreads()
{
- if (fView == NULL)
+ if (fBuffer == NULL)
return B_ERROR;
fQuitting = true;
@@ -105,7 +105,7 @@
StopPtyReader();
StopTermParse();
- fView = NULL;
+ fBuffer = NULL;
return B_OK;
}
@@ -121,11 +121,11 @@
} while (status == B_INTERRUPTED);
if (status == B_TIMED_OUT) {
- fView->ScrollAtCursor();
- fView->UpdateLine();
+ fBuffer->ScrollAtCursor();
+ fBuffer->UpdateLine();
// Reset cursor blinking time and turn on cursor blinking.
- fView->SetCurDraw(true);
+ fBuffer->SetCurDraw(true);
// wait new input from pty.
do {
@@ -146,7 +146,7 @@
release_sem(fReaderLocker);
}
- fView->SetCurDraw(false);
+ fBuffer->SetCurDraw(false);
return B_OK;
}
@@ -256,7 +256,7 @@
uchar buf[READ_BUF_SIZE];
int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition));
if (nread <= 0) {
- fView->NotifyQuit(errno);
+ fBuffer->NotifyQuit(errno);
return B_OK;
}
@@ -348,11 +348,11 @@
//DumpState(groundtable, parsestate, c);
- if (now_coding != fView->Encoding()) {
+ if (now_coding != fBuffer->Encoding()) {
/*
* Change coding, change parse table.
*/
- switch (fView->Encoding()) {
+ switch (fBuffer->Encoding()) {
case B_ISO1_CONVERSION:
case B_ISO2_CONVERSION:
case B_ISO3_CONVERSION:
@@ -379,14 +379,14 @@
break;
}
parsestate = groundtable;
- now_coding = fView->Encoding();
+ now_coding = fBuffer->Encoding();
}
switch (parsestate[c]) {
case CASE_PRINT:
cbuf[0] = c;
cbuf[1] = '\0';
- fView->Insert(cbuf, attr);
+ fBuffer->Insert(cbuf, attr);
break;
case CASE_PRINT_GR:
@@ -427,7 +427,7 @@
else
CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, B_EUC_CONVERSION);
- fView->Insert(dstbuf, attr);
+ fBuffer->Insert(dstbuf, attr);
break;
case CASE_PRINT_CS96:
@@ -436,22 +436,22 @@
cbuf[1] |= 0x80;
cbuf[2] = 0;
CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, B_EUC_CONVERSION);
- fView->Insert(dstbuf, attr);
+ fBuffer->Insert(dstbuf, attr);
break;
case CASE_LF:
- fView->InsertLF();
+ fBuffer->InsertLF();
break;
case CASE_CR:
- fView->InsertCR();
+ fBuffer->InsertCR();
break;
case CASE_SJIS_KANA:
cbuf[0] = (uchar)c;
cbuf[1] = '\0';
CodeConv::ConvertToInternal((char*)cbuf, 1, (char*)dstbuf, now_coding);
- fView->Insert(dstbuf, attr);
+ fBuffer->Insert(dstbuf, attr);
break;
case CASE_SJIS_INSTRING:
@@ -459,7 +459,7 @@
GetReaderBuf(cbuf[1]);
cbuf[2] = '\0';
CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, now_coding);
- fView->Insert(dstbuf, attr);
+ fBuffer->Insert(dstbuf, attr);
break;
case CASE_UTF8_2BYTE:
@@ -470,7 +470,7 @@
cbuf[1] = (uchar)c;
cbuf[2] = '\0';
- fView->Insert(cbuf, attr);
+ fBuffer->Insert(cbuf, attr);
break;
case CASE_UTF8_3BYTE:
@@ -485,7 +485,7 @@
break;
cbuf[2] = c;
cbuf[3] = '\0';
- fView->Insert(cbuf, attr);
+ fBuffer->Insert(cbuf, attr);
break;
case CASE_MBCS:
@@ -517,13 +517,13 @@
break;
case CASE_BS:
- fView->MoveCurLeft(1);
+ fBuffer->MoveCurLeft(1);
break;
case CASE_TAB:
- tmp = fView->GetCurX();
+ tmp = fBuffer->GetCurX();
tmp %= 8;
- fView->MoveCurRight(8 - tmp);
+ fBuffer->MoveCurRight(8 - tmp);
break;
case CASE_ESC:
@@ -583,7 +583,7 @@
/* ICH */
if ((row = param[0]) < 1)
row = 1;
- fView->InsertSpace(row);
+ fBuffer->InsertSpace(row);
parsestate = groundtable;
break;
@@ -591,7 +591,7 @@
/* CUU */
if ((row = param[0]) < 1)
row = 1;
- fView->MoveCurUp(row);
+ fBuffer->MoveCurUp(row);
parsestate = groundtable;
break;
@@ -599,7 +599,7 @@
/* CUD */
if ((row = param[0]) < 1)
row = 1;
- fView->MoveCurDown(row);
+ fBuffer->MoveCurDown(row);
parsestate = groundtable;
break;
@@ -607,7 +607,7 @@
/* CUF */
if ((row = param[0]) < 1)
row = 1;
- fView->MoveCurRight(row);
+ fBuffer->MoveCurRight(row);
parsestate = groundtable;
break;
@@ -615,7 +615,7 @@
/* CUB */
if ((row = param[0]) < 1)
row = 1;
- fView->MoveCurLeft(row);
+ fBuffer->MoveCurLeft(row);
parsestate = groundtable;
break;
@@ -626,7 +626,7 @@
if (nparam < 2 || (col = param[1]) < 1)
col = 1;
- fView->SetCurPos(col - 1, row - 1 );
+ fBuffer->SetCurPos(col - 1, row - 1 );
parsestate = groundtable;
break;
@@ -635,15 +635,15 @@
switch (param[0]) {
case DEFAULT:
case 0:
- fView->EraseBelow();
+ fBuffer->EraseBelow();
break;
case 1:
break;
case 2:
- fView->SetCurPos(0, 0);
- fView->EraseBelow();
+ fBuffer->SetCurPos(0, 0);
+ fBuffer->EraseBelow();
break;
}
parsestate = groundtable;
@@ -651,7 +651,7 @@
case CASE_EL: // delete line
/* EL */
- fView->DeleteColumns();
+ fBuffer->DeleteColumns();
parsestate = groundtable;
break;
@@ -659,7 +659,7 @@
/* IL */
if ((row = param[0]) < 1)
row = 1;
- fView->InsertNewLine(row);
+ fBuffer->InsertNewLine(row);
parsestate = groundtable;
break;
@@ -667,7 +667,7 @@
/* DL */
if ((row = param[0]) < 1)
row = 1;
- fView->DeleteLine(row);
+ fBuffer->DeleteLine(row);
parsestate = groundtable;
break;
@@ -675,19 +675,19 @@
/* DCH */
if ((row = param[0]) < 1)
row = 1;
- fView->DeleteChar(row);
+ fBuffer->DeleteChar(row);
parsestate = groundtable;
break;
case CASE_SET:
/* SET */
- fView->SetInsertMode(MODE_INSERT);
+ fBuffer->SetInsertMode(MODE_INSERT);
parsestate = groundtable;
break;
case CASE_RST:
/* RST */
- fView->SetInsertMode(MODE_OVER);
+ fBuffer->SetInsertMode(MODE_OVER);
parsestate = groundtable;
break;
@@ -766,7 +766,7 @@
case CASE_CPR:
// Q & D hack by Y.Hayakawa (hida at sawada.riec.tohoku.ac.jp)
// 21-JUL-99
- fView->DeviceStatusReport(param[0]);
+ fBuffer->DeviceStatusReport(param[0]);
parsestate = groundtable;
break;
@@ -785,7 +785,7 @@
bot--;
if (bot > top)
- fView->SetScrollRegion(top, bot);
+ fBuffer->SetScrollRegion(top, bot);
parsestate = groundtable;
break;
@@ -822,13 +822,13 @@
case CASE_DECSC:
/* DECSC */
- fView->SaveCursor();
+ fBuffer->SaveCursor();
parsestate = groundtable;
break;
case CASE_DECRC:
/* DECRC */
- fView->RestoreCursor();
+ fBuffer->RestoreCursor();
parsestate = groundtable;
break;
@@ -840,7 +840,7 @@
case CASE_RI:
/* RI */
- fView->ScrollRegion(-1, -1, SCRDOWN, 1);
+ fBuffer->ScrollRegion(-1, -1, SCRDOWN, 1);
parsestate = groundtable;
break;
@@ -890,7 +890,7 @@
switch (mode_char) {
case '0':
case '2':
- fView->SetTitle(string);
+ fBuffer->SetTitle(string);
break;
case '1':
break;
@@ -939,7 +939,7 @@
row = 1;
// note beterm wants it 1-based unlike usual terminals
- fView->SetCurY(row - 1);
+ fBuffer->SetCurY(row - 1);
parsestate = groundtable;
break;
@@ -949,7 +949,7 @@
col = 1;
// note beterm wants it 1-based unlike usual terminals
- fView->SetCurX(col - 1);
+ fBuffer->SetCurX(col - 1);
parsestate = groundtable;
break;
Modified: haiku/trunk/src/apps/terminal/TermParse.h
===================================================================
--- haiku/trunk/src/apps/terminal/TermParse.h 2008-06-03 15:17:59 UTC (rev 25786)
+++ haiku/trunk/src/apps/terminal/TermParse.h 2008-06-03 15:29:10 UTC (rev 25787)
@@ -40,13 +40,14 @@
//PtyReader buffer size.
#define READ_BUF_SIZE 2048
-class TermView;
+class TerminalBuffer;
+
class TermParse : public BHandler {
public:
TermParse(int fd);
~TermParse();
- status_t StartThreads(TermView *view);
+ status_t StartThreads(TerminalBuffer *view);
status_t StopThreads();
private:
@@ -80,7 +81,7 @@
int fLockFlag;
- TermView *fView;
+ TerminalBuffer *fBuffer;
bool fQuitting;
};
Modified: haiku/trunk/src/apps/terminal/TermView.h
===================================================================
--- haiku/trunk/src/apps/terminal/TermView.h 2008-06-03 15:17:59 UTC (rev 25786)
+++ haiku/trunk/src/apps/terminal/TermView.h 2008-06-03 15:29:10 UTC (rev 25787)
@@ -12,21 +12,22 @@
#ifndef TERMVIEW_H
#define TERMVIEW_H
-
-#include "CurPos.h"
-
#include
#include
#include
+#include "CurPos.h"
+#include "TerminalBuffer.h"
+
class BClipboard;
class BMessageRunner;
class BScrollBar;
class BString;
class Shell;
class TermBuffer;
-class TermView : public BView {
+
+class TermView : public BView, public TerminalBuffer {
public:
TermView(BRect frame, int32 argc, const char **argv, int32 historySize = 1000);
TermView(int rows, int columns, int32 argc, const char **argv, int32 historySize = 1000);
Added: haiku/trunk/src/apps/terminal/TerminalBuffer.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TerminalBuffer.cpp 2008-06-03 15:17:59 UTC (rev 25786)
+++ haiku/trunk/src/apps/terminal/TerminalBuffer.cpp 2008-06-03 15:29:10 UTC (rev 25787)
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include "TerminalBuffer.h"
+
+
+TerminalBuffer::TerminalBuffer()
+{
+}
+
+
+TerminalBuffer::~TerminalBuffer()
+{
+}
Added: haiku/trunk/src/apps/terminal/TerminalBuffer.h
===================================================================
--- haiku/trunk/src/apps/terminal/TerminalBuffer.h 2008-06-03 15:17:59 UTC (rev 25786)
+++ haiku/trunk/src/apps/terminal/TerminalBuffer.h 2008-06-03 15:29:10 UTC (rev 25787)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef TERMINAL_BUFFER_H
+#define TERMINAL_BUFFER_H
+
+#include
+
+
+class TerminalBuffer {
+public:
+ TerminalBuffer();
+ virtual ~TerminalBuffer();
+
+ virtual int Encoding() const = 0;
+
+ // Output Character
+ virtual void Insert(uchar* string, ushort attr) = 0;
+ virtual void InsertCR() = 0;
+ virtual void InsertLF() = 0;
+ virtual void InsertNewLine(int num) = 0;
+ virtual void SetInsertMode(int flag) = 0;
+ virtual void InsertSpace(int num) = 0;
+
+ // Delete Character
+ virtual void EraseBelow() = 0;
+ virtual void DeleteChar(int num) = 0;
+ virtual void DeleteColumns() = 0;
+ virtual void DeleteLine(int num) = 0;
+
+ // Get and Set Cursor position
+ virtual void SetCurPos(int x, int y) = 0;
+ virtual void SetCurX(int x) = 0;
+ virtual void SetCurY(int y) = 0;
+ virtual int GetCurX() = 0;
+ virtual void SaveCursor() = 0;
+ virtual void RestoreCursor() = 0;
+
+ // Move Cursor
+ virtual void MoveCurRight(int num) = 0;
+ virtual void MoveCurLeft(int num) = 0;
+ virtual void MoveCurUp(int num) = 0;
+ virtual void MoveCurDown(int num) = 0;
+
+ // Cursor setting
+ virtual void SetCurDraw(bool flag) = 0;
+
+ // Scroll region
+ virtual void ScrollRegion(int top, int bot, int dir,
+ int num) = 0;
+ virtual void SetScrollRegion(int top, int bot) = 0;
+ virtual void ScrollAtCursor() = 0;
+
+ // Other
+ virtual void DeviceStatusReport(int) = 0;
+ virtual void UpdateLine() = 0;
+
+ virtual void SetTitle(const char* title) = 0;
+ virtual void NotifyQuit(int32 reason) = 0;
+};
+
+#endif // TERMINAL_BUFFER_H
From axeld at pinc-software.de Tue Jun 3 17:34:33 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Tue, 03 Jun 2008 17:34:33 +0200 CEST
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To: <473118456-BeMail@laptop>
Message-ID: <31302405687-BeMail@zon>
"Fran?ois Revol" wrote:
> > stippi at BerliOS wrote:
> > > Log:
> > > Resolved TODO and set the flags for the kind of additional
> > > bitmap support (bitmaps support child views or BViews can
> > > draw them)
> > Wasn't aware of this function - so we can just add a
> > B_BITMAP_SUPPORTS_OVERLAY there and that's it?
> Hmm overlay support depends on the gfx card usually...
> So it should be tied to BScreen I think.
In the Be API, overlay support is completely implemented by BBitmap.
There is not a single overlay related function in BScreen.
> Anyway most cards have a limited number (1 but sometimes 2 or 3) of
> available overlays, so apps should fall back in that case.
This has nothing to do with the general capability of using the overlay
with a certain color space.
Bye,
Axel.
From revol at free.fr Tue Jun 3 17:36:28 2008
From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol)
Date: Tue, 03 Jun 2008 17:36:28 +0200 CEST
Subject: [Haiku-commits] r25785 - haiku/trunk/build/jam
In-Reply-To: <200806031513.m53FDYem010238@sheep.berlios.de>
Message-ID: <1199766362-BeMail@laptop>
> Author: bonefish
> Date: 2008-06-03 17:13:33 +0200 (Tue, 03 Jun 2008)
> New Revision: 25785
> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25785&view=rev
>
> Modified:
> haiku/trunk/build/jam/MainBuildRules
> Log:
> The Executable and Addon rules also use --no-undefined, now.
> Apparently
> -nostdlib disables that for executables although it should be enabled
> by
> default.
Hmm is that for all platforms ?
Sometimes when building things for R5 (with specifically an R5 devkit
for zeta) it fails as the old gcc doesn't handle that option...
Fran?ois.
From revol at free.fr Tue Jun 3 17:40:26 2008
From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol)
Date: Tue, 03 Jun 2008 17:40:26 +0200 CEST
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To: <31302405687-BeMail@zon>
Message-ID: <1437451805-BeMail@laptop>
> "Fran?ois Revol" wrote:
> > > stippi at BerliOS wrote:
> > > > Log:
> > > > Resolved TODO and set the flags for the kind of additional
> > > > bitmap support (bitmaps support child views or BViews can
> > > > draw them)
> > > Wasn't aware of this function - so we can just add a
> > > B_BITMAP_SUPPORTS_OVERLAY there and that's it?
> > Hmm overlay support depends on the gfx card usually...
> > So it should be tied to BScreen I think.
>
> In the Be API, overlay support is completely implemented by BBitmap.
Indeed.
> There is not a single overlay related function in BScreen.
Yes but it's the most logical place for it.
>
> > Anyway most cards have a limited number (1 but sometimes 2 or 3) of
> > available overlays, so apps should fall back in that case.
>
> This has nothing to do with the general capability of using the
> overlay
> with a certain color space.
Well unless you mean being able to convert to/from that colorspace,
BBitmap is just a container for overlay in R5, it doesn't necessarily
know how to convert the data itself.
Oh and BTW, some cards do support some RGB colorspaces (ATI Rage Pro
comes to mind).
Fran?ois.
From ingo_weinhold at gmx.de Tue Jun 3 17:43:49 2008
From: ingo_weinhold at gmx.de (Ingo Weinhold)
Date: Tue, 03 Jun 2008 17:43:49 +0200
Subject: [Haiku-commits] r25785 - haiku/trunk/build/jam
In-Reply-To: <1199766362-BeMail@laptop>
References: <1199766362-BeMail@laptop>
Message-ID: <20080603174349.576.3@knochen-vm.1212499610.fake>
On 2008-06-03 at 17:36:28 [+0200], Fran?ois Revol wrote:
> > Author: bonefish
> > Date: 2008-06-03 17:13:33 +0200 (Tue, 03 Jun 2008)
> > New Revision: 25785
> > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25785&view=rev
> >
> > Modified:
> > haiku/trunk/build/jam/MainBuildRules
> > Log:
> > The Executable and Addon rules also use --no-undefined, now.
> > Apparently
> > -nostdlib disables that for executables although it should be enabled
> > by
> > default.
>
> Hmm is that for all platforms ?
ATM, yes.
> Sometimes when building things for R5 (with specifically an R5 devkit
> for zeta) it fails as the old gcc doesn't handle that option...
I thought gcc 2.95.3 supports it. Or do you mean the ancient gcc 2.9?
CU, Ingo
From anevilyak at gmail.com Tue Jun 3 17:46:30 2008
From: anevilyak at gmail.com (Rene Gollent)
Date: Tue, 3 Jun 2008 10:46:30 -0500
Subject: [Haiku-commits] r25787 - haiku/trunk/src/apps/terminal
In-Reply-To: <200806031529.m53FTBbN012218@sheep.berlios.de>
References: <200806031529.m53FTBbN012218@sheep.berlios.de>
Message-ID:
Hi Ingo,
On Tue, Jun 3, 2008 at 10:29 AM, bonefish at BerliOS
wrote:
> Author: bonefish
> Date: 2008-06-03 17:29:10 +0200 (Tue, 03 Jun 2008)
> New Revision: 25787
> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25787&view=rev
>
Log:
> Pulled the TermView interface used by TermParse into a new interface
> class TerminalBuffer, which will evolve into a TermBuffer replacement
> and decouple the parse thread from the window.
>
>
Is there more to come with respect to this commit? Right now it breaks
the build on gcc4 complaining about memcpy being undeclared in
TermParse.cpp .
Regards,
Rene
From revol at free.fr Tue Jun 3 17:50:10 2008
From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol)
Date: Tue, 03 Jun 2008 17:50:10 +0200 CEST
Subject: [Haiku-commits] r25785 - haiku/trunk/build/jam
In-Reply-To: <20080603174349.576.3@knochen-vm.1212499610.fake>
Message-ID: <150363106-BeMail@laptop>
>
> On 2008-06-03 at 17:36:28 [+0200], Fran?ois Revol
> wrote:
> > > Author: bonefish
> > > Date: 2008-06-03 17:13:33 +0200 (Tue, 03 Jun 2008)
> > > New Revision: 25785
> > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25785&view=rev
> > >
> > > Modified:
> > > haiku/trunk/build/jam/MainBuildRules
> > > Log:
> > > The Executable and Addon rules also use --no-undefined, now.
> > > Apparently
> > > -nostdlib disables that for executables although it should be
> > > enabled
> > > by
> > > default.
> >
> > Hmm is that for all platforms ?
>
> ATM, yes.
>
> > Sometimes when building things for R5 (with specifically an R5
> > devkit
> > for zeta) it fails as the old gcc doesn't handle that option...
>
> I thought gcc 2.95.3 supports it. Or do you mean the ancient gcc 2.9?
Yes I have R5 and BONE devkits using it...
I guess I can always comment that out.
Fran?ois.
From axeld at mail.berlios.de Tue Jun 3 18:00:14 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 18:00:14 +0200
Subject: [Haiku-commits] r25788 -
haiku/trunk/src/add-ons/accelerants/intel_extreme
Message-ID: <200806031600.m53G0EP0015475@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 18:00:09 +0200 (Tue, 03 Jun 2008)
New Revision: 25788
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25788&view=rev
Modified:
haiku/trunk/src/add-ons/accelerants/intel_extreme/hooks.cpp
Log:
Fixed copy and paste error.
Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/hooks.cpp
===================================================================
--- haiku/trunk/src/add-ons/accelerants/intel_extreme/hooks.cpp 2008-06-03 15:29:10 UTC (rev 25787)
+++ haiku/trunk/src/add-ons/accelerants/intel_extreme/hooks.cpp 2008-06-03 16:00:09 UTC (rev 25788)
@@ -1,5 +1,5 @@
/*
- * Copyright 2006, Haiku, Inc. All Rights Reserved.
+ * Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -104,7 +104,7 @@
// overlay
case B_OVERLAY_COUNT:
- return (void*)intel_overlay_supported_spaces;
+ return (void*)intel_overlay_count;
case B_OVERLAY_SUPPORTED_SPACES:
return (void*)intel_overlay_supported_spaces;
case B_OVERLAY_SUPPORTED_FEATURES:
From bonefish at mail.berlios.de Tue Jun 3 18:31:37 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Tue, 3 Jun 2008 18:31:37 +0200
Subject: [Haiku-commits] r25789 - haiku/trunk/src/apps/terminal
Message-ID: <200806031631.m53GVbKJ019679@sheep.berlios.de>
Author: bonefish
Date: 2008-06-03 18:31:36 +0200 (Tue, 03 Jun 2008)
New Revision: 25789
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25789&view=rev
Modified:
haiku/trunk/src/apps/terminal/TermParse.cpp
Log:
Fixed gcc 4 build.
Modified: haiku/trunk/src/apps/terminal/TermParse.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermParse.cpp 2008-06-03 16:00:09 UTC (rev 25788)
+++ haiku/trunk/src/apps/terminal/TermParse.cpp 2008-06-03 16:31:36 UTC (rev 25789)
@@ -10,6 +10,7 @@
#include
#include
#include
+#include
#include
#include
From bonefish at mail.berlios.de Tue Jun 3 18:34:08 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Tue, 3 Jun 2008 18:34:08 +0200
Subject: [Haiku-commits] r25790 - haiku/trunk/build/jam
Message-ID: <200806031634.m53GY85q023462@sheep.berlios.de>
Author: bonefish
Date: 2008-06-03 18:34:02 +0200 (Tue, 03 Jun 2008)
New Revision: 25790
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25790&view=rev
Modified:
haiku/trunk/build/jam/MainBuildRules
Log:
Moved --no-undefined flag addition to AddSharedObjectGlueCode where it
is added in case of target platform haiku only.
Modified: haiku/trunk/build/jam/MainBuildRules
===================================================================
--- haiku/trunk/build/jam/MainBuildRules 2008-06-03 16:31:36 UTC (rev 25789)
+++ haiku/trunk/build/jam/MainBuildRules 2008-06-03 16:34:02 UTC (rev 25790)
@@ -30,7 +30,8 @@
NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] $(stdLibs) ;
Depends $(1) : $(stdLibs) $(beginGlue) $(endGlue) ;
- LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ;
+ LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib
+ -Xlinker --no-undefined ;
}
}
@@ -52,7 +53,7 @@
Main $(1) : $(2) ;
LinkAgainst $(1) : $(3) ;
LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ]
- -Xlinker --no-undefined -Xlinker -soname=_APP_ ;
+ -Xlinker -soname=_APP_ ;
# we link with -nostdlib and add the required libs manually, when building
# for Haiku
@@ -112,8 +113,7 @@
Main $(target) : $(sources) ;
- local linkFlags = -Xlinker --no-undefined
- -Xlinker -soname=\"$(target:G=)\" ;
+ local linkFlags = -Xlinker -soname=\"$(target:G=)\" ;
if $(isExecutable) != true {
linkFlags = -nostart $(linkFlags) ;
}
@@ -398,7 +398,7 @@
MainFromObjects $(_lib) : $(2) ;
LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ]
- -nostart -Xlinker --no-undefined -Xlinker -soname=\"$(_lib:G=)\" ;
+ -nostart -Xlinker -soname=\"$(_lib:G=)\" ;
LinkAgainst $(_lib) : $(3) ;
AddSharedObjectGlueCode $(_lib) : false ;
From ingo_weinhold at gmx.de Tue Jun 3 18:37:10 2008
From: ingo_weinhold at gmx.de (Ingo Weinhold)
Date: Tue, 03 Jun 2008 18:37:10 +0200
Subject: [Haiku-commits] r25787 - haiku/trunk/src/apps/terminal
In-Reply-To:
References: <200806031529.m53FTBbN012218@sheep.berlios.de>
Message-ID: <20080603183710.721.4@knochen-vm.1212499610.fake>
On 2008-06-03 at 17:46:30 [+0200], Rene Gollent wrote:
> On Tue, Jun 3, 2008 at 10:29 AM, bonefish at BerliOS
> wrote:
> > Author: bonefish
> > Date: 2008-06-03 17:29:10 +0200 (Tue, 03 Jun 2008)
> > New Revision: 25787
> > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25787&view=rev
> >
> > Log:
> > Pulled the TermView interface used by TermParse into a new interface
> > class TerminalBuffer, which will evolve into a TermBuffer replacement
> > and decouple the parse thread from the window.
>
> Is there more to come with respect to this commit? Right now it breaks
> the build on gcc4 complaining about memcpy being undeclared in
> TermParse.cpp .
There's definitely more to come, though it will take a bit of time. I'll
try to think of checking the gcc 4 build before checking something in -- no
promises, though. :-)
CU, Ingo
From anevilyak at gmail.com Tue Jun 3 18:38:47 2008
From: anevilyak at gmail.com (Rene Gollent)
Date: Tue, 3 Jun 2008 11:38:47 -0500
Subject: [Haiku-commits] r25787 - haiku/trunk/src/apps/terminal
In-Reply-To: <20080603183710.721.4@knochen-vm.1212499610.fake>
References: <200806031529.m53FTBbN012218@sheep.berlios.de>
<20080603183710.721.4@knochen-vm.1212499610.fake>
Message-ID:
On Tue, Jun 3, 2008 at 11:37 AM, Ingo Weinhold wrote:
>
> On 2008-06-03 at 17:46:30 [+0200], Rene Gollent wrote:
> There's definitely more to come, though it will take a bit of time. I'll
> try to think of checking the gcc 4 build before checking something in -- no
> promises, though. :-)
>
No worries, I would've fixed it myself but wasn't sure if you were
still tinkering in that file. Didn't want to cause any conflicts so I
thought I'd just ask to be sure first :)
Regards,
Rene
From ingo_weinhold at gmx.de Tue Jun 3 18:41:54 2008
From: ingo_weinhold at gmx.de (Ingo Weinhold)
Date: Tue, 03 Jun 2008 18:41:54 +0200
Subject: [Haiku-commits] r25785 - haiku/trunk/build/jam
In-Reply-To: <150363106-BeMail@laptop>
References: <150363106-BeMail@laptop>
Message-ID: <20080603184154.751.5@knochen-vm.1212499610.fake>
On 2008-06-03 at 17:50:10 [+0200], Fran?ois Revol wrote:
> > On 2008-06-03 at 17:36:28 [+0200], Fran?ois Revol
> > wrote:
> > > Sometimes when building things for R5 (with specifically an R5
> > > devkit
> > > for zeta) it fails as the old gcc doesn't handle that option...
> >
> > I thought gcc 2.95.3 supports it. Or do you mean the ancient gcc 2.9?
>
> Yes I have R5 and BONE devkits using it...
> I guess I can always comment that out.
I've changed it, so that the flag is only used for platform "haiku" now. We
might want to move it to another place later (e.g. TARGET_LINKFLAGS).
CU, Ingo
From stippi at mail.berlios.de Tue Jun 3 19:07:48 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Tue, 3 Jun 2008 19:07:48 +0200
Subject: [Haiku-commits] r25791 - haiku/trunk/src/kits/media
Message-ID: <200806031707.m53H7mga032667@sheep.berlios.de>
Author: stippi
Date: 2008-06-03 19:07:47 +0200 (Tue, 03 Jun 2008)
New Revision: 25791
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25791&view=rev
Modified:
haiku/trunk/src/kits/media/PluginManager.cpp
Log:
Honor the 80 char per line limit.
Modified: haiku/trunk/src/kits/media/PluginManager.cpp
===================================================================
--- haiku/trunk/src/kits/media/PluginManager.cpp 2008-06-03 16:34:02 UTC (rev 25790)
+++ haiku/trunk/src/kits/media/PluginManager.cpp 2008-06-03 17:07:47 UTC (rev 25791)
@@ -17,20 +17,23 @@
status_t
-PluginManager::CreateReader(Reader **reader, int32 *streamCount, media_file_format *mff, BDataIO *source)
+PluginManager::CreateReader(Reader **reader, int32 *streamCount,
+ media_file_format *mff, BDataIO *source)
{
TRACE("PluginManager::CreateReader enter\n");
BPositionIO *seekable_source = dynamic_cast(source);
if (seekable_source == 0) {
- printf("PluginManager::CreateReader: non-seekable sources not supported yet\n");
+ printf("PluginManager::CreateReader: non-seekable sources not "
+ "supported yet\n");
return B_ERROR;
}
// get list of available readers from the server
server_get_readers_request request;
server_get_readers_reply reply;
- if (B_OK != QueryServer(SERVER_GET_READERS, &request, sizeof(request), &reply, sizeof(reply))) {
+ if (QueryServer(SERVER_GET_READERS, &request, sizeof(request),
+ &reply, sizeof(reply)) != B_OK) {
printf("PluginManager::CreateReader: can't get list of readers\n");
return B_ERROR;
}
@@ -61,8 +64,9 @@
seekable_source->Seek(0, SEEK_SET);
(*reader)->Setup(seekable_source);
- if (B_OK == (*reader)->Sniff(streamCount)) {
- TRACE("PluginManager::CreateReader: Sniff success (%ld stream(s))\n", *streamCount);
+ if ((*reader)->Sniff(streamCount) == B_OK) {
+ TRACE("PluginManager::CreateReader: Sniff success "
+ "(%ld stream(s))\n", *streamCount);
(*reader)->GetFileFormatInfo(mff);
return B_OK;
}
@@ -136,7 +140,8 @@
status_t
-PluginManager::GetDecoderInfo(Decoder *decoder, media_codec_info *out_info) const
+PluginManager::GetDecoderInfo(Decoder *decoder,
+ media_codec_info *out_info) const
{
if (!decoder)
return B_BAD_VALUE;
@@ -174,7 +179,8 @@
while (!fPluginList->IsEmpty()) {
plugin_info *info = NULL;
fPluginList->Get(fPluginList->CountItems() - 1, &info);
- printf("PluginManager: Error, unloading PlugIn %s with usecount %d\n", info->name, info->usecount);
+ printf("PluginManager: Error, unloading PlugIn %s with usecount "
+ "%d\n", info->name, info->usecount);
delete info->plugin;
unload_add_on(info->image);
fPluginList->Remove(fPluginList->CountItems() - 1);
@@ -247,7 +253,8 @@
status_t
-PluginManager::LoadPlugin(const entry_ref &ref, MediaPlugin **plugin, image_id *image)
+PluginManager::LoadPlugin(const entry_ref &ref, MediaPlugin **plugin,
+ image_id *image)
{
BPath p(&ref);
@@ -260,8 +267,10 @@
MediaPlugin *(*instantiate_plugin_func)();
- if (get_image_symbol(id, "instantiate_plugin", B_SYMBOL_TYPE_TEXT, (void**)&instantiate_plugin_func) < B_OK) {
- printf("PluginManager: Error, LoadPlugin can't find instantiate_plugin in %s\n", p.Path());
+ if (get_image_symbol(id, "instantiate_plugin", B_SYMBOL_TYPE_TEXT,
+ (void**)&instantiate_plugin_func) < B_OK) {
+ printf("PluginManager: Error, LoadPlugin can't find "
+ "instantiate_plugin in %s\n", p.Path());
unload_add_on(id);
return B_ERROR;
}
@@ -270,7 +279,8 @@
pl = (*instantiate_plugin_func)();
if (pl == NULL) {
- printf("PluginManager: Error, LoadPlugin instantiate_plugin in %s returned NULL\n", p.Path());
+ printf("PluginManager: Error, LoadPlugin instantiate_plugin in %s "
+ "returned NULL\n", p.Path());
unload_add_on(id);
return B_ERROR;
}
From stippi at mail.berlios.de Tue Jun 3 19:09:14 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Tue, 3 Jun 2008 19:09:14 +0200
Subject: [Haiku-commits] r25792 - haiku/trunk/src/kits/media
Message-ID: <200806031709.m53H9EWP001025@sheep.berlios.de>
Author: stippi
Date: 2008-06-03 19:09:13 +0200 (Tue, 03 Jun 2008)
New Revision: 25792
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25792&view=rev
Modified:
haiku/trunk/src/kits/media/PluginManager.cpp
Log:
Do not remove the plugin from the list if the ref count has not reached
zero, otherwise we leak these plugins, since the ref counting is based
on the plugin still being in the list.
Modified: haiku/trunk/src/kits/media/PluginManager.cpp
===================================================================
--- haiku/trunk/src/kits/media/PluginManager.cpp 2008-06-03 17:07:47 UTC (rev 25791)
+++ haiku/trunk/src/kits/media/PluginManager.cpp 2008-06-03 17:09:13 UTC (rev 25792)
@@ -239,8 +239,8 @@
if (pinfo->usecount == 0) {
delete pinfo->plugin;
unload_add_on(pinfo->image);
+ fPluginList->RemoveCurrent();
}
- fPluginList->RemoveCurrent();
fLocker->Unlock();
return;
}
From superstippi at gmx.de Tue Jun 3 19:19:19 2008
From: superstippi at gmx.de (Stephan Assmus)
Date: Tue, 03 Jun 2008 19:19:19 +0200
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To:
References: <47430005181-BeMail@zon> <473118456-BeMail@laptop>
Message-ID: <20080603171919.312560@gmx.net>
-------- Original-Nachricht --------
> Datum: Tue, 3 Jun 2008 10:13:02 -0500
> Von: "Rene Gollent"
> An: "SVN commits to the Haiku source repository"
> Betreff: Re: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
> On Tue, Jun 3, 2008 at 10:08 AM, Fran?ois Revol wrote:
> > Anyway most cards have a limited number (1 but sometimes 2 or 3) of
> > available overlays, so apps should fall back in that case.
>
> Really? I haven't heard of a card that had more than one BES, at least
> not in the consumer space. Happen to know one offhand? Or does
> double/triple buffer overlay count as multiple as well?
No it doesn't. In fact, you can create as many overlay bitmaps as fit into your video mem with just one overlay engine. IIRC, later Matrox models supported 2 or more overlay engines. However, with 3D engines which support video colorspaces in textures, you can use as many "overlays" as you want, with even better scaling algorithms. Not that this would change anyhing for Haiku at the moment... :-)
But Francois is right, if the function reported overlay capabilities, it would need to know which screen would be used by the application. Fortunately at least the BBitmap constructor already gets the screen id.
Best regards,
-Stephan
From axeld at mail.berlios.de Tue Jun 3 19:44:47 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 19:44:47 +0200
Subject: [Haiku-commits] r25793 - in haiku/trunk: headers/os/interface
src/kits/interface src/servers/app
Message-ID: <200806031744.m53HilqN017358@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 19:44:46 +0200 (Tue, 03 Jun 2008)
New Revision: 25793
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25793&view=rev
Modified:
haiku/trunk/headers/os/interface/GraphicsDefs.h
haiku/trunk/src/kits/interface/GraphicsDefs.cpp
haiku/trunk/src/servers/app/ServerApp.cpp
Log:
* Implemented retrieving additional bitmap support flags by the app_server.
* Added B_BITMAPS_SUPPORT_OVERLAY flag to indicate overlay support for the
color space.
* Rewrote GraphicsDefs.h - the previous one was obvious a copy of the Be header,
including typos and strange white space. I was a bit lazy with respect to
the color space details, and mostly trusted the information provided by the
Be header else.
Modified: haiku/trunk/headers/os/interface/GraphicsDefs.h
===================================================================
--- haiku/trunk/headers/os/interface/GraphicsDefs.h 2008-06-03 17:09:13 UTC (rev 25792)
+++ haiku/trunk/headers/os/interface/GraphicsDefs.h 2008-06-03 17:44:46 UTC (rev 25793)
@@ -1,52 +1,19 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2001-2002, OpenBeOS
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-//
-// File Name: GraphicsDefs.h
-// Author: Frans van Nispen
-// Description: BMessageFilter class creates objects that filter
-// in-coming BMessages.
-//------------------------------------------------------------------------------
-
+/*
+ * Copyright 2008, Haiku Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
#ifndef _GRAPHICS_DEFS_H
#define _GRAPHICS_DEFS_H
-// Standard Includes -----------------------------------------------------------
-// System Includes -------------------------------------------------------------
#include
#include
-// Project Includes ------------------------------------------------------------
-// Local Includes --------------------------------------------------------------
+// Pattern
-// Local Defines ---------------------------------------------------------------
-
-// Globals ---------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-
typedef struct pattern {
- uint8 data[8];
+ uint8 data[8];
} pattern;
#ifdef __cplusplus
@@ -69,8 +36,9 @@
extern const pattern B_MIXED_COLORS;
extern const pattern B_SOLID_LOW;
-//------------------------------------------------------------------------------
+// rgb_color
+
typedef struct rgb_color {
uint8 red;
uint8 green;
@@ -119,8 +87,6 @@
}
#endif
-//------------------------------------------------------------------------------
-
extern const rgb_color B_TRANSPARENT_COLOR;
extern const uint8 B_TRANSPARENT_MAGIC_CMAP8;
extern const uint16 B_TRANSPARENT_MAGIC_RGBA15;
@@ -131,8 +97,9 @@
extern const uint8 B_TRANSPARENT_8_BIT;
extern const rgb_color B_TRANSPARENT_32_BIT;
-//------------------------------------------------------------------------------
+// color map
+
typedef struct color_map {
int32 id;
rgb_color color_list[256];
@@ -140,6 +107,9 @@
uint8 index_map[32768];
} color_map;
+
+// overlay
+
typedef struct overlay_rect_limits {
uint16 horizontal_alignment;
uint16 vertical_alignment;
@@ -162,133 +132,128 @@
uint32 reserved[8];
} overlay_restrictions;
-//------------------------------------------------------------------------------
+// screen ID
+
struct screen_id { int32 id; };
extern const struct screen_id B_MAIN_SCREEN_ID;
-//------------------------------------------------------------------------------
-typedef enum
-{
- B_NO_COLOR_SPACE = 0x0000, //* byte in memory order, high bit first
-
- // linear color space (little endian is the default)
- B_RGB32 = 0x0008, //* B[7:0] G[7:0] R[7:0] -[7:0]
- B_RGBA32 = 0x2008, // B[7:0] G[7:0] R[7:0] A[7:0]
- B_RGB24 = 0x0003, // B[7:0] G[7:0] R[7:0]
- B_RGB16 = 0x0005, // G[2:0],B[4:0] R[4:0],G[5:3]
- B_RGB15 = 0x0010, // G[2:0],B[4:0] -[0],R[4:0],G[4:3]
- B_RGBA15 = 0x2010, // G[2:0],B[4:0] A[0],R[4:0],G[4:3]
- B_CMAP8 = 0x0004, // D[7:0]
- B_GRAY8 = 0x0002, // Y[7:0]
- B_GRAY1 = 0x0001, // Y0[0],Y1[0],Y2[0],Y3[0],Y4[0],Y5[0],Y6[0],Y7[0]
+// color spaces
- // big endian version, when the encoding is not endianess independant
- B_RGB32_BIG = 0x1008, // -[7:0] R[7:0] G[7:0] B[7:0]
- B_RGBA32_BIG = 0x3008, // A[7:0] R[7:0] G[7:0] B[7:0]
- B_RGB24_BIG = 0x1003, // R[7:0] G[7:0] B[7:0]
- B_RGB16_BIG = 0x1005, // R[4:0],G[5:3] G[2:0],B[4:0]
- B_RGB15_BIG = 0x1010, // -[0],R[4:0],G[4:3] G[2:0],B[4:0]
- B_RGBA15_BIG = 0x3010, // A[0],R[4:0],G[4:3] G[2:0],B[4:0]
+typedef enum {
+ B_NO_COLOR_SPACE = 0x0000,
- // little-endian declarations, for completness
- B_RGB32_LITTLE = B_RGB32,
- B_RGBA32_LITTLE = B_RGBA32,
- B_RGB24_LITTLE = B_RGB24,
- B_RGB16_LITTLE = B_RGB16,
- B_RGB15_LITTLE = B_RGB15,
- B_RGBA15_LITTLE = B_RGBA15,
+ // linear color space (little endian)
+ B_RGB32 = 0x0008, // BGR-
+ B_RGBA32 = 0x2008, // BGRA
+ B_RGB24 = 0x0003, // BGR
+ B_RGB16 = 0x0005,
+ B_RGB15 = 0x0010,
+ B_RGBA15 = 0x2010,
+ B_CMAP8 = 0x0004,
+ B_GRAY8 = 0x0002,
+ B_GRAY1 = 0x0001,
- // non linear color space -- note that these are here for exchange purposes;
- // a BBitmap or BView may not necessarily support all these color spaces.
+ // big endian version
+ B_RGB32_BIG = 0x1008, // -RGB
+ B_RGBA32_BIG = 0x3008, // ARGB
+ B_RGB24_BIG = 0x1003, // RGB
+ B_RGB16_BIG = 0x1005,
+ B_RGB15_BIG = 0x1010,
+ B_RGBA15_BIG = 0x3010,
- // Loss/Saturation points are Y 16-235 (absoulte); Cb/Cr 16-240 (center 128)
+ // explicit little-endian for completeness
+ B_RGB32_LITTLE = B_RGB32,
+ B_RGBA32_LITTLE = B_RGBA32,
+ B_RGB24_LITTLE = B_RGB24,
+ B_RGB16_LITTLE = B_RGB16,
+ B_RGB15_LITTLE = B_RGB15,
+ B_RGBA15_LITTLE = B_RGBA15,
- B_YCbCr422 = 0x4000, // Y0[7:0] Cb0[7:0] Y1[7:0] Cr0[7:0] Y2[7:0]...
- // Cb2[7:0] Y3[7:0] Cr2[7:0]
- B_YCbCr411 = 0x4001, // Cb0[7:0] Y0[7:0] Cr0[7:0] Y1[7:0] Cb4[7:0]...
- // Y2[7:0] Cr4[7:0] Y3[7:0] Y4[7:0] Y5[7:0]...
- // Y6[7:0] Y7[7:0]
- B_YCbCr444 = 0x4003, // Y0[7:0] Cb0[7:0] Cr0[7:0]
- B_YCbCr420 = 0x4004, // Non-interlaced only, Cb0 Y0 Y1 Cb2 Y2 Y3
- // on even scan lines, Cr0 Y0 Y1 Cr2 Y2 Y3
- // on odd scan lines
+ // non linear color space -- incidently, all with 8 bits per value
+ // Note, BBitmap and BView do not support all of these!
- // Extrema points are
- // Y 0 - 207 (absolute)
- // U -91 - 91 (offset 128)
- // V -127 - 127 (offset 128)
- // note that YUV byte order is different from YCbCr
- // USE YCbCr, not YUV, when that's what you mean!
- B_YUV422 = 0x4020, // U0[7:0] Y0[7:0] V0[7:0] Y1[7:0] ...
- // U2[7:0] Y2[7:0] V2[7:0] Y3[7:0]
- B_YUV411 = 0x4021, // U0[7:0] Y0[7:0] Y1[7:0] V0[7:0] Y2[7:0] Y3[7:0]
- // U4[7:0] Y4[7:0] Y5[7:0] V4[7:0] Y6[7:0] Y7[7:0]
- B_YUV444 = 0x4023, // U0[7:0] Y0[7:0] V0[7:0] U1[7:0] Y1[7:0] V1[7:0]
- B_YUV420 = 0x4024, // Non-interlaced only, U0 Y0 Y1 U2 Y2 Y3
- // on even scan lines, V0 Y0 Y1 V2 Y2 Y3
- // on odd scan lines
- B_YUV9 = 0x402C, // planar? 410?
- B_YUV12 = 0x402D, // planar? 420?
+ // loss/saturation points are Y 16-235 (absolute), Cb/Cr 16-240 (center 128)
- B_UVL24 = 0x4030, // U0[7:0] V0[7:0] L0[7:0] ...
- B_UVL32 = 0x4031, // U0[7:0] V0[7:0] L0[7:0] X0[7:0]...
- B_UVLA32 = 0x6031, // U0[7:0] V0[7:0] L0[7:0] A0[7:0]...
+ B_YCbCr422 = 0x4000, // Y0 Cb0 Y1 Cr0 Y2...
+ // Cb2 Y3 Cr2...
+ B_YCbCr411 = 0x4001, // Cb0 Y0 Cr0 Y1 Cb4...
+ // Y2 Cr4 Y3 Y4 Y5...
+ // Y6 Y7...
+ B_YCbCr444 = 0x4003, // Y Cb Cr
+ B_YCbCr420 = 0x4004, // Non-interlaced only
+ // on even scan lines: Cb0 Y0 Y1 Cb2 Y2 Y3
+ // on odd scan lines: Cr0 Y0 Y1 Cr2 Y2 Y3
- B_LAB24 = 0x4032, // L0[7:0] a0[7:0] b0[7:0] ... (a is not alpha!)
- B_LAB32 = 0x4033, // L0[7:0] a0[7:0] b0[7:0] X0[7:0] ... (b is not alpha!)
- B_LABA32 = 0x6033, // L0[7:0] a0[7:0] b0[7:0] A0[7:0] ... (A is alpha)
+ // Extrema points are:
+ // Y 0 - 207 (absolute)
+ // U -91 - 91 (offset 128)
+ // V -127 - 127 (offset 128)
- // red is at hue = 0
+ // Note that YUV byte order is different from YCbCr; use YCbCr, not YUV,
+ // when that's what you mean!
+ B_YUV422 = 0x4020, // U0 Y0 V0 Y1...
+ // U2 Y2 V2 Y3...
+ B_YUV411 = 0x4021, // U0 Y0 Y1 V0 Y2 Y3...
+ // U4 Y4 Y5 V4 Y6 Y7...
+ B_YUV444 = 0x4023, // U0 Y0 V0 U1 Y1 V1
+ B_YUV420 = 0x4024, // Non-interlaced only
+ // on even scan lines: U0 Y0 Y1 U2 Y2 Y3
+ // on odd scan lines: V0 Y0 Y1 V2 Y2 Y3
+ B_YUV9 = 0x402C,
+ B_YUV12 = 0x402D,
- B_HSI24 = 0x4040, // H[7:0] S[7:0] I[7:0]
- B_HSI32 = 0x4041, // H[7:0] S[7:0] I[7:0] X[7:0]
- B_HSIA32 = 0x6041, // H[7:0] S[7:0] I[7:0] A[7:0]
+ B_UVL24 = 0x4030, // UVL
+ B_UVL32 = 0x4031, // UVL-
+ B_UVLA32 = 0x6031, // UVLA
- B_HSV24 = 0x4042, // H[7:0] S[7:0] V[7:0]
- B_HSV32 = 0x4043, // H[7:0] S[7:0] V[7:0] X[7:0]
- B_HSVA32 = 0x6043, // H[7:0] S[7:0] V[7:0] A[7:0]
+ // L lightness, a/b color-opponent dimensions
+ B_LAB24 = 0x4032, // Lab
+ B_LAB32 = 0x4033, // Lab-
+ B_LABA32 = 0x6033, // LabA
- B_HLS24 = 0x4044, // H[7:0] L[7:0] S[7:0]
- B_HLS32 = 0x4045, // H[7:0] L[7:0] S[7:0] X[7:0]
- B_HLSA32 = 0x6045, // H[7:0] L[7:0] S[7:0] A[7:0]
+ // Red is at hue 0
+ B_HSI24 = 0x4040, // HSI
+ B_HSI32 = 0x4041, // HSI-
+ B_HSIA32 = 0x6041, // HSIA
- B_CMY24 = 0xC001, // C[7:0] M[7:0] Y[7:0] No gray removal done
- B_CMY32 = 0xC002, // C[7:0] M[7:0] Y[7:0] X[7:0] No gray removal done
- B_CMYA32 = 0xE002, // C[7:0] M[7:0] Y[7:0] A[7:0] No gray removal done
- B_CMYK32 = 0xC003, // C[7:0] M[7:0] Y[7:0] K[7:0]
+ B_HSV24 = 0x4042, // HSV
+ B_HSV32 = 0x4043, // HSV-
+ B_HSVA32 = 0x6043, // HSVA
+ B_HLS24 = 0x4044, // HLS
+ B_HLS32 = 0x4045, // HLS-
+ B_HLSA32 = 0x6045, // HLSA
+
+ B_CMY24 = 0xC001, // CMY
+ B_CMY32 = 0xC002, // CMY-
+ B_CMYA32 = 0xE002, // CMYA
+ B_CMYK32 = 0xC003, // CMYK
+
// compatibility declarations
- B_MONOCHROME_1_BIT = B_GRAY1,
- B_GRAYSCALE_8_BIT = B_GRAY8,
- B_COLOR_8_BIT = B_CMAP8,
- B_RGB_32_BIT = B_RGB32,
- B_RGB_16_BIT = B_RGB15,
- B_BIG_RGB_32_BIT = B_RGB32_BIG,
- B_BIG_RGB_16_BIT = B_RGB15_BIG
+ B_MONOCHROME_1_BIT = B_GRAY1,
+ B_GRAYSCALE_8_BIT = B_GRAY8,
+ B_COLOR_8_BIT = B_CMAP8,
+ B_RGB_32_BIT = B_RGB32,
+ B_RGB_16_BIT = B_RGB15,
+ B_BIG_RGB_32_BIT = B_RGB32_BIG,
+ B_BIG_RGB_16_BIT = B_RGB15_BIG
} color_space;
-// Find out whether a specific color space is supported by BBitmaps.
-// Support_flags will be set to what kinds of support are available.
-// If support_flags is set to 0, false will be returned.
+// Bitmap Support Flags
+
enum {
- B_VIEWS_SUPPORT_DRAW_BITMAP = 0x1,
- B_BITMAPS_SUPPORT_ATTACHED_VIEWS = 0x2
+ B_VIEWS_SUPPORT_DRAW_BITMAP = 0x1,
+ B_BITMAPS_SUPPORT_ATTACHED_VIEWS = 0x2,
+ B_BITMAPS_SUPPORT_OVERLAY = 0x4,
};
-bool bitmaps_support_space(color_space space, uint32 * support_flags);
+bool bitmaps_support_space(color_space space, uint32* _supportFlags);
-//------------------------------------------------------------------------------
-// "pixel_chunk" is the native increment from one pixel starting on an integral byte
-// to the next. "row_alignment" is the native alignment for pixel scanline starts.
-// "pixels_per_chunk" is the number of pixels in a pixel_chunk. For instance, B_GRAY1
-// sets pixel_chunk to 1, row_alignment to 4 and pixels_per_chunk to 8, whereas
-// B_RGB24 sets pixel_chunk to 3, row_alignment to 4 and pixels_per_chunk to 1.
-//------------------------------------------------------------------------------
-status_t get_pixel_size_for(color_space space, size_t * pixel_chunk,
- size_t * row_alignment, size_t * pixels_per_chunk);
+status_t get_pixel_size_for(color_space space, size_t* _pixelChunk,
+ size_t* _rowAlignment, size_t* _pixelsPerChunk);
enum buffer_orientation {
@@ -299,8 +264,9 @@
enum buffer_layout {
B_BUFFER_NONINTERLEAVED = 1
};
+
-//------------------------------------------------------------------------------
+// Drawing Modes
enum drawing_mode {
B_OP_COPY,
@@ -317,52 +283,45 @@
};
enum source_alpha {
- B_PIXEL_ALPHA=0,
+ B_PIXEL_ALPHA = 0,
B_CONSTANT_ALPHA
};
enum alpha_function {
- B_ALPHA_OVERLAY=0,
+ B_ALPHA_OVERLAY = 0,
B_ALPHA_COMPOSITE
};
+
+// Fixed Screen Modes
+
enum {
- B_8_BIT_640x480 = 0x00000001,
- B_8_BIT_800x600 = 0x00000002,
- B_8_BIT_1024x768 = 0x00000004,
- B_8_BIT_1280x1024 = 0x00000008,
- B_8_BIT_1600x1200 = 0x00000010,
- B_16_BIT_640x480 = 0x00000020,
- B_16_BIT_800x600 = 0x00000040,
- B_16_BIT_1024x768 = 0x00000080,
- B_16_BIT_1280x1024 = 0x00000100,
- B_16_BIT_1600x1200 = 0x00000200,
- B_32_BIT_640x480 = 0x00000400,
- B_32_BIT_800x600 = 0x00000800,
- B_32_BIT_1024x768 = 0x00001000,
- B_32_BIT_1280x1024 = 0x00002000,
- B_32_BIT_1600x1200 = 0x00004000,
- B_8_BIT_1152x900 = 0x00008000,
- B_16_BIT_1152x900 = 0x00010000,
- B_32_BIT_1152x900 = 0x00020000,
- B_15_BIT_640x480 = 0x00040000,
- B_15_BIT_800x600 = 0x00080000,
- B_15_BIT_1024x768 = 0x00100000,
- B_15_BIT_1280x1024 = 0x00200000,
- B_15_BIT_1600x1200 = 0x00400000,
- B_15_BIT_1152x900 = 0x00800000,
+ B_8_BIT_640x480 = 0x00000001,
+ B_8_BIT_800x600 = 0x00000002,
+ B_8_BIT_1024x768 = 0x00000004,
+ B_8_BIT_1280x1024 = 0x00000008,
+ B_8_BIT_1600x1200 = 0x00000010,
+ B_16_BIT_640x480 = 0x00000020,
+ B_16_BIT_800x600 = 0x00000040,
+ B_16_BIT_1024x768 = 0x00000080,
+ B_16_BIT_1280x1024 = 0x00000100,
+ B_16_BIT_1600x1200 = 0x00000200,
+ B_32_BIT_640x480 = 0x00000400,
+ B_32_BIT_800x600 = 0x00000800,
+ B_32_BIT_1024x768 = 0x00001000,
+ B_32_BIT_1280x1024 = 0x00002000,
+ B_32_BIT_1600x1200 = 0x00004000,
+ B_8_BIT_1152x900 = 0x00008000,
+ B_16_BIT_1152x900 = 0x00010000,
+ B_32_BIT_1152x900 = 0x00020000,
+ B_15_BIT_640x480 = 0x00040000,
+ B_15_BIT_800x600 = 0x00080000,
+ B_15_BIT_1024x768 = 0x00100000,
+ B_15_BIT_1280x1024 = 0x00200000,
+ B_15_BIT_1600x1200 = 0x00400000,
+ B_15_BIT_1152x900 = 0x00800000,
- // do not use B_FAKE_DEVICE--it will go away!
- B_FAKE_DEVICE = 0x40000000,
- B_8_BIT_640x400 = (int)0x80000000
+ B_8_BIT_640x400 = 0x80000000
};
-#endif // _GRAPHICSDEFS_H
-
-/*
- * $Log $
- *
- * $Id $
- *
- */
-
+#endif // _GRAPHICS_DEFS_H
Modified: haiku/trunk/src/kits/interface/GraphicsDefs.cpp
===================================================================
--- haiku/trunk/src/kits/interface/GraphicsDefs.cpp 2008-06-03 17:09:13 UTC (rev 25792)
+++ haiku/trunk/src/kits/interface/GraphicsDefs.cpp 2008-06-03 17:44:46 UTC (rev 25793)
@@ -1,34 +1,21 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2001-2004, Haiku
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-//
-// File Name: GraphicsDefs.cpp
-// Author: DarkWyrm
-// Caz
-// Axel D?rfler
-// Description: Graphics functions and variables for the Interface Kit
-//
-//------------------------------------------------------------------------------
+/*
+ * Copyright 2001-2008, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * DarkWyrm
+ * Caz
+ * Axel D?rfler, axeld at pinc-software.de
+ */
+//! Graphics functions and variables for the Interface Kit
+
#include
+#include
+#include
+
+
// patterns
const pattern B_SOLID_HIGH = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
const pattern B_MIXED_COLORS = {{0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55}};
@@ -50,7 +37,8 @@
status_t
-get_pixel_size_for(color_space space, size_t *pixelChunk, size_t *rowAlignment, size_t *pixelsPerChunk)
+get_pixel_size_for(color_space space, size_t *pixelChunk, size_t *rowAlignment,
+ size_t *pixelsPerChunk)
{
status_t status = B_OK;
int32 bytesPerPixel = 0;
@@ -152,12 +140,22 @@
case B_RGB16: case B_RGB15: case B_RGBA15:
case B_RGB16_BIG: case B_RGB15_BIG: case B_RGBA15_BIG:
case B_CMAP8: case B_GRAY8: case B_GRAY1:
- if (supportFlags) {
- *supportFlags = 0;
- *supportFlags |= B_VIEWS_SUPPORT_DRAW_BITMAP;
- *supportFlags |= B_BITMAPS_SUPPORT_ATTACHED_VIEWS;
+ if (supportFlags != NULL) {
+ *supportFlags = B_VIEWS_SUPPORT_DRAW_BITMAP
+ | B_BITMAPS_SUPPORT_ATTACHED_VIEWS;
+
+ BPrivate::AppServerLink link;
+ link.StartMessage(AS_GET_BITMAP_SUPPORT_FLAGS);
+
+ int32 code;
+ if (link.FlushWithReply(code) == B_OK && code == B_OK) {
+ uint32 flags = 0;
+ if (link.Read(&flags) == B_OK)
+ *supportFlags |= flags;
+ }
}
break;
+
// supported, but cannot draw
case B_YCbCr422: case B_YCbCr411: case B_YCbCr444: case B_YCbCr420:
case B_YUV422: case B_YUV411: case B_YUV444: case B_YUV420:
Modified: haiku/trunk/src/servers/app/ServerApp.cpp
===================================================================
--- haiku/trunk/src/servers/app/ServerApp.cpp 2008-06-03 17:09:13 UTC (rev 25792)
+++ haiku/trunk/src/servers/app/ServerApp.cpp 2008-06-03 17:44:46 UTC (rev 25793)
@@ -682,7 +682,22 @@
fLink.Flush();
break;
}
+ case AS_GET_BITMAP_SUPPORT_FLAGS:
+ {
+ uint32 colorSpace;
+ if (link.Read(&colorSpace) != B_OK)
+ break;
+ bool overlay = fDesktop->HWInterface()->CheckOverlayRestrictions(
+ 64, 64, (color_space)colorSpace);
+ uint32 flags = overlay ? B_BITMAPS_SUPPORT_OVERLAY : 0;
+
+ fLink.StartMessage(B_OK);
+ fLink.Attach(flags);
+ fLink.Flush();
+ break;
+ }
+
case AS_CREATE_PICTURE:
{
// TODO: Maybe rename this to AS_UPLOAD_PICTURE ?
From axeld at mail.berlios.de Tue Jun 3 19:45:54 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 19:45:54 +0200
Subject: [Haiku-commits] r25794 - haiku/trunk/headers/private/app
Message-ID: <200806031745.m53Hjs8C017501@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 19:45:54 +0200 (Tue, 03 Jun 2008)
New Revision: 25794
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25794&view=rev
Modified:
haiku/trunk/headers/private/app/ServerProtocol.h
Log:
This should have been part of r25793.
Modified: haiku/trunk/headers/private/app/ServerProtocol.h
===================================================================
--- haiku/trunk/headers/private/app/ServerProtocol.h 2008-06-03 17:44:46 UTC (rev 25793)
+++ haiku/trunk/headers/private/app/ServerProtocol.h 2008-06-03 17:45:54 UTC (rev 25794)
@@ -54,6 +54,7 @@
AS_CREATE_BITMAP,
AS_DELETE_BITMAP,
AS_GET_BITMAP_OVERLAY_RESTRICTIONS,
+ AS_GET_BITMAP_SUPPORT_FLAGS,
// Cursor commands
AS_SET_CURSOR,
From axeld at pinc-software.de Tue Jun 3 19:45:51 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Tue, 03 Jun 2008 19:45:51 +0200 CEST
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To: <20080603141243.239490@gmx.net>
Message-ID: <39180157702-BeMail@zon>
"Stephan Assmus" wrote:
> > Wasn't aware of this function - so we can just add a
> > B_BITMAP_SUPPORTS_OVERLAY there and that's it?
> Ah yeah, didn't even think of that, but yes! We could also add flags
> whether or not
> BBitmap can convert from/to the format (from B_RGBA32 as
> intermediate).
> Would be a nice, unintrucive way to extend existing API.
Indeed, sounds nice :-)
I took the liberty and implemented the overlay part of it in r25793.
Bye,
Axel.
From axeld at pinc-software.de Tue Jun 3 20:37:47 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Tue, 03 Jun 2008 20:37:47 +0200 CEST
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To: <20080603171919.312560@gmx.net>
Message-ID: <42296061755-BeMail@zon>
"Stephan Assmus" wrote:
> But Francois is right, if the function reported overlay capabilities,
> it would need to
> know which screen would be used by the application. Fortunately at
> least the BBitmap
> constructor already gets the screen id.
That is indeed some sort of a problem. But if there is more than one
graphcis card in the system (the only case where different supported
overlay spaces can occur), we might want to only show the conjunction
of their supported spaces; else, it would not be possible to move an
overlay window from one workspace to another (at least the current API
does not allow for a way to handle this IIRC).
Bye,
Axel.
From axeld at pinc-software.de Tue Jun 3 20:41:24 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Tue, 03 Jun 2008 20:41:24 +0200 CEST
Subject: [Haiku-commits] r25762 - haiku/trunk/src/kits/interface
In-Reply-To: <1437451805-BeMail@laptop>
Message-ID: <42513946310-BeMail@zon>
"Fran?ois Revol" wrote:
> > > Hmm overlay support depends on the gfx card usually...
> > > So it should be tied to BScreen I think.
> > In the Be API, overlay support is completely implemented by
> > BBitmap.
> Indeed.
> > There is not a single overlay related function in BScreen.
> Yes but it's the most logical place for it.
You would think so, indeed :-)
But OTOH, there is little that BScreen could provide besides some
informational things (or a GetOverlayBitmap() method).
> > > Anyway most cards have a limited number (1 but sometimes 2 or 3)
> > > of
> > > available overlays, so apps should fall back in that case.
> > This has nothing to do with the general capability of using the
> > overlay with a certain color space.
> Well unless you mean being able to convert to/from that colorspace,
> BBitmap is just a container for overlay in R5, it doesn't necessarily
> know how to convert the data itself.
>
> Oh and BTW, some cards do support some RGB colorspaces (ATI Rage Pro
> comes to mind).
See my other mail - that's not really a problem.
Bye,
Axel.
From axeld at mail.berlios.de Tue Jun 3 20:59:12 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 20:59:12 +0200
Subject: [Haiku-commits] r25795 - haiku/trunk/src/preferences/screen
Message-ID: <200806031859.m53IxCgY025588@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 20:59:12 +0200 (Tue, 03 Jun 2008)
New Revision: 25795
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25795&view=rev
Modified:
haiku/trunk/src/preferences/screen/ScreenWindow.cpp
haiku/trunk/src/preferences/screen/ScreenWindow.h
Log:
Applied patch by Jan Kl?\195?\182tzke with some changes by myself:
* The vesa driver/accelerant supports mode switching now. No special handling
is needed anymore.
* Always write the vesa settings file to directly start with the right
resolution regardless of the used graphics driver. Should save an additional
mode switch while booting.
Modified: haiku/trunk/src/preferences/screen/ScreenWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/screen/ScreenWindow.cpp 2008-06-03 17:45:54 UTC (rev 25794)
+++ haiku/trunk/src/preferences/screen/ScreenWindow.cpp 2008-06-03 18:59:12 UTC (rev 25795)
@@ -216,8 +216,7 @@
ScreenWindow::ScreenWindow(ScreenSettings *settings)
: BWindow(settings->WindowFrame(), "Screen", B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES),
- fIsVesa(false),
- fVesaApplied(false),
+ fBootWorkspaceApplied(false),
fScreenMode(this),
fTempScreenMode(this),
fModified(false)
@@ -249,11 +248,8 @@
// TODO: since per workspace settings is unimplemented (Ticket #693)
// we force the menu to "All Workspaces" for now
- //if (_IsVesa()) {
- fAllWorkspacesItem->SetMarked(true);
- item->SetEnabled(false);
- //} else
- // item->SetMarked(true);
+ fAllWorkspacesItem->SetMarked(true);
+ item->SetEnabled(false);
popUpMenu->AddItem(item);
@@ -530,14 +526,16 @@
ScreenWindow::QuitRequested()
{
fSettings->SetWindowFrame(Frame());
- if (fVesaApplied) {
- status_t status = _WriteVesaModeFile(fSelected);
+
+ // Write mode of workspace 0 (the boot workspace) to the vesa settings file
+ screen_mode vesaMode;
+ if (fBootWorkspaceApplied && fScreenMode.Get(vesaMode, 0) == B_OK) {
+ status_t status = _WriteVesaModeFile(vesaMode);
if (status < B_OK) {
BString warning = "Could not write VESA mode settings file:\n\t";
warning << strerror(status);
(new BAlert("VesaAlert", warning.String(), "Okay", NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
-
}
}
@@ -766,8 +764,7 @@
// has been set manually; still, as the graphics driver
// is free to fiddle with mode passed, we better ask
// what kind of mode we actually got
- if (!fVesaApplied)
- fScreenMode.Get(fActive);
+ fScreenMode.Get(fActive);
fSelected = fActive;
_UpdateControls();
@@ -789,10 +786,8 @@
void
ScreenWindow::WorkspaceActivated(int32 workspace, bool state)
{
- if (!_IsVesa()) {
- fScreenMode.GetOriginalMode(fOriginal, workspace);
- _UpdateActiveMode();
- }
+ fScreenMode.GetOriginalMode(fOriginal, workspace);
+ _UpdateActiveMode();
BMessage message(UPDATE_DESKTOP_COLOR_MSG);
PostMessage(&message, fMonitorView);
@@ -948,7 +943,7 @@
case BUTTON_REVERT_MSG:
{
fModified = false;
- fVesaApplied = false;
+ fBootWorkspaceApplied = false;
BMenuItem *item;
item = fWorkspaceCountField->Menu()->ItemAt(fOriginalWorkspaceCount - 1);
if (item != NULL)
@@ -956,17 +951,9 @@
// ScreenMode::Revert() assumes that we first set the correct number
// of workspaces
-
- if (_IsVesa()) {
- set_workspace_count(fOriginalWorkspaceCount);
- fActive = fOriginal;
- fSelected = fOriginal;
- _UpdateControls();
- } else {
- set_workspace_count(fOriginalWorkspaceCount);
- fScreenMode.Revert();
- _UpdateActiveMode();
- }
+ set_workspace_count(fOriginalWorkspaceCount);
+ fScreenMode.Revert();
+ _UpdateActiveMode();
break;
}
@@ -1018,68 +1005,6 @@
}
-status_t
-ScreenWindow::_ReadVesaModeFile(screen_mode& mode) const
-{
- BPath path;
- status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
- if (status < B_OK)
- return status;
-
- path.Append("kernel/drivers/vesa");
- BFile file;
- status = file.SetTo(path.Path(), B_READ_ONLY);
- if (status < B_OK)
- return status;
-
- char buffer[256];
-
- ssize_t bytesRead = file.Read(buffer, sizeof(buffer) - 1);
- if (bytesRead < B_OK) {
- return bytesRead;
- } else {
- buffer[bytesRead] = '\0';
- }
-
- char ignore[256];
- // if the file is malformed, sscanf shouldn't crash
- // on reading a big string since we don't even read
- // as much from the file
- uint32 bitDepth = 0;
-
- if (sscanf(buffer, "%s %ld %ld %ld", ignore, &mode.width, &mode.height,
- &bitDepth) != 4) {
- return B_ERROR;
- }
-
- // TODO: check for valid width and height values
-
- switch (bitDepth) {
- case 32:
- mode.space = B_RGB32;
- break;
- case 24:
- mode.space = B_RGB24;
- break;
- case 16:
- mode.space = B_RGB16;
- break;
- case 15:
- mode.space = B_RGB15;
- break;
- case 8:
- mode.space = B_CMAP8;
- break;
- default:
- // invalid value, we force it to B_RGB16 just in case
- mode.space = B_RGB16;
- return B_ERROR;
- }
-
- return B_OK;
-}
-
-
void
ScreenWindow::_CheckApplyEnabled()
{
@@ -1094,12 +1019,6 @@
{
fOriginalWorkspaceCount = count_workspaces();
fScreenMode.Get(fOriginal);
-
- // If we are in vesa we overwrite fOriginal's resolution and bitdepth
- // with those found the vesa settings file. (if the file exists)
- if (_IsVesa())
- _ReadVesaModeFile(fOriginal);
-
fScreenMode.UpdateOriginalModes();
}
@@ -1107,18 +1026,6 @@
void
ScreenWindow::_Apply()
{
- if (_IsVesa()) {
- (new BAlert("VesaAlert",
- "Haiku is using your video card in compatibility mode (VESA)."
- " Your settings will be applied on next startup.\n", "Okay", NULL, NULL, B_WIDTH_AS_USUAL,
- B_INFO_ALERT))->Go(NULL);
-
- fVesaApplied = true;
- fActive = fSelected;
- _UpdateControls();
- return;
- }
-
// make checkpoint, so we can undo these changes
fTempScreenMode.UpdateOriginalModes();
status_t status = fScreenMode.Set(fSelected);
@@ -1136,6 +1043,10 @@
if (i != originatingWorkspace)
screen.SetMode(i, &newMode, true);
}
+ fBootWorkspaceApplied = true;
+ } else {
+ if (current_workspace() == 0)
+ fBootWorkspaceApplied = true;
}
fActive = fSelected;
Modified: haiku/trunk/src/preferences/screen/ScreenWindow.h
===================================================================
--- haiku/trunk/src/preferences/screen/ScreenWindow.h 2008-06-03 17:45:54 UTC (rev 25794)
+++ haiku/trunk/src/preferences/screen/ScreenWindow.h 2008-06-03 18:59:12 UTC (rev 25795)
@@ -51,7 +51,6 @@
void _Apply();
status_t _WriteVesaModeFile(const screen_mode& mode) const;
- status_t _ReadVesaModeFile(screen_mode& mode) const;
bool _IsVesa() const { return fIsVesa; }
void _LayoutControls(uint32 flags);
@@ -59,7 +58,7 @@
ScreenSettings* fSettings;
bool fIsVesa;
- bool fVesaApplied;
+ bool fBootWorkspaceApplied;
BBox* fScreenBox;
BBox* fControlsBox;
From axeld at mail.berlios.de Tue Jun 3 21:06:58 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Tue, 3 Jun 2008 21:06:58 +0200
Subject: [Haiku-commits] r25796 -
haiku/trunk/src/add-ons/kernel/drivers/network/etherpci
Message-ID: <200806031906.m53J6wnv027899@sheep.berlios.de>
Author: axeld
Date: 2008-06-03 21:06:57 +0200 (Tue, 03 Jun 2008)
New Revision: 25796
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25796&view=rev
Modified:
haiku/trunk/src/add-ons/kernel/drivers/network/etherpci/etherpci.c
Log:
* Fixed warnings, and turned off debugging output.
* This fixes bug #2274.
Modified: haiku/trunk/src/add-ons/kernel/drivers/network/etherpci/etherpci.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/etherpci/etherpci.c 2008-06-03 18:59:12 UTC (rev 25795)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/etherpci/etherpci.c 2008-06-03 19:06:57 UTC (rev 25796)
@@ -39,9 +39,14 @@
/* diagnostic debug flags - compile in here or set while running with debugger "AcmeRoadRunner" command */
#define DEFAULT_DEBUG_FLAGS ( ERR | INFO | WARN | FUNCTION )
-#define ETHER_DEBUG(mask, enabled, format, args...) \
- do { if (mask & enabled) \
- dprintf(format , ##args); } while (0)
+//#define TRACE_ETHERPCI
+#ifdef TRACE_ETHERPCI
+# define ETHER_DEBUG(mask, enabled, format, args...) \
+ do { if (mask & enabled) \
+ dprintf(format , ##args); } while (0)
+#else
+# define ETHER_DEBUG(mask, enabled, format, args...) ;
+#endif
static pci_module_info *gPCIModInfo;
@@ -1494,7 +1499,7 @@
data->nonblocking = 0;
data->debug = DEFAULT_DEBUG_FLAGS;
- ETHER_DEBUG(FUNCTION, data->debug, kDevName ": open %s dev=%x\n", name, data);
+ ETHER_DEBUG(FUNCTION, data->debug, kDevName ": open %s dev=%p\n", name, data);
#if DEBUGGER_COMMAND
gdev = data;
@@ -1543,7 +1548,7 @@
close_hook(void *_data)
{
etherpci_private_t *data = (etherpci_private_t *)_data;
- ETHER_DEBUG(FUNCTION, data->debug, kDevName ": close dev=%x\n", data);
+ ETHER_DEBUG(FUNCTION, data->debug, kDevName ": close dev=%p\n", data);
/*
* Force pending reads and writes to terminate
@@ -1613,7 +1618,7 @@
etherpci_private_t *data = (etherpci_private_t *)_data;
int32 mask;
- ETHER_DEBUG(FUNCTION, data->debug, kDevName ": free %s dev=%x\n", data);
+ ETHER_DEBUG(FUNCTION, data->debug, kDevName ": free dev=%p\n", data);
#if !__INTEL__
delete_area(data->ioarea);
@@ -1706,7 +1711,7 @@
return B_OK;
case ETHER_ADDMULTI:
- ETHER_DEBUG(FUNCTION, data->debug, kDevName ": control: DO_MULTI %x\n");
+ ETHER_DEBUG(FUNCTION, data->debug, kDevName ": control: DO_MULTI\n");
return domulti(data, (char *)buf);
}
From anevilyak at mail.berlios.de Tue Jun 3 21:24:57 2008
From: anevilyak at mail.berlios.de (anevilyak at BerliOS)
Date: Tue, 3 Jun 2008 21:24:57 +0200
Subject: [Haiku-commits] r25797 - haiku/trunk/headers/os/interface
Message-ID: <200806031924.m53JOvei029582@sheep.berlios.de>
Author: anevilyak
Date: 2008-06-03 21:24:56 +0200 (Tue, 03 Jun 2008)
New Revision: 25797
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25797&view=rev
Modified:
haiku/trunk/headers/os/interface/GraphicsDefs.h
Log:
Fix GCC4 build.
Modified: haiku/trunk/headers/os/interface/GraphicsDefs.h
===================================================================
--- haiku/trunk/headers/os/interface/GraphicsDefs.h 2008-06-03 19:06:57 UTC (rev 25796)
+++ haiku/trunk/headers/os/interface/GraphicsDefs.h 2008-06-03 19:24:56 UTC (rev 25797)
@@ -248,7 +248,7 @@
enum {
B_VIEWS_SUPPORT_DRAW_BITMAP = 0x1,
B_BITMAPS_SUPPORT_ATTACHED_VIEWS = 0x2,
- B_BITMAPS_SUPPORT_OVERLAY = 0x4,
+ B_BITMAPS_SUPPORT_OVERLAY = 0x4
};
bool bitmaps_support_space(color_space space, uint32* _supportFlags);
From korli at mail.berlios.de Tue Jun 3 22:13:59 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Tue, 3 Jun 2008 22:13:59 +0200
Subject: [Haiku-commits] r25798 - haiku/trunk/headers/os/drivers
Message-ID: <200806032013.m53KDxQZ001290@sheep.berlios.de>
Author: korli
Date: 2008-06-03 22:13:59 +0200 (Tue, 03 Jun 2008)
New Revision: 25798
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25798&view=rev
Modified:
haiku/trunk/headers/os/drivers/block_io.h
Log:
use the typedef
Modified: haiku/trunk/headers/os/drivers/block_io.h
===================================================================
--- haiku/trunk/headers/os/drivers/block_io.h 2008-06-03 19:24:56 UTC (rev 25797)
+++ haiku/trunk/headers/os/drivers/block_io.h 2008-06-03 20:13:59 UTC (rev 25798)
@@ -57,7 +57,7 @@
#define B_BLOCK_DEVICE_MAX_SG_BLOCKS "block_device/max_sg_blocks"
typedef struct block_device_cookie {
- struct device_node *node;
+ device_node *node;
} block_device_cookie;
// interface to be provided by device driver
From korli at mail.berlios.de Tue Jun 3 23:05:59 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Tue, 3 Jun 2008 23:05:59 +0200
Subject: [Haiku-commits] r25799 -
haiku/trunk/src/system/kernel/device_manager
Message-ID: <200806032105.m53L5xWj007815@sheep.berlios.de>
Author: korli
Date: 2008-06-03 23:05:58 +0200 (Tue, 03 Jun 2008)
New Revision: 25799
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25799&view=rev
Modified:
haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
Log:
* some typos
* a driver can register children and have a fixed child (ie for a bus manager).
Modified: haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-03 20:13:59 UTC (rev 25798)
+++ haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-03 21:05:58 UTC (rev 25799)
@@ -1325,7 +1325,6 @@
}
if (registered > 0) {
fRegistered = true;
- return B_OK;
}
// Register the children the driver wants
@@ -1355,7 +1354,7 @@
}
-/*! Registers any children that are identified via the B_DRIVER_FIXED_CHILD
+/*! Registers any children that are identified via the B_DEVICE_FIXED_CHILD
attribute.
If any of these children cannot be registered, this call will fail (we
don't remove children we already registered up to this point in this case).
@@ -2047,7 +2046,7 @@
/*! This returns the priority or importance of this node. Nodes with higher
priority are registered/probed first.
- Currently, only the B_FIND_MULITPLE_CHILDREN flag alters the priority;
+ Currently, only the B_FIND_MULTIPLE_CHILDREN flag alters the priority;
it might make sense to be able to directly set the priority via an
attribute.
*/
From axeld at pinc-software.de Tue Jun 3 23:15:28 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Tue, 03 Jun 2008 23:15:28 +0200 CEST
Subject: [Haiku-commits]
=?utf-8?q?r25799_-_haiku/trunk/src/system/kernel/?=
=?utf-8?q?device=5Fmanager?=
In-Reply-To: <200806032105.m53L5xWj007815@sheep.berlios.de>
Message-ID: <51757542339-BeMail@zon>
korli at BerliOS wrote:
> * a driver can register children and have a fixed child (ie for a bus
> manager).
Should it really?
And even if (which is probably handy indeed, although I don't have a
good example), the change is not correct, as it now also allows dynamic
children when there shouldn't be any.
Bye,
Axel.
From marcusoverhagen at arcor.de Tue Jun 3 23:55:57 2008
From: marcusoverhagen at arcor.de (Marcus Overhagen)
Date: Tue, 03 Jun 2008 23:55:57 +0200
Subject: [Haiku-commits] r25773 - in
haiku/trunk: headers/private/kernel/arch/x86 src/system/kernel/arch/x86
In-Reply-To: <200806030437.m534bKgT017729@sheep.berlios.de>
References: <200806030437.m534bKgT017729@sheep.berlios.de>
Message-ID: <4845BDED.1000500@arcor.de>
jackburton at BerliOS schrieb:
> +/* Global Capability Register Masks */
> +#define HPET_CAP_MASK_ID 0x00000000000000FF
> +#define HPET_CAP_MASK_NUMTIMERS 0x0000000000001F00
> +#define HPET_CAP_MASK_WIDTH 0x0000000000002000
> +#define HPET_CAP_MASK_LEGACY 0x0000000000008000
> +#define HPET_CAP_MASK_VENDOR_ID 0x00000000FFFF0000
> +#define HPET_CAP_MASK_PERIOD 0xFFFFFFFF00000000
I think those defines need ULL appended, to avoid truncation
to 32 bit integer. At least the last one probably won't work
this way.
regards
Marcus
From korli at users.berlios.de Wed Jun 4 09:09:35 2008
From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=)
Date: Wed, 4 Jun 2008 09:09:35 +0200
Subject: [Haiku-commits] r25799 -
haiku/trunk/src/system/kernel/device_manager
In-Reply-To: <51757542339-BeMail@zon>
References: <200806032105.m53L5xWj007815@sheep.berlios.de>
<51757542339-BeMail@zon>
Message-ID:
2008/6/3 Axel D?rfler :
> korli at BerliOS wrote:
>> * a driver can register children and have a fixed child (ie for a bus
>> manager).
>
> Should it really?
I have the following problem with acpi atm :
acpi_root -|
|=> acpi_namespace (fixed child for a devfs entry)
|=> device1 (dynamic)
|=> device2 (dynamic)
|=> device3 (dynamic) -|
|=> device5 (dynamic)
|=> device6 (dynamic)
|=> device4 (dynamic)
> And even if (which is probably handy indeed, although I don't have a
> good example), the change is not correct, as it now also allows dynamic
> children when there shouldn't be any.
Why shouldn't there be any ?
Bye,
J?r?me
From axeld at pinc-software.de Wed Jun 4 10:27:06 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Wed, 04 Jun 2008 10:27:06 +0200 CEST
Subject: [Haiku-commits]
=?utf-8?q?r25799_-_haiku/trunk/src/system/kernel/?=
=?utf-8?q?device=5Fmanager?=
In-Reply-To:
Message-ID: <736262293-BeMail@zon>
"J?r?me Duval" wrote:
> acpi_root -|
> |=> acpi_namespace (fixed child for a devfs entry)
You don't need a fixed child for a devfs entry, you would publish it
with your other children in register_child_devices().
What should be the purpose of that devfs entry, BTW? I have ACPI on my
list as well in the future, so it's very appreciated that you work on
that :-)
> > And even if (which is probably handy indeed, although I don't have
> > a
> > good example), the change is not correct, as it now also allows
> > dynamic
> > children when there shouldn't be any.
> Why shouldn't there be any ?
Because that's how it works, you either have dynamic or fixed children,
never both.
Bye,
Axel.
From axeld at mail.berlios.de Wed Jun 4 12:39:02 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Wed, 4 Jun 2008 12:39:02 +0200
Subject: [Haiku-commits] r25800 - in haiku/trunk: headers/os/drivers
src/add-ons/kernel/bus_managers/scsi
src/add-ons/kernel/generic/block_io
src/system/kernel/device_manager src/system/kernel/fs
Message-ID: <200806041039.m54Ad2qn016023@sheep.berlios.de>
Author: axeld
Date: 2008-06-04 12:38:59 +0200 (Wed, 04 Jun 2008)
New Revision: 25800
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25800&view=rev
Removed:
haiku/trunk/headers/os/drivers/pnp_devfs.h
Modified:
haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi.c
haiku/trunk/src/add-ons/kernel/generic/block_io/block_io_private.h
haiku/trunk/src/system/kernel/device_manager/devfs.cpp
haiku/trunk/src/system/kernel/fs/IOScheduler.cpp
haiku/trunk/src/system/kernel/fs/IOScheduler.h
Log:
* Removed the now superfluous pnp_devfs.h header.
* There was a leftover in devfs that still needed it.
Deleted: haiku/trunk/headers/os/drivers/pnp_devfs.h
Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi.c 2008-06-03 21:05:58 UTC (rev 25799)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi.c 2008-06-04 10:38:59 UTC (rev 25800)
@@ -4,7 +4,6 @@
*/
#include "scsi_internal.h"
-#include
locked_pool_interface *locked_pool;
device_manager_info *pnp;
Modified: haiku/trunk/src/add-ons/kernel/generic/block_io/block_io_private.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/generic/block_io/block_io_private.h 2008-06-03 21:05:58 UTC (rev 25799)
+++ haiku/trunk/src/add-ons/kernel/generic/block_io/block_io_private.h 2008-06-04 10:38:59 UTC (rev 25800)
@@ -10,9 +10,7 @@
*/
#include
-#include
#include
-#include
#include
#include
Modified: haiku/trunk/src/system/kernel/device_manager/devfs.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2008-06-03 21:05:58 UTC (rev 25799)
+++ haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2008-06-04 10:38:59 UTC (rev 25800)
@@ -450,47 +450,6 @@
}
-static pnp_devfs_driver_info *
-create_new_driver_info(device_hooks *ops, int32 version)
-{
- pnp_devfs_driver_info *info = (pnp_devfs_driver_info *)malloc(
- sizeof(pnp_devfs_driver_info));
- if (info == NULL)
- return NULL;
-
- memset(info, 0, sizeof(driver_module_info));
-
- info->open = NULL;
- // ops->open is used directly for old devices
- info->close = ops->close;
- info->free = ops->free;
- info->control = ops->control;
- info->read = ops->read;
- info->write = ops->write;
- // depends on api_version
- info->select = NULL;
- info->deselect = NULL;
-
- info->read_pages = NULL;
- info->write_pages = NULL;
- // old devices can't know how to do physical page access
-
- if (version >= 2) {
- // According to Be newsletter, vol II, issue 36,
- // version 2 added readv/writev, which we don't support, but also
- // select/deselect.
- info->select = ops->select;
- info->deselect = ops->deselect;
-
- // ops->readv;
- // ops->writev;
- // we don't implement scatter-gather atm, so ignore those.
- }
-
- return info;
-}
-
-
static status_t
get_node_for_path(struct devfs *fs, const char *path,
struct devfs_vnode **_node)
Modified: haiku/trunk/src/system/kernel/fs/IOScheduler.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/IOScheduler.cpp 2008-06-03 21:05:58 UTC (rev 25799)
+++ haiku/trunk/src/system/kernel/fs/IOScheduler.cpp 2008-06-04 10:38:59 UTC (rev 25800)
@@ -1,7 +1,7 @@
/*
-** Copyright 2004, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
-** Distributed under the terms of the Haiku License.
-*/
+ * Copyright 2004-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
#include "IOScheduler.h"
@@ -41,9 +41,9 @@
// #pragma mark -
-IOScheduler::IOScheduler(const char *name, pnp_devfs_driver_info *hooks)
+IOScheduler::IOScheduler(const char* name, device_module_info* module)
:
- fDeviceHooks(hooks)
+ fModule(module)
{
mutex_init(&fLock, "I/O scheduler queue");
@@ -82,9 +82,9 @@
// ToDo: assume locked memory?
if (request.write)
- return fDeviceHooks->write(request.cookie, request.offset, (const void *)request.virtual_address, &request.size);
+ return fModule->write(request.cookie, request.offset, (const void *)request.virtual_address, &request.size);
- return fDeviceHooks->read(request.cookie, request.offset, (void *)request.virtual_address, &request.size);
+ return fModule->read(request.cookie, request.offset, (void *)request.virtual_address, &request.size);
}
Modified: haiku/trunk/src/system/kernel/fs/IOScheduler.h
===================================================================
--- haiku/trunk/src/system/kernel/fs/IOScheduler.h 2008-06-03 21:05:58 UTC (rev 25799)
+++ haiku/trunk/src/system/kernel/fs/IOScheduler.h 2008-06-04 10:38:59 UTC (rev 25800)
@@ -1,14 +1,12 @@
/*
-** Copyright 2004, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
-** Distributed under the terms of the Haiku License.
-*/
+ * Copyright 2004-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
#ifndef IO_SCHEDULER_H
#define IO_SCHEDULER_H
-#include
-#include
-#include
+#include
#include
#include
@@ -34,11 +32,11 @@
class IOScheduler {
public:
- IOScheduler(const char *name, pnp_devfs_driver_info *hooks);
+ IOScheduler(const char* name, device_module_info* module);
~IOScheduler();
status_t InitCheck() const;
- status_t Process(IORequest &request);
+ status_t Process(IORequest& request);
#if 0
static IOScheduler *GetScheduler();
@@ -46,10 +44,10 @@
private:
int32 Scheduler();
- static int32 scheduler(void *);
+ static int32 scheduler(void*);
private:
- pnp_devfs_driver_info *fDeviceHooks;
+ device_module_info* fModule;
mutex fLock;
thread_id fThread;
DoublyLinkedList fRequests;
From axeld at mail.berlios.de Wed Jun 4 12:50:09 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Wed, 4 Jun 2008 12:50:09 +0200
Subject: [Haiku-commits] r25801 -
haiku/trunk/src/system/kernel/device_manager
Message-ID: <200806041050.m54Ao9d4032664@sheep.berlios.de>
Author: axeld
Date: 2008-06-04 12:50:06 +0200 (Wed, 04 Jun 2008)
New Revision: 25801
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25801&view=rev
Modified:
haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
Log:
* While it's okay to allow nodes with fixed children to register their own
children, you either have dynamic or fixed children, never both.
Modified: haiku/trunk/src/system/kernel/device_manager/device_manager.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-04 10:38:59 UTC (rev 25800)
+++ haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-06-04 10:50:06 UTC (rev 25801)
@@ -1317,15 +1317,12 @@
// We don't uninitialize the driver - this is done by the caller
// in order to save reinitializing during driver loading.
- uint32 registered;
- status = _RegisterFixed(registered);
+ uint32 registeredFixedCount;
+ status = _RegisterFixed(registeredFixedCount);
if (status != B_OK) {
UninitUnusedDriver();
return status;
}
- if (registered > 0) {
- fRegistered = true;
- }
// Register the children the driver wants
@@ -1342,6 +1339,13 @@
}
}
+ if (registeredFixedCount > 0) {
+ // Nodes with fixed children cannot have any dynamic children, so bail
+ // out here
+ fRegistered = true;
+ return B_OK;
+ }
+
// Register all possible child device nodes
status = _RegisterDynamic();
From korli at users.berlios.de Wed Jun 4 13:17:02 2008
From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=)
Date: Wed, 4 Jun 2008 13:17:02 +0200
Subject: [Haiku-commits] r25799 -
haiku/trunk/src/system/kernel/device_manager
In-Reply-To: <736262293-BeMail@zon>
References:
<736262293-BeMail@zon>
Message-ID:
Hi Axel,
2008/6/4 Axel D?rfler :
> "J?r?me Duval" wrote:
>> acpi_root -|
>> |=> acpi_namespace (fixed child for a devfs entry)
>
> You don't need a fixed child for a devfs entry, you would publish it
> with your other children in register_child_devices().
Will try that.
> What should be the purpose of that devfs entry, BTW? I have ACPI on my
> list as well in the future, so it's very appreciated that you work on
> that :-)
it is used to publish a /dev/bus/acpi/namespace entry, then cat
/dev/bus/acpi/namespace dumps the acpi tree (not that useful).
If you wonder, the current driver lives in
src/add-ons/kernel/bus_managers/acpi/acpi_ns_dump.c
>
>> > And even if (which is probably handy indeed, although I don't have
>> > a
>> > good example), the change is not correct, as it now also allows
>> > dynamic
>> > children when there shouldn't be any.
>> Why shouldn't there be any ?
>
> Because that's how it works, you either have dynamic or fixed children,
> never both.
It wasn't the case on the previous device manager, so one cannot know :)
BTW when registering a tree of devices in acpi, it seems that a
reference has to be acquired on each non-leaf device. If not, the
second probe triggers a deletion of non-leaf devices, which is bad. I
added a get_parent_node() call to avoid this deletion.
Bye,
J?r?me
From axeld at mail.berlios.de Wed Jun 4 13:40:01 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Wed, 4 Jun 2008 13:40:01 +0200
Subject: [Haiku-commits] r25802 - haiku/trunk/docs/develop/kernel
Message-ID: <200806041140.m54Be1D2004829@sheep.berlios.de>
Author: axeld
Date: 2008-06-04 13:40:00 +0200 (Wed, 04 Jun 2008)
New Revision: 25802
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25802&view=rev
Modified:
haiku/trunk/docs/develop/kernel/device_manager_introduction.html
Log:
More or less completed the introduction. I would just want to add the image,
and publish it on the website - comments are still welcome, though.
Modified: haiku/trunk/docs/develop/kernel/device_manager_introduction.html
===================================================================
--- haiku/trunk/docs/develop/kernel/device_manager_introduction.html 2008-06-04 10:50:06 UTC (rev 25801)
+++ haiku/trunk/docs/develop/kernel/device_manager_introduction.html 2008-06-04 11:40:00 UTC (rev 25802)
@@ -11,7 +11,7 @@
although most of its details are already specificed.
-1. The Basics
+1. The Basics
The device manager functionality builds upon device_node objects.
Every driver in the system publishes one or more of such nodes, building a
@@ -36,7 +36,7 @@
userland applications. All drivers and devices are kernel modules.
-2. Exploring the Device Tree
+2. Exploring the Device Tree
So how does it all work? When building the initial device tree, the system only
explores a minimum of device drivers only, resulting in a tree that basically
@@ -55,10 +55,15 @@
are in a matching module directory. In the above example of a disk driver, this
would be either in "busses/scsi", "busses/ide", "drivers/disk", ...
-TODO: untyped/generic busses are not yet supported!
+For untyped or generic busses, it will use the context information gained
+from the devfs query directly, and will search for drivers in that sub directory
+only. The only exception to this rule are the devfs directories "disk", "ports",
+and "bus", which will also allow to search matching drivers in "busses". While
+this is relatively limited, it is a good way to cut down the number of drivers
+to be loaded.
-3. Writing a Driver
+3. Writing a Driver
The device manager assumes the following API from a driver module:
@@ -92,6 +97,7 @@
- resume()
Resumes a device from a previous sleep mode.
+
To ensure that a module exports this API, it must end its module name
with "driver_v1" to denote the version of the API it supports. Note that
suspend() and resume() are currently never called, as Haiku has
@@ -100,6 +106,7 @@
If your driver can give the device it is attached to a nice name that can be
presented to the user, it should add the B_DEVICE_PRETTY_NAME attribute
to the device node.
+
The B_DEVICE_UNIQUE_ID should be used in case the device has a unique
ID that can be used to identify it, and also differentiate it from other devices
of the same model and vendor. This information will be added to the file system
@@ -107,15 +114,21 @@
can identify, say, a USB printer no matter what USB slot it is attached to, and
assign it additional data, like paper configuration, or recognize it as the
default printer.
+
If your driver implements an API that is used by a support or bus module, you
will usually use the B_DEVICE_FIXED_CHILD attribute to specify exactly
which child device node you will be talking to. If you support several child
nodes, you may want to have a closer look at the section explaining
how to write a bus driver.
+In addition to the child nodes a driver registers itself, a driver can either
+have dynamic children or fixed children, never both. Also, fixed children are
+registered before register_child_devices() is called, while dynamic
+children are registered afterwards.
-4. Publishing a Device
+4. Publishing a Device
+
To publish a device entry in the device file system under /dev, all your
driver has to do is to call the
@@ -166,7 +179,7 @@
-
+
A bus driver is a driver that represents a bus where one or more arbitrary
devices can be attached to.
@@ -211,11 +224,28 @@
5.2. Writing a Simple Bus Driver
-TODO: support for these drivers is still missing!
+A bus can be simple in a number of ways:
+
+- It may not know how many or if any devices are attached to it
+- It cannot retrieve any type information about the devices it has, but
+ knows all devices that are attached to it
+
+An example of the latter would be the Zorro bus of the Amiga - it only has
+information about the vendor and device ID, but no type information. It should
+be implemented like an intelligent bus, though, with the type information simply
+omitted.
-6. Open Issues
+Therefore, this section is about the former case, that is, a simple bus like
+the ISA bus. Since it doesn't know anything about its children, it does not
+publish any child nodes, instead, it will just specify the
+B_FIND_MULTIPLE_CHILDREN and B_FIND_CHILD_ON_DEMAND flags for its device node.
+Since there are no additional informations about this bus, the device manager
+will assume a simple bus, and will try to find drivers on demand only.
+
+6. Open Issues
+
While most of the new device manager is fledged out, there are some areas that
could use improvements or are problematic under certain requirements. Also, some
parts just haven't been written yet.
@@ -245,5 +275,39 @@
6.5. Unregistering Nodes
+6.6. Support for generic drivers is missing
+
+This should probably be done by simply adding a simple bus driver named
+"generic" that generic drivers need to ask for.
+
+6.7. Mappings, And Other Optimizations
+
+Due to the way the device tree is built, the device manager could remember
+which driver served a given device node. That way, it wouldn't need to search
+for a driver anymore, but could just pick it up. Practically, the device manager
+should cache the type (and/or vendor/device) information of a node, and assign
+one or more drivers (via module name) to this information. It should also
+remember negative outcome, that is if there is no driver supporting the
+hardware.
+
+This way, only the first boot would require an actual search for drivers, as
+subsequent boots would reuse the type-driver assignments. If a new driver is
+installed, the cached assignments would need to be updated immediately. If a
+driver has been installed outside of the running system, the device manager
+might want to create a hash per module directory to see if anything changed to
+flush the cache. Alternatively or additionally, the boot loader could have a
+menu causing the cache to be ignored.
+
+It would be nice to find a way for generic and simple busses to reduce the
+amount of searching necessary for them. One way would be to remember which
+driver supports which bus - but this information is currently only accessible
+derived from what the driver does, and is therefore not reliable or complete.
+A separately exported information would be necessary for this.
+
+Also, when looking for a generic or simple bus driver, actual directories
+could be omitted; currently, driver search is always recursive, as that's how
+the module mechanism is working. Eventually, we might want to extend the
+open_module_list_etc() call a bit more to accomplish that.
+