From korli at mail.berlios.de Thu Nov 1 02:27:34 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 1 Nov 2007 02:27:34 +0100 Subject: [Haiku-commits] r22782 - haiku/trunk/src/bin/zip Message-ID: <200711010127.lA11RYdf001822@sheep.berlios.de> Author: korli Date: 2007-11-01 02:27:31 +0100 (Thu, 01 Nov 2007) New Revision: 22782 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22782&view=rev Added: haiku/trunk/src/bin/zip/beos_.c haiku/trunk/src/bin/zip/crypt_.c haiku/trunk/src/bin/zip/fileio_.c haiku/trunk/src/bin/zip/util_.c haiku/trunk/src/bin/zip/zipfile_.c Removed: haiku/trunk/src/bin/zip/bedefs.c Modified: haiku/trunk/src/bin/zip/Jamfile haiku/trunk/src/bin/zip/api.c haiku/trunk/src/bin/zip/api.h haiku/trunk/src/bin/zip/beos.c haiku/trunk/src/bin/zip/crc32.c haiku/trunk/src/bin/zip/crctab.c haiku/trunk/src/bin/zip/crypt.c haiku/trunk/src/bin/zip/crypt.h haiku/trunk/src/bin/zip/deflate.c haiku/trunk/src/bin/zip/ebcdic.h haiku/trunk/src/bin/zip/fileio.c haiku/trunk/src/bin/zip/globals.c haiku/trunk/src/bin/zip/revision.h haiku/trunk/src/bin/zip/tailor.h haiku/trunk/src/bin/zip/trees.c haiku/trunk/src/bin/zip/ttyio.c haiku/trunk/src/bin/zip/ttyio.h haiku/trunk/src/bin/zip/util.c haiku/trunk/src/bin/zip/zip.c haiku/trunk/src/bin/zip/zip.h haiku/trunk/src/bin/zip/zipcloak.c haiku/trunk/src/bin/zip/ziperr.h haiku/trunk/src/bin/zip/zipfile.c haiku/trunk/src/bin/zip/zipnote.c haiku/trunk/src/bin/zip/zipsplit.c haiku/trunk/src/bin/zip/zipup.c Log: updated zip to version 2.32 Modified: haiku/trunk/src/bin/zip/Jamfile =================================================================== --- haiku/trunk/src/bin/zip/Jamfile 2007-10-31 21:16:22 UTC (rev 22781) +++ haiku/trunk/src/bin/zip/Jamfile 2007-11-01 01:27:31 UTC (rev 22782) @@ -3,40 +3,54 @@ local zip_rsrc = [ FGristFiles zip.rsrc ] ; ResComp $(zip_rsrc) : [ FGristFiles zip.rdef ] ; -StaticLibrary libzip.a : - zipup.c - crypt.c +local common_files = + globals.c + ; + +local common_files2 = + crctab.c ttyio.c + ; + +local util_files = + beos_.c + fileio_.c + util_.c + zipfile_.c + ; + +Objects $(common_files) $(common_files2) $(util_files) ; + +BinCommand zip : + [ FGristFiles $(common_files:S=.o) $(common_files2:S=.o) ] beos.c - globals.c + crc32.c + crypt.c deflate.c fileio.c + trees.c util.c - crc32.c + zip.c zipfile.c - trees.c - crctab.c + zipup.c + : be : zip.rsrc ; -BinCommand zip : - zip.c - : libzip.a be : zip.rsrc -; - BinCommand zipcloak : + crypt_.c zipcloak.c - bedefs.c - : libzip.a : zip.rsrc + [ FGristFiles $(common_files:S=.o) $(common_files2:S=.o) $(util_files:S=.o) ] + : be : zip.rsrc ; BinCommand zipnote : zipnote.c - bedefs.c - : libzip.a be : zip.rsrc + [ FGristFiles $(common_files:S=.o) $(util_files:S=.o) ] + : be : zip.rsrc ; BinCommand zipsplit : zipsplit.c - bedefs.c - : libzip.a be : zip.rsrc + [ FGristFiles $(common_files:S=.o) $(util_files:S=.o) ] + : be : zip.rsrc ; Modified: haiku/trunk/src/bin/zip/api.c =================================================================== --- haiku/trunk/src/bin/zip/api.c 2007-10-31 21:16:22 UTC (rev 22781) +++ haiku/trunk/src/bin/zip/api.c 2007-11-01 01:27:31 UTC (rev 22782) @@ -1,10 +1,10 @@ /* - Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + Copyright (c) 1990-2005 Info-ZIP. All rights reserved. - See the accompanying file LICENSE, version 1999-Oct-05 or later + See the accompanying file LICENSE, version 2004-May-22 or later (the contents of which are also included in zip.h) for terms of use. If, for some reason, both of these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /*--------------------------------------------------------------------------- @@ -58,6 +58,31 @@ int ZipRet; +/* ------------------------------------------------- */ +/* Visual Basic converts strings from VB native Unicode to + byte strings when passing to dlls. It seems that any + strings pointed to in structures are converted and the + conversion passed to the dll, but when the dll call + returns the converted strings are garbage collected + unless the debugger prevents it. This leaves the + pointers going to memory that may have been reused + by the time the following dll call is made. This + affects the strings in the Options stucture. + + The following kluge stores the strings locally in + the dll between calls. A better fix is to redesign + the api interface so that strings in structures are + removed or are passed in the same call they are used. EG + +/* oversized to be sure */ +#define MAX_ZIP_DATE_LEN 50 +#define MAX_ZIP_DIR_PATH_LEN 4098 + +char szDate[MAX_ZIP_DATE_LEN + 1]; +char szRootDir[MAX_ZIP_DIR_PATH_LEN + 1]; +char szTempDir[MAX_ZIP_DIR_PATH_LEN + 1]; +/* ------------------------------------------------- */ + /* Local forward declarations */ extern int zipmain OF((int, char **)); int AllocMemory(int, char *, char *); @@ -106,7 +131,27 @@ BOOL EXPENTRY ZpSetOptions(LPZPOPT Opts) { +/* copy the structure including pointers to strings */ Options = *Opts; + +/* fix for calling dll from VB - 2002-11-25 */ +/* make copies of strings in structure if not NULL passed for empty string */ +if (Options.Date) { + szDate[0] = '\0'; + strncat(szDate, Options.Date, MAX_ZIP_DATE_LEN); + Options.Date = szDate; +} +if (Options.szRootDir) { + szRootDir[0] = '\0'; + strncat(szRootDir, Options.szRootDir, MAX_ZIP_DIR_PATH_LEN); + Options.szRootDir = szRootDir; +} +if (Options.szTempDir) { + szTempDir[0] = '\0'; + strncat(szTempDir, Options.szTempDir, MAX_ZIP_DIR_PATH_LEN); + Options.szTempDir = szTempDir; +} + return TRUE; } @@ -258,18 +303,6 @@ return ZE_MEM; argCee++; } -if (Options.fRecurse == 1) /* recurse into subdirectories -r */ - { - if (AllocMemory(argCee, "-r", "Recurse -r") != ZE_OK) - return ZE_MEM; - argCee++; - } -else if (Options.fRecurse == 2) /* recurse into subdirectories -R */ - { - if (AllocMemory(argCee, "-R", "Recurse -R") != ZE_OK) - return ZE_MEM; - argCee++; - } if (Options.fSystem) /* include system and hidden files -S */ { if (AllocMemory(argCee, "-S", "System") != ZE_OK) @@ -320,7 +353,7 @@ return ZE_MEM; argCee++; } -#ifdef WIN32 +#ifdef NTSD_EAS /* was WIN32 1/22/2005 EG */ if (Options.fPrivilege) /* Use privileges -! */ { if (AllocMemory(argCee, "-!", "Privileges") != ZE_OK) @@ -344,6 +377,19 @@ return ZE_MEM; argCee++; } +/* -r and -R moved down here to avoid VB problem 1/31/2005 EG */ +if (Options.fRecurse == 1) /* recurse into subdirectories -r */ + { + if (AllocMemory(argCee, "-r", "Recurse -r") != ZE_OK) + return ZE_MEM; + argCee++; + } +else if (Options.fRecurse == 2) /* recurse into subdirectories -R */ + { + if (AllocMemory(argCee, "-R", "Recurse -R") != ZE_OK) + return ZE_MEM; + argCee++; + } if (AllocMemory(argCee, C.lpszZipFN, "Zip file name") != ZE_OK) return ZE_MEM; argCee++; Modified: haiku/trunk/src/bin/zip/api.h =================================================================== --- haiku/trunk/src/bin/zip/api.h 2007-10-31 21:16:22 UTC (rev 22781) +++ haiku/trunk/src/bin/zip/api.h 2007-11-01 01:27:31 UTC (rev 22782) @@ -1,10 +1,10 @@ /* - Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + Copyright (c) 1990-2005 Info-ZIP. All rights reserved. - See the accompanying file LICENSE, version 1999-Oct-05 or later + See the accompanying file LICENSE, version 2004-May-22 or later (the contents of which are also included in zip.h) for terms of use. If, for some reason, both of these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* Only the Windows DLL is currently supported */ #ifndef _ZIPAPI_H Deleted: haiku/trunk/src/bin/zip/bedefs.c Modified: haiku/trunk/src/bin/zip/beos.c =================================================================== --- haiku/trunk/src/bin/zip/beos.c 2007-10-31 21:16:22 UTC (rev 22781) +++ haiku/trunk/src/bin/zip/beos.c 2007-11-01 01:27:31 UTC (rev 22782) @@ -1,10 +1,10 @@ /* - Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + Copyright (c) 1990-2005 Info-ZIP. All rights reserved. - See the accompanying file LICENSE, version 1999-Oct-05 or later + See the accompanying file LICENSE, version 2004-May-22 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html + If, for some reason, all these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* @@ -283,8 +283,8 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -295,18 +295,26 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + if ((name = malloc(len + 1)) == NULL) { + ZIPERR(ZE_MEM, "filetime"); + } strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (strcmp(f, "-") == 0) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); - } else if (LSSTAT(name, &s) != 0) + } + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE); @@ -322,6 +330,8 @@ t->ctime = s.st_mtime; /* best guess (s.st_ctime: last status change!) */ } + free(name); + return unix2dostime(&s.st_mtime); } @@ -663,9 +673,11 @@ #define EB_L_BE_SIZE (EB_HEADSIZE + EB_L_BE_LEN) /* + attr size */ #define EB_C_BE_SIZE (EB_HEADSIZE + EB_C_BE_LEN) -#define MEMCOMPRESS_HEADER 6 /* ush compression type, ulg CRC */ -#define DEFLAT_WORSTCASE_ADD 5 /* byte blocktype, 2 * ush blocklength */ -#define MEMCOMPRESS_OVERHEAD (MEMCOMPRESS_HEADER + DEFLAT_WORSTCASE_ADD) +/* maximum memcompress overhead is the sum of the compression header length */ +/* (6 = ush compression type, ulg CRC) and the worstcase deflate overhead */ +/* when uncompressible data are kept in 2 "stored" blocks (5 per block = */ +/* byte blocktype + 2 * ush blocklength) */ +#define MEMCOMPRESS_OVERHEAD (EB_MEMCMPR_HSIZ + EB_DEFLAT_EXTRA) local int add_Be_ef( struct zlist far *z ) { Added: haiku/trunk/src/bin/zip/beos_.c =================================================================== --- haiku/trunk/src/bin/zip/beos_.c 2007-10-31 21:16:22 UTC (rev 22781) +++ haiku/trunk/src/bin/zip/beos_.c 2007-11-01 01:27:31 UTC (rev 22782) @@ -0,0 +1,2 @@ +#define UTIL +#include "beos.c" Modified: haiku/trunk/src/bin/zip/crc32.c =================================================================== --- haiku/trunk/src/bin/zip/crc32.c 2007-10-31 21:16:22 UTC (rev 22781) +++ haiku/trunk/src/bin/zip/crc32.c 2007-11-01 01:27:31 UTC (rev 22782) @@ -1,17 +1,17 @@ /* - Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + Copyright (c) 1990-2005 Info-ZIP. All rights reserved. - See the accompanying file LICENSE, version 1999-Oct-05 or later + See the accompanying file LICENSE, version 2004-May-22 or later (the contents of which are also included in zip.h) for terms of use. If, for some reason, both of these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* crc32.c -- compute the CRC-32 of a data stream * Copyright (C) 1995 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ -/* $Id: crc32.c,v 1.1 2002/09/21 16:08:49 darkwyrm Exp $ */ +/* $Id$ */ #define __CRC32_C /* identifies this source module */ Modified: haiku/trunk/src/bin/zip/crctab.c =================================================================== --- haiku/trunk/src/bin/zip/crctab.c 2007-10-31 21:16:22 UTC (rev 22781) +++ haiku/trunk/src/bin/zip/crctab.c 2007-11-01 01:27:31 UTC (rev 22782) @@ -1,17 +1,17 @@ /* - Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + Copyright (c) 1990-2005 Info-ZIP. All rights reserved. - See the accompanying file LICENSE, version 1999-Oct-05 or later + See the accompanying file LICENSE, version 2004-May-22 or later (the contents of which are also included in zip.h) for terms of use. If, for some reason, both of these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* crctab.c -- supply the CRC table needed for CRC-32 calculations. * Copyright (C) 1995 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ -/* $Id: crctab.c,v 1.1 2002/09/21 16:08:49 darkwyrm Exp $ */ +/* $Id$ */ /* Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: Modified: haiku/trunk/src/bin/zip/crypt.c =================================================================== --- haiku/trunk/src/bin/zip/crypt.c 2007-10-31 21:16:22 UTC (rev 22781) +++ haiku/trunk/src/bin/zip/crypt.c 2007-11-01 01:27:31 UTC (rev 22782) @@ -1,20 +1,598 @@ /* - Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + Copyright (c) 1990-2006 Info-ZIP. All rights reserved. - See the accompanying file LICENSE, version 1999-Oct-05 or later - (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html + See the accompanying file LICENSE, version 2005-Feb-10 or later + (the contents of which are also included in (un)zip.h) for terms of use. + If, for some reason, all these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* - crypt.c (dummy version) by Info-ZIP. Last revised: 15 Aug 98 + crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] - This is a non-functional version of Info-ZIP's crypt.c encryption/ - decryption code for Zip, ZipCloak, UnZip and fUnZip. This file is - not copyrighted and may be distributed freely. :-) See the "WHERE" - file for sites from which to obtain the full encryption/decryption - sources (zcrypt28.zip or later). + The main encryption/decryption source code for Info-Zip software was + originally written in Europe. To the best of our knowledge, it can + be freely distributed in both source and object forms from any country, + including the USA under License Exception TSU of the U.S. Export + Administration Regulations (section 740.13(e)) of 6 June 2002. + + NOTE on copyright history: + Previous versions of this source package (up to version 2.8) were + not copyrighted and put in the public domain. If you cannot comply + with the Info-Zip LICENSE, you may want to look for one of those + public domain versions. */ +/* + This encryption code is a direct transcription of the algorithm from + Roger Schlafly, described by Phil Katz in the file appnote.txt. This + file (appnote.txt) is distributed with the PKZIP program (even in the + version without encryption capabilities). + */ + +#define ZCRYPT_INTERNAL +#include "zip.h" +#include "crypt.h" +#include "ttyio.h" + +#if CRYPT + +#ifndef FALSE +# define FALSE 0 +#endif + +#ifdef ZIP + /* For the encoding task used in Zip (and ZipCloak), we want to initialize + the crypt algorithm with some reasonably unpredictable bytes, see + the crypthead() function. The standard rand() library function is + used to supply these `random' bytes, which in turn is initialized by + a srand() call. The srand() function takes an "unsigned" (at least 16bit) + seed value as argument to determine the starting point of the rand() + pseudo-random number generator. + This seed number is constructed as "Seed = Seed1 .XOR. Seed2" with + Seed1 supplied by the current time (= "(unsigned)time()") and Seed2 + as some (hopefully) nondeterministic bitmask. On many (most) systems, + we use some "process specific" number, as the PID or something similar, + but when nothing unpredictable is available, a fixed number may be + sufficient. + NOTE: + 1.) This implementation requires the availability of the following + standard UNIX C runtime library functions: time(), rand(), srand(). + On systems where some of them are missing, the environment that + incorporates the crypt routines must supply suitable replacement + functions. + 2.) It is a very bad idea to use a second call to time() to set the + "Seed2" number! In this case, both "Seed1" and "Seed2" would be + (almost) identical, resulting in a (mostly) "zero" constant seed + number passed to srand(). + + The implementation environment defined in the "zip.h" header should + supply a reasonable definition for ZCR_SEED2 (an unsigned number; for + most implementations of rand() and srand(), only the lower 16 bits are + significant!). An example that works on many systems would be + "#define ZCR_SEED2 (unsigned)getpid()". + The default definition for ZCR_SEED2 supplied below should be regarded + as a fallback to allow successful compilation in "beta state" + environments. + */ +# include /* time() function supplies first part of crypt seed */ + /* "last resort" source for second part of crypt seed pattern */ +# ifndef ZCR_SEED2 +# define ZCR_SEED2 (unsigned)3141592654L /* use PI as default pattern */ +# endif +# ifdef GLOBAL /* used in Amiga system headers, maybe others too */ +# undef GLOBAL +# endif +# define GLOBAL(g) g +#else /* !ZIP */ +# define GLOBAL(g) G.g +#endif /* ?ZIP */ + + +#ifdef UNZIP + /* char *key = (char *)NULL; moved to globals.h */ +# ifndef FUNZIP + local int testp OF((__GPRO__ ZCONST uch *h)); + local int testkey OF((__GPRO__ ZCONST uch *h, ZCONST char *key)); +# endif +#endif /* UNZIP */ + +#ifndef UNZIP /* moved to globals.h for UnZip */ + local ulg keys[3]; /* keys defining the pseudo-random sequence */ +#endif /* !UNZIP */ + +#ifndef Trace +# ifdef CRYPT_DEBUG +# define Trace(x) fprintf x +# else +# define Trace(x) +# endif +#endif + +#ifndef CRC_32_TAB +# define CRC_32_TAB crc_32_tab +#endif + +#define CRC32(c, b) (CRC_32_TAB[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8)) + +/*********************************************************************** + * Return the next byte in the pseudo-random sequence + */ +int decrypt_byte(__G) + __GDEF +{ + unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an + * unpredictable manner on 16-bit systems; not a problem + * with any known compiler so far, though */ + + temp = ((unsigned)GLOBAL(keys[2]) & 0xffff) | 2; + return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); +} + +/*********************************************************************** + * Update the encryption keys with the next byte of plain text + */ +int update_keys(__G__ c) + __GDEF + int c; /* byte of plain text */ +{ + GLOBAL(keys[0]) = CRC32(GLOBAL(keys[0]), c); + GLOBAL(keys[1]) += GLOBAL(keys[0]) & 0xff; + GLOBAL(keys[1]) = GLOBAL(keys[1]) * 134775813L + 1; + { + register int keyshift = (int)(GLOBAL(keys[1]) >> 24); + GLOBAL(keys[2]) = CRC32(GLOBAL(keys[2]), keyshift); + } + return c; +} + + +/*********************************************************************** + * Initialize the encryption keys and the random header according to + * the given password. + */ +void init_keys(__G__ passwd) + __GDEF + ZCONST char *passwd; /* password string with which to modify keys */ +{ + GLOBAL(keys[0]) = 305419896L; + GLOBAL(keys[1]) = 591751049L; + GLOBAL(keys[2]) = 878082192L; + while (*passwd != '\0') { + update_keys(__G__ (int)*passwd); + passwd++; + } +} + + +#ifdef ZIP + +/*********************************************************************** + * Write encryption header to file zfile using the password passwd + * and the cyclic redundancy check crc. + */ +void crypthead(passwd, crc, zfile) + ZCONST char *passwd; /* password string */ + ulg crc; /* crc of file being encrypted */ + FILE *zfile; /* where to write header */ +{ + int n; /* index in random header */ + int t; /* temporary */ + int c; /* random byte */ + int ztemp; /* temporary for zencoded value */ + uch header[RAND_HEAD_LEN-2]; /* random header */ + static unsigned calls = 0; /* ensure different random header each time */ + + /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the + * output of rand() to get less predictability, since rand() is + * often poorly implemented. + */ + if (++calls == 1) { + srand((unsigned)time(NULL) ^ ZCR_SEED2); + } + init_keys(passwd); + for (n = 0; n < RAND_HEAD_LEN-2; n++) { + c = (rand() >> 7) & 0xff; + header[n] = (uch)zencode(c, t); + } + /* Encrypt random header (last two bytes is high word of crc) */ + init_keys(passwd); + for (n = 0; n < RAND_HEAD_LEN-2; n++) { + ztemp = zencode(header[n], t); + putc(ztemp, zfile); + } + ztemp = zencode((int)(crc >> 16) & 0xff, t); + putc(ztemp, zfile); + ztemp = zencode((int)(crc >> 24) & 0xff, t); + putc(ztemp, zfile); +} + + +#ifdef UTIL + +/*********************************************************************** + * Encrypt the zip entry described by z from file source to file dest + * using the password passwd. Return an error code in the ZE_ class. + */ +int zipcloak(z, source, dest, passwd) + struct zlist far *z; /* zip entry to encrypt */ + FILE *source, *dest; /* source and destination files */ + ZCONST char *passwd; /* password string */ +{ + int c; /* input byte */ + int res; /* result code */ + ulg n; /* holds offset and counts size */ + ush flag; /* previous flags */ + int t; /* temporary */ + int ztemp; /* temporary storage for zencode value */ + + /* Set encrypted bit, clear extended local header bit and write local + header to output file */ + if ((n = (ulg)ftell(dest)) == (ulg)-1L) return ZE_TEMP; + z->off = n; + flag = z->flg; + z->flg |= 1, z->flg &= ~8; + z->lflg |= 1, z->lflg &= ~8; + z->siz += RAND_HEAD_LEN; + if ((res = putlocal(z, dest)) != ZE_OK) return res; + + /* Initialize keys with password and write random header */ + crypthead(passwd, z->crc, dest); + + /* Skip local header in input file */ + if (fseek(source, (long)((4 + LOCHEAD) + (ulg)z->nam + (ulg)z->ext), + SEEK_CUR)) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + + /* Encrypt data */ + for (n = z->siz - RAND_HEAD_LEN; n; n--) { + if ((c = getc(source)) == EOF) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + ztemp = zencode(c, t); + putc(ztemp, dest); + } + /* Skip extended local header in input file if there is one */ + if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + if (fflush(dest) == EOF) return ZE_TEMP; + + /* Update number of bytes written to output file */ + tempzn += (4 + LOCHEAD) + z->nam + z->ext + z->siz; + + return ZE_OK; +} + +/*********************************************************************** + * Decrypt the zip entry described by z from file source to file dest + * using the password passwd. Return an error code in the ZE_ class. + */ +int zipbare(z, source, dest, passwd) + struct zlist far *z; /* zip entry to encrypt */ + FILE *source, *dest; /* source and destination files */ + ZCONST char *passwd; /* password string */ +{ +#ifdef ZIP10 + int c0 /* byte preceding the last input byte */ +#endif + int c1; /* last input byte */ + ulg offset; /* used for file offsets */ + ulg size; /* size of input data */ + int r; /* size of encryption header */ + int res; /* return code */ + ush flag; /* previous flags */ + + /* Save position and skip local header in input file */ + if ((offset = (ulg)ftell(source)) == (ulg)-1L || + fseek(source, (long)((4 + LOCHEAD) + (ulg)z->nam + (ulg)z->ext), + SEEK_CUR)) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + /* Initialize keys with password */ + init_keys(passwd); + + /* Decrypt encryption header, save last two bytes */ + c1 = 0; + for (r = RAND_HEAD_LEN; r; r--) { +#ifdef ZIP10 + c0 = c1; +#endif + if ((c1 = getc(source)) == EOF) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + Trace((stdout, " (%02x)", c1)); + zdecode(c1); + Trace((stdout, " %02x", c1)); + } + Trace((stdout, "\n")); + + /* If last two bytes of header don't match crc (or file time in the + * case of an extended local header), back up and just copy. For + * pkzip 2.0, the check has been reduced to one byte only. + */ +#ifdef ZIP10 + if ((ush)(c0 | (c1<<8)) != + (z->flg & 8 ? (ush) z->tim & 0xffff : (ush)(z->crc >> 16))) { +#else + if ((ush)c1 != (z->flg & 8 ? (ush) z->tim >> 8 : (ush)(z->crc >> 24))) { +#endif + if (fseek(source, offset, SEEK_SET)) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + if ((res = zipcopy(z, source, dest)) != ZE_OK) return res; + return ZE_MISS; + } + + /* Clear encrypted bit and local header bit, and write local header to + output file */ + if ((offset = (ulg)ftell(dest)) == (ulg)-1L) return ZE_TEMP; + z->off = offset; + flag = z->flg; + z->flg &= ~9; + z->lflg &= ~9; + z->siz -= RAND_HEAD_LEN; + if ((res = putlocal(z, dest)) != ZE_OK) return res; + + /* Decrypt data */ + for (size = z->siz; size; size--) { + if ((c1 = getc(source)) == EOF) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + zdecode(c1); + putc(c1, dest); + } + /* Skip extended local header in input file if there is one */ + if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + if (fflush(dest) == EOF) return ZE_TEMP; + + /* Update number of bytes written to output file */ + tempzn += (4 + LOCHEAD) + z->nam + z->ext + z->siz; + + return ZE_OK; +} + + +#else /* !UTIL */ + +/*********************************************************************** + * If requested, encrypt the data in buf, and in any case call fwrite() + * with the arguments to zfwrite(). Return what fwrite() returns. + * + * A bug has been found when encrypting large files. See trees.c + * for details and the fix. + */ +unsigned zfwrite(buf, item_size, nb, f) + zvoid *buf; /* data buffer */ + extent item_size; /* size of each item in bytes */ + extent nb; /* number of items */ + FILE *f; /* file to write to */ +{ + int t; /* temporary */ + + if (key != (char *)NULL) { /* key is the global password pointer */ + ulg size; /* buffer size */ + char *p = (char*)buf; /* steps through buffer */ + + /* Encrypt data in buffer */ + for (size = item_size*(ulg)nb; size != 0; p++, size--) { + *p = (char)zencode(*p, t); + } + } + /* Write the buffer out */ + return fwrite(buf, item_size, nb, f); +} + +#endif /* ?UTIL */ +#endif /* ZIP */ + + +#if (defined(UNZIP) && !defined(FUNZIP)) + +/*********************************************************************** + * Get the password and set up keys for current zipfile member. + * Return PK_ class error. + */ +int decrypt(__G__ passwrd) + __GDEF + ZCONST char *passwrd; +{ + ush b; + int n, r; + uch h[RAND_HEAD_LEN]; + + Trace((stdout, "\n[incnt = %d]: ", GLOBAL(incnt))); + + /* get header once (turn off "encrypted" flag temporarily so we don't + * try to decrypt the same data twice) */ + GLOBAL(pInfo->encrypted) = FALSE; + defer_leftover_input(__G); + for (n = 0; n < RAND_HEAD_LEN; n++) { + b = NEXTBYTE; + h[n] = (uch)b; + Trace((stdout, " (%02x)", h[n])); + } + undefer_input(__G); + GLOBAL(pInfo->encrypted) = TRUE; + + if (GLOBAL(newzip)) { /* this is first encrypted member in this zipfile */ + GLOBAL(newzip) = FALSE; + if (passwrd != (char *)NULL) { /* user gave password on command line */ + if (!GLOBAL(key)) { + if ((GLOBAL(key) = (char *)malloc(strlen(passwrd)+1)) == + (char *)NULL) + return PK_MEM2; + strcpy(GLOBAL(key), passwrd); + GLOBAL(nopwd) = TRUE; /* inhibit password prompting! */ + } + } else if (GLOBAL(key)) { /* get rid of previous zipfile's key */ + free(GLOBAL(key)); + GLOBAL(key) = (char *)NULL; + } + } + + /* if have key already, test it; else allocate memory for it */ + if (GLOBAL(key)) { + if (!testp(__G__ h)) + return PK_COOL; /* existing password OK (else prompt for new) */ + else if (GLOBAL(nopwd)) + return PK_WARN; /* user indicated no more prompting */ + } else if ((GLOBAL(key) = (char *)malloc(IZ_PWLEN+1)) == (char *)NULL) + return PK_MEM2; + + /* try a few keys */ + n = 0; + do { + r = (*G.decr_passwd)((zvoid *)&G, &n, GLOBAL(key), IZ_PWLEN+1, + GLOBAL(zipfn), GLOBAL(filename)); + if (r == IZ_PW_ERROR) { /* internal error in fetch of PW */ + free (GLOBAL(key)); + GLOBAL(key) = NULL; + return PK_MEM2; + } + if (r != IZ_PW_ENTERED) { /* user replied "skip" or "skip all" */ + *GLOBAL(key) = '\0'; /* We try the NIL password, ... */ + n = 0; /* and cancel fetch for this item. */ + } + if (!testp(__G__ h)) + return PK_COOL; + if (r == IZ_PW_CANCELALL) /* User replied "Skip all" */ + GLOBAL(nopwd) = TRUE; /* inhibit any further PW prompt! */ + } while (n > 0); + + return PK_WARN; + +} /* end function decrypt() */ + + + +/*********************************************************************** + * Test the password. Return -1 if bad, 0 if OK. + */ +local int testp(__G__ h) + __GDEF + ZCONST uch *h; +{ + int r; + char *key_translated; + + /* On systems with "obscure" native character coding (e.g., EBCDIC), + * the first test translates the password to the "main standard" + * character coding. */ + +#ifdef STR_TO_CP1 + /* allocate buffer for translated password */ + if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL) + return -1; + /* first try, test password translated "standard" charset */ + r = testkey(__G__ h, STR_TO_CP1(key_translated, GLOBAL(key))); +#else /* !STR_TO_CP1 */ + /* first try, test password as supplied on the extractor's host */ + r = testkey(__G__ h, GLOBAL(key)); +#endif /* ?STR_TO_CP1 */ + +#ifdef STR_TO_CP2 + if (r != 0) { +#ifndef STR_TO_CP1 + /* now prepare for second (and maybe third) test with translated pwd */ + if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL) + return -1; +#endif + /* second try, password translated to alternate ("standard") charset */ + r = testkey(__G__ h, STR_TO_CP2(key_translated, GLOBAL(key))); +#ifdef STR_TO_CP3 + if (r != 0) + /* third try, password translated to another "standard" charset */ + r = testkey(__G__ h, STR_TO_CP3(key_translated, GLOBAL(key))); +#endif +#ifndef STR_TO_CP1 + free(key_translated); +#endif + } +#endif /* STR_TO_CP2 */ + +#ifdef STR_TO_CP1 + free(key_translated); + if (r != 0) { + /* last resort, test password as supplied on the extractor's host */ + r = testkey(__G__ h, GLOBAL(key)); + } +#endif /* STR_TO_CP1 */ + + return r; + +} /* end function testp() */ + + +local int testkey(__G__ h, key) + __GDEF + ZCONST uch *h; /* decrypted header */ + ZCONST char *key; /* decryption password to test */ +{ + ush b; +#ifdef ZIP10 + ush c; +#endif + int n; + uch *p; + uch hh[RAND_HEAD_LEN]; /* decrypted header */ + + /* set keys and save the encrypted header */ + init_keys(__G__ key); + memcpy(hh, h, RAND_HEAD_LEN); + + /* check password */ + for (n = 0; n < RAND_HEAD_LEN; n++) { + zdecode(hh[n]); + Trace((stdout, " %02x", hh[n])); + } + + Trace((stdout, + "\n lrec.crc= %08lx crec.crc= %08lx pInfo->ExtLocHdr= %s\n", + GLOBAL(lrec.crc32), GLOBAL(pInfo->crc), + GLOBAL(pInfo->ExtLocHdr) ? "true":"false")); + Trace((stdout, " incnt = %d unzip offset into zipfile = %ld\n", + GLOBAL(incnt), + GLOBAL(cur_zipfile_bufstart)+(GLOBAL(inptr)-GLOBAL(inbuf)))); + + /* same test as in zipbare(): */ + +#ifdef ZIP10 /* check two bytes */ + c = hh[RAND_HEAD_LEN-2], b = hh[RAND_HEAD_LEN-1]; + Trace((stdout, + " (c | (b<<8)) = %04x (crc >> 16) = %04x lrec.time = %04x\n", + (ush)(c | (b<<8)), (ush)(GLOBAL(lrec.crc32) >> 16), + ((ush)GLOBAL(lrec.last_mod_dos_datetime) & 0xffff)))); + if ((ush)(c | (b<<8)) != (GLOBAL(pInfo->ExtLocHdr) ? + ((ush)GLOBAL(lrec.last_mod_dos_datetime) & 0xffff) : + (ush)(GLOBAL(lrec.crc32) >> 16))) + return -1; /* bad */ +#else + b = hh[RAND_HEAD_LEN-1]; + Trace((stdout, " b = %02x (crc >> 24) = %02x (lrec.time >> 8) = %02x\n", + b, (ush)(GLOBAL(lrec.crc32) >> 24), + ((ush)GLOBAL(lrec.last_mod_dos_datetime) >> 8) & 0xff)); + if (b != (GLOBAL(pInfo->ExtLocHdr) ? + ((ush)GLOBAL(lrec.last_mod_dos_datetime) >> 8) & 0xff : + (ush)(GLOBAL(lrec.crc32) >> 24))) + return -1; /* bad */ +#endif + /* password OK: decrypt current buffer contents before leaving */ + for (n = (long)GLOBAL(incnt) > GLOBAL(csize) ? + (int)GLOBAL(csize) : GLOBAL(incnt), + p = GLOBAL(inptr); n--; p++) + zdecode(*p); + return 0; /* OK */ + +} /* end function testkey() */ + +#endif /* UNZIP && !FUNZIP */ + +#else /* !CRYPT */ + /* something "externally visible" to shut up compiler/linker warnings */ int zcr_dummy; + +#endif /* ?CRYPT */ Modified: haiku/trunk/src/bin/zip/crypt.h =================================================================== --- haiku/trunk/src/bin/zip/crypt.h 2007-10-31 21:16:22 UTC (rev 22781) +++ haiku/trunk/src/bin/zip/crypt.h 2007-11-01 01:27:31 UTC (rev 22782) @@ -1,19 +1,25 @@ /* - Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + Copyright (c) 1990-2006 Info-ZIP. All rights reserved. - See the accompanying file LICENSE, version 1999-Oct-05 or later - (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html [... truncated: 3345 lines follow ...] From mmu_man at mail.berlios.de Thu Nov 1 04:43:09 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 1 Nov 2007 04:43:09 +0100 Subject: [Haiku-commits] r22783 - haiku/trunk/src/system/libroot/os/arch/m68k Message-ID: <200711010343.lA13h9aW007307@sheep.berlios.de> Author: mmu_man Date: 2007-11-01 04:43:08 +0100 (Thu, 01 Nov 2007) New Revision: 22783 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22783&view=rev Modified: haiku/trunk/src/system/libroot/os/arch/m68k/atomic.S Log: Optimized 64bit atomics: - use movem - fix return value: the convention is to return in d0:d1 (MSB:LSB) Modified: haiku/trunk/src/system/libroot/os/arch/m68k/atomic.S =================================================================== --- haiku/trunk/src/system/libroot/os/arch/m68k/atomic.S 2007-11-01 01:27:31 UTC (rev 22782) +++ haiku/trunk/src/system/libroot/os/arch/m68k/atomic.S 2007-11-01 03:43:08 UTC (rev 22783) @@ -85,150 +85,116 @@ // else we get the correct one anyway rts -/* m68k elf convention is to return structs in (a0) */ -/* other conventions use d0/d1 but which is MSB ?? */ +/* m68k elf convention is to return structs in (a0) + * but use d0/d1 for int64 and small structs. + * d0 MSB, d1 LSB + */ #warning M68K: 68060 doesn't have CAS2: use spinlock ?? /* see http://retropc.net/x68000/software/develop/as/has060/m68k.htm */ /* int64 atomic_add64(vint64 *value, int64 addValue) */ FUNCTION(atomic_add64): - move.l %d2,-(%a7) - move.l %d3,-(%a7) - move.l %a2,-(%a7) - move.l (4,%a7),%a1 - lea.l (4,%a1),%a2 + movem.l %d2-%d3/%a2,-(%a7) + move.l (4,%a7),%a2 + lea.l (4,%a2),%a1 // addValue - move.l (12,%a7),%d2 /*LSB*/ - move.l (8,%a7),%d3 /*MSB*/ + move.l (12,%a7),%d3 /*LSB*/ + move.l (8,%a7),%d2 /*MSB*/ miss5: // old value - move.l (4,%a1),%d0 /*LSB*/ - move.l (%a1),%d1 /*MSB*/ - add.l %d0,%d2 - addx.l %d1,%d3 + move.l (%a1),%d1 /*LSB*/ + move.l (%a2),%d0 /*MSB*/ + add.l %d1,%d3 + addx.l %d0,%d2 cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1) bne miss5 - // return value - move.l %d0,(4,%a0) - move.l %d1,(%a0) - move.l (%a7)+,%a2 - move.l (%a7)+,%d3 - move.l (%a7)+,%d2 + // return value d0:d1 + movem.l (%a7)+,%d2-%d3/%a2 rts /* int64 atomic_and64(vint64 *value, int64 andValue) */ FUNCTION(atomic_and64): - move.l %d2,-(%a7) - move.l %d3,-(%a7) - move.l %a2,-(%a7) - move.l (4,%a7),%a1 - lea.l (4,%a1),%a2 + movem.l %d2-%d3/%a2,-(%a7) + move.l (4,%a7),%a2 + lea.l (4,%a2),%a1 // addValue - move.l (12,%a7),%d2 /*LSB*/ - move.l (8,%a7),%d3 /*MSB*/ + move.l (12,%a7),%d3 /*LSB*/ + move.l (8,%a7),%d2 /*MSB*/ miss6: // old value - move.l (4,%a1),%d0 /*LSB*/ - move.l (%a1),%d1 /*MSB*/ - and.l %d0,%d2 + move.l (%a1),%d1 /*LSB*/ + move.l (%a2),%d0 /*MSB*/ and.l %d1,%d3 + and.l %d0,%d2 cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1) bne miss6 - // return value - move.l %d0,(4,%a0) - move.l %d1,(%a0) - move.l (%a7)+,%a2 - move.l (%a7)+,%d3 - move.l (%a7)+,%d2 + // return value d0:d1 + movem.l (%a7)+,%d2-%d3/%a2 rts /* int64 atomic_or64(vint64 *value, int64 orValue) */ FUNCTION(atomic_or64): - move.l %d2,-(%a7) - move.l %d3,-(%a7) - move.l %a2,-(%a7) - move.l (4,%a7),%a1 - lea.l (4,%a1),%a2 + movem.l %d2-%d3/%a2,-(%a7) + move.l (4,%a7),%a2 + lea.l (4,%a2),%a1 // addValue - move.l (12,%a7),%d2 /*LSB*/ - move.l (8,%a7),%d3 /*MSB*/ + move.l (12,%a7),%d3 /*LSB*/ + move.l (8,%a7),%d2 /*MSB*/ miss7: // old value - move.l (4,%a1),%d0 /*LSB*/ - move.l (%a1),%d1 /*MSB*/ - or.l %d0,%d2 + move.l (%a1),%d1 /*LSB*/ + move.l (%a2),%d0 /*MSB*/ or.l %d1,%d3 + or.l %d0,%d2 cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1) bne miss7 - // return value - move.l %d0,(4,%a0) - move.l %d1,(%a0) - move.l (%a7)+,%a2 - move.l (%a7)+,%d3 - move.l (%a7)+,%d2 + // return value d0:d1 + movem.l (%a7)+,%d2-%d3/%a2 rts /* int64 atomic_set64(vint64 *value, int64 newValue) */ FUNCTION(atomic_set64): - move.l %d2,-(%a7) - move.l %d3,-(%a7) - move.l %a2,-(%a7) - move.l (4,%a7),%a1 - lea.l (4,%a1),%a2 + movem.l %d2-%d3/%a2,-(%a7) + move.l (4,%a7),%a2 + lea.l (4,%a2),%a1 // new value - move.l (12,%a7),%d2 /*LSB*/ - move.l (8,%a7),%d3 /*MSB*/ + move.l (12,%a7),%d3 /*LSB*/ + move.l (8,%a7),%d2 /*MSB*/ // old value - move.l (4,%a1),%d0 /*LSB*/ - move.l (%a1),%d1 /*MSB*/ + move.l (%a1),%d1 /*LSB*/ + move.l (%a2),%d0 /*MSB*/ miss8: cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1) bne miss8 - // return value - move.l %d0,(4,%a0) - move.l %d1,(%a0) - move.l (%a7)+,%a2 - move.l (%a7)+,%d3 - move.l (%a7)+,%d2 + // return value d0:d1 + movem.l (%a7)+,%d2-%d3/%a2 rts /* int64 atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst) */ FUNCTION(atomic_test_and_set64): - move.l %d2,-(%a7) - move.l %d3,-(%a7) - move.l %a2,-(%a7) - move.l (4,%a7),%a1 - lea.l (4,%a1),%a2 + movem.l %d2-%d3/%a2,-(%a7) + move.l (4,%a7),%a2 + lea.l (4,%a2),%a1 // new value - move.l (12,%a7),%d2 /*LSB*/ - move.l (8,%a7),%d3 /*MSB*/ + move.l (12,%a7),%d3 /*LSB*/ + move.l (8,%a7),%d2 /*MSB*/ // test against value - move.l (20,%a7),%d0 /*LSB*/ - move.l (16,%a7),%d1 /*MSB*/ + move.l (20,%a7),%d1 /*LSB*/ + move.l (16,%a7),%d0 /*MSB*/ cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1) - // return value - move.l %d0,(4,%a0) - move.l %d1,(%a0) - move.l (%a7)+,%a2 - move.l (%a7)+,%d3 - move.l (%a7)+,%d2 + // return value d0:d1 + movem.l (%a7)+,%d2-%d3/%a2 rts /* int64 atomic_get64(vint64 *value) */ FUNCTION(atomic_get64): - move.l %d2,-(%a7) - move.l %d3,-(%a7) - move.l %a2,-(%a7) - move.l (4,%a7),%a1 - lea.l (4,%a1),%a2 - move.l (4,%a1),%d0 /*LSB*/ - move.l (%a1),%d1 /*MSB*/ - move.l %d0,%d2 + movem.l %d2-%d3/%a2,-(%a7) + move.l (4,%a7),%a2 + lea.l (4,%a2),%a1 + move.l (%a1),%d1 /*LSB*/ + move.l (%a2),%d0 /*MSB*/ move.l %d1,%d3 + move.l %d0,%d2 // we must use cas... so we change to the same value if matching, // else we get the correct one anyway cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1) // return value - move.l %d0,(4,%a0) - move.l %d1,(%a0) - move.l (%a7)+,%a2 - move.l (%a7)+,%d3 - move.l (%a7)+,%d2 + movem.l (%a7)+,%d2-%d3/%a2 rts From stippi at mail.berlios.de Thu Nov 1 13:05:59 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 1 Nov 2007 13:05:59 +0100 Subject: [Haiku-commits] r22784 - haiku/trunk/src/kits/interface Message-ID: <200711011205.lA1C5xOI032392@sheep.berlios.de> Author: stippi Date: 2007-11-01 13:05:56 +0100 (Thu, 01 Nov 2007) New Revision: 22784 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22784&view=rev Modified: haiku/trunk/src/kits/interface/View.cpp Log: * despite what the BeBook suggests, using CopyBits() on a non-attached BView does not drop you into the debugger on R5. Should fix #1598. Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2007-11-01 03:43:08 UTC (rev 22783) +++ haiku/trunk/src/kits/interface/View.cpp 2007-11-01 12:05:56 UTC (rev 22784) @@ -3215,16 +3215,19 @@ void BView::CopyBits(BRect src, BRect dst) { + if (fOwner == NULL) + return; + if (!src.IsValid() || !dst.IsValid()) return; - if (do_owner_check()) { - fOwner->fLink->StartMessage(AS_LAYER_COPY_BITS); - fOwner->fLink->Attach(src); - fOwner->fLink->Attach(dst); + check_lock(); - _FlushIfNotInTransaction(); - } + fOwner->fLink->StartMessage(AS_LAYER_COPY_BITS); + fOwner->fLink->Attach(src); + fOwner->fLink->Attach(dst); + + _FlushIfNotInTransaction(); } From stippi at mail.berlios.de Thu Nov 1 15:14:43 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 1 Nov 2007 15:14:43 +0100 Subject: [Haiku-commits] r22785 - haiku/trunk/src/kits/mail Message-ID: <200711011414.lA1EEhvu013778@sheep.berlios.de> Author: stippi Date: 2007-11-01 15:14:43 +0100 (Thu, 01 Nov 2007) New Revision: 22785 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22785&view=rev Modified: haiku/trunk/src/kits/mail/MailAttachment.cpp Log: * fix build on test environment Modified: haiku/trunk/src/kits/mail/MailAttachment.cpp =================================================================== --- haiku/trunk/src/kits/mail/MailAttachment.cpp 2007-11-01 12:05:56 UTC (rev 22784) +++ haiku/trunk/src/kits/mail/MailAttachment.cpp 2007-11-01 14:14:43 UTC (rev 22785) @@ -13,6 +13,7 @@ #include #include +#include class _EXPORT BSimpleMailAttachment; class _EXPORT BAttributedMailAttachment; From stippi at mail.berlios.de Thu Nov 1 16:03:58 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 1 Nov 2007 16:03:58 +0100 Subject: [Haiku-commits] r22786 - in haiku/trunk: headers/build/private/kernel src/build/libhaikucompat Message-ID: <200711011503.lA1F3wgg017588@sheep.berlios.de> Author: stippi Date: 2007-11-01 16:03:58 +0100 (Thu, 01 Nov 2007) New Revision: 22786 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22786&view=rev Modified: haiku/trunk/headers/build/private/kernel/syscalls.h haiku/trunk/src/build/libhaikucompat/syscalls.cpp Log: * fix the build of the libbe_test target Modified: haiku/trunk/headers/build/private/kernel/syscalls.h =================================================================== --- haiku/trunk/headers/build/private/kernel/syscalls.h 2007-11-01 14:14:43 UTC (rev 22785) +++ haiku/trunk/headers/build/private/kernel/syscalls.h 2007-11-01 15:03:58 UTC (rev 22786) @@ -403,6 +403,9 @@ const char *parameters, size_t parametersSize, partition_id *childID); extern status_t _kern_delete_partition(partition_id partitionID, int32 changeCounter); +extern status_t _kern_delete_child_partition(partition_id partitionID, + int32* changeCounter, partition_id childID, + int32 childChangeCounter); // jobs extern status_t _kern_get_next_disk_device_job_info(int32 *cookie, Modified: haiku/trunk/src/build/libhaikucompat/syscalls.cpp =================================================================== --- haiku/trunk/src/build/libhaikucompat/syscalls.cpp 2007-11-01 14:14:43 UTC (rev 22785) +++ haiku/trunk/src/build/libhaikucompat/syscalls.cpp 2007-11-01 15:03:58 UTC (rev 22786) @@ -395,8 +395,18 @@ return B_ERROR; } + +status_t +_kern_delete_child_partition(partition_id partitionID, int32* changeCounter, + partition_id childID, int32 childChangeCounter) +{ + return B_ERROR; +} + + // #pragma mark - jobs + status_t _kern_get_next_disk_device_job_info(int32 *cookie, struct user_disk_device_job_info *info) From stippi at mail.berlios.de Thu Nov 1 16:58:08 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 1 Nov 2007 16:58:08 +0100 Subject: [Haiku-commits] r22787 - in haiku/trunk/src/kits/interface: . textview_support Message-ID: <200711011558.lA1Fw8i9021059@sheep.berlios.de> Author: stippi Date: 2007-11-01 16:58:07 +0100 (Thu, 01 Nov 2007) New Revision: 22787 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22787&view=rev Modified: haiku/trunk/src/kits/interface/TextView.cpp haiku/trunk/src/kits/interface/textview_support/TextGapBuffer.cpp haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp Log: this should complete the work on password mode for BTextView: * fixed +/- 1 bug in _BTextGapBuffer_::GetString() * used the correct text and offsets in BTextView whenever the visible text is to be used * when copying to the clipboard, copy the bullets * when dragging the text, drag the bullets TODO: * test more with UTF8 chars in the original text (I am unsure if fSelStart and so on is really in bytes rather than glyphs) * test with multiple font styles Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2007-11-01 15:03:58 UTC (rev 22786) +++ haiku/trunk/src/kits/interface/TextView.cpp 2007-11-01 15:58:07 UTC (rev 22787) @@ -1233,8 +1233,9 @@ BMessage *clip = clipboard->Data(); if (clip != NULL) { - clip->AddData("text/plain", B_MIME_TYPE, Text() + fSelStart, - fSelEnd - fSelStart); + int32 numBytes = fSelEnd - fSelStart; + const char* text = fText->GetString(fSelStart, &numBytes); + clip->AddData("text/plain", B_MIME_TYPE, text, numBytes); int32 size; if (fStylable) { @@ -2642,9 +2643,10 @@ drag->AddInt32("be_actions", B_TRASH_TARGET); // add the text - drag->AddData("text/plain", B_MIME_TYPE, fText->RealText() + fSelStart, - fSelEnd - fSelStart); - + int32 numBytes = fSelEnd - fSelStart; + const char* text = fText->GetString(fSelStart, &numBytes); + drag->AddData("text/plain", B_MIME_TYPE, text, numBytes); + // add the corresponding styles int32 size = 0; text_run_array *styles = RunArray(fSelStart, fSelEnd, &size); @@ -3422,10 +3424,15 @@ LockWidthBuffer(); result += sWidths->StringWidth(*fText, fromOffset, numChars, font); UnlockWidthBuffer(); - } else + } else { #endif - result += font->StringWidth(fText->RealText() + fromOffset, numChars); - + const char* text = fText->GetString(fromOffset, &numChars); + result += font->StringWidth(text, numChars); + +#if USE_WIDTHBUFFER + } +#endif + fromOffset += numChars; length -= numChars; } Modified: haiku/trunk/src/kits/interface/textview_support/TextGapBuffer.cpp =================================================================== --- haiku/trunk/src/kits/interface/textview_support/TextGapBuffer.cpp 2007-11-01 15:03:58 UTC (rev 22786) +++ haiku/trunk/src/kits/interface/textview_support/TextGapBuffer.cpp 2007-11-01 15:58:07 UTC (rev 22787) @@ -205,7 +205,7 @@ uint32 numChars = UTF8CountChars(result, numBytes); uint32 charLen = UTF8CountBytes(B_UTF8_BULLET, 1); uint32 newSize = numChars * charLen; - + if ((uint32)fScratchSize < newSize) { fScratchBuffer = (char *)realloc(fScratchBuffer, newSize); fScratchSize = newSize; @@ -217,7 +217,8 @@ memcpy(scratchPtr, B_UTF8_BULLET, charLen); scratchPtr += charLen; } - *_numBytes = newSize - 1; + + *_numBytes = newSize; } return result; Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp =================================================================== --- haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2007-11-01 15:03:58 UTC (rev 22786) +++ haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2007-11-01 15:58:07 UTC (rev 22787) @@ -148,7 +148,8 @@ _BWidthBuffer_::StringWidth(_BTextGapBuffer_ &inBuffer, int32 fromOffset, int32 length, const BFont *inStyle) { - return StringWidth(inBuffer.Text(), fromOffset, length, inStyle); + const char* text = inBuffer.GetString(fromOffset, &length); + return StringWidth(text, 0, length, inStyle); } From axeld at pinc-software.de Thu Nov 1 17:23:38 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 01 Nov 2007 17:23:38 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r22787_-_in_haiku/trunk/src/kits/?= =?iso-8859-15?q?interface=3A_=2E_textview=5Fsupport?= In-Reply-To: <200711011558.lA1Fw8i9021059@sheep.berlios.de> Message-ID: <25395053474-BeMail@zon> stippi at BerliOS wrote: > * when copying to the clipboard, copy the bullets Isn't that a bit useless? Wouldn't it be better to beep instead, and just copy nothing? Or at least only an empty string? Also, I thought Stefano had already worked on the previous solution for that? Bye, Axel. From superstippi at gmx.de Thu Nov 1 17:37:18 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 01 Nov 2007 17:37:18 +0100 Subject: [Haiku-commits] r22787 - in haiku/trunk/src/kits/interface: . textview_support In-Reply-To: <25395053474-BeMail@zon> References: <25395053474-BeMail@zon> Message-ID: <20071101173718.50513.1@stippis.WG> Axel D?rfler wrote (2007-11-01, 17:23:38 [+0100]): > stippi at BerliOS wrote: > > * when copying to the clipboard, copy the bullets > > Isn't that a bit useless? Wouldn't it be better to beep instead, and just > copy nothing? Or at least only an empty string? Yes, I could do that instead. > Also, I thought Stefano had already worked on the previous solution for > that? Maybe he forgot to commit something? Stefano? See my patch: @@ -1233,8 +1233,9 @@ BMessage *clip = clipboard->Data(); if (clip != NULL) { - clip->AddData("text/plain", B_MIME_TYPE, Text() + fSelStart, - fSelEnd - fSelStart); + int32 numBytes = fSelEnd - fSelStart; + const char* text = fText->GetString(fSelStart, &numBytes); + clip->AddData("text/plain", B_MIME_TYPE, text, numBytes); int32 size; if (fStylable) { @@ -2642,9 +2643,10 @@ drag->AddInt32("be_actions", B_TRASH_TARGET); // add the text - drag->AddData("text/plain", B_MIME_TYPE, fText->RealText() + fSelStart, - fSelEnd - fSelStart); - + int32 numBytes = fSelEnd - fSelStart; + const char* text = fText->GetString(fSelStart, &numBytes); + drag->AddData("text/plain", B_MIME_TYPE, text, numBytes); fText->RealText() is what it says and also what BTextView::Text() returns, fText->Text()/GetString() is potentially the bullets if in password mode. Best regards, -Stephan From korli at mail.berlios.de Thu Nov 1 19:01:12 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 1 Nov 2007 19:01:12 +0100 Subject: [Haiku-commits] r22788 - in haiku/trunk/src/add-ons/kernel/drivers/audio: echo emuxki Message-ID: <200711011801.lA1I1Cv7006098@sheep.berlios.de> Author: korli Date: 2007-11-01 19:01:10 +0100 (Thu, 01 Nov 2007) New Revision: 22788 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22788&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c Log: fixed handling of parameters Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp 2007-11-01 15:58:07 UTC (rev 22787) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp 2007-11-01 18:01:10 UTC (rev 22788) @@ -532,26 +532,41 @@ char *end; uint32 value; - item = get_driver_parameter (settings_handle, "channels", "0", "0"); - value = strtoul (item, &end, 0); - if (*end == '\0') current_settings.channels = value; + item = get_driver_parameter (settings_handle, "channels", NULL, NULL); + if (item) { + value = strtoul (item, &end, 0); + if (*end == '\0') current_settings.channels = value; + } + PRINT(("channels %lu\n", current_settings.channels)); + + item = get_driver_parameter (settings_handle, "bitsPerSample", NULL, NULL); + if (item) { + value = strtoul (item, &end, 0); + if (*end == '\0') current_settings.bitsPerSample = value; + } + PRINT(("bitsPerSample %lu\n", current_settings.bitsPerSample)); + + item = get_driver_parameter (settings_handle, "sample_rate", NULL, NULL); + if (item) { + value = strtoul (item, &end, 0); + if (*end == '\0') current_settings.sample_rate = value; + } + PRINT(("sample_rate %lu\n", current_settings.sample_rate)); + + item = get_driver_parameter (settings_handle, "buffer_frames", NULL, NULL); + if (item) { + value = strtoul (item, &end, 0); + if (*end == '\0') current_settings.buffer_frames = value; + } + PRINT(("buffer_frames %lu\n", current_settings.buffer_frames)); - item = get_driver_parameter (settings_handle, "bitsPerSample", "0", "0"); - value = strtoul (item, &end, 0); - if (*end == '\0') current_settings.bitsPerSample = value; - - item = get_driver_parameter (settings_handle, "sample_rate", "0", "0"); - value = strtoul (item, &end, 0); - if (*end == '\0') current_settings.sample_rate = value; - - item = get_driver_parameter (settings_handle, "buffer_frames", "0", "0"); - value = strtoul (item, &end, 0); - if (*end == '\0') current_settings.buffer_frames = value; - - item = get_driver_parameter (settings_handle, "buffer_count", "0", "0"); - value = strtoul (item, &end, 0); - if (*end == '\0') current_settings.buffer_count = value; - + item = get_driver_parameter (settings_handle, "buffer_count", NULL, NULL); + if (item) { + value = strtoul (item, &end, 0); + if (*end == '\0') current_settings.buffer_count = value; + } + PRINT(("buffer_count %lu\n", current_settings.buffer_count)); + unload_driver_settings (settings_handle); } Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c 2007-11-01 15:58:07 UTC (rev 22787) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c 2007-11-01 18:01:10 UTC (rev 22788) @@ -2751,25 +2751,35 @@ char *end; uint32 value; - item = get_driver_parameter (settings_handle, "channels", "0", "0"); - value = strtoul (item, &end, 0); - if (*end == '\0') current_settings.channels = value; + item = get_driver_parameter (settings_handle, "channels", NULL, NULL); + if (item) { + value = strtoul (item, &end, 0); + if (*end == '\0') current_settings.channels = value; + } - item = get_driver_parameter (settings_handle, "bitsPerSample", "0", "0"); - value = strtoul (item, &end, 0); - if (*end == '\0') current_settings.bitsPerSample = value; + item = get_driver_parameter (settings_handle, "bitsPerSample", NULL, NULL); + if (item) { + value = strtoul (item, &end, 0); + if (*end == '\0') current_settings.bitsPerSample = value; + } - item = get_driver_parameter (settings_handle, "sample_rate", "0", "0"); - value = strtoul (item, &end, 0); - if (*end == '\0') current_settings.sample_rate = value; + item = get_driver_parameter (settings_handle, "sample_rate", NULL, NULL); + if (item) { + value = strtoul (item, &end, 0); + if (*end == '\0') current_settings.sample_rate = value; + } - item = get_driver_parameter (settings_handle, "buffer_frames", "0", "0"); - value = strtoul (item, &end, 0); - if (*end == '\0') current_settings.buffer_frames = value; + item = get_driver_parameter (settings_handle, "buffer_frames", NULL, NULL); + if (item) { + value = strtoul (item, &end, 0); + if (*end == '\0') current_settings.buffer_frames = value; + } - item = get_driver_parameter (settings_handle, "buffer_count", "0", "0"); - value = strtoul (item, &end, 0); - if (*end == '\0') current_settings.buffer_count = value; + item = get_driver_parameter (settings_handle, "buffer_count", NULL, NULL); + if (item) { + value = strtoul (item, &end, 0); + if (*end == '\0') current_settings.buffer_count = value; + } unload_driver_settings (settings_handle); } From bonefish at mail.berlios.de Thu Nov 1 19:03:37 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 1 Nov 2007 19:03:37 +0100 Subject: [Haiku-commits] r22789 - in haiku/trunk: headers/posix src/system/libroot/posix/signal Message-ID: <200711011803.lA1I3brS008751@sheep.berlios.de> Author: bonefish Date: 2007-11-01 19:03:36 +0100 (Thu, 01 Nov 2007) New Revision: 22789 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22789&view=rev Added: haiku/trunk/src/system/libroot/posix/signal/sigignore.cpp Modified: haiku/trunk/headers/posix/signal.h haiku/trunk/src/system/libroot/posix/signal/Jamfile Log: Patch by Vasilis Kaoutsis: Implemented sigignore(). Small changes by myself. Modified: haiku/trunk/headers/posix/signal.h =================================================================== --- haiku/trunk/headers/posix/signal.h 2007-11-01 18:01:10 UTC (rev 22788) +++ haiku/trunk/headers/posix/signal.h 2007-11-01 18:03:36 UTC (rev 22789) @@ -163,6 +163,7 @@ int sigaddset(sigset_t *set, int signo); int sigdelset(sigset_t *set, int signo); int sigismember(const sigset_t *set, int signo); +int sigignore(int signo); const char *strsignal(int sig); Modified: haiku/trunk/src/system/libroot/posix/signal/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/signal/Jamfile 2007-11-01 18:01:10 UTC (rev 22788) +++ haiku/trunk/src/system/libroot/posix/signal/Jamfile 2007-11-01 18:03:36 UTC (rev 22789) @@ -10,6 +10,7 @@ set_signal_stack.c sigaction.c sigaltstack.c + sigignore.cpp signal.c sigpending.c sigprocmask.c Added: haiku/trunk/src/system/libroot/posix/signal/sigignore.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/signal/sigignore.cpp 2007-11-01 18:01:10 UTC (rev 22788) +++ haiku/trunk/src/system/libroot/posix/signal/sigignore.cpp 2007-11-01 18:03:36 UTC (rev 22789) @@ -0,0 +1,37 @@ +/* + * Copyright 2007, Vasilis Kaoutsis, kaoutsis at sch.gr + * Distributed under the terms of the MIT License. + */ + + +#include +#include + +#include + + +int +sigignore(int signal) +{ + // check for invalid signals or for signals + // that can not be ignored (SIGKILL, SIGSTOP) + if (signal <= 0 || signal >= NSIG || signal == SIGKILL + || signal == SIGSTOP) { + errno = EINVAL; + return -1; + } + + struct sigaction ignoreSignalAction; + // create an action to ignore the signal + + // request that the signal will be ignored + // by the handler of the action + ignoreSignalAction.sa_handler = SIG_IGN; + ignoreSignalAction.sa_flags = 0; + + // In case of SIGCHLD the specification requires SA_NOCLDWAIT behavior. + if (signal == SIGCHLD) + ignoreSignalAction.sa_flags |= SA_NOCLDWAIT; + + return sigaction(signal, &ignoreSignalAction, NULL); +} From bonefish at mail.berlios.de Thu Nov 1 19:05:23 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 1 Nov 2007 19:05:23 +0100 Subject: [Haiku-commits] r22790 - haiku/trunk/src/system/libroot/posix/signal Message-ID: <200711011805.lA1I5Nia011157@sheep.berlios.de> Author: bonefish Date: 2007-11-01 19:05:22 +0100 (Thu, 01 Nov 2007) New Revision: 22790 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22790&view=rev Modified: haiku/trunk/src/system/libroot/posix/signal/sigset.c Log: Patch by Vasilis Kaoutsis: Style cleanup. Modified: haiku/trunk/src/system/libroot/posix/signal/sigset.c =================================================================== --- haiku/trunk/src/system/libroot/posix/signal/sigset.c 2007-11-01 18:03:36 UTC (rev 22789) +++ haiku/trunk/src/system/libroot/posix/signal/sigset.c 2007-11-01 18:05:22 UTC (rev 22790) @@ -34,8 +34,8 @@ sigset_t mask; if (sig <= 0 || sig >= NSIG) { - errno = EINVAL; - return -1; + errno = EINVAL; + return -1; } mask = (((sigset_t)1) << (sig - 1)) ; @@ -49,8 +49,8 @@ sigset_t mask; if (sig <= 0 || sig >= NSIG) { - errno = EINVAL; - return -1; + errno = EINVAL; + return -1; } mask = (((sigset_t)1) << (sig - 1)) ; @@ -65,8 +65,8 @@ sigset_t mask; if (sig <= 0 || sig >= NSIG) { - errno = EINVAL; - return -1; + errno = EINVAL; + return -1; } mask = (((sigset_t)1) << (sig - 1)) ; From korli at mail.berlios.de Thu Nov 1 19:08:43 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 1 Nov 2007 19:08:43 +0100 Subject: [Haiku-commits] r22791 - haiku/trunk/src/add-ons/media/media-add-ons/multi_audio Message-ID: <200711011808.lA1I8h12014976@sheep.berlios.de> Author: korli Date: 2007-11-01 19:08:42 +0100 (Thu, 01 Nov 2007) New Revision: 22791 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22791&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.h haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/driver_io.h Log: clean up Modified: haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp 2007-11-01 18:05:22 UTC (rev 22790) +++ haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp 2007-11-01 18:08:42 UTC (rev 22791) @@ -2,28 +2,7 @@ * multiaudio replacement media addon for BeOS * * Copyright (c) 2002, 2003 Jerome Duval (jerome.duval at free.fr) - * - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * Distributed under the terms of the MIT License. */ #include #include @@ -1621,7 +1600,21 @@ case media_raw_audio_format::B_AUDIO_FLOAT: switch(input.fFormat.u.raw_audio.format) { - case media_raw_audio_format::B_AUDIO_FLOAT: + case media_raw_audio_format::B_AUDIO_FLOAT: { + size_t frame_size = input.fInput.format.u.raw_audio.channel_count * sizeof(float); + size_t stride = fDevice->MBL.playback_buffers[input.fBufferCycle][input.fChannelId].stride; + //PRINT(("stride : %i, frame_size : %i, return_playback_buffer_size : %i\n", stride, frame_size, fDevice->MBL.return_playback_buffer_size)); + for(uint32 channel = 0; channel < input.fInput.format.u.raw_audio.channel_count; channel++) { + char *sample_dest = fDevice->MBL.playback_buffers[input.fBufferCycle][input.fChannelId + channel].base; + //char *sample_src = (char*)buffer->Data() + (input.fInput.format.u.raw_audio.channel_count - 1 - channel) * sizeof(int16); + char *sample_src = (char*)buffer->Data() + channel * sizeof(float); + for(uint32 i=fDevice->MBL.return_playback_buffer_size; i>0; i--) { + *(float *)sample_dest = *(float *)sample_src; + sample_dest += stride; + sample_src += frame_size; + } + } + } break; case media_raw_audio_format::B_AUDIO_INT: break; @@ -1688,7 +1681,7 @@ //char *sample_src = (char*)buffer->Data() + (input.fInput.format.u.raw_audio.channel_count - 1 - channel) * sizeof(int16); char *sample_src = (char*)buffer->Data() + channel * sizeof(int32); for(uint32 i=fDevice->MBL.return_playback_buffer_size; i>0; i--) { - *(int32*)sample_dest = *(int32*)sample_src; + *(int32 *)sample_dest = *(int32 *)sample_src; sample_dest += stride; sample_src += frame_size; } @@ -1745,7 +1738,7 @@ //char *sample_src = (char*)buffer->Data() + (input.fInput.format.u.raw_audio.channel_count - 1 - channel) * sizeof(int16); char *sample_src = (char*)buffer->Data() + channel * sizeof(int16); for(uint32 i=fDevice->MBL.return_playback_buffer_size; i>0; i--) { - *(int16*)sample_dest = *(int16*)sample_src; + *(int16 *)sample_dest = *(int16 *)sample_src; sample_dest += stride; sample_src += frame_size; } @@ -1819,10 +1812,10 @@ //CALLED(); if(fTimeSourceStarted) { bigtime_t perf_time = (bigtime_t)(MBI.played_frames_count / - input.fInput.format.u.raw_audio.frame_rate * 1000000); + input.fInput.format.u.raw_audio.frame_rate * 1000000LL); bigtime_t real_time = MBI.played_real_time; float drift = ((MBI.played_frames_count - oldMBI.played_frames_count) - / input.fInput.format.u.raw_audio.frame_rate * 1000000) + / input.fInput.format.u.raw_audio.frame_rate * 1000000LL) / (MBI.played_real_time - oldMBI.played_real_time); PublishTime(perf_time, real_time, drift); Modified: haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.h 2007-11-01 18:05:22 UTC (rev 22790) +++ haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.h 2007-11-01 18:08:42 UTC (rev 22791) @@ -2,28 +2,7 @@ * multiaudio replacement media addon for BeOS * * Copyright (c) 2002, Jerome Duval (jerome.duval at free.fr) - * - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * Distributed under the terms of the MIT License. */ #ifndef _MULTIAUDIONODE_H #define _MULTIAUDIONODE_H @@ -46,349 +25,334 @@ /*bool format_is_acceptible( const media_format & producer_format, const media_format & consumer_format);*/ - - + + class node_input { public: - node_input(media_input &input, media_format format); - ~node_input(); + node_input(media_input &input, media_format format); + ~node_input(); - int32 fChannelId; - media_input fInput; - media_format fPreferredFormat; - media_format fFormat; - uint32 fBufferCycle; - multi_buffer_info fOldMBI; - BBuffer *fBuffer; + int32 fChannelId; + media_input fInput; + media_format fPreferredFormat; + media_format fFormat; + uint32 fBufferCycle; + multi_buffer_info fOldMBI; + BBuffer *fBuffer; }; class node_output { public: - node_output(media_output &output, media_format format); - ~node_output(); + node_output(media_output &output, media_format format); + ~node_output(); - int32 fChannelId; - media_output fOutput; - media_format fPreferredFormat; - media_format fFormat; - - BBufferGroup *fBufferGroup; - bool fOutputEnabled; - uint64 fSamplesSent; - volatile uint32 fBufferCycle; - multi_buffer_info fOldMBI; + int32 fChannelId; + media_output fOutput; + media_format fPreferredFormat; + media_format fFormat; + + BBufferGroup *fBufferGroup; + bool fOutputEnabled; + uint64 fSamplesSent; + volatile uint32 fBufferCycle; + multi_buffer_info fOldMBI; }; class MultiAudioNode : - public BBufferConsumer, - public BBufferProducer, - public BTimeSource, - public BMediaEventLooper, - public BControllable + public BBufferConsumer, + public BBufferProducer, + public BTimeSource, + public BMediaEventLooper, + public BControllable { -protected: -virtual ~MultiAudioNode(void); + protected: + virtual ~MultiAudioNode(void); -public: + public: -explicit MultiAudioNode(BMediaAddOn *addon, char* name, MultiAudioDevice *device, - int32 internal_id, BMessage * config); + explicit MultiAudioNode(BMediaAddOn *addon, char* name, MultiAudioDevice *device, + int32 internal_id, BMessage * config); -virtual status_t InitCheck(void) const; + virtual status_t InitCheck(void) const; -/*************************/ -/* begin from BMediaNode */ -public: -virtual BMediaAddOn* AddOn( - int32 * internal_id) const; /* Who instantiated you -- or NULL for app class */ + /*************************/ + /* begin from BMediaNode */ + public: + virtual BMediaAddOn* AddOn( + int32 * internal_id) const; /* Who instantiated you -- or NULL for app class */ -protected: + protected: /* These don't return errors; instead, they use the global error condition reporter. */ /* A node is required to have a queue of at least one pending command (plus TimeWarp) */ /* and is recommended to allow for at least one pending command of each type. */ /* Allowing an arbitrary number of outstanding commands might be nice, but apps */ /* cannot depend on that happening. */ -virtual void Preroll(void); + virtual void Preroll(void); -public: -virtual status_t HandleMessage( - int32 message, - const void * data, - size_t size); - -protected: -virtual void NodeRegistered(void); /* reserved 2 */ -virtual status_t RequestCompleted(const media_request_info &info); -virtual void SetTimeSource(BTimeSource *timeSource); + public: + virtual status_t HandleMessage( + int32 message, + const void * data, + size_t size); -/* end from BMediaNode */ -/***********************/ + protected: + virtual void NodeRegistered(void); /* reserved 2 */ + virtual status_t RequestCompleted(const media_request_info &info); + virtual void SetTimeSource(BTimeSource *timeSource); -/******************************/ -/* begin from BBufferConsumer */ + /* end from BMediaNode */ + /***********************/ + /******************************/ + /* begin from BBufferConsumer */ + //included from BMediaAddOn //virtual status_t HandleMessage( // int32 message, // const void * data, // size_t size); - /* Someone, probably the producer, is asking you about this format. Give */ - /* your honest opinion, possibly modifying *format. Do not ask upstream */ - /* producer about the format, since he's synchronously waiting for your */ - /* reply. */ -virtual status_t AcceptFormat( - const media_destination & dest, - media_format * format); -virtual status_t GetNextInput( - int32 * cookie, - media_input * out_input); -virtual void DisposeInputCookie( - int32 cookie); -virtual void BufferReceived( - BBuffer * buffer); -virtual void ProducerDataStatus( - const media_destination & for_whom, - int32 status, - bigtime_t at_performance_time); -virtual status_t GetLatencyFor( - const media_destination & for_whom, - bigtime_t * out_latency, - media_node_id * out_timesource); -virtual status_t Connected( - const media_source & producer, /* here's a good place to request buffer group usage */ - const media_destination & where, - const media_format & with_format, - media_input * out_input); -virtual void Disconnected( - const media_source & producer, - const media_destination & where); - /* The notification comes from the upstream producer, so he's already cool with */ - /* the format; you should not ask him about it in here. */ -virtual status_t FormatChanged( - const media_source & producer, - const media_destination & consumer, - int32 change_tag, - const media_format & format); + /* Someone, probably the producer, is asking you about this format. Give */ + /* your honest opinion, possibly modifying *format. Do not ask upstream */ + /* producer about the format, since he's synchronously waiting for your */ + /* reply. */ + virtual status_t AcceptFormat( + const media_destination & dest, + media_format * format); + virtual status_t GetNextInput( + int32 * cookie, + media_input * out_input); + virtual void DisposeInputCookie( + int32 cookie); + virtual void BufferReceived( + BBuffer * buffer); + virtual void ProducerDataStatus( + const media_destination & for_whom, + int32 status, + bigtime_t at_performance_time); + virtual status_t GetLatencyFor( + const media_destination & for_whom, + bigtime_t * out_latency, + media_node_id * out_timesource); + virtual status_t Connected( + const media_source & producer, /* here's a good place to request buffer group usage */ + const media_destination & where, + const media_format & with_format, + media_input * out_input); + virtual void Disconnected( + const media_source & producer, + const media_destination & where); + /* The notification comes from the upstream producer, so he's already cool with */ + /* the format; you should not ask him about it in here. */ + virtual status_t FormatChanged( + const media_source & producer, + const media_destination & consumer, + int32 change_tag, + const media_format & format); - /* Given a performance time of some previous buffer, retrieve the remembered tag */ - /* of the closest (previous or exact) performance time. Set *out_flags to 0; the */ - /* idea being that flags can be added later, and the understood flags returned in */ - /* *out_flags. */ -virtual status_t SeekTagRequested( - const media_destination & destination, - bigtime_t in_target_time, - uint32 in_flags, - media_seek_tag * out_seek_tag, - bigtime_t * out_tagged_time, - uint32 * out_flags); + /* Given a performance time of some previous buffer, retrieve the remembered tag */ + /* of the closest (previous or exact) performance time. Set *out_flags to 0; the */ + /* idea being that flags can be added later, and the understood flags returned in */ + /* *out_flags. */ + virtual status_t SeekTagRequested( + const media_destination & destination, + bigtime_t in_target_time, + uint32 in_flags, + media_seek_tag * out_seek_tag, + bigtime_t * out_tagged_time, + uint32 * out_flags); -/* end from BBufferConsumer */ -/****************************/ + /* end from BBufferConsumer */ + /****************************/ -/******************************/ -/* begin from BBufferProducer */ + /******************************/ + /* begin from BBufferProducer */ - virtual status_t FormatSuggestionRequested( media_type type, - int32 quality, - media_format* format); - - virtual status_t FormatProposal( const media_source& output, - media_format* format); - - virtual status_t FormatChangeRequested( const media_source& source, - const media_destination& destination, - media_format* io_format, - int32* _deprecated_); - virtual status_t GetNextOutput( int32* cookie, - media_output* out_output); - virtual status_t DisposeOutputCookie( int32 cookie); - - virtual status_t SetBufferGroup( const media_source& for_source, - BBufferGroup* group); - - virtual status_t PrepareToConnect( const media_source& what, - const media_destination& where, - media_format* format, - media_source* out_source, - char* out_name); - - virtual void Connect( status_t error, - const media_source& source, - const media_destination& destination, - const media_format& format, - char* io_name); - - virtual void Disconnect( const media_source& what, - const media_destination& where); - - virtual void LateNoticeReceived( const media_source& what, - bigtime_t how_much, - bigtime_t performance_time); - - virtual void EnableOutput( const media_source & what, - bool enabled, - int32* _deprecated_); - virtual void AdditionalBufferRequested( const media_source& source, - media_buffer_id prev_buffer, - bigtime_t prev_time, - const media_seek_tag* prev_tag); + virtual status_t FormatSuggestionRequested(media_type type, + int32 quality, + media_format* format); -/* end from BBufferProducer */ -/****************************/ + virtual status_t FormatProposal(const media_source& output, + media_format* format); -/*****************/ -/* BControllable */ -/*****************/ + virtual status_t FormatChangeRequested(const media_source& source, + const media_destination& destination, + media_format* io_format, + int32* _deprecated_); + virtual status_t GetNextOutput(int32* cookie, + media_output* out_output); + virtual status_t DisposeOutputCookie(int32 cookie); -/********************************/ -/* start from BMediaEventLooper */ + virtual status_t SetBufferGroup(const media_source& for_source, + BBufferGroup* group); + virtual status_t PrepareToConnect(const media_source& what, + const media_destination& where, + media_format* format, + media_source* out_source, + char* out_name); + + virtual void Connect(status_t error, + const media_source& source, + const media_destination& destination, + const media_format& format, + char* io_name); + + virtual void Disconnect(const media_source& what, + const media_destination& where); + + virtual void LateNoticeReceived(const media_source& what, + bigtime_t how_much, + bigtime_t performance_time); + + virtual void EnableOutput(const media_source & what, + bool enabled, + int32* _deprecated_); + virtual void AdditionalBufferRequested(const media_source& source, + media_buffer_id prev_buffer, + bigtime_t prev_time, + const media_seek_tag* prev_tag); + + /* end from BBufferProducer */ + /****************************/ + + /*****************/ + /* BControllable */ + /*****************/ + + /********************************/ + /* start from BMediaEventLooper */ + protected: /* you must override to handle your events! */ /* you should not call HandleEvent directly */ - virtual void HandleEvent( const media_timed_event *event, - bigtime_t lateness, - bool realTimeEvent = false); + virtual void HandleEvent(const media_timed_event *event, + bigtime_t lateness, + bool realTimeEvent = false); -/* end from BMediaEventLooper */ -/******************************/ + /* end from BMediaEventLooper */ + /******************************/ -/********************************/ -/* start from BTimeSource */ + /********************************/ + /* start from BTimeSource */ protected: - virtual void SetRunMode( run_mode mode); - virtual status_t TimeSourceOp( const time_source_op_info &op, - void *_reserved); + virtual void SetRunMode(run_mode mode); + virtual status_t TimeSourceOp(const time_source_op_info &op, + void *_reserved); -/* end from BTimeSource */ -/******************************/ + /* end from BTimeSource */ + /******************************/ -/********************************/ -/* start from BControllable */ + /********************************/ + /* start from BControllable */ protected: - virtual status_t GetParameterValue( int32 id, - bigtime_t* last_change, - void* value, - size_t* ioSize); - virtual void SetParameterValue( int32 id, - bigtime_t when, - const void* value, - size_t size); + virtual status_t GetParameterValue(int32 id, + bigtime_t* last_change, + void * value, + size_t* ioSize); + virtual void SetParameterValue(int32 id, + bigtime_t when, + const void * value, + size_t size); virtual BParameterWeb* MakeParameterWeb(); - -/* end from BControllable */ -/******************************/ -protected: + /* end from BControllable */ + /******************************/ -virtual status_t HandleStart( - const media_timed_event *event, - bigtime_t lateness, - bool realTimeEvent = false); -virtual status_t HandleSeek( - const media_timed_event *event, - bigtime_t lateness, - bool realTimeEvent = false); -virtual status_t HandleWarp( - const media_timed_event *event, - bigtime_t lateness, - bool realTimeEvent = false); -virtual status_t HandleStop( - const media_timed_event *event, - bigtime_t lateness, - bool realTimeEvent = false); -virtual status_t HandleBuffer( - const media_timed_event *event, - bigtime_t lateness, - bool realTimeEvent = false); -virtual status_t HandleDataStatus( - const media_timed_event *event, - bigtime_t lateness, - bool realTimeEvent = false); -virtual status_t HandleParameter( - const media_timed_event *event, - bigtime_t lateness, - bool realTimeEvent = false); + protected: -public: + virtual status_t HandleStart( + const media_timed_event *event, + bigtime_t lateness, + bool realTimeEvent = false); + virtual status_t HandleSeek( + const media_timed_event *event, + bigtime_t lateness, + bool realTimeEvent = false); + virtual status_t HandleWarp( + const media_timed_event *event, + bigtime_t lateness, + bool realTimeEvent = false); + virtual status_t HandleStop( + const media_timed_event *event, + bigtime_t lateness, + bool realTimeEvent = false); + virtual status_t HandleBuffer( + const media_timed_event *event, + bigtime_t lateness, + bool realTimeEvent = false); + virtual status_t HandleDataStatus( + const media_timed_event *event, + bigtime_t lateness, + bool realTimeEvent = false); + virtual status_t HandleParameter( + const media_timed_event *event, + bigtime_t lateness, + bool realTimeEvent = false); -static void GetFlavor(flavor_info * outInfo, int32 id); -static void GetFormat(media_format * outFormat); + public: -status_t GetConfigurationFor(BMessage * into_message); + static void GetFlavor(flavor_info * outInfo, int32 id); + static void GetFormat(media_format * outFormat); + status_t GetConfigurationFor(BMessage * into_message); -private: - MultiAudioNode( /* private unimplemented */ - const MultiAudioNode & clone); + private: + + MultiAudioNode(/* private unimplemented */ + const MultiAudioNode & clone); MultiAudioNode & operator=( - const MultiAudioNode & clone); - + const MultiAudioNode & clone); + //void WriteBuffer( BBuffer *buffer, node_input &input ); void WriteZeros(node_input &input, uint32 bufferCycle); void FillWithZeros(node_input &input); void FillNextBuffer(node_input &channel, BBuffer* buffer); - static int32 _run_thread_( void *data ); + static int32 _run_thread_(void *data); int32 RunThread(); status_t StartThread(); status_t StopThread(); - - + + void AllocateBuffers(node_output &channel); - BBuffer* FillNextBuffer( multi_buffer_info &MBI, - node_output &channel); + BBuffer* FillNextBuffer(multi_buffer_info &MBI, + node_output &channel); void UpdateTimeSource(multi_buffer_info &MBI, - multi_buffer_info &oldMBI, - node_input &input); - + multi_buffer_info &oldMBI, + node_input &input); + node_output* FindOutput(media_source source); node_input* FindInput(media_destination dest); node_input* FindInput(int32 destinationId); - + void ProcessGroup(BParameterGroup *group, int32 index, int32 &nbParameters); void ProcessMux(BDiscreteParameter *parameter, int32 index); - + status_t fInitCheckStatus; BMediaAddOn *fAddOn; int32 fId; BList fInputs; - + bigtime_t fLatency; BList fOutputs; media_format fPreferredFormat; - + bigtime_t fInternalLatency; // this is computed from the real (negotiated) chunk size and bit rate, // not the defaults that are in the parameters bigtime_t fBufferPeriod; - - - //volatile uint32 fBufferCycle; + sem_id fBuffer_free; - - thread_id fThread; - MultiAudioDevice *fDevice; - - //multi_description MD; - //multi_format_info MFI; - //multi_buffer_list MBL; - - //multi_mix_control_info MMCI; - //multi_mix_control MMC[MAX_CONTROLS]; - bool fTimeSourceStarted; - BParameterWeb *fWeb; - BMessage fConfig; }; Modified: haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/driver_io.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/driver_io.h 2007-11-01 18:05:22 UTC (rev 22790) +++ haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/driver_io.h 2007-11-01 18:08:42 UTC (rev 22791) @@ -2,28 +2,7 @@ * multiaudio replacement media addon for BeOS * * Copyright (c) 2002, Jerome Duval (jerome.duval at free.fr) - * - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * Distributed under the terms of the MIT License. */ #ifndef _DRIVER_IO_H #define _DRIVER_IO_H From bonefish at mail.berlios.de Thu Nov 1 19:12:56 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 1 Nov 2007 19:12:56 +0100 Subject: [Haiku-commits] r22792 - in haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces: . difftime kill sigignore sigprocmask sigsuspend Message-ID: <200711011812.lA1ICu6t018856@sheep.berlios.de> Author: bonefish Date: 2007-11-01 19:12:55 +0100 (Thu, 01 Nov 2007) New Revision: 22792 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22792&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/4-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/5-core-buildonly.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-2.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/Jamfile Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/difftime/Jamfile haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/kill/Jamfile haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/Jamfile haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigsuspend/Jamfile Log: Patch by Vasilis Kaoutsis: * Added sigignore() tests. * Renamed names of the test executables to avoid clashes in the build system. Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-11-01 18:12:55 UTC (rev 22792) @@ -7,5 +7,6 @@ SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_key_delete ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_getspecific ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_setspecific ; +SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigignore ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigprocmask ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigsuspend ; Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/difftime/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/difftime/Jamfile 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/difftime/Jamfile 2007-11-01 18:12:55 UTC (rev 22792) @@ -2,5 +2,5 @@ SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ; -SimpleTest 1-1.test : 1-1.c ; +SimpleTest difftime_1-1 : 1-1.c ; Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/kill/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/kill/Jamfile 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/kill/Jamfile 2007-11-01 18:12:55 UTC (rev 22792) @@ -2,5 +2,4 @@ SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ; -SimpleTest 2-1.test : 2-1.c ; - +SimpleTest kill_2-1 : 2-1.c ; Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/1-1.c 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/1-1.c 2007-11-01 18:12:55 UTC (rev 22792) @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Steps: + 1. Set up a handler for signal SIGABRT, such that it is called if +signal is ever raised. + 2. Call sigignore on SIGABRT. + 3. Raise a SIGABRT and verify that the signal handler was not called. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include "posixtest.h" + +int handler_called = 0; + +void handler(int signo) +{ + handler_called = 1; +} + +int main() +{ + struct sigaction act; + + act.sa_handler = handler; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + if (sigaction(SIGABRT, &act, 0) == -1) { + perror("Unexpected error while attempting to setup test " + "pre-conditions"); + return PTS_UNRESOLVED; + } + + sigignore(SIGABRT); + + if (raise(SIGABRT) == -1) { + perror("Unexpected error while attempting to setup test " + "pre-conditions"); + return PTS_UNRESOLVED; + } + + if (handler_called) { + printf("FAIL: Signal was not ignored\n"); + return PTS_FAIL; + } + printf("PASS\n"); + return PTS_PASS; +} + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/4-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/4-1.c 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/4-1.c 2007-11-01 18:12:55 UTC (rev 22792) @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Simply, if sigignore returns a 0 here, test passes. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include "posixtest.h" + +int main() +{ + + if (sigignore(SIGABRT) != 0) { + perror("sigignore failed -- returned -- test aborted"); + return PTS_UNRESOLVED; + } + printf("sigignore passed\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/5-core-buildonly.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/5-core-buildonly.c 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/5-core-buildonly.c 2007-11-01 18:12:55 UTC (rev 22792) @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Testing passing an invalid signals to sighold(). + After sighold is called on an invalid signal, sigignore() should +return -1 and set errno to EINVAL + + The invalid signal passed to sigignore() depends on the argument +passed to this program. There are currently 4 invalid signals. + */ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include +#include "posixtest.h" + +int main(int argc, char *argv[]) +{ + int signo; + + if (argc < 2) { + printf("Usage: %s [1|2|3|4]\n", argv[0]); + return PTS_UNRESOLVED; + } + + /* + Various error conditions + */ + switch (argv[1][0]) { + case '1': + signo=-1; + break; + case '2': + signo=-10000; + break; + case '3': + signo=INT32_MIN+1; + break; + case '4': + signo=INT32_MIN; + break; + default: + printf("Usage: %s [1|2|3|4]\n", argv[0]); + return PTS_UNRESOLVED; + } + + if (sigignore(signo) == -1) { + if (EINVAL == errno) { + printf ("errno set to EINVAL\n"); + return PTS_PASS; + } else { + printf ("errno not set to EINVAL\n"); + return PTS_FAIL; + } + } + + printf("sighold did not return -1\n"); + return PTS_FAIL; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-1.c 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-1.c 2007-11-01 18:12:55 UTC (rev 22792) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Testing trying to ignore a signal that cannot be ignored. + Line 1264 in Issue 6 of the Posix System Interfaces document says that + the system shall not allow the signals SIGKILL or SIGSTOP + to be ignored. + */ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include +#include "posixtest.h" + +int main() +{ + if (sigignore(SIGKILL) == -1) { + if (EINVAL == errno) { + printf ("errno set to EINVAL\n"); + return PTS_PASS; + } else { + printf ("errno not set to EINVAL\n"); + return PTS_FAIL; + } + } + + printf("sigignore did not return -1\n"); + return PTS_FAIL; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-2.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-2.c 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-2.c 2007-11-01 18:12:55 UTC (rev 22792) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Testing trying to ignore a signal that cannot be ignored. + Line 1264 in Issue 6 of the Posix System Interfaces document says that + the system shall not allow the signals SIGKILL or SIGSTOP + to be ignored. + */ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include +#include "posixtest.h" + +int main() +{ + if (sigignore(SIGSTOP) == -1) { + if (EINVAL == errno) { + printf ("errno set to EINVAL\n"); + return PTS_PASS; + } else { + printf ("errno not set to EINVAL\n"); + return PTS_FAIL; + } + } + + printf("sigignore did not return -1\n"); + return PTS_FAIL; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/Jamfile 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/Jamfile 2007-11-01 18:12:55 UTC (rev 22792) @@ -0,0 +1,9 @@ +SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigignore ; + +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ; + +SimpleTest sigignore_1-1 : 1-1.c ; +SimpleTest sigignore_4-1 : 4-1.c ; +SimpleTest sigignore_5-core-buildonly : 5-core-buildonly.c ; +SimpleTest sigignore_6-1 : 6-1.c ; +SimpleTest sigignore_6-2 : 6-2.c ; Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/Jamfile 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/Jamfile 2007-11-01 18:12:55 UTC (rev 22792) @@ -2,8 +2,7 @@ SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ; -SimpleTest 8-1.test : 8-1.c ; -SimpleTest 8-2.test : 8-2.c ; -SimpleTest 8-3.test : 8-3.c ; -SimpleTest 12-1.test : 12-1.c ; - +SimpleTest sigprocmask_8-1 : 8-1.c ; +SimpleTest sigprocmask_8-2 : 8-2.c ; +SimpleTest sigprocmask_8-3 : 8-3.c ; +SimpleTest sigprocmask_12-1 : 12-1.c ; Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigsuspend/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigsuspend/Jamfile 2007-11-01 18:08:42 UTC (rev 22791) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigsuspend/Jamfile 2007-11-01 18:12:55 UTC (rev 22792) @@ -2,5 +2,4 @@ SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ; -SimpleTest 6-1.test : 6-1.c ; - +SimpleTest sigsuspend_6-1 : 6-1.c ; From marcusoverhagen at arcor.de Thu Nov 1 20:26:46 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Thu, 1 Nov 2007 20:26:46 +0100 (CET) Subject: [Haiku-commits] r22789 - in haiku/trunk: headers/posix In-Reply-To: <200711011803.lA1I3brS008751@sheep.berlios.de> References: <200711011803.lA1I3brS008751@sheep.berlios.de> Message-ID: <22314872.1193945206683.JavaMail.ngmail@webmail12> > Patch by Vasilis Kaoutsis: Implemented sigignore(). Small changes by > myself. > +++ haiku/trunk/src/system/libroot/posix/signal/sigignore.cpp 2007-11-01 > + // check for invalid signals or for signals > + // that can not be ignored (SIGKILL, SIGSTOP) > + if (signal <= 0 || signal >= NSIG || signal == SIGKILL > + || signal == SIGSTOP) { > + errno = EINVAL; > + return -1; > + } > + What happens if I call sigaction directly with SIGKILL or SIGSTOP? Shouldn't these checks be made by the kernel? regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From korli at mail.berlios.de Thu Nov 1 20:36:35 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 1 Nov 2007 20:36:35 +0100 Subject: [Haiku-commits] r22793 - haiku/trunk/src/system/libroot/os/arch/ppc Message-ID: <200711011936.lA1JaZDH019753@sheep.berlios.de> Author: korli Date: 2007-11-01 20:36:34 +0100 (Thu, 01 Nov 2007) New Revision: 22793 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22793&view=rev Modified: haiku/trunk/src/system/libroot/os/arch/ppc/syscalls.inc Log: added a few more syscalls arguments for _kern_create_child_partition() Modified: haiku/trunk/src/system/libroot/os/arch/ppc/syscalls.inc =================================================================== --- haiku/trunk/src/system/libroot/os/arch/ppc/syscalls.inc 2007-11-01 18:12:55 UTC (rev 22792) +++ haiku/trunk/src/system/libroot/os/arch/ppc/syscalls.inc 2007-11-01 19:36:34 UTC (rev 22793) @@ -68,3 +68,21 @@ .align 4; \ name: +#define SYSCALL11(name, n) \ +.globl name; \ +.type name, at function; \ +.align 4; \ +name: + +#define SYSCALL12(name, n) \ +.globl name; \ +.type name, at function; \ +.align 4; \ +name: + +#define SYSCALL13(name, n) \ +.globl name; \ +.type name, at function; \ +.align 4; \ +name: + From ingo_weinhold at gmx.de Thu Nov 1 21:07:34 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 01 Nov 2007 21:07:34 +0100 Subject: [Haiku-commits] r22789 - in haiku/trunk: headers/posix In-Reply-To: <22314872.1193945206683.JavaMail.ngmail@webmail12> References: <200711011803.lA1I3brS008751@sheep.berlios.de> <22314872.1193945206683.JavaMail.ngmail@webmail12> Message-ID: <20071101210734.3740.2@graete.1193937212.fake> On 2007-11-01 at 20:26:46 [+0100], Marcus Overhagen wrote: > > > Patch by Vasilis Kaoutsis: Implemented sigignore(). Small changes by > > myself. > > +++ haiku/trunk/src/system/libroot/posix/signal/sigignore.cpp > > 2007-11-01 > > + // check for invalid signals or for signals > > + // that can not be ignored (SIGKILL, SIGSTOP) > > + if (signal <= 0 || signal >= NSIG || signal == SIGKILL > > + || signal == SIGSTOP) { > > + errno = EINVAL; > > + return -1; > > + } > > + > > What happens if I call sigaction directly with SIGKILL or SIGSTOP? > Shouldn't these checks be made by the kernel? That's done anyway. Therefore the checks in sigignore() are actually redundant, but I find that OK. CU, Ingo From mmu_man at mail.berlios.de Thu Nov 1 22:21:44 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 1 Nov 2007 22:21:44 +0100 Subject: [Haiku-commits] r22794 - haiku/trunk/src/add-ons/media/media-add-ons/esound_sink Message-ID: <200711012121.lA1LLiFv025957@sheep.berlios.de> Author: mmu_man Date: 2007-11-01 22:21:44 +0100 (Thu, 01 Nov 2007) New Revision: 22794 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22794&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.cpp Log: We now have BTextParameter even if BMediaTheme doesn't know about it yet. Modified: haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.cpp 2007-11-01 19:36:34 UTC (rev 22793) +++ haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.cpp 2007-11-01 21:21:44 UTC (rev 22794) @@ -1291,7 +1291,7 @@ BParameterGroup *group = web->MakeGroup("Server"); BParameter *p; fWebHostId = fWebPortId = -1; -#ifdef B_BEOS_VERSION_DANO /* not yet in Haiku */ +#if defined(B_BEOS_VERSION_DANO) || defined(__HAIKU__) fWebHostId = id++; p = group->MakeTextParameter(fWebHostId, B_MEDIA_RAW_AUDIO, "Hostname", B_GENERIC, 128); fWebPortId = id++; From mmu_man at mail.berlios.de Thu Nov 1 22:22:54 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 1 Nov 2007 22:22:54 +0100 Subject: [Haiku-commits] r22795 - haiku/trunk/src/add-ons/media/media-add-ons/opensound Message-ID: <200711012122.lA1LMsDD026014@sheep.berlios.de> Author: mmu_man Date: 2007-11-01 22:22:53 +0100 (Thu, 01 Nov 2007) New Revision: 22795 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22795&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/opensound/makefile Log: fix building with make Modified: haiku/trunk/src/add-ons/media/media-add-ons/opensound/makefile =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/opensound/makefile 2007-11-01 21:21:44 UTC (rev 22794) +++ haiku/trunk/src/add-ons/media/media-add-ons/opensound/makefile 2007-11-01 21:22:53 UTC (rev 22795) @@ -73,7 +73,7 @@ # additional paths to look for system headers # thes use the form: #include
# source file directories are NOT auto-included here -SYSTEM_INCLUDE_PATHS := ../../include +SYSTEM_INCLUDE_PATHS := ../../include ../../../../../headers/private/media # additional paths to look for local headers # thes use the form: #include "header" From mmu_man at mail.berlios.de Thu Nov 1 22:40:33 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 1 Nov 2007 22:40:33 +0100 Subject: [Haiku-commits] r22796 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200711012140.lA1LeX2S027667@sheep.berlios.de> Author: mmu_man Date: 2007-11-01 22:40:32 +0100 (Thu, 01 Nov 2007) New Revision: 22796 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22796&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp Log: Fixed the in8/16/32 command. Added out8/16/32 commands. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2007-11-01 21:22:53 UTC (rev 22795) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2007-11-01 21:40:32 UTC (rev 22796) @@ -132,7 +132,7 @@ { int32 displayWidth; int32 itemSize; - int32 num = -1; + int32 num = 1; int address; int i = 1, j; @@ -141,6 +141,7 @@ num = atoi(argv[2]); case 2: address = strtoul(argv[1], NULL, 0); + break; default: kprintf("usage: %s
[num]\n", argv[0]); return 0; @@ -161,9 +162,6 @@ return 0; } - if (num <= 0) - num = displayWidth; - for (i = 0; i < num; i++) { if ((i % displayWidth) == 0) { int32 displayed = min_c(displayWidth, (num-i)) * itemSize; @@ -198,7 +196,55 @@ } +static int +write_io(int argc, char **argv) +{ + int32 itemSize; + uint32 value; + int address; + int i = 1; + if (argc < 3) { + kprintf("usage: %s
[value [...]]\n", argv[0]); + return 0; + } + + address = strtoul(argv[1], NULL, 0); + + if (strcmp(argv[0], "outb") == 0 || strcmp(argv[0], "out8") == 0) { + itemSize = 1; + } else if (strcmp(argv[0], "outs") == 0 || strcmp(argv[0], "out16") == 0) { + itemSize = 2; + } else if (strcmp(argv[0], "outw") == 0 || strcmp(argv[0], "out32") == 0) { + itemSize = 4; + } else { + kprintf("write_io called in an invalid way!\n"); + return 0; + } + + // skip cmd name and address + argv += 2; + argc -= 2; + + for (i = 0; i < argc; i++) { + value = strtoul(argv[i], NULL, 0); + switch (itemSize) { + case 1: + pci_write_io_8(address + i * itemSize, value); + break; + case 2: + pci_write_io_16(address + i * itemSize, value); + break; + case 4: + pci_write_io_32(address + i * itemSize, value); + break; + } + } + + return 0; +} + + // #pragma mark bus manager init/uninit status_t @@ -218,6 +264,13 @@ add_debugger_command("inb", &display_io, "dump io bytes (8-bit)"); add_debugger_command("in8", &display_io, "dump io bytes (8-bit)"); + add_debugger_command("outw", &write_io, "write io words (32-bit)"); + add_debugger_command("out32", &write_io, "write io words (32-bit)"); + add_debugger_command("outs", &write_io, "write io shorts (16-bit)"); + add_debugger_command("out16", &write_io, "write io shorts (16-bit)"); + add_debugger_command("outb", &write_io, "write io bytes (8-bit)"); + add_debugger_command("out8", &write_io, "write io bytes (8-bit)"); + if (pci_controller_init() != B_OK) { TRACE(("PCI: pci_controller_init failed\n")); return B_ERROR; @@ -233,12 +286,20 @@ void pci_uninit(void) { + remove_debugger_command("outw", &write_io); + remove_debugger_command("out32", &write_io); + remove_debugger_command("outs", &write_io); + remove_debugger_command("out16", &write_io); + remove_debugger_command("outb", &write_io); + remove_debugger_command("out8", &write_io); + remove_debugger_command("inw", &display_io); remove_debugger_command("in32", &display_io); remove_debugger_command("ins", &display_io); remove_debugger_command("in16", &display_io); remove_debugger_command("inb", &display_io); remove_debugger_command("in8", &display_io); + delete sPCI; } From mmu_man at mail.berlios.de Thu Nov 1 22:52:58 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 1 Nov 2007 22:52:58 +0100 Subject: [Haiku-commits] r22797 - haiku/trunk/src/bin Message-ID: <200711012152.lA1Lqw94029257@sheep.berlios.de> Author: mmu_man Date: 2007-11-01 22:52:58 +0100 (Thu, 01 Nov 2007) New Revision: 22797 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22797&view=rev Added: haiku/trunk/src/bin/listfont.cpp Log: Added a listfont command to dump fonts and their properties. Added: haiku/trunk/src/bin/listfont.cpp =================================================================== --- haiku/trunk/src/bin/listfont.cpp 2007-11-01 21:40:32 UTC (rev 22796) +++ haiku/trunk/src/bin/listfont.cpp 2007-11-01 21:52:58 UTC (rev 22797) @@ -0,0 +1,113 @@ +/* + * listfont + * (c) 2004, Fran?ois Revol. + */ + +#include +#include +#include +#include + +int32 th(void *) +{ + be_app->Lock(); + be_app->Run(); + return B_OK; +} + +int usage(int ret) +{ + printf("listfont [-s] [-l]\n"); + printf("lists currently installed font families.\n"); + printf("\t-s list styles for each family\n"); + printf("\t-l long listing with more info\n"); + printf("\t-u update font families\n"); + return ret; +} + +int main(int argc, char **argv) +{ + int32 family_count, f; + font_family family; + int32 style_count, s; + font_style style; + uint16 face; + uint32 flags; + int i; + bool display_styles = false; + bool display_long = false; + bool update_families = false; + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "-u")) + update_families = true; + else if (!strcmp(argv[i], "-s")) + display_styles = true; + else if (!strcmp(argv[i], "-l")) { + display_long = true; + display_styles = true; + } else + return usage(1); + } + BApplication app("application/x-vnd.mmu_man.listfont"); + resume_thread(spawn_thread(th, "be_app", B_NORMAL_PRIORITY, NULL)); + be_app->Unlock(); + if (update_families) { + bool changed = update_font_families(true); + printf("font families %schanged.\n", changed?"":"didn't "); + return 0; + } + family_count = count_font_families(); + for (f = 0; f < family_count; f++) { + if (get_font_family(f, &family) < B_OK) + continue; + if (!display_styles) { + printf("%s\n", family); + continue; + } + style_count = count_font_styles(family); + for (s = 0; s < style_count; s++) { + if (get_font_style(family, s, &style, &face, &flags) < B_OK) + continue; + if (!display_long) { + printf("%s/%s\n", family, style); + continue; + } + BString fname; + fname << family << "/" << style; + printf("%-30s", fname.String()); + BFont fnt; + fnt.SetFamilyAndStyle(family, style); + //fnt.PrintToStream(); + printf("\tface=%08x ", face); + font_height fh; + fnt.GetHeight(&fh); + printf("\theight={%f %f %f} ", fh.ascent, fh.descent, fh.leading); + printf("\t%s", (flags & B_IS_FIXED)?"fixed ":""); +#ifndef B_BEOS_VERSION_DANO + /* seems R5 is broken there :-( locks up on 'a> recv' */ + printf("\t%s", (flags & B_HAS_TUNED_FONT)?"hastuned ":""); +#else + if (flags & B_HAS_TUNED_FONT) { + int32 tunedcount = fnt.CountTuned(); + printf("%ld tuned: ", tunedcount); +//puts(""); +#if 1 + for (i = 0; i < tunedcount; i++) { + tuned_font_info tfi; + fnt.GetTunedInfo(i, &tfi); + printf("{%f, %f, %f, %08lx, %x} ", tfi.size, tfi.shear, tfi.rotation, tfi.flags, tfi.face); +//puts(""); + } +#endif + } +#endif + //printf("\tFlags=%08lx ", fnt.Flags()); + printf("\tspacing=%d ", fnt.Spacing()); + printf("\tencoding=%d ", fnt.Encoding()); + puts(""); + } + } + be_app->Lock(); + be_app->Quit(); + return 0; +} From mmu_man at mail.berlios.de Thu Nov 1 22:53:25 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 1 Nov 2007 22:53:25 +0100 Subject: [Haiku-commits] r22798 - haiku/trunk/src/bin Message-ID: <200711012153.lA1LrPD9029329@sheep.berlios.de> Author: mmu_man Date: 2007-11-01 22:53:25 +0100 (Thu, 01 Nov 2007) New Revision: 22798 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22798&view=rev Modified: haiku/trunk/src/bin/Jamfile Log: Add listfont Modified: haiku/trunk/src/bin/Jamfile =================================================================== --- haiku/trunk/src/bin/Jamfile 2007-11-01 21:52:58 UTC (rev 22797) +++ haiku/trunk/src/bin/Jamfile 2007-11-01 21:53:25 UTC (rev 22798) @@ -86,6 +86,7 @@ hey.cpp iroster.cpp listattr.cpp + listfont.cpp listres.cpp mimeset.cpp mkindex.cpp From axeld at pinc-software.de Thu Nov 1 22:59:21 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 01 Nov 2007 22:59:21 +0100 CET Subject: [Haiku-commits] r22797 - haiku/trunk/src/bin In-Reply-To: <200711012152.lA1Lqw94029257@sheep.berlios.de> Message-ID: <45538939636-BeMail@zon> mmu_man at BerliOS wrote: > +int32 th(void *) > +{ > + be_app->Lock(); > + be_app->Run(); > + return B_OK; > +} > + > +int usage(int ret) Besides that you've obviously forgotten about our coding style again, since when do one need to run a be_app to have a working app_server connection? Bye, Axel. From bonefish at mail.berlios.de Thu Nov 1 23:41:25 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 1 Nov 2007 23:41:25 +0100 Subject: [Haiku-commits] r22799 - in haiku/trunk: headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager src/system/kernel/fs Message-ID: <200711012241.lA1MfPSk004288@sheep.berlios.de> Author: bonefish Date: 2007-11-01 23:41:22 +0100 (Thu, 01 Nov 2007) New Revision: 22799 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22799&view=rev Removed: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJob.h haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJobFactory.h haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJobQueue.h haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobFactory.cpp haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobGenerator.cpp haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobGenerator.h haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobQueue.cpp haiku/trunk/src/system/kernel/disk_device_manager/ddm_operation_validation.cpp haiku/trunk/src/system/kernel/disk_device_manager/ddm_operation_validation.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/ Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h haiku/trunk/src/system/kernel/disk_device_manager/Jamfile haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp haiku/trunk/src/system/kernel/disk_device_manager/KFileSystem.cpp haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp haiku/trunk/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp haiku/trunk/src/system/kernel/disk_device_manager/disk_device_manager.cpp haiku/trunk/src/system/kernel/fs/vfs.cpp Log: * Moved partition scanning back to KDiskDeviceManager. ATM only synchronous scanning is supported. * Removed the disk device job support from the disk device manager. * K{Disk,File,Partitioning}System: - Remove querying and validation methods. - Commented out the modification methods until their fate is decided. * Removed obsolete _user_get_partitionable_spaces(). Deleted: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJob.h Deleted: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJobFactory.h Deleted: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJobQueue.h Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h 2007-11-01 21:53:25 UTC (rev 22798) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h 2007-11-01 22:41:22 UTC (rev 22799) @@ -16,9 +16,6 @@ namespace DiskDevice { class KDiskDevice; -class KDiskDeviceJob; -class KDiskDeviceJobFactory; -class KDiskDeviceJobQueue; class KDiskSystem; class KFileDiskDevice; class KPartition; @@ -66,10 +63,10 @@ // Both the device and the partition is also registered and must be // unregistered by the caller. - status_t ScanPartition(KPartition* partition, bool async); + status_t ScanPartition(KPartition* partition); - partition_id CreateFileDevice(const char *filePath, - bool *newlyCreated = NULL, bool async = true); + partition_id CreateFileDevice(const char* filePath, + bool* newlyCreated = NULL); status_t DeleteFileDevice(const char *filePath); status_t DeleteFileDevice(partition_id id); @@ -81,29 +78,6 @@ bool PartitionRemoved(KPartition *partition); // bool DeletePartition(KPartition *partition); // - // Jobs - - // manager must be locked - KDiskDeviceJob *FindJob(disk_job_id id); - int32 CountJobs(); - KDiskDeviceJob *NextJob(int32 *cookie); - - // manager must be locked - status_t AddJobQueue(KDiskDeviceJobQueue *jobQueue); - // the device must be write locked - status_t RemoveJobQueue(KDiskDeviceJobQueue *jobQueue); - status_t DeleteJobQueue(KDiskDeviceJobQueue *jobQueue); - // called when the execution is done - int32 CountJobQueues(); - KDiskDeviceJobQueue *NextJobQueue(int32 *cookie); - - KDiskDeviceJobFactory *JobFactory() const; - - // manager must *not* be locked - status_t UpdateBusyPartitions(KDiskDevice *device); - status_t UpdateJobStatus(KDiskDeviceJob *job, uint32 status, - bool updateBusyPartitions); - // Disk Systems // manager must be locked @@ -137,20 +111,14 @@ bool _AddDevice(KDiskDevice *device); bool _RemoveDevice(KDiskDevice *device); - bool _RemoveJobQueue(KDiskDeviceJobQueue *jobQueue); - - status_t _UpdateBusyPartitions(KDiskDevice *device); - status_t _UpdateJobStatus(KDiskDeviceJob *job, uint32 status, - bool updateBusyPartitions); - status_t _Scan(const char *path); status_t _ScanPartition(KPartition *partition, bool async); // the manager must be locked and the device write locked + status_t _ScanPartition(KPartition *partition); + // used by the other _ScanPartition() version only struct DeviceMap; struct DiskSystemMap; - struct JobMap; - struct JobQueueVector; struct PartitionMap; struct PartitionSet; @@ -159,9 +127,6 @@ PartitionMap *fPartitions; DiskSystemMap *fDiskSystems; PartitionSet *fObsoletePartitions; - JobMap *fJobs; - JobQueueVector *fJobQueues; - KDiskDeviceJobFactory *fJobFactory; static KDiskDeviceManager *sDefaultManager; }; Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h 2007-11-01 21:53:25 UTC (rev 22798) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h 2007-11-01 22:41:22 UTC (rev 22799) @@ -15,7 +15,7 @@ namespace BPrivate { namespace DiskDevice { -class KDiskDeviceJob; +//class KDiskDeviceJob; class KPartition; //! \brief Common ancestor for disk system add-on wrappers @@ -51,60 +51,10 @@ virtual void FreeCookie(KPartition *partition); virtual void FreeContentCookie(KPartition *partition); - // Querying - // Device must be read locked. - - virtual uint32 GetSupportedOperations(KPartition* partition, uint32 mask); - virtual uint32 GetSupportedChildOperations(KPartition* child, uint32 mask); - - // for convenience - bool SupportsOperations(KPartition* partition, uint32 operations) - { return (GetSupportedOperations(partition, operations) & operations) - == operations; } - bool SupportsChildOperations(KPartition* child, uint32 operations) - { return (GetSupportedChildOperations(child, operations) & operations) - == operations; } - - virtual bool SupportsInitializingChild(KPartition *child, - const char *diskSystem); - virtual bool IsSubSystemFor(KPartition *partition); - - virtual bool ValidateResize(KPartition *partition, off_t *size); - virtual bool ValidateResizeChild(KPartition *child, off_t *size); - virtual bool ValidateMove(KPartition *partition, off_t *start); - virtual bool ValidateMoveChild(KPartition *child, off_t *start); - virtual bool ValidateSetName(KPartition *partition, char *name); - virtual bool ValidateSetContentName(KPartition *partition, char *name); - virtual bool ValidateSetType(KPartition *partition, const char *type); - virtual bool ValidateSetParameters(KPartition *partition, - const char *parameters); - virtual bool ValidateSetContentParameters(KPartition *parameters, - const char *parameters); - virtual bool ValidateInitialize(KPartition *partition, char *name, - const char *parameters); - virtual bool ValidateCreateChild(KPartition *partition, off_t *start, - off_t *size, const char *type, - const char *parameters, int32 *index); - virtual int32 CountPartitionableSpaces(KPartition *partition); - virtual status_t GetPartitionableSpaces(KPartition *partition, - partitionable_space_data *buffer, - int32 count, - int32 *actualCount = NULL); - - virtual status_t GetNextSupportedType(KPartition *partition, int32 *cookie, - char *type); - virtual status_t GetTypeForContentType(const char *contentType, - char *type); - - // Shadow partition modification - // Device must be write locked. - - virtual status_t ShadowPartitionChanged(KPartition *partition, - KPartition *child, uint32 operation); - // Writing // Device should not be locked. +#if 0 virtual status_t Defragment(KPartition *partition, KDiskDeviceJob *job); virtual status_t Repair(KPartition *partition, bool checkOnly, KDiskDeviceJob *job); @@ -140,6 +90,7 @@ // since the device will not be locked, when they are called. The KPartition // is registered though, so that it is at least guaranteed that the object // won't go away. +#endif // 0 protected: virtual status_t LoadModule(); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h 2007-11-01 21:53:25 UTC (rev 22798) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h 2007-11-01 22:41:22 UTC (rev 22799) @@ -33,25 +33,9 @@ virtual void FreeIdentifyCookie(KPartition *partition, void *cookie); virtual void FreeContentCookie(KPartition *partition); - // Querying - - virtual uint32 GetSupportedOperations(KPartition* partition, uint32 mask); - - virtual bool ValidateResize(KPartition *partition, off_t *size); - virtual bool ValidateMove(KPartition *partition, off_t *start); - virtual bool ValidateSetContentName(KPartition *partition, char *name); - virtual bool ValidateSetContentParameters(KPartition *partition, - const char *parameters); - virtual bool ValidateInitialize(KPartition *partition, char *name, - const char *parameters); - - // Shadow partition modification - - virtual status_t ShadowPartitionChanged(KPartition *partition, - KPartition *child, uint32 operation); - // Writing +#if 0 virtual status_t Defragment(KPartition *partition, KDiskDeviceJob *job); virtual status_t Repair(KPartition *partition, bool checkOnly, KDiskDeviceJob *job); @@ -66,6 +50,7 @@ KDiskDeviceJob *job); virtual status_t Initialize(KPartition *partition, const char *name, const char *parameters, KDiskDeviceJob *job); +#endif // 0 protected: virtual status_t LoadModule(); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h 2007-11-01 21:53:25 UTC (rev 22798) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h 2007-11-01 22:41:22 UTC (rev 22799) @@ -35,49 +35,9 @@ virtual void FreeCookie(KPartition *partition); virtual void FreeContentCookie(KPartition *partition); - // Querying - - virtual uint32 GetSupportedOperations(KPartition* partition, uint32 mask); - virtual uint32 GetSupportedChildOperations(KPartition* child, uint32 mask); - - virtual bool SupportsInitializingChild(KPartition *child, - const char *diskSystem); - virtual bool IsSubSystemFor(KPartition *partition); - - virtual bool ValidateResize(KPartition *partition, off_t *size); - virtual bool ValidateResizeChild(KPartition *child, off_t *size); - virtual bool ValidateMove(KPartition *partition, off_t *start); - virtual bool ValidateMoveChild(KPartition *child, off_t *start); - virtual bool ValidateSetName(KPartition *partition, char *name); - virtual bool ValidateSetContentName(KPartition *partition, char *name); - virtual bool ValidateSetType(KPartition *partition, const char *type); - virtual bool ValidateSetParameters(KPartition *partition, - const char *parameters); - virtual bool ValidateSetContentParameters(KPartition *parameters, - const char *parameters); - virtual bool ValidateInitialize(KPartition *partition, char *name, - const char *parameters); - virtual bool ValidateCreateChild(KPartition *partition, off_t *start, - off_t *size, const char *type, - const char *parameters, int32 *index); - virtual int32 CountPartitionableSpaces(KPartition *partition); - virtual status_t GetPartitionableSpaces(KPartition *partition, - partitionable_space_data *buffer, - int32 count, - int32 *actualCount = NULL); - - virtual status_t GetNextSupportedType(KPartition *partition, int32 *cookie, - char *type); - virtual status_t GetTypeForContentType(const char *contentType, - char *type); - - // Shadow partition modification - - virtual status_t ShadowPartitionChanged(KPartition *partition, - KPartition *child, uint32 operation); - // Writing +#if 0 virtual status_t Repair(KPartition *partition, bool checkOnly, KDiskDeviceJob *job); virtual status_t Resize(KPartition *partition, off_t size, @@ -108,6 +68,7 @@ virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job); virtual status_t Initialize(KPartition *partition, const char *name, const char *parameters, KDiskDeviceJob *job); +#endif // 0 protected: virtual status_t LoadModule(); Modified: haiku/trunk/src/system/kernel/disk_device_manager/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/Jamfile 2007-11-01 21:53:25 UTC (rev 22798) +++ haiku/trunk/src/system/kernel/disk_device_manager/Jamfile 2007-11-01 22:41:22 UTC (rev 22799) @@ -13,14 +13,9 @@ UsePrivateHeaders storage ; KernelMergeObject kernel_disk_device_manager.o : - ddm_operation_validation.cpp ddm_userland_interface.cpp disk_device_manager.cpp KDiskDevice.cpp - KDiskDeviceJob.cpp - KDiskDeviceJobFactory.cpp - KDiskDeviceJobGenerator.cpp - KDiskDeviceJobQueue.cpp KDiskDeviceManager.cpp KFileDiskDevice.cpp KDiskSystem.cpp @@ -33,20 +28,6 @@ KShadowPartition.cpp UserDataWriter.cpp - # jobs - KCreateChildJob.cpp - KDefragmentJob.cpp - KDeleteChildJob.cpp - KInitializeJob.cpp - KMoveJob.cpp - KRepairJob.cpp - KResizeJob.cpp - KScanPartitionJob.cpp - KSetNameJob.cpp - KSetParametersJob.cpp - KSetTypeJob.cpp - KUninitializeJob.cpp - # utilities Locker.cpp RWLocker.cpp Deleted: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJob.cpp Deleted: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobFactory.cpp Deleted: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobGenerator.cpp Deleted: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobGenerator.h Deleted: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobQueue.cpp Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-01 21:53:25 UTC (rev 22798) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-01 22:41:22 UTC (rev 22799) @@ -7,9 +7,6 @@ #include "KDiskDevice.h" -#include "KDiskDeviceJob.h" -#include "KDiskDeviceJobFactory.h" -#include "KDiskDeviceJobQueue.h" #include "KDiskDeviceManager.h" #include "KDiskDeviceUtils.h" #include "KDiskSystem.h" @@ -66,13 +63,6 @@ } }; -// GetJobID -struct GetJobID { - inline disk_job_id operator()(const KDiskDeviceJob *job) const - { - return job->ID(); - } -}; // PartitionMap struct KDiskDeviceManager::PartitionMap : VectorMap { }; -// JobMap -struct KDiskDeviceManager::JobMap : VectorMap > { -}; -// JobQueueVector -struct KDiskDeviceManager::JobQueueVector : Vector {}; - - static bool is_active_job_status(uint32 status) { @@ -123,10 +104,7 @@ fDevices(new(nothrow) DeviceMap), fPartitions(new(nothrow) PartitionMap), fDiskSystems(new(nothrow) DiskSystemMap), - fObsoletePartitions(new(nothrow) PartitionSet), - fJobs(new(nothrow) JobMap), - fJobQueues(new(nothrow) JobQueueVector), - fJobFactory(new(nothrow) KDiskDeviceJobFactory) + fObsoletePartitions(new(nothrow) PartitionSet) { if (InitCheck() != B_OK) return; @@ -184,19 +162,15 @@ delete fDevices; delete fDiskSystems; delete fObsoletePartitions; - delete fJobs; - delete fJobQueues; - delete fJobFactory; } // InitCheck status_t KDiskDeviceManager::InitCheck() const { - if (!fPartitions || !fDevices || !fDiskSystems || !fObsoletePartitions - || !fJobs || !fJobQueues || !fJobFactory) { + if (!fPartitions || !fDevices || !fDiskSystems || !fObsoletePartitions) return B_NO_MEMORY; - } + return (fLock.Sem() >= 0 ? B_OK : fLock.Sem()); } @@ -496,15 +470,15 @@ // ScanPartition status_t -KDiskDeviceManager::ScanPartition(KPartition* partition, bool async) +KDiskDeviceManager::ScanPartition(KPartition* partition) { // TODO: This won't do. Locking the DDM while scanning the partition is not a -// good idea. Even locking the device doesn't feels right. Marking the partition +// good idea. Even locking the device doesn't feel right. Marking the partition // busy and passing the disk system a temporary clone of the partition_data // should work as well. if (DeviceWriteLocker deviceLocker = partition->Device()) { if (ManagerLocker locker = this) - return _ScanPartition(partition, async); + return _ScanPartition(partition, false); } return B_ERROR; @@ -513,8 +487,7 @@ // CreateFileDevice partition_id -KDiskDeviceManager::CreateFileDevice(const char *filePath, bool *newlyCreated, - bool async) +KDiskDeviceManager::CreateFileDevice(const char *filePath, bool* newlyCreated) { if (!filePath) return B_BAD_VALUE; @@ -532,6 +505,7 @@ if ((device = FindFileDevice(filePath))) { if (newlyCreated) *newlyCreated = false; + return device->ID(); } @@ -553,10 +527,11 @@ // scan device if (error == B_OK) { - _ScanPartition(device, async); + _ScanPartition(device, false); if (newlyCreated) *newlyCreated = true; + return device->ID(); } @@ -655,161 +630,7 @@ return false; } -// FindJob -KDiskDeviceJob * -KDiskDeviceManager::FindJob(disk_job_id id) -{ - JobMap::Iterator it = fJobs->Find(id); - if (it == fJobs->End()) - return NULL; - return it->Value(); -} -// CountJobs -int32 -KDiskDeviceManager::CountJobs() -{ - return fJobs->Count(); -} - -// NextJob -KDiskDeviceJob * -KDiskDeviceManager::NextJob(int32 *cookie) -{ - if (!cookie) - return NULL; - JobMap::Iterator it = fJobs->FindClose(*cookie, false); - if (it != fJobs->End()) { - KDiskDeviceJob *job = it->Value(); - *cookie = job->ID() + 1; - return job; - } - return NULL; -} - -// AddJobQueue -/*! - The device must be write locked, the manager must be locked. -*/ -status_t -KDiskDeviceManager::AddJobQueue(KDiskDeviceJobQueue *jobQueue) -{ - // check the parameter - if (!jobQueue) - return B_BAD_VALUE; - if (jobQueue->InitCheck() != B_OK) - return jobQueue->InitCheck(); - // add the queue - status_t error = fJobQueues->PushBack(jobQueue); - if (error != B_OK) - return error; - // add the queue's jobs - int32 count = jobQueue->CountJobs(); - for (int32 i = 0; i < count; i++) { - KDiskDeviceJob *job = jobQueue->JobAt(i); - error = fJobs->Put(job->ID(), job); - if (error != B_OK) { - _RemoveJobQueue(jobQueue); - return error; - } - } - // mark the jobs scheduled - for (int32 i = 0; KDiskDeviceJob *job = jobQueue->JobAt(i); i++) - _UpdateJobStatus(job, B_DISK_DEVICE_JOB_SCHEDULED, false); - _UpdateBusyPartitions(jobQueue->Device()); - // start the execution of the queue - error = jobQueue->Execute(); - if (error != B_OK) { - // resuming the execution failed -- mark all jobs failed and - // remove the queue - for (int32 i = 0; KDiskDeviceJob *job = jobQueue->JobAt(i); i++) - _UpdateJobStatus(job, B_DISK_DEVICE_JOB_FAILED, false); - _RemoveJobQueue(jobQueue); - _UpdateBusyPartitions(jobQueue->Device()); - } - return error; -} - -// RemoveJobQueue -status_t -KDiskDeviceManager::RemoveJobQueue(KDiskDeviceJobQueue *jobQueue) -{ - if (!jobQueue) - return B_BAD_VALUE; - if (jobQueue->InitCheck() != B_OK) - return jobQueue->InitCheck(); - if (jobQueue->IsExecuting()) - return B_BAD_VALUE; - return (_RemoveJobQueue(jobQueue) - ? (status_t)B_OK : (status_t)B_ENTRY_NOT_FOUND); -} - -// DeleteJobQueue -status_t -KDiskDeviceManager::DeleteJobQueue(KDiskDeviceJobQueue *jobQueue) -{ - status_t error = RemoveJobQueue(jobQueue); - if (error == B_OK) - delete jobQueue; - return error; -} - -// CountJobQueues -int32 -KDiskDeviceManager::CountJobQueues() -{ - return fJobQueues->Count(); -} - -// NextJobQueue -KDiskDeviceJobQueue * -KDiskDeviceManager::NextJobQueue(int32 *cookie) -{ - if (!cookie || *cookie < 0 || *cookie >= CountJobQueues()) - return NULL; - return fJobQueues->ElementAt((*cookie)++); -} - -// JobFactory -KDiskDeviceJobFactory * -KDiskDeviceManager::JobFactory() const -{ - return fJobFactory; -} - -// UpdateBusyPartitions -status_t -KDiskDeviceManager::UpdateBusyPartitions(KDiskDevice *device) -{ - if (!device) - return B_BAD_VALUE; - if (DeviceWriteLocker deviceLocker = device) { - if (ManagerLocker locker = this) - return _UpdateBusyPartitions(device); - } - return B_ERROR; -} - -// UpdateJobStatus -status_t -KDiskDeviceManager::UpdateJobStatus(KDiskDeviceJob *job, uint32 status, - bool updateBusyPartitions) -{ - // check parameters - if (!job) - return B_BAD_VALUE; - KDiskDeviceJobQueue *jobQueue = job->JobQueue(); - KDiskDevice *device = (jobQueue ? jobQueue->Device() : NULL); - if (!device) - return B_BAD_VALUE; - // lock device and manager - if (DeviceWriteLocker deviceLocker = device) { - if (ManagerLocker locker = this) - return _UpdateJobStatus(job, status, updateBusyPartitions); - } - return B_ERROR; -} - // FindDiskSystem KDiskSystem * KDiskDeviceManager::FindDiskSystem(const char *name) @@ -1038,26 +859,8 @@ && PartitionRemoved(device)); } -// _RemoveJobQueue -bool -KDiskDeviceManager::_RemoveJobQueue(KDiskDeviceJobQueue *jobQueue) -{ - if (!jobQueue) - return false; - // find the job queue - JobQueueVector::Iterator it = fJobQueues->Find(jobQueue); - if (it == fJobQueues->End()) - return false; - // remove the queue's jobs - int32 count = jobQueue->CountJobs(); - for (int32 i = 0; i < count; i++) { - KDiskDeviceJob *job = jobQueue->JobAt(i); - fJobs->Remove(job->ID()); - } - fJobQueues->Erase(it); - return true; -} +#if 0 // _UpdateBusyPartitions /*! The device must be write locked, the manager must be locked. @@ -1119,32 +922,8 @@ device->VisitEachDescendant(&visitor2); return B_OK; } +#endif -// _UpdateJobStatus -status_t -KDiskDeviceManager::_UpdateJobStatus(KDiskDeviceJob *job, uint32 status, - bool updateBusyPartitions) -{ - // check parameters - if (!job) - return B_BAD_VALUE; - KDiskDeviceJobQueue *jobQueue = job->JobQueue(); - KDiskDevice *device = (jobQueue ? jobQueue->Device() : NULL); - if (!device) - return B_BAD_VALUE; - if (job->Status() == status) - return B_OK; - // check migration of a schedule/in progress to a terminal state - // or vice versa - updateBusyPartitions &= (is_active_job_status(job->Status()) - != is_active_job_status(status)); - // set new state and update the partitions' busy flags - job->SetStatus(status); - if (updateBusyPartitions) - return _UpdateBusyPartitions(device); - // TODO: notifications - return B_OK; -} // _Scan status_t @@ -1210,45 +989,151 @@ status_t KDiskDeviceManager::_ScanPartition(KPartition *partition, bool async) { +// TODO: There's no reason why the manager needs to be locked anymore. if (!partition) return B_BAD_VALUE; +// TODO: Reimplement asynchronous scanning, if we really need it. +#if 0 if (async) { // create a new job queue for the device KDiskDeviceJobQueue *jobQueue = new(nothrow) KDiskDeviceJobQueue; if (!jobQueue) return B_NO_MEMORY; jobQueue->SetDevice(partition->Device()); + // create a job for scanning the device and add it to the job queue KDiskDeviceJob *job = fJobFactory->CreateScanPartitionJob(partition->ID()); if (!job) { delete jobQueue; return B_NO_MEMORY; } + if (!jobQueue->AddJob(job)) { delete jobQueue; delete job; return B_NO_MEMORY; } + // add the job queue status_t error = AddJobQueue(jobQueue); if (error != B_OK) delete jobQueue; + return error; } +#endif - KDiskDeviceJob *job = fJobFactory->CreateScanPartitionJob(partition->ID()); - if (job == NULL) - return B_NO_MEMORY; + // scan synchronously - status_t status = job->Do(); - UpdateBusyPartitions(partition->Device()); + if (!partition->Device()->HasMedia()) + return B_OK; - delete job; - return status; + status_t error = _ScanPartition(partition); + + // mark all partitions un-busy +// TODO: This is not quite correct here. Partitions are created marked "busy", +// hence the one creating it should be responsible for clearing the flag, not +// us. + struct UnmarkBusyVisitor : KPartitionVisitor { + virtual bool VisitPre(KPartition* partition) + { + partition->ClearFlags(B_PARTITION_BUSY + | B_PARTITION_DESCENDANT_BUSY); + return false; + } + } visitor; + + partition->VisitEachDescendant(&visitor); + + return error; } +status_t +KDiskDeviceManager::_ScanPartition(KPartition *partition) +{ + // the partition's device must be write-locked + if (!partition) + return B_BAD_VALUE; + if (partition->DiskSystem() != NULL) { + // TODO: this is more or less a hack to allow rescanning a partition + for (int32 i = 0; KPartition *child = partition->ChildAt(i); i++) + _ScanPartition(child); + return B_OK; + } + + DBG( + KPath partitionPath; + partition->GetPath(&partitionPath); + OUT("KDiskDeviceManager::_ScanPartition(%s)\n", partitionPath.Path()); + ) + + // publish the partition + status_t error = B_OK; + if (!partition->IsPublished()) { + error = partition->PublishDevice(); + if (error != B_OK) + return error; + } + + // find the disk system that returns the best priority for this partition + float bestPriority = -1; + KDiskSystem *bestDiskSystem = NULL; + void *bestCookie = NULL; + int32 itCookie = 0; + while (KDiskSystem *diskSystem = LoadNextDiskSystem(&itCookie)) { + DBG(OUT(" trying: %s\n", diskSystem->Name())); + + void *cookie = NULL; + float priority = diskSystem->Identify(partition, &cookie); + + DBG(OUT(" returned: %ld/1000\n", int32(1000 * priority))); + + if (priority >= 0 && priority > bestPriority) { + // new best disk system + if (bestDiskSystem) { + bestDiskSystem->FreeIdentifyCookie(partition, bestCookie); + bestDiskSystem->Unload(); + } + bestPriority = priority; + bestDiskSystem = diskSystem; + bestCookie = cookie; + } else { + // disk system doesn't identify the partition or worse than our + // current favorite + if (priority >= 0) + diskSystem->FreeIdentifyCookie(partition, cookie); + diskSystem->Unload(); + } + } + + // now, if we have found a disk system, let it scan the partition + if (bestDiskSystem) { + DBG(OUT(" scanning with: %s\n", bestDiskSystem->Name())); + error = bestDiskSystem->Scan(partition, bestCookie); + bestDiskSystem->FreeIdentifyCookie(partition, bestCookie); + if (error == B_OK) { + partition->SetDiskSystem(bestDiskSystem); + for (int32 i = 0; KPartition *child = partition->ChildAt(i); i++) + _ScanPartition(child); + } else { + // TODO: Handle the error. + DBG(OUT(" scanning failed: %s\n", strerror(error))); + } + + // now we can safely unload the disk system -- it has been loaded by + // the partition(s) and thus will not really be unloaded + bestDiskSystem->Unload(); + } else { + // contents not recognized + // nothing to be done -- partitions are created as unrecognized + } + + return error; +} + + void KDiskDeviceManager::_CheckMediaStatus() { Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp 2007-11-01 21:53:25 UTC (rev 22798) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp 2007-11-01 22:41:22 UTC (rev 22799) @@ -190,196 +190,8 @@ } -// GetSupportedOperations -uint32 -KDiskSystem::GetSupportedOperations(KPartition* partition, uint32 mask) -{ - // to be implemented by derived classes - return 0; -} +#if 0 - -// GetSupportedChildOperations -uint32 -KDiskSystem::GetSupportedChildOperations(KPartition* child, uint32 mask) -{ - // to be implemented by derived classes - return 0; -} - - -// SupportsInitializingChild -bool -KDiskSystem::SupportsInitializingChild(KPartition *child, - const char *diskSystem) -{ - // to be implemented by derived classes - return false; -} - - -// IsSubSystemFor -bool -KDiskSystem::IsSubSystemFor(KPartition *partition) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateResize -bool -KDiskSystem::ValidateResize(KPartition *partition, off_t *size) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateResizeChild -bool -KDiskSystem::ValidateResizeChild(KPartition *child, off_t *size) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateMove -bool -KDiskSystem::ValidateMove(KPartition *partition, off_t *start) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateMoveChild -bool -KDiskSystem::ValidateMoveChild(KPartition *child, off_t *start) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateSetName -bool -KDiskSystem::ValidateSetName(KPartition *partition, char *name) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateSetContentName -bool -KDiskSystem::ValidateSetContentName(KPartition *partition, char *name) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateSetType -bool -KDiskSystem::ValidateSetType(KPartition *partition, const char *type) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateSetParameters -bool -KDiskSystem::ValidateSetParameters(KPartition *partition, - const char *parameters) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateSetContentParameters -bool -KDiskSystem::ValidateSetContentParameters(KPartition *partition, - const char *parameters) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateInitialize -bool -KDiskSystem::ValidateInitialize(KPartition *partition, char *name, - const char *parameters) -{ - // to be implemented by derived classes - return false; -} - - -// ValidateCreateChild -bool -KDiskSystem::ValidateCreateChild(KPartition *partition, off_t *start, - off_t *size, const char *type, - const char *parameters, int32 *index) -{ - // to be implemented by derived classes - return false; -} - - [... truncated: 748 lines follow ...] From bonefish at mail.berlios.de Fri Nov 2 00:36:29 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 2 Nov 2007 00:36:29 +0100 Subject: [Haiku-commits] r22800 - in haiku/trunk: headers/os/drivers headers/private/kernel headers/private/kernel/disk_device_manager src/add-ons/kernel/partitioning_systems/intel src/kits/storage/disk_device src/system/kernel/disk_device_manager src/system/kernel/fs Message-ID: <200711012336.lA1NaTpi024328@sheep.berlios.de> Author: bonefish Date: 2007-11-02 00:36:21 +0100 (Fri, 02 Nov 2007) New Revision: 22800 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22800&view=rev Removed: haiku/trunk/headers/private/kernel/disk_device_manager/KPhysicalPartition.h haiku/trunk/headers/private/kernel/disk_device_manager/KShadowPartition.h haiku/trunk/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp haiku/trunk/src/system/kernel/disk_device_manager/KShadowPartition.cpp Modified: haiku/trunk/headers/os/drivers/disk_device_manager.h haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h haiku/trunk/headers/private/kernel/syscalls.h haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp haiku/trunk/src/kits/storage/disk_device/DiskDevice.cpp haiku/trunk/src/system/kernel/disk_device_manager/Jamfile haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp haiku/trunk/src/system/kernel/disk_device_manager/disk_device_manager.cpp haiku/trunk/src/system/kernel/fs/vfs.cpp Log: Folded KPhysicalPartition into KPartition. Removed the notion of shadow partitions from the disk device manager. Modified: haiku/trunk/headers/os/drivers/disk_device_manager.h =================================================================== --- haiku/trunk/headers/os/drivers/disk_device_manager.h 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/headers/os/drivers/disk_device_manager.h 2007-11-01 23:36:21 UTC (rev 22800) @@ -97,7 +97,6 @@ // disk device/partition read access // (read lock required) disk_device_data *get_disk_device(partition_id partitionID); -partition_data *get_physical_partition(partition_id partitionID); partition_data *get_partition(partition_id partitionID); partition_data *get_parent_partition(partition_id partitionID); partition_data *get_child_partition(partition_id partitionID, int32 index); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h 2007-11-01 23:36:21 UTC (rev 22800) @@ -7,15 +7,18 @@ #include -#include "KPhysicalPartition.h" +#include "KPartition.h" #include "RWLocker.h" + namespace BPrivate { namespace DiskDevice { + class UserDataWriter; -class KDiskDevice : public KPhysicalPartition { + +class KDiskDevice : public KPartition { public: KDiskDevice(partition_id id = -1); virtual ~KDiskDevice(); @@ -38,8 +41,6 @@ void WriteUnlock(); bool IsWriteLocked(); - virtual bool PrepareForRemoval(); - virtual void SetID(partition_id id); virtual status_t PublishDevice(); @@ -70,14 +71,9 @@ disk_device_data *DeviceData(); const disk_device_data *DeviceData() const; - status_t CreateShadowDevice(team_id team); - status_t DeleteShadowDevice(); - void SetShadowOwner(team_id team); - team_id ShadowOwner() const; - virtual void WriteUserData(UserDataWriter &writer, user_partition_data *data); - void WriteUserData(UserDataWriter &writer, bool shadow); + void WriteUserData(UserDataWriter &writer); virtual void Dump(bool deep = true, int32 level = 0); @@ -92,9 +88,9 @@ RWLocker fLocker; int fFD; status_t fMediaStatus; - team_id fShadowOwner; }; + } // namespace DiskDevice } // namespace BPrivate Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h 2007-11-01 23:36:21 UTC (rev 22800) @@ -43,15 +43,15 @@ // manager must be locked KDiskDevice *FindDevice(const char *path); KDiskDevice *FindDevice(partition_id id, bool deviceOnly = true); - KPartition *FindPartition(const char *path, bool noShadow = false); - KPartition *FindPartition(partition_id id, bool noShadow = false); + KPartition *FindPartition(const char *path); + KPartition *FindPartition(partition_id id); KFileDiskDevice *FindFileDevice(const char *filePath); KDiskDevice *RegisterDevice(const char *path); KDiskDevice *RegisterDevice(partition_id id, bool deviceOnly = true); KDiskDevice *RegisterNextDevice(int32 *cookie); - KPartition *RegisterPartition(const char *path, bool noShadow = false); - KPartition *RegisterPartition(partition_id id, bool noShadow = false); + KPartition *RegisterPartition(const char *path); + KPartition *RegisterPartition(partition_id id); KFileDiskDevice *RegisterFileDevice(const char *filePath); KDiskDevice *ReadLockDevice(partition_id id, bool deviceOnly = true); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-11-01 23:36:21 UTC (rev 22800) @@ -24,7 +24,6 @@ class KPartitionVisitor; class KPath; class KPhysicalPartition; -class KShadowPartition; //! \brief Class representing a single partition. class KPartition { @@ -139,7 +138,7 @@ status_t AddChild(KPartition *partition, int32 index = -1); virtual status_t CreateChild(partition_id id, int32 index, - KPartition **child = NULL) = 0; + KPartition **child = NULL); bool RemoveChild(int32 index); bool RemoveChild(KPartition *child); bool RemoveAllChildren(); @@ -149,14 +148,6 @@ KPartition *VisitEachDescendant(KPartitionVisitor *visitor); - // Shadow Partition - - virtual status_t CreateShadowPartition(); // creates a complete tree - virtual void UnsetShadowPartition(bool doDelete); - virtual KShadowPartition *ShadowPartition() const = 0; - virtual bool IsShadowPartition() const = 0; - virtual KPhysicalPartition *PhysicalPartition() const = 0; - // DiskSystem void SetDiskSystem(KDiskSystem *diskSystem); Deleted: haiku/trunk/headers/private/kernel/disk_device_manager/KPhysicalPartition.h Deleted: haiku/trunk/headers/private/kernel/disk_device_manager/KShadowPartition.h Modified: haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h 2007-11-01 23:36:21 UTC (rev 22800) @@ -17,7 +17,6 @@ typedef struct user_partition_data user_partition_data; struct user_partition_data { partition_id id; - partition_id shadow_id; off_t offset; off_t size; off_t content_size; @@ -70,8 +69,8 @@ partition_id _user_find_disk_device(const char *filename, size_t *neededSize); partition_id _user_find_partition(const char *filename, size_t *neededSize); status_t _user_get_disk_device_data(partition_id deviceID, bool deviceOnly, - bool shadow, user_disk_device_data *buffer, - size_t bufferSize, size_t *neededSize); + user_disk_device_data *buffer, size_t bufferSize, + size_t *neededSize); partition_id _user_register_file_device(const char *filename); status_t _user_unregister_file_device(partition_id deviceID, Modified: haiku/trunk/headers/private/kernel/syscalls.h =================================================================== --- haiku/trunk/headers/private/kernel/syscalls.h 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/headers/private/kernel/syscalls.h 2007-11-01 23:36:21 UTC (rev 22800) @@ -324,8 +324,8 @@ extern partition_id _kern_get_next_disk_device_id(int32 *cookie, size_t *neededSize); extern partition_id _kern_find_disk_device(const char *filename, size_t *neededSize); extern partition_id _kern_find_partition(const char *filename, size_t *neededSize); -extern status_t _kern_get_disk_device_data(partition_id deviceID, bool deviceOnly, - bool shadow, struct user_disk_device_data *buffer, +extern status_t _kern_get_disk_device_data(partition_id deviceID, + bool deviceOnly, struct user_disk_device_data *buffer, size_t bufferSize, size_t *neededSize); extern partition_id _kern_register_file_device(const char *filename); extern status_t _kern_unregister_file_device(partition_id deviceID, Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp 2007-11-01 23:36:21 UTC (rev 22800) @@ -740,7 +740,7 @@ case B_PARTITION_SHADOW: { // get the physical partition - partition_data* physicalPartition = get_physical_partition( + partition_data* physicalPartition = get_partition( partition->id); if (!physicalPartition) { dprintf("intel: pm_shadow_changed(B_PARTITION_SHADOW): no " @@ -774,7 +774,7 @@ case B_PARTITION_SHADOW_CHILD: { // get the physical child partition - partition_data* physical = get_physical_partition(child->id); + partition_data* physical = get_partition(child->id); if (!physical) { dprintf("intel: pm_shadow_changed(B_PARTITION_SHADOW_CHILD): " "no physical partition with ID %ld\n", child->id); Modified: haiku/trunk/src/kits/storage/disk_device/DiskDevice.cpp =================================================================== --- haiku/trunk/src/kits/storage/disk_device/DiskDevice.cpp 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/src/kits/storage/disk_device/DiskDevice.cpp 2007-11-01 23:36:21 UTC (rev 22800) @@ -366,7 +366,7 @@ status_t error = B_OK; do { - error = _kern_get_disk_device_data(id, deviceOnly, false, + error = _kern_get_disk_device_data(id, deviceOnly, (user_disk_device_data*)buffer, bufferSize, &neededSize); if (error == B_BUFFER_OVERFLOW) { // buffer to small re-allocate it Modified: haiku/trunk/src/system/kernel/disk_device_manager/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/Jamfile 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/src/system/kernel/disk_device_manager/Jamfile 2007-11-01 23:36:21 UTC (rev 22800) @@ -24,8 +24,6 @@ KPartitioningSystem.cpp KPartitionListener.cpp KPartitionVisitor.cpp - KPhysicalPartition.cpp - KShadowPartition.cpp UserDataWriter.cpp # utilities Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp 2007-11-01 23:36:21 UTC (rev 22800) @@ -11,7 +11,6 @@ #include "ddm_userland_interface.h" #include "KDiskDevice.h" #include "KDiskDeviceUtils.h" -#include "KShadowPartition.h" #include "KPath.h" #include "UserDataWriter.h" @@ -22,12 +21,11 @@ // constructor KDiskDevice::KDiskDevice(partition_id id) - : KPhysicalPartition(id), + : KPartition(id), fDeviceData(), fLocker("diskdevice"), fFD(-1), - fMediaStatus(B_ERROR), - fShadowOwner(-1) + fMediaStatus(B_ERROR) { Unset(); fDevice = this; @@ -98,7 +96,6 @@ fFD = -1; } fMediaStatus = B_ERROR; - fShadowOwner = -1; fDeviceData.id = -1; fDeviceData.flags = 0; if (fDeviceData.path) { @@ -164,20 +161,12 @@ return fLocker.IsWriteLocked(); } -// PrepareForRemoval -bool -KDiskDevice::PrepareForRemoval() -{ - if (ShadowOwner() >= 0) - DeleteShadowDevice(); - return KPhysicalPartition::PrepareForRemoval(); -} // SetID void KDiskDevice::SetID(partition_id id) { - KPhysicalPartition::SetID(id); + KPartition::SetID(id); fDeviceData.id = id; } @@ -312,58 +301,19 @@ return &fDeviceData; } -// CreateShadowDevice -status_t -KDiskDevice::CreateShadowDevice(team_id team) -{ - if (fShadowOwner >= 0 || team < 0 || !HasMedia()) - return B_BAD_VALUE; - // create the shadow partitions - status_t error = CreateShadowPartition(); - if (error == B_OK) - SetShadowOwner(team); - return error; -} -// DeleteShadowDevice -status_t -KDiskDevice::DeleteShadowDevice() -{ - if (fShadowOwner < 0) - return B_BAD_VALUE; - UnsetShadowPartition(true); - SetShadowOwner(-1); - return B_OK; -} - -// SetShadowOwner -void -KDiskDevice::SetShadowOwner(team_id team) -{ - fShadowOwner = team; -} - -// ShadowOwner -team_id -KDiskDevice::ShadowOwner() const -{ - return fShadowOwner; -} - // WriteUserData void KDiskDevice::WriteUserData(UserDataWriter &writer, user_partition_data *data) { - return KPhysicalPartition::WriteUserData(writer, data); + return KPartition::WriteUserData(writer, data); } // WriteUserData void -KDiskDevice::WriteUserData(UserDataWriter &writer, bool shadow) +KDiskDevice::WriteUserData(UserDataWriter &writer) { - KPartition *partition = shadow ? ShadowPartition() : static_cast(this); - if (!partition) - partition = this; + KPartition *partition = this; user_disk_device_data *data = writer.AllocateDeviceData(partition->CountChildren()); char *path = writer.PlaceString(Path()); @@ -384,7 +334,7 @@ OUT(" media status: %s\n", strerror(fMediaStatus)); OUT(" device flags: %lx\n", DeviceFlags()); if (fMediaStatus == B_OK) - KPhysicalPartition::Dump(deep, 0); + KPartition::Dump(deep, 0); } // GetMediaStatus Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-01 23:36:21 UTC (rev 22800) @@ -16,7 +16,6 @@ #include "KPartitioningSystem.h" #include "KPartitionVisitor.h" #include "KPath.h" -#include "KShadowPartition.h" #include #include @@ -252,36 +251,34 @@ // FindPartition KPartition * -KDiskDeviceManager::FindPartition(const char *path, bool noShadow) +KDiskDeviceManager::FindPartition(const char *path) { // TODO: Optimize! KPath partitionPath; if (partitionPath.InitCheck() != B_OK) return NULL; + for (PartitionMap::Iterator it = fPartitions->Begin(); it != fPartitions->End(); ++it) { KPartition *partition = it->Value(); if (partition->GetPath(&partitionPath) == B_OK && partitionPath == path) { - if (noShadow && partition->IsShadowPartition()) - return partition->PhysicalPartition(); return partition; } } + return NULL; } // FindPartition KPartition * -KDiskDeviceManager::FindPartition(partition_id id, bool noShadow) +KDiskDeviceManager::FindPartition(partition_id id) { PartitionMap::Iterator it = fPartitions->Find(id); - if (it != fPartitions->End()) { - if (noShadow && it->Value()->IsShadowPartition()) - return it->Value()->PhysicalPartition(); + if (it != fPartitions->End()) return it->Value(); - } + return NULL; } @@ -342,10 +339,10 @@ // RegisterPartition KPartition * -KDiskDeviceManager::RegisterPartition(const char *path, bool noShadow) +KDiskDeviceManager::RegisterPartition(const char *path) { if (ManagerLocker locker = this) { - if (KPartition *partition = FindPartition(path, noShadow)) { + if (KPartition *partition = FindPartition(path)) { partition->Register(); return partition; } @@ -355,10 +352,10 @@ // RegisterPartition KPartition * -KDiskDeviceManager::RegisterPartition(partition_id id, bool noShadow) +KDiskDeviceManager::RegisterPartition(partition_id id) { if (ManagerLocker locker = this) { - if (KPartition *partition = FindPartition(id, noShadow)) { + if (KPartition *partition = FindPartition(id)) { partition->Register(); return partition; } Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2007-11-01 23:36:21 UTC (rev 22800) @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -147,22 +148,75 @@ status_t KPartition::Open(int flags, int *fd) { - return B_BAD_VALUE; + if (!fd) + return B_BAD_VALUE; + + // get the path + KPath path; + status_t error = GetPath(&path); + if (error != B_OK) + return error; + + // open the device + *fd = open(path.Path(), flags); + if (*fd < 0) + return errno; + + return B_OK; } // PublishDevice status_t KPartition::PublishDevice() { - // we're just a stupid base class, what do we know? - return B_ERROR; + if (fPublished) + return B_OK; + + // get the path + KPath path; + status_t error = GetPath(&path); + if (error != B_OK) + return error; + + // prepare a partition_info + partition_info info; + info.offset = Offset(); + info.size = Size(); + info.logical_block_size = BlockSize(); + info.session = 0; + info.partition = ID(); + if (strlcpy(info.device, Device()->Path(), B_PATH_NAME_LENGTH) + >= B_PATH_NAME_LENGTH) { + return B_NAME_TOO_LONG; + } + + error = devfs_publish_partition(path.Path() + 5, &info); + // we need to remove the "/dev/" part from the path + if (error != B_OK) + return error; + + fPublished = true; + + return B_OK; } // UnpublishDevice status_t KPartition::UnpublishDevice() { - return B_ERROR; + if (!fPublished) + return B_OK; + + // get the path + KPath path; + status_t error = GetPath(&path); + if (error != B_OK) + return error; + + fPublished = false; + + return devfs_unpublish_partition(path.Path() + 5); + // we need to remove the "/dev/" part from the path } @@ -660,6 +714,35 @@ return B_ERROR; } + +// CreateChild +status_t +KPartition::CreateChild(partition_id id, int32 index, KPartition **_child) +{ + // check parameters + int32 count = fPartitionData.child_count; + if (index == -1) + index = count; + if (index < 0 || index > count) + return B_BAD_VALUE; + + // create and add partition + KPartition *child = new(nothrow) KPartition(id); + if (!child) + return B_NO_MEMORY; + + status_t error = AddChild(child, index); + + // cleanup / set result + if (error != B_OK) + delete child; + else if (_child) + *_child = child; + + return error; +} + + // RemoveChild bool KPartition::RemoveChild(int32 index) @@ -752,21 +835,7 @@ return NULL; } -// CreateShadowPartition -status_t -KPartition::CreateShadowPartition() -{ - // implemented by derived classes - return B_ERROR; -} -// UnsetShadowPartition -void -KPartition::UnsetShadowPartition(bool doDelete) -{ - // implemented by derived classes -} - // SetDiskSystem void KPartition::SetDiskSystem(KDiskSystem *diskSystem) @@ -991,7 +1060,6 @@ // fill in data if (data) { data->id = ID(); - data->shadow_id = -1; data->offset = Offset(); data->size = Size(); data->content_size = ContentSize(); Deleted: haiku/trunk/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp Deleted: haiku/trunk/src/system/kernel/disk_device_manager/KShadowPartition.cpp Modified: haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp 2007-11-01 23:36:21 UTC (rev 22800) @@ -12,7 +12,6 @@ #include #include #include -#include #include #include "UserDataWriter.h" @@ -105,7 +104,7 @@ if (DeviceReadLocker locker = device) { // get the needed size UserDataWriter writer; - device->WriteUserData(writer, false); + device->WriteUserData(writer); *neededSize = writer.AllocatedSize(); } else { id = B_ERROR; @@ -139,7 +138,7 @@ if (DeviceReadLocker locker = device) { // get the needed size UserDataWriter writer; - device->WriteUserData(writer, false); + device->WriteUserData(writer); *neededSize = writer.AllocatedSize(); } else return B_ERROR; @@ -176,7 +175,7 @@ if (DeviceReadLocker locker = device) { // get the needed size UserDataWriter writer; - device->WriteUserData(writer, false); + device->WriteUserData(writer); *neededSize = writer.AllocatedSize(); } else return B_ERROR; @@ -206,9 +205,6 @@ itself (if \a deviceOnly is true). \param deviceOnly Specifies whether only IDs of disk devices (\c true), or also IDs of partitions (\c false) are accepted for \a id. - \param shadow If \c true, the data of the shadow disk device is returned, - otherwise of the physical device. If there is no shadow device, - the parameter is ignored. \param buffer The buffer into which the disk device data shall be written. May be \c NULL. \param bufferSize The size of \a buffer. @@ -229,7 +225,7 @@ - another error code... */ status_t -_user_get_disk_device_data(partition_id id, bool deviceOnly, bool shadow, +_user_get_disk_device_data(partition_id id, bool deviceOnly, user_disk_device_data *buffer, size_t bufferSize, size_t *_neededSize) { if (!buffer && bufferSize > 0) @@ -241,7 +237,7 @@ if (DeviceReadLocker locker = device) { // do a dry run first to get the needed size UserDataWriter writer; - device->WriteUserData(writer, shadow); + device->WriteUserData(writer); size_t neededSize = writer.AllocatedSize(); if (_neededSize) { status_t error = copy_ref_var_to_user(neededSize, _neededSize); @@ -260,7 +256,7 @@ MemoryDeleter deleter(kernelBuffer); // write the device data into the buffer writer.SetTo(kernelBuffer, bufferSize); - device->WriteUserData(writer, shadow); + device->WriteUserData(writer); // sanity check if (writer.AllocatedSize() != neededSize) { ERROR(("Size of written disk device user data changed from " Modified: haiku/trunk/src/system/kernel/disk_device_manager/disk_device_manager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/disk_device_manager.cpp 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/src/system/kernel/disk_device_manager/disk_device_manager.cpp 2007-11-01 23:36:21 UTC (rev 22800) @@ -119,22 +119,12 @@ } -// get_physical_partition -partition_data* -get_physical_partition(partition_id partitionID) -{ - KDiskDeviceManager* manager = KDiskDeviceManager::Default(); - KPartition* partition = manager->FindPartition(partitionID, true); - return (partition ? partition->PartitionData() : NULL); -} - - // get_partition partition_data * get_partition(partition_id partitionID) { KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - KPartition *partition = manager->FindPartition(partitionID, false); + KPartition *partition = manager->FindPartition(partitionID); return (partition ? partition->PartitionData() : NULL); } Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-11-01 22:41:22 UTC (rev 22799) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-11-01 23:36:21 UTC (rev 22800) @@ -5343,7 +5343,7 @@ return status; // get a corresponding partition from the DDM - partition = ddm->RegisterPartition(normalizedDevice.Path(), true); + partition = ddm->RegisterPartition(normalizedDevice.Path()); if (!partition) { // Partition not found: This either means, the user supplied @@ -5352,7 +5352,7 @@ partition_id deviceID = ddm->CreateFileDevice(normalizedDevice.Path(), &newlyCreatedFileDevice); if (deviceID >= 0) { - partition = ddm->RegisterPartition(deviceID, true); + partition = ddm->RegisterPartition(deviceID); if (newlyCreatedFileDevice) fileDeviceDeleter.id = deviceID; } From revol at free.fr Fri Nov 2 01:24:26 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 02 Nov 2007 01:24:26 +0100 CET Subject: [Haiku-commits] r22797 - haiku/trunk/src/bin In-Reply-To: <45538939636-BeMail@zon> Message-ID: <279675050-BeMail@laptop> > mmu_man at BerliOS wrote: > > +int32 th(void *) > > +{ > > + be_app->Lock(); > > + be_app->Run(); > > + return B_OK; > > +} > > + > > +int usage(int ret) > > Besides that you've obviously forgotten about our coding style again, Ugh sorry I'm used to so many... besides it's old code. > since when do one need to run a be_app to have a working app_server > connection? If I did that it was likely required in R5. Fran?ois. From bonefish at mail.berlios.de Fri Nov 2 01:29:48 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 2 Nov 2007 01:29:48 +0100 Subject: [Haiku-commits] r22801 - in haiku/trunk: headers/os/storage headers/private/kernel/disk_device_manager src/kits/storage/disk_device src/system/kernel/disk_device_manager src/system/kernel/fs Message-ID: <200711020029.lA20TmpI029769@sheep.berlios.de> Author: bonefish Date: 2007-11-02 01:29:46 +0100 (Fri, 02 Nov 2007) New Revision: 22801 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22801&view=rev Modified: haiku/trunk/headers/os/storage/DiskDeviceDefs.h haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h haiku/trunk/src/kits/storage/disk_device/Partition.cpp haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp haiku/trunk/src/system/kernel/fs/vfs.cpp Log: * Got rid of the B_PARTITION_DESCENDANT_BUSY flag. * Added CheckAndMarkBusy() and UnmarkBusy() methods to KPartition. Modified: haiku/trunk/headers/os/storage/DiskDeviceDefs.h =================================================================== --- haiku/trunk/headers/os/storage/DiskDeviceDefs.h 2007-11-01 23:36:21 UTC (rev 22800) +++ haiku/trunk/headers/os/storage/DiskDeviceDefs.h 2007-11-02 00:29:46 UTC (rev 22801) @@ -21,7 +21,6 @@ B_PARTITION_READ_ONLY = 0x08, B_PARTITION_MOUNTED = 0x10, // needed? B_PARTITION_BUSY = 0x20, - B_PARTITION_DESCENDANT_BUSY = 0x40, }; // partition statuses Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-11-01 23:36:21 UTC (rev 22800) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-11-02 00:29:46 UTC (rev 22801) @@ -52,12 +52,8 @@ void SetBusy(bool busy); bool IsBusy() const; - // == jobs which may affect this partition are scheduled/in progress - void SetDescendantBusy(bool busy); - bool IsDescendantBusy() const; - // == jobs which may affect a descendant of this partition are - // scheduled/in progress; IsBusy() => IsDescendantBusy() - // In the userland API, both can probably be mapped to one flag. + bool CheckAndMarkBusy(bool includeDescendants); + void UnmarkBusy(bool includeDescendants); void SetOffset(off_t offset); off_t Offset() const; // 0 for devices Modified: haiku/trunk/src/kits/storage/disk_device/Partition.cpp =================================================================== --- haiku/trunk/src/kits/storage/disk_device/Partition.cpp 2007-11-01 23:36:21 UTC (rev 22800) +++ haiku/trunk/src/kits/storage/disk_device/Partition.cpp 2007-11-02 00:29:46 UTC (rev 22801) @@ -197,8 +197,7 @@ bool BPartition::IsBusy() const { - return _PartitionData()->flags - & (B_PARTITION_BUSY | B_PARTITION_DESCENDANT_BUSY); + return _PartitionData()->flags & B_PARTITION_BUSY; } Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-01 23:36:21 UTC (rev 22800) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-02 00:29:46 UTC (rev 22801) @@ -1032,17 +1032,8 @@ // TODO: This is not quite correct here. Partitions are created marked "busy", // hence the one creating it should be responsible for clearing the flag, not // us. - struct UnmarkBusyVisitor : KPartitionVisitor { - virtual bool VisitPre(KPartition* partition) - { - partition->ClearFlags(B_PARTITION_BUSY - | B_PARTITION_DESCENDANT_BUSY); - return false; - } - } visitor; + partition->UnmarkBusy(true); - partition->VisitEachDescendant(&visitor); - return error; } Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2007-11-01 23:36:21 UTC (rev 22800) +++ haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2007-11-02 00:29:46 UTC (rev 22801) @@ -58,7 +58,7 @@ fPartitionData.child_count = 0; fPartitionData.index = -1; fPartitionData.status = B_PARTITION_UNRECOGNIZED; - fPartitionData.flags = B_PARTITION_BUSY | B_PARTITION_DESCENDANT_BUSY; + fPartitionData.flags = B_PARTITION_BUSY; fPartitionData.volume = -1; fPartitionData.mount_cookie = NULL; fPartitionData.name = NULL; @@ -238,6 +238,7 @@ ClearFlags(B_PARTITION_BUSY); } + // IsBusy bool KPartition::IsBusy() const @@ -245,23 +246,63 @@ return (fPartitionData.flags & B_PARTITION_BUSY); } -// SetDescendantBusy -void -KPartition::SetDescendantBusy(bool busy) + +// CheckAndMarkBusy +bool +KPartition::CheckAndMarkBusy(bool includeDescendants) { - if (busy) - SetFlags(B_PARTITION_DESCENDANT_BUSY); - else - ClearFlags(B_PARTITION_DESCENDANT_BUSY); + if (includeDescendants) { + // check + struct IsBusyVisitor : KPartitionVisitor { + virtual bool VisitPre(KPartition* partition) + { + return partition->IsBusy(); + } + } checkVisitor; + + if (VisitEachDescendant(&checkVisitor)) + return false; + + // mark busy + struct MarkBusyVisitor : KPartitionVisitor { + virtual bool VisitPre(KPartition* partition) + { + partition->AddFlags(B_PARTITION_BUSY); + return false; + } + } markVisitor; + + VisitEachDescendant(&markVisitor); + } else { + if (IsBusy()) + return false; + + SetBusy(true); + } + + return true; } -// IsDescendantBusy -bool -KPartition::IsDescendantBusy() const + +// UnmarkBusy +void +KPartition::UnmarkBusy(bool includeDescendants) { - return (fPartitionData.flags & B_PARTITION_DESCENDANT_BUSY); + if (includeDescendants) { + struct UnmarkBusyVisitor : KPartitionVisitor { + virtual bool VisitPre(KPartition* partition) + { + partition->ClearFlags(B_PARTITION_BUSY); + return false; + } + } visitor; + + VisitEachDescendant(&visitor); + } else + SetBusy(false); } + // SetOffset void KPartition::SetOffset(off_t offset) Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-11-01 23:36:21 UTC (rev 22800) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-11-02 00:29:46 UTC (rev 22801) @@ -5387,7 +5387,7 @@ if (partition) { // make sure, that the partition is not busy - if (partition->IsBusy() || partition->IsDescendantBusy()) { + if (partition->IsBusy()) { TRACE(("fs_mount(): Partition is busy.\n")); return B_BUSY; } @@ -5601,7 +5601,7 @@ // make sure, that the partition is not busy if (partition) { - if (partition->IsBusy() || partition->IsDescendantBusy()) { + if (partition->IsBusy()) { TRACE(("fs_unmount(): Partition is busy.\n")); return B_BUSY; } From superstippi at gmx.de Fri Nov 2 10:22:05 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 02 Nov 2007 10:22:05 +0100 Subject: [Haiku-commits] r22797 - haiku/trunk/src/bin In-Reply-To: <279675050-BeMail@laptop> References: <279675050-BeMail@laptop> Message-ID: <20071102102205.730.1@stippis.WG> Hi, Fran?ois Revol wrote (2007-11-02, 01:24:26 [+0100]): > > since when do one need to run a be_app to have a working app_server > > connection? > > If I did that it was likely required in R5. I think you might not need to call Run() on it. It's enough if it's just created, also on R5 (should be). Best regards, -Stephan From revol at free.fr Fri Nov 2 10:31:06 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 02 Nov 2007 10:31:06 +0100 CET Subject: [Haiku-commits] r22797 - haiku/trunk/src/bin In-Reply-To: <20071102102205.730.1@stippis.WG> Message-ID: <345725270-BeMail@laptop> > Fran?ois Revol wrote (2007-11-02, 01:24:26 [+0100]): > > > since when do one need to run a be_app to have a working > > > app_server > > > connection? > > > > If I did that it was likely required in R5. > > I think you might not need to call Run() on it. It's enough if it's > just > created, also on R5 (should be). > Yes I know that. IIRC it was required for a specific thing, likely the rescanning of the fonts. I'll try again without it. Fran?ois. From superstippi at gmx.de Fri Nov 2 11:31:05 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 02 Nov 2007 11:31:05 +0100 Subject: [Haiku-commits] r22797 - haiku/trunk/src/bin In-Reply-To: <345725270-BeMail@laptop> References: <345725270-BeMail@laptop> Message-ID: <20071102113105.1309.2@stippis.WG> Fran?ois Revol wrote (2007-11-02, 10:31:06 [+0100]): > > Fran?ois Revol wrote (2007-11-02, 01:24:26 [+0100]): > > > > since when do one need to run a be_app to have a working app_server > > > > connection? > > > > > > If I did that it was likely required in R5. > > > > I think you might not need to call Run() on it. It's enough if it's > > just > > created, also on R5 (should be). > > > > Yes I know that. > IIRC it was required for a specific thing, likely the rescanning of the > fonts. > I'll try again without it. Oh don't bother. You tested it back then. I guess Axel and I just mentioned it assuming you thought a be_app always needs to be Run(). Best regards, -Stephan From stefano.ceccherini at gmail.com Fri Nov 2 15:22:27 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Fri, 2 Nov 2007 15:22:27 +0100 Subject: [Haiku-commits] r22787 - in haiku/trunk/src/kits/interface: . textview_support In-Reply-To: <20071101173718.50513.1@stippis.WG> References: <25395053474-BeMail@zon> <20071101173718.50513.1@stippis.WG> Message-ID: <894b9700711020722n3af7c53bnde8ae81744d1942f@mail.gmail.com> 2007/11/1, Stephan Assmus : > > Axel D?rfler wrote (2007-11-01, 17:23:38 [+0100]): > > stippi at BerliOS wrote: > > > * when copying to the clipboard, copy the bullets > > > > Isn't that a bit useless? Wouldn't it be better to beep instead, and just > > copy nothing? Or at least only an empty string? > > Yes, I could do that instead. > > > Also, I thought Stefano had already worked on the previous solution for > > that? > > Maybe he forgot to commit something? Stefano? I had done that for the B_COPY and B_CUT handlers in BTextView::MessageReceived(). With your patch, though, the Copy() and Cut() methods also will copy the bullets, while I thought they should return the correct text (local vs remote call, no?) BTW, thank you for fixing this :) From axeld at mail.berlios.de Fri Nov 2 16:00:46 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 2 Nov 2007 16:00:46 +0100 Subject: [Haiku-commits] r22802 - in haiku/trunk/src/libs/compat/freebsd_network: . compat/sys compat/vm Message-ID: <200711021500.lA2F0kTP021627@sheep.berlios.de> Author: axeld Date: 2007-11-02 16:00:45 +0100 (Fri, 02 Nov 2007) New Revision: 22802 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22802&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/malloc.h haiku/trunk/src/libs/compat/freebsd_network/compat/vm/vm.h Log: * Since vtophys() is no public API in FreeBSD, vtophys() is now a macro to pmap_kextract() not vice versa, just like it is done in FreeBSD itself. * Added missing contigmalloc() definition for kernel drivers. * Fixed the "*_devclass defined but not used" warning. * Fixed warnings. * Added/adjusted (to our style guide) the license headers for the files I touched. * Minor cleanup. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2007-11-02 00:29:46 UTC (rev 22801) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2007-11-02 15:00:45 UTC (rev 22802) @@ -1,20 +1,20 @@ /* * Copyright 2007, Hugo Santos. All Rights Reserved. * Distributed under the terms of the MIT License. - * - * Authors: - * Hugo Santos, hugosantos at gmail.com */ #ifndef _FBSD_COMPAT_SYS_HAIKU_MODULE_H_ #define _FBSD_COMPAT_SYS_HAIKU_MODULE_H_ -#include /* for device_hooks */ + +#include #include -#include /* mutex, recursive_lock for mtx */ -#include /* net_timer, for callout */ -#undef ASSERT /* private/kernel/debug.h sets it */ +#include +#include +#undef ASSERT + /* private/kernel/debug.h sets it */ + typedef struct device *device_t; typedef struct devclass *devclass_t; @@ -148,7 +148,7 @@ driver_t driver = { #name, methods, size } #define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \ - driver_t *DRIVER_MODULE_NAME(name, busname) = &(driver) + driver_t *DRIVER_MODULE_NAME(name, busname) = &(driver); \ + devclass_t *__class_ ## busname ## _ ## devclass = &(devclass) - -#endif +#endif /* _FBSD_COMPAT_SYS_HAIKU_MODULE_H_ */ Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/malloc.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/malloc.h 2007-11-02 00:29:46 UTC (rev 22801) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/malloc.h 2007-11-02 15:00:45 UTC (rev 22802) @@ -1,3 +1,7 @@ +/* + * Copyright 2007, Hugo Santos. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _FBSD_COMPAT_SYS_MALLOC_H_ #define _FBSD_COMPAT_SYS_MALLOC_H_ @@ -9,6 +13,7 @@ #define M_WAITOK 0x0002 #define M_ZERO 0x0100 +#define M_DEVBUF void *_kernel_malloc(size_t size, int flags); void _kernel_free(void *ptr); @@ -24,7 +29,7 @@ #define kernel_free( ptr, base) \ _kernel_free(ptr) -#define kernel_contigmalloc(size, base, flags, low, high, alignment, boundary) \ +#define kernel_contigmalloc(size, type, flags, low, high, alignment, boundary) \ _kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \ alignment, boundary) @@ -32,8 +37,11 @@ _kernel_contigfree(addr, size) #ifdef FBSD_DRIVER -#define malloc(size, tag, flags) kernel_malloc(size, tag, flags) -#define free(pointer, tag) kernel_free(pointer, tag) +# define malloc(size, tag, flags) kernel_malloc(size, tag, flags) +# define free(pointer, tag) kernel_free(pointer, tag) +# define contigmalloc(size, type, flags, low, high, alignment, boundary) \ + _kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \ + alignment, boundary) #endif -#endif +#endif /* _FBSD_COMPAT_SYS_MALLOC_H_ */ Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/vm/vm.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/vm/vm.h 2007-11-02 00:29:46 UTC (rev 22801) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/vm/vm.h 2007-11-02 15:00:45 UTC (rev 22802) @@ -1,3 +1,7 @@ +/* + * Copyright 2007, Hugo Santos. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _FBSD_COMPAT_VM_VM_H_ #define _FBSD_COMPAT_VM_VM_H_ @@ -15,8 +19,8 @@ #define pmap_extract(...) NULL -#define pmap_kextract(vaddr) vtophys(vaddr) +vm_paddr_t pmap_kextract(vm_offset_t virtualAddress); -unsigned long vtophys(vm_offset_t vaddr); +#define vtophys(vaddr) pmap_kextract(virtualAddress) -#endif +#endif /* _FBSD_COMPAT_VM_VM_H_ */ Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-02 00:29:46 UTC (rev 22801) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-02 15:00:45 UTC (rev 22802) @@ -1,11 +1,8 @@ /* - * Copyright 2007, Hugo Santos. All Rights Reserved. - * Distributed under the terms of the MIT License. + * Copyright 2007, Hugo Santos, hugosantos at gmail.com. All Rights Reserved. + * Copyright 2004, Marcus Overhagen. All Rights Reserved. * - * Authors: - * Hugo Santos, hugosantos at gmail.com - * - * Some of this code is based on previous work by Marcus Overhagen. + * Distributed under the terms of the MIT License. */ #include "device.h" @@ -21,25 +18,26 @@ #include #define DEBUG_PCI - #ifdef DEBUG_PCI -#define TRACE_PCI(dev, format, args...) device_printf(dev, format , ##args) +# define TRACE_PCI(dev, format, args...) device_printf(dev, format , ##args) #else -#define TRACE_PCI(dev, format, args...) do { } while (0) +# define TRACE_PCI(dev, format, args...) do { } while (0) #endif + spinlock __haiku_intr_spinlock; struct net_stack_module_info *gStack; pci_module_info *gPci; + uint32_t pci_read_config(device_t dev, int offset, int size) { uint32_t value = gPci->read_pci_config(NETDEV(dev)->pci_info.bus, NETDEV(dev)->pci_info.device, NETDEV(dev)->pci_info.function, offset, size); - TRACE_PCI(dev, "pci_read_config(%i, %i) = 0x%lx\n", offset, size, value); + TRACE_PCI(dev, "pci_read_config(%i, %i) = 0x%x\n", offset, size, value); return value; } @@ -47,7 +45,7 @@ void pci_write_config(device_t dev, int offset, uint32_t value, int size) { - TRACE_PCI(dev, "pci_write_config(%i, 0x%lx, %i)\n", offset, value, size); + TRACE_PCI(dev, "pci_write_config(%i, 0x%x, %i)\n", offset, value, size); gPci->write_pci_config(NETDEV(dev)->pci_info.bus, NETDEV(dev)->pci_info.device, NETDEV(dev)->pci_info.function, @@ -517,19 +515,17 @@ } -/* Marcus' vtophys */ -unsigned long -vtophys(vm_offset_t vaddr) +vm_paddr_t +pmap_kextract(vm_offset_t virtualAddress) { - physical_entry pe; - status_t status; - - status = get_memory_map((void *)vaddr, 1, &pe, 1); - if (status < 0) + physical_entry entry; + status_t status = get_memory_map((void *)virtualAddress, 1, &entry, 1); + if (status < B_OK) { panic("fbsd compat: get_memory_map failed for %p, error %08lx\n", - (void *)vaddr, status); + (void *)virtualAddress, status); + } - return (unsigned long)pe.address; + return (vm_paddr_t)entry.address; } From axeld at mail.berlios.de Fri Nov 2 16:05:12 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 2 Nov 2007 16:05:12 +0100 Subject: [Haiku-commits] r22803 - haiku/trunk/src/libs/compat/freebsd_network/compat/vm Message-ID: <200711021505.lA2F5Cc5021817@sheep.berlios.de> Author: axeld Date: 2007-11-02 16:05:12 +0100 (Fri, 02 Nov 2007) New Revision: 22803 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22803&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/vm/vm.h Log: Accidently messed up the vtophys() macro... Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/vm/vm.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/vm/vm.h 2007-11-02 15:00:45 UTC (rev 22802) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/vm/vm.h 2007-11-02 15:05:12 UTC (rev 22803) @@ -21,6 +21,6 @@ vm_paddr_t pmap_kextract(vm_offset_t virtualAddress); -#define vtophys(vaddr) pmap_kextract(virtualAddress) +#define vtophys(virtualAddress) pmap_kextract(virtualAddress) #endif /* _FBSD_COMPAT_VM_VM_H_ */ From axeld at mail.berlios.de Fri Nov 2 16:07:50 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 2 Nov 2007 16:07:50 +0100 Subject: [Haiku-commits] r22804 - haiku/trunk/src/libs/compat/freebsd_network/compat/sys Message-ID: <200711021507.lA2F7oIr022079@sheep.berlios.de> Author: axeld Date: 2007-11-02 16:07:50 +0100 (Fri, 02 Nov 2007) New Revision: 22804 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22804&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/malloc.h Log: Added contigfree() as well. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/malloc.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/malloc.h 2007-11-02 15:05:12 UTC (rev 22803) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/malloc.h 2007-11-02 15:07:50 UTC (rev 22804) @@ -26,7 +26,7 @@ #define kernel_malloc(size, base, flags) \ _kernel_malloc(size, flags) -#define kernel_free( ptr, base) \ +#define kernel_free(ptr, base) \ _kernel_free(ptr) #define kernel_contigmalloc(size, type, flags, low, high, alignment, boundary) \ @@ -42,6 +42,8 @@ # define contigmalloc(size, type, flags, low, high, alignment, boundary) \ _kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \ alignment, boundary) +# define contigfree(addr, size, base) \ + _kernel_contigfree(addr, size) #endif #endif /* _FBSD_COMPAT_SYS_MALLOC_H_ */ From superstippi at gmx.de Fri Nov 2 16:22:18 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 02 Nov 2007 16:22:18 +0100 Subject: [Haiku-commits] r22787 - in haiku/trunk/src/kits/interface: . textview_support In-Reply-To: <894b9700711020722n3af7c53bnde8ae81744d1942f@mail.gmail.com> References: <25395053474-BeMail@zon> <20071101173718.50513.1@stippis.WG> <894b9700711020722n3af7c53bnde8ae81744d1942f@mail.gmail.com> Message-ID: <20071102162218.8103.5@stippis.WG> Stefano Ceccherini wrote (2007-11-02, 15:22:27 [+0100]): > 2007/11/1, Stephan Assmus : > > Maybe he forgot to commit something? Stefano? > > I had done that for the B_COPY and B_CUT handlers in > BTextView::MessageReceived(). > With your patch, though, the Copy() and Cut() methods also will copy the > bullets, while I thought they should return the correct text (local vs > remote call, no?) Thanks for clearing this up. Hm. Why are there even two implementations? As for Copy/Cut()... why would an application call those methods (local), which exposes a password to the system clipboard? It just doesn't make sense to me, but at the time I did those changes, I wasn't even aware that there is another implementation in the message handling code. > BTW, thank you for fixing this :) You're welcome! The code path was easy enough to follow and I just had to use what was already there. Best regards, -Stephan From axeld at mail.berlios.de Fri Nov 2 16:47:50 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 2 Nov 2007 16:47:50 +0100 Subject: [Haiku-commits] r22805 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711021547.lA2FloZd025133@sheep.berlios.de> Author: axeld Date: 2007-11-02 16:47:47 +0100 (Fri, 02 Nov 2007) New Revision: 22805 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22805&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/bus.c Log: Turned off extensive debug output, minor cleanup. Modified: haiku/trunk/src/libs/compat/freebsd_network/bus.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-11-02 15:07:50 UTC (rev 22804) +++ haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-11-02 15:47:47 UTC (rev 22805) @@ -1,11 +1,8 @@ /* * Copyright 2007, Hugo Santos. All Rights Reserved. - * Distributed under the terms of the MIT License. + * Copyright 2004, Marcus Overhagen. All Rights Reserved. * - * Authors: - * Hugo Santos, hugosantos at gmail.com - * - * Some of this code is based on previous work by Marcus Overhagen. + * Distributed under the terms of the MIT License. */ #include "device.h" @@ -18,6 +15,13 @@ #include +//#define DEBUG_BUS_SPACE_RW +#ifdef DEBUG_BUS_SPACE_RW +# define TRACE_BUS_SPACE_RW(x) driver_printf x +#else +# define TRACE_BUS_SPACE_RW(x) +#endif + #define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1)) @@ -25,11 +29,9 @@ int type; bus_space_tag_t tag; bus_space_handle_t handle; - area_id mapped_area; }; - struct internal_intr { device_t dev; driver_intr_t handler; @@ -349,15 +351,6 @@ } -#define DEBUG_BUS_SPACE_RW - -#ifdef DEBUG_BUS_SPACE_RW -#define TRACE_BUS_SPACE_RW(x) driver_printf x -#else -#define TRACE_BUS_SPACE_RW(x) -#endif - - #define BUS_SPACE_READ(size, type, fun) \ type bus_space_read_##size(bus_space_tag_t tag, \ bus_space_handle_t handle, bus_size_t offset) \ From axeld at mail.berlios.de Fri Nov 2 19:09:12 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 2 Nov 2007 19:09:12 +0100 Subject: [Haiku-commits] r22806 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711021809.lA2I9CCg018385@sheep.berlios.de> Author: axeld Date: 2007-11-02 19:09:02 +0100 (Fri, 02 Nov 2007) New Revision: 22806 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22806&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c Log: The MII stuff did not work at all, this is at least an improvement for that; apparently, probing/attaching the MII bus should come later, though. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-02 15:47:47 UTC (rev 22805) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-02 18:09:02 UTC (rev 22806) @@ -17,7 +17,7 @@ #include -#define DEBUG_PCI +//#define DEBUG_PCI #ifdef DEBUG_PCI # define TRACE_PCI(dev, format, args...) device_printf(dev, format , ##args) #else @@ -111,14 +111,14 @@ int bit = 0; switch (space) { - case SYS_RES_IOPORT: - bit = PCI_command_io; - break; - case SYS_RES_MEMORY: - bit = PCI_command_memory; - break; - default: - return EINVAL; + case SYS_RES_IOPORT: + bit = PCI_command_io; + break; + case SYS_RES_MEMORY: + bit = PCI_command_memory; + break; + default: + return EINVAL; } pci_set_command_bit(dev, bit); @@ -352,6 +352,7 @@ if (child == NULL) return NULL; + snprintf(child->dev_name, sizeof(child->dev_name), "%s", name); child->parent = dev; list_add_item(&dev->children, child); @@ -370,10 +371,12 @@ _resolve_method(drivers[i], "device_probe"); if (probe) { int result = probe(dev); - if (result >= 0) { + // the ukphy driver (fallback for unknown PHYs) return -100 here + if (result >= -100) { if (selected == NULL || result > selcost) { selected = drivers[i]; selcost = result; + device_printf(dev, "Found MII: %s\n", selected->name); } } } @@ -392,16 +395,21 @@ if (child->driver == NULL) { if (dev->driver == &miibus_driver) { driver_t *driver = __haiku_select_miibus_driver(child); - if (driver) device_set_driver(child, driver); + else { + struct mii_attach_args *ma = device_get_ivars(child); + + device_printf(dev, "No PHY module found (%x/%x)!\n", ma->mii_id1, + ma->mii_id2); + } } - - if (dev->driver == NULL) - panic("can't attach unknown driver"); + } else if (child->driver == &miibus_driver) { + child->methods.probe(child); } - child->methods.attach(child); + if (child->driver != NULL) + child->methods.attach(child); } } From axeld at mail.berlios.de Fri Nov 2 19:24:06 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 2 Nov 2007 19:24:06 +0100 Subject: [Haiku-commits] r22807 - in haiku/trunk/src/libs/compat/freebsd_network: . compat/sys Message-ID: <200711021824.lA2IO6ha018538@sheep.berlios.de> Author: axeld Date: 2007-11-02 19:24:05 +0100 (Fri, 02 Nov 2007) New Revision: 22807 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22807&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h haiku/trunk/src/libs/compat/freebsd_network/device.c Log: Delayed scanning the MII bus until the first ifm_media has been set for the device. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2007-11-02 18:09:02 UTC (rev 22806) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2007-11-02 18:24:05 UTC (rev 22807) @@ -54,6 +54,7 @@ extern const char gDriverName[]; driver_t *__haiku_select_miibus_driver(device_t dev); driver_t *__haiku_probe_miibus(device_t dev, driver_t *drivers[], int count); +void __haiku_scan_miibus(device_t dev); /* we define the driver methods with HAIKU_FBSD_DRIVER_GLUE to * force the rest of the stuff to be linked back with the driver. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-02 18:09:02 UTC (rev 22806) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-02 18:24:05 UTC (rev 22807) @@ -31,6 +31,9 @@ pci_module_info *gPci; +// #pragma mark - PCI + + uint32_t pci_read_config(device_t dev, int offset, int size) { @@ -131,6 +134,9 @@ } +// #pragma mark - Device + + void driver_printf(const char *format, ...) { @@ -387,27 +393,44 @@ void -bus_generic_attach(device_t dev) +__haiku_scan_miibus(device_t dev) { + device_t miibus = NULL; device_t child = NULL; - while ((child = list_get_next_item(&dev->children, child)) != NULL) { + // find miibus + + while ((miibus = list_get_next_item(&dev->children, miibus)) != NULL) { + if (miibus->driver == &miibus_driver) + break; + } + + while ((child = list_get_next_item(&miibus->children, child)) != NULL) { if (child->driver == NULL) { - if (dev->driver == &miibus_driver) { - driver_t *driver = __haiku_select_miibus_driver(child); - if (driver) - device_set_driver(child, driver); - else { - struct mii_attach_args *ma = device_get_ivars(child); + driver_t *driver = __haiku_select_miibus_driver(child); + if (driver) { + device_set_driver(child, driver); + child->methods.attach(child); + } else { + struct mii_attach_args *ma = device_get_ivars(child); - device_printf(dev, "No PHY module found (%x/%x)!\n", ma->mii_id1, - ma->mii_id2); - } + device_printf(dev, "No PHY module found (%x/%x)!\n", ma->mii_id1, + ma->mii_id2); } - } else if (child->driver == &miibus_driver) { - child->methods.probe(child); } + } +} + +void +bus_generic_attach(device_t dev) +{ + device_t child = NULL; + + while ((child = list_get_next_item(&dev->children, child)) != NULL) { + if (child->driver == &miibus_driver) + child->methods.probe(child); + if (child->driver != NULL) child->methods.attach(child); } @@ -430,6 +453,9 @@ } +// #pragma mark - Misc, Malloc + + int printf(const char *format, ...) { Modified: haiku/trunk/src/libs/compat/freebsd_network/device.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-02 18:09:02 UTC (rev 22806) +++ haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-02 18:24:05 UTC (rev 22807) @@ -127,6 +127,8 @@ struct ifnet *ifp = dev->ifp; struct ifreq ifr; + __haiku_scan_miibus(DEVNET(dev)); + ifp->if_flags &= ~IFF_UP; ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); From korli at mail.berlios.de Fri Nov 2 20:18:01 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 2 Nov 2007 20:18:01 +0100 Subject: [Haiku-commits] r22808 - haiku/trunk/src/system/libroot/os/arch/x86 Message-ID: <200711021918.lA2JI1fv022018@sheep.berlios.de> Author: korli Date: 2007-11-02 20:18:01 +0100 (Fri, 02 Nov 2007) New Revision: 22808 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22808&view=rev Modified: haiku/trunk/src/system/libroot/os/arch/x86/syscalls.inc Log: SYSCALL20 is needed on x64-64 Modified: haiku/trunk/src/system/libroot/os/arch/x86/syscalls.inc =================================================================== --- haiku/trunk/src/system/libroot/os/arch/x86/syscalls.inc 2007-11-02 18:24:05 UTC (rev 22807) +++ haiku/trunk/src/system/libroot/os/arch/x86/syscalls.inc 2007-11-02 19:18:01 UTC (rev 22808) @@ -41,4 +41,8 @@ #define SYSCALL14(name, n) _SYSCALL(name, n) #define SYSCALL15(name, n) _SYSCALL(name, n) #define SYSCALL16(name, n) _SYSCALL(name, n) +#define SYSCALL17(name, n) _SYSCALL(name, n) +#define SYSCALL18(name, n) _SYSCALL(name, n) +#define SYSCALL19(name, n) _SYSCALL(name, n) +#define SYSCALL20(name, n) _SYSCALL(name, n) From hugosantos at mail.berlios.de Sat Nov 3 12:36:51 2007 From: hugosantos at mail.berlios.de (hugosantos at mail.berlios.de) Date: Sat, 3 Nov 2007 12:36:51 +0100 Subject: [Haiku-commits] r22809 - in haiku/trunk: . src/add-ons/kernel/network/stack Message-ID: <200711031136.lA3Bap98027586@sheep.berlios.de> Author: hugosantos Date: 2007-11-03 12:36:02 +0100 (Sat, 03 Nov 2007) New Revision: 22809 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22809&view=rev Modified: haiku/trunk/ haiku/trunk/src/add-ons/kernel/network/stack/routes.cpp Log: r10168 at haiku-devel: hugo | 2007-11-03 12:35:29 +0100 find_route() is not really IPv4 specific. Property changes on: haiku/trunk ___________________________________________________________________ Name: svk:merge + 6868e255-f64d-48ee-a222-11b7e48ea3cc:/local/haiku:10168 Modified: haiku/trunk/src/add-ons/kernel/network/stack/routes.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/routes.cpp 2007-11-02 19:18:01 UTC (rev 22808) +++ haiku/trunk/src/add-ons/kernel/network/stack/routes.cpp 2007-11-03 11:36:02 UTC (rev 22809) @@ -149,14 +149,10 @@ static net_route_private * -find_route(struct net_domain *_domain, const struct sockaddr *address) +find_route(net_domain *_domain, const sockaddr *address) { - struct net_domain_private *domain = (net_domain_private *)_domain; + net_domain_private *domain = (net_domain_private *)_domain; - // TODO: the following only works for IPv4 routes! - if (domain->family != AF_INET) - panic("you should have known better..."); - // find last matching route RouteList::Iterator iterator = domain->routes.GetIterator(); @@ -165,23 +161,21 @@ while (iterator.HasNext()) { net_route_private *route = iterator.Next(); - bool found; - if (route->mask != NULL) { + if (route->mask) { sockaddr maskedAddress; domain->address_module->mask_address(address, route->mask, &maskedAddress); - found = domain->address_module->equal_addresses(&maskedAddress, - route->destination); - } else { - found = domain->address_module->equal_addresses(address, - route->destination); - } + if (!domain->address_module->equal_addresses(&maskedAddress, + route->destination)) + continue; + } else if (!domain->address_module->equal_addresses(address, + route->destination)) + continue - if (found) { - TRACE((" found route: %s, flags %lx\n", - AddressString(domain, route->destination).Data(), route->flags)); - return route; - } + TRACE((" found route: %s, flags %lx\n", + AddressString(domain, route->destination).Data(), route->flags)); + + return route; } return NULL; From hugosantos at mail.berlios.de Sat Nov 3 12:56:14 2007 From: hugosantos at mail.berlios.de (hugosantos at mail.berlios.de) Date: Sat, 3 Nov 2007 12:56:14 +0100 Subject: [Haiku-commits] r22810 - haiku/trunk Message-ID: <200711031156.lA3BuEKH016737@sheep.berlios.de> Author: hugosantos Date: 2007-11-03 12:55:57 +0100 (Sat, 03 Nov 2007) New Revision: 22810 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22810&view=rev Modified: haiku/trunk/ Log: Hm, svk shouldn't populate the destination repo. with it's local merge data.. Property changes on: haiku/trunk ___________________________________________________________________ Name: svk:merge - 6868e255-f64d-48ee-a222-11b7e48ea3cc:/local/haiku:10168 From axeld at mail.berlios.de Sat Nov 3 13:07:28 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 3 Nov 2007 13:07:28 +0100 Subject: [Haiku-commits] r22811 - in haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine: . dev dev/mii pci Message-ID: <200711031207.lA3C7SoI027795@sheep.berlios.de> Author: axeld Date: 2007-11-03 13:07:26 +0100 (Sat, 03 Nov 2007) New Revision: 22811 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22811&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ciphy.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ciphyreg.h haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/miidevs.h haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ukphy.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ukphy_subr.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/pci/ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/pci/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/pci/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/pci/if_vr.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/pci/if_vrreg.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/Jamfile Log: Added VIA Rhine driver from FreeBSD 6.2 unchanged. It does not work yet, though, because of problems with the MII bus support in the compatibility layer. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/Jamfile 2007-11-03 11:55:57 UTC (rev 22810) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/Jamfile 2007-11-03 12:07:26 UTC (rev 22811) @@ -43,3 +43,5 @@ installed-symlink ; +SubInclude HAIKU_TOP src add-ons kernel drivers network via-rhine dev ; +SubInclude HAIKU_TOP src add-ons kernel drivers network via-rhine pci ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/Jamfile 2007-11-03 11:55:57 UTC (rev 22810) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/Jamfile 2007-11-03 12:07:26 UTC (rev 22811) @@ -0,0 +1,3 @@ +SubDir HAIKU_TOP src add-ons kernel drivers network via-rhine dev ; + +SubInclude HAIKU_TOP src add-ons kernel drivers network via-rhine dev mii ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/Jamfile 2007-11-03 11:55:57 UTC (rev 22810) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/Jamfile 2007-11-03 12:07:26 UTC (rev 22811) @@ -0,0 +1,16 @@ +SubDir HAIKU_TOP src add-ons kernel drivers network via-rhine dev mii ; + +UsePrivateHeaders kernel net ; + +UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ; +UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ; + +SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ; + +KernelStaticLibrary via_rhine_mii.a + : + ciphy.c + ukphy.c + ukphy_subr.c + ; + Added: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ciphy.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ciphy.c 2007-11-03 11:55:57 UTC (rev 22810) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ciphy.c 2007-11-03 12:07:26 UTC (rev 22811) @@ -0,0 +1,435 @@ +/*- + * Copyright (c) 2004 + * Bill Paul . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/mii/ciphy.c,v 1.2 2005/01/06 01:42:55 imp Exp $ + */ + +#include +__FBSDID("$FreeBSD: src/sys/dev/mii/ciphy.c,v 1.2 2005/01/06 01:42:55 imp Exp $"); + +/* + * Driver for the Cicada CS8201 10/100/1000 copper PHY. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include "miidevs.h" + +#include + +#include "miibus_if.h" + +#include +/* +#include +*/ +static int ciphy_probe(device_t); +static int ciphy_attach(device_t); + +static device_method_t ciphy_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, ciphy_probe), + DEVMETHOD(device_attach, ciphy_attach), + DEVMETHOD(device_detach, mii_phy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + { 0, 0 } +}; + +static devclass_t ciphy_devclass; + +static driver_t ciphy_driver = { + "ciphy", + ciphy_methods, + sizeof(struct mii_softc) +}; + +DRIVER_MODULE(ciphy, miibus, ciphy_driver, ciphy_devclass, 0, 0); + +static int ciphy_service(struct mii_softc *, struct mii_data *, int); +static void ciphy_status(struct mii_softc *); +static void ciphy_reset(struct mii_softc *); +static void ciphy_fixup(struct mii_softc *); + +static int +ciphy_probe(dev) + device_t dev; +{ + struct mii_attach_args *ma; + + ma = device_get_ivars(dev); + +device_printf(dev, "OUI: %x\n", MII_OUI(ma->mii_id1, ma->mii_id2)); +device_printf(dev, "MODEL: %x\n", MII_MODEL(ma->mii_id2)); + if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_CICADA && + MII_MODEL(ma->mii_id2) == MII_MODEL_CICADA_CS8201) { + device_set_desc(dev, MII_STR_CICADA_CS8201); + return(0); + } + + if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_CICADA && + MII_MODEL(ma->mii_id2) == MII_MODEL_CICADA_CS8201A) { + device_set_desc(dev, MII_STR_CICADA_CS8201A); + return(0); + } + + if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_CICADA && + MII_MODEL(ma->mii_id2) == MII_MODEL_CICADA_CS8201B) { + device_set_desc(dev, MII_STR_CICADA_CS8201B); + return(0); + } + + return(ENXIO); +} + +static int +ciphy_attach(dev) + device_t dev; +{ + struct mii_softc *sc; + struct mii_attach_args *ma; + struct mii_data *mii; + + sc = device_get_softc(dev); + ma = device_get_ivars(dev); + sc->mii_dev = device_get_parent(dev); + mii = device_get_softc(sc->mii_dev); + LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); + + sc->mii_inst = mii->mii_instance; + sc->mii_phy = ma->mii_phyno; + sc->mii_service = ciphy_service; + sc->mii_pdata = mii; + + sc->mii_flags |= MIIF_NOISOLATE; + mii->mii_instance++; + + ciphy_reset(sc); + + sc->mii_capabilities = + PHY_READ(sc, MII_BMSR) & ma->mii_capmask; + if (sc->mii_capabilities & BMSR_EXTSTAT) + sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); + device_printf(dev, " "); + mii_phy_add_media(sc); + printf("\n"); + + MIIBUS_MEDIAINIT(sc->mii_dev); + return(0); +} + +static int +ciphy_service(sc, mii, cmd) + struct mii_softc *sc; + struct mii_data *mii; + int cmd; +{ + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; + int reg, speed, gig; + + switch (cmd) { + case MII_POLLSTAT: + /* + * If we're not polling our PHY instance, just return. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) + return (0); + break; + + case MII_MEDIACHG: + /* + * If the media indicates a different PHY instance, + * isolate ourselves. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) { + reg = PHY_READ(sc, MII_BMCR); + PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); + return (0); + } + + /* + * If the interface is not up, don't do anything. + */ + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + break; + + ciphy_fixup(sc); /* XXX hardware bug work-around */ + + switch (IFM_SUBTYPE(ife->ifm_media)) { + case IFM_AUTO: +#ifdef foo + /* + * If we're already in auto mode, just return. + */ + if (PHY_READ(sc, CIPHY_MII_BMCR) & CIPHY_BMCR_AUTOEN) + return (0); +#endif + (void) mii_phy_auto(sc); + break; + case IFM_1000_T: + speed = CIPHY_S1000; + goto setit; + case IFM_100_TX: + speed = CIPHY_S100; + goto setit; + case IFM_10_T: + speed = CIPHY_S10; +setit: + if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { + speed |= CIPHY_BMCR_FDX; + gig = CIPHY_1000CTL_AFD; + } else { + gig = CIPHY_1000CTL_AHD; + } + + PHY_WRITE(sc, CIPHY_MII_1000CTL, 0); + PHY_WRITE(sc, CIPHY_MII_BMCR, speed); + PHY_WRITE(sc, CIPHY_MII_ANAR, CIPHY_SEL_TYPE); + + if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) + break; + + PHY_WRITE(sc, CIPHY_MII_1000CTL, gig); + PHY_WRITE(sc, CIPHY_MII_BMCR, + speed|CIPHY_BMCR_AUTOEN|CIPHY_BMCR_STARTNEG); + + /* + * When setting the link manually, one side must + * be the master and the other the slave. However + * ifmedia doesn't give us a good way to specify + * this, so we fake it by using one of the LINK + * flags. If LINK0 is set, we program the PHY to + * be a master, otherwise it's a slave. + */ + if ((mii->mii_ifp->if_flags & IFF_LINK0)) { + PHY_WRITE(sc, CIPHY_MII_1000CTL, + gig|CIPHY_1000CTL_MSE|CIPHY_1000CTL_MSC); + } else { + PHY_WRITE(sc, CIPHY_MII_1000CTL, + gig|CIPHY_1000CTL_MSE); + } + break; + case IFM_NONE: + PHY_WRITE(sc, MII_BMCR, BMCR_ISO|BMCR_PDOWN); + break; + case IFM_100_T4: + default: + return (EINVAL); + } + break; + + case MII_TICK: + /* + * If we're not currently selected, just return. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) + return (0); + + /* + * Is the interface even up? + */ + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + return (0); + + /* + * Only used for autonegotiation. + */ + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; + + /* + * Check to see if we have link. If we do, we don't + * need to restart the autonegotiation process. Read + * the BMSR twice in case it's latched. + */ + reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); + if (reg & BMSR_LINK) + break; + + /* + * Only retry autonegotiation every 5 seconds. + */ + if (++sc->mii_ticks <= 5/*10*/) + break; + + sc->mii_ticks = 0; + mii_phy_auto(sc); + return (0); + } + + /* Update the media status. */ + ciphy_status(sc); + + /* + * Callback if something changed. Note that we need to poke + * apply fixups for certain PHY revs. + */ + if (sc->mii_media_active != mii->mii_media_active || + sc->mii_media_status != mii->mii_media_status || + cmd == MII_MEDIACHG) { + ciphy_fixup(sc); + } + mii_phy_update(sc, cmd); + return (0); +} + +static void +ciphy_status(sc) + struct mii_softc *sc; +{ + struct mii_data *mii = sc->mii_pdata; + int bmsr, bmcr; + + mii->mii_media_status = IFM_AVALID; + mii->mii_media_active = IFM_ETHER; + + bmsr = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); + + if (bmsr & BMSR_LINK) + mii->mii_media_status |= IFM_ACTIVE; + + bmcr = PHY_READ(sc, CIPHY_MII_BMCR); + + if (bmcr & CIPHY_BMCR_LOOP) + mii->mii_media_active |= IFM_LOOP; + + if (bmcr & CIPHY_BMCR_AUTOEN) { + if ((bmsr & CIPHY_BMSR_ACOMP) == 0) { + /* Erg, still trying, I guess... */ + mii->mii_media_active |= IFM_NONE; + return; + } + } + + bmsr = PHY_READ(sc, CIPHY_MII_AUXCSR); + switch (bmsr & CIPHY_AUXCSR_SPEED) { + case CIPHY_SPEED10: + mii->mii_media_active |= IFM_10_T; + break; + case CIPHY_SPEED100: + mii->mii_media_active |= IFM_100_TX; + break; + case CIPHY_SPEED1000: + mii->mii_media_active |= IFM_1000_T; + break; + default: + device_printf(sc->mii_dev, "unknown PHY speed %x\n", + bmsr & CIPHY_AUXCSR_SPEED); + break; + } + + if (bmsr & CIPHY_AUXCSR_FDX) + mii->mii_media_active |= IFM_FDX; + + return; +} + +static void +ciphy_reset(struct mii_softc *sc) +{ + mii_phy_reset(sc); + DELAY(1000); + + return; +} + +#define PHY_SETBIT(x, y, z) \ + PHY_WRITE(x, y, (PHY_READ(x, y) | (z))) +#define PHY_CLRBIT(x, y, z) \ + PHY_WRITE(x, y, (PHY_READ(x, y) & ~(z))) + +static void +ciphy_fixup(struct mii_softc *sc) +{ + uint16_t model; + uint16_t status, speed; + + model = MII_MODEL(PHY_READ(sc, CIPHY_MII_PHYIDR2)); + status = PHY_READ(sc, CIPHY_MII_AUXCSR); + speed = status & CIPHY_AUXCSR_SPEED; + + switch (model) { + case MII_MODEL_CICADA_CS8201: + + /* Turn off "aux mode" (whatever that means) */ + PHY_SETBIT(sc, CIPHY_MII_AUXCSR, CIPHY_AUXCSR_MDPPS); + + /* + * Work around speed polling bug in VT3119/VT3216 + * when using MII in full duplex mode. + */ + if ((speed == CIPHY_SPEED10 || speed == CIPHY_SPEED100) && + (status & CIPHY_AUXCSR_FDX)) { + PHY_SETBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); + } else { + PHY_CLRBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); + } + + /* Enable link/activity LED blink. */ + PHY_SETBIT(sc, CIPHY_MII_LED, CIPHY_LED_LINKACTBLINK); + + break; + + case MII_MODEL_CICADA_CS8201A: + case MII_MODEL_CICADA_CS8201B: + + /* + * Work around speed polling bug in VT3119/VT3216 + * when using MII in full duplex mode. + */ + if ((speed == CIPHY_SPEED10 || speed == CIPHY_SPEED100) && + (status & CIPHY_AUXCSR_FDX)) { + PHY_SETBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); + } else { + PHY_CLRBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); + } + + break; + default: + device_printf(sc->mii_dev, "unknown CICADA PHY model %x\n", + model); + break; + } + + return; +} Added: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ciphyreg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ciphyreg.h 2007-11-03 11:55:57 UTC (rev 22810) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ciphyreg.h 2007-11-03 12:07:26 UTC (rev 22811) @@ -0,0 +1,351 @@ +/*- + * Copyright (c) 2004 + * Bill Paul . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/mii/ciphyreg.h,v 1.2 2005/01/06 01:42:55 imp Exp $ + */ + +#ifndef _DEV_MII_CIPHYREG_H_ +#define _DEV_MII_CIPHYREG_H_ + +/* + * Register definitions for the Cicada CS8201 10/100/1000 gigE copper + * PHY, embedded within the VIA Networks VT6122 controller. + */ + +/* Command register */ +#define CIPHY_MII_BMCR 0x00 +#define CIPHY_BMCR_RESET 0x8000 +#define CIPHY_BMCR_LOOP 0x4000 +#define CIPHY_BMCR_SPD0 0x2000 /* speed select, lower bit */ +#define CIPHY_BMCR_AUTOEN 0x1000 /* Autoneg enabled */ +#define CIPHY_BMCR_PDOWN 0x0800 /* Power down */ +#define CIPHY_BMCR_STARTNEG 0x0200 /* Restart autoneg */ +#define CIPHY_BMCR_FDX 0x0100 /* Duplex mode */ +#define CIPHY_BMCR_CTEST 0x0080 /* Collision test enable */ +#define CIPHY_BMCR_SPD1 0x0040 /* Speed select, upper bit */ + +#define CIPHY_S1000 CIPHY_BMCR_SPD1 /* 1000mbps */ +#define CIPHY_S100 CIPHY_BMCR_SPD0 /* 100mpbs */ +#define CIPHY_S10 0 /* 10mbps */ + +/* Status register */ +#define CIPHY_MII_BMSR 0x01 +#define CIPHY_BMSR_100T4 0x8000 /* 100 base T4 capable */ +#define CIPHY_BMSR_100TXFDX 0x4000 /* 100 base Tx full duplex capable */ +#define CIPHY_BMSR_100TXHDX 0x2000 /* 100 base Tx half duplex capable */ +#define CIPHY_BMSR_10TFDX 0x1000 /* 10 base T full duplex capable */ +#define CIPHY_BMSR_10THDX 0x0800 /* 10 base T half duplex capable */ +#define CIPHY_BMSR_100T2FDX 0x0400 /* 100 base T2 full duplex capable */ +#define CIPHY_BMSR_100T2HDX 0x0200 /* 100 base T2 half duplex capable */ +#define CIPHY_BMSR_EXTSTS 0x0100 /* Extended status present */ +#define CIPHY_BMSR_PRESUB 0x0040 /* Preamble surpression */ +#define CIPHY_BMSR_ACOMP 0x0020 /* Autoneg complete */ +#define CIPHY_BMSR_RFAULT 0x0010 /* Remote fault condition occured */ +#define CIPHY_BMSR_ANEG 0x0008 /* Autoneg capable */ +#define CIPHY_BMSR_LINK 0x0004 /* Link status */ +#define CIPHY_BMSR_JABBER 0x0002 /* Jabber detected */ +#define CIPHY_BMSR_EXT 0x0001 /* Extended capability */ + +/* PHY ID registers */ +#define CIPHY_MII_PHYIDR1 0x02 +#define CIPHY_MII_PHYIDR2 0x03 + +/* Autoneg advertisement */ +#define CIPHY_MII_ANAR 0x04 +#define CIPHY_ANAR_NP 0x8000 /* Next page */ +#define CIPHY_ANAR_RF 0x2000 /* Remote fault */ +#define CIPHY_ANAR_ASP 0x0800 /* Asymmetric Pause */ +#define CIPHY_ANAR_PC 0x0400 /* Pause capable */ +#define CIPHY_ANAR_T4 0x0200 /* local device supports 100bT4 */ +#define CIPHY_ANAR_TX_FD 0x0100 /* local device supports 100bTx FD */ +#define CIPHY_ANAR_TX 0x0080 /* local device supports 100bTx */ +#define CIPHY_ANAR_10_FD 0x0040 /* local device supports 10bT FD */ +#define CIPHY_ANAR_10 0x0020 /* local device supports 10bT */ +#define CIPHY_ANAR_SEL 0x001F /* selector field, 00001=Ethernet */ + +/* Autoneg link partner ability */ +#define CIPHY_MII_ANLPAR 0x05 +#define CIPHY_ANLPAR_NP 0x8000 /* Next page */ +#define CIPHY_ANLPAR_ACK 0x4000 /* link partner acknowledge */ +#define CIPHY_ANLPAR_RF 0x2000 /* Remote fault */ +#define CIPHY_ANLPAR_ASP 0x0800 /* Asymmetric Pause */ +#define CIPHY_ANLPAR_PC 0x0400 /* Pause capable */ +#define CIPHY_ANLPAR_T4 0x0200 /* link partner supports 100bT4 */ +#define CIPHY_ANLPAR_TX_FD 0x0100 /* link partner supports 100bTx FD */ +#define CIPHY_ANLPAR_TX 0x0080 /* link partner supports 100bTx */ +#define CIPHY_ANLPAR_10_FD 0x0040 /* link partner supports 10bT FD */ +#define CIPHY_ANLPAR_10 0x0020 /* link partner supports 10bT */ +#define CIPHY_ANLPAR_SEL 0x001F /* selector field, 00001=Ethernet */ + +#define CIPHY_SEL_TYPE 0x0001 /* ethernet */ + +/* Antoneg expansion register */ +#define CIPHY_MII_ANER 0x06 +#define CIPHY_ANER_PDF 0x0010 /* Parallel detection fault */ +#define CIPHY_ANER_LPNP 0x0008 /* Link partner can next page */ +#define CIPHY_ANER_NP 0x0004 /* Local PHY can next page */ +#define CIPHY_ANER_RX 0x0002 /* Next page received */ +#define CIPHY_ANER_LPAN 0x0001 /* Link partner autoneg capable */ + +/* Autoneg next page transmit regisyer */ +#define CIPHY_MII_NEXTP 0x07 +#define CIPHY_NEXTP_MOREP 0x8000 /* More pages to follow */ +#define CIPHY_NEXTP_MESS 0x2000 /* 1 = message page, 0 = unformatted */ +#define CIPHY_NEXTP_ACK2 0x1000 /* MAC acknowledge */ +#define CIPHY_NEXTP_TOGGLE 0x0800 /* Toggle */ +#define CIPHY_NEXTP_CODE 0x07FF /* Code bits */ + +/* Autoneg link partner next page receive register */ +#define CIPHY_MII_NEXTP_LP 0x08 +#define CIPHY_NEXTPLP_MOREP 0x8000 /* More pages to follow */ +#define CIPHY_NEXTPLP_MESS 0x2000 /* 1 = message page, 0 = unformatted */ +#define CIPHY_NEXTPLP_ACK2 0x1000 /* MAC acknowledge */ +#define CIPHY_NEXTPLP_TOGGLE 0x0800 /* Toggle */ +#define CIPHY_NEXTPLP_CODE 0x07FF /* Code bits */ + +/* 1000BT control register */ +#define CIPHY_MII_1000CTL 0x09 +#define CIPHY_1000CTL_TST 0xE000 /* test modes */ +#define CIPHY_1000CTL_MSE 0x1000 /* Master/Slave manual enable */ +#define CIPHY_1000CTL_MSC 0x0800 /* Master/Slave select */ +#define CIPHY_1000CTL_RD 0x0400 /* Repeater/DTE */ +#define CIPHY_1000CTL_AFD 0x0200 /* Advertise full duplex */ +#define CIPHY_1000CTL_AHD 0x0100 /* Advertise half duplex */ + +#define CIPHY_TEST_TX_JITTER 0x2000 +#define CIPHY_TEST_TX_JITTER_MASTER_MODE 0x4000 +#define CIPHY_TEST_TX_JITTER_SLAVE_MODE 0x6000 +#define CIPHY_TEST_TX_DISTORTION 0x8000 + +/* 1000BT status register */ +#define CIPHY_MII_1000STS 0x0A +#define CIPHY_1000STS_MSF 0x8000 /* Master/slave fault */ +#define CIPHY_1000STS_MSR 0x4000 /* Master/slave result */ +#define CIPHY_1000STS_LRS 0x2000 /* Local receiver status */ +#define CIPHY_1000STS_RRS 0x1000 /* Remote receiver status */ +#define CIPHY_1000STS_LPFD 0x0800 /* Link partner can FD */ +#define CIPHY_1000STS_LPHD 0x0400 /* Link partner can HD */ +#define CIPHY_1000STS_IEC 0x00FF /* Idle error count */ + +#define CIPHY_MII_EXTSTS 0x0F /* Extended status */ +#define CIPHY_EXTSTS_X_FD_CAP 0x8000 /* 1000base-X FD capable */ +#define CIPHY_EXTSTS_X_HD_CAP 0x4000 /* 1000base-X HD capable */ +#define CIPHY_EXTSTS_T_FD_CAP 0x2000 /* 1000base-T FD capable */ +#define CIPHY_EXTSTS_T_HD_CAP 0x1000 /* 1000base-T HD capable */ + +/* 1000BT status extension register #1 */ +#define CIPHY_MII_1000STS1 0x0F +#define CIPHY_1000STS1_1000XFDX 0x8000 /* 1000baseX FDX capable */ +#define CIPHY_1000STS1_1000XHDX 0x4000 /* 1000baseX HDX capable */ +#define CIPHY_1000STS1_1000TFDX 0x2000 /* 1000baseT FDX capable */ +#define CIPHY_1000STS1_1000THDX 0x1000 /* 1000baseT HDX capable */ + +/* Vendor-specific PHY registers */ + +/* 100baseTX status extention register */ +#define CIPHY_MII_100STS 0x10 +#define CIPHY_100STS_DESLCK 0x8000 /* descrambler locked */ +#define CIPHY_100STS_LKCERR 0x4000 /* lock error detected/lock lost */ +#define CIPHY_100STS_DISC 0x2000 /* disconnect state */ +#define CIPHY_100STS_LINK 0x1000 /* current link state */ +#define CIPHY_100STS_RXERR 0x0800 /* receive error detected */ +#define CIPHY_100STS_TXERR 0x0400 /* transmit error detected */ +#define CIPHY_100STS_SSDERR 0x0200 /* false carrier error detected */ +#define CIPHY_100STS_ESDERR 0x0100 /* premature end of stream error */ + +/* 1000BT status extention register #2 */ +#define CIPHY_MII_1000STS2 0x11 +#define CIPHY_1000STS2_DESLCK 0x8000 /* descrambler locked */ +#define CIPHY_1000STS2_LKCERR 0x4000 /* lock error detected/lock lost */ +#define CIPHY_1000STS2_DISC 0x2000 /* disconnect state */ +#define CIPHY_1000STS2_LINK 0x1000 /* current link state */ +#define CIPHY_1000STS2_RXERR 0x0800 /* receive error detected */ +#define CIPHY_1000STS2_TXERR 0x0400 /* transmit error detected */ +#define CIPHY_1000STS2_SSDERR 0x0200 /* false carrier error detected */ +#define CIPHY_1000STS2_ESDERR 0x0100 /* premature end of stream error */ +#define CIPHY_1000STS2_CARREXT 0x0080 /* carrier extention err detected */ +#define CIPHY_1000STS2_BCM5400 0x0040 /* non-complient BCM5400 detected */ + +/* Bypass control register */ +#define CIPHY_MII_BYPASS 0x12 +#define CIPHY_BYPASS_TX 0x8000 /* transmit disable */ +#define CIPHY_BYPASS_4B5B 0x4000 /* bypass the 4B5B encoder */ +#define CIPHY_BYPASS_SCRAM 0x2000 /* bypass scrambler */ +#define CIPHY_BYPASS_DSCAM 0x1000 /* bypass descrambler */ +#define CIPHY_BYPASS_PCSRX 0x0800 /* bypass PCS receive */ +#define CIPHY_BYPASS_PCSTX 0x0400 /* bypass PCS transmit */ +#define CIPHY_BYPASS_LFI 0x0200 /* bypass LFI timer */ +#define CIPHY_BYPASS_TXCLK 0x0100 /* enable transmit clock on LED4 pin */ +#define CIPHY_BYPASS_BCM5400_F 0x0080 /* force BCM5400 detect */ +#define CIPHY_BYPASS_BCM5400 0x0040 /* bypass BCM5400 detect */ +#define CIPHY_BYPASS_PAIRSWAP 0x0020 /* disable automatic pair swap */ +#define CIPHY_BYPASS_POLARITY 0x0010 /* disable polarity correction */ +#define CIPHY_BYPASS_PARALLEL 0x0008 /* parallel detect enable */ +#define CIPHY_BYPASS_PULSE 0x0004 /* disable pulse shaping filter */ +#define CIPHY_BYPASS_1000BNP 0x0002 /* disable 1000BT next page exchange */ + +/* RX error count register */ +#define CIPHY_MII_RXERR 0x13 + +/* False carrier sense count register */ +#define CIPHY_MII_FCSERR 0x14 + +/* Ddisconnect error counter */ +#define CIPHY_MII_DISCERR 0x15 + +/* 10baseT control/status register */ +#define CIPHY_MII_10BTCSR 0x16 +#define CIPHY_10BTCSR_DLIT 0x8000 /* Disable data link integrity test */ +#define CIPHY_10BTCSR_JABBER 0x4000 /* Disable jabber detect */ +#define CIPHY_10BTCSR_ECHO 0x2000 /* Disable echo mode */ +#define CIPHY_10BTCSR_SQE 0x1000 /* Disable signal quality error */ +#define CIPHY_10BTCSR_SQUENCH 0x0C00 /* Squelch control */ +#define CIPHY_10BTCSR_EOFERR 0x0100 /* End of Frame error */ +#define CIPHY_10BTCSR_DISC 0x0080 /* Disconnect status */ +#define CIPHY_10BTCSR_LINK 0x0040 /* current link state */ +#define CIPHY_10BTCSR_ITRIM 0x0038 /* current reference trim */ +#define CIPHY_10BTCSR_CSR 0x0006 /* CSR behavior control */ + +#define CIPHY_SQUELCH_300MV 0x0000 +#define CIPHY_SQUELCH_197MV 0x0400 +#define CIPHY_SQUELCH_450MV 0x0800 +#define CIPHY_SQUELCH_RSVD 0x0C00 + +#define CIPHY_ITRIM_PLUS2 0x0000 +#define CIPHY_ITRIM_PLUS4 0x0008 +#define CIPHY_ITRIM_PLUS6 0x0010 +#define CIPHY_ITRIM_PLUS6_ 0x0018 +#define CIPHY_ITRIM_MINUS4 0x0020 +#define CIPHY_ITRIM_MINUS4_ 0x0028 +#define CIPHY_ITRIM_MINUS2 0x0030 +#define CIPHY_ITRIM_ZERO 0x0038 + +/* Extended PHY control register #1 */ +#define CIPHY_MII_ECTL1 0x17 +#define CIPHY_ECTL1_ACTIPHY 0x0020 /* Enable ActiPHY power saving */ + +/* Extended PHY control register #2 */ +#define CIPHY_MII_ECTL2 0x18 +#define CIPHY_ECTL2_ERATE 0xE000 /* 10/1000 edge rate control */ +#define CIPHY_ECTL2_VTRIM 0x1C00 /* voltage reference trim */ +#define CIPHY_ECTL2_CABLELEN 0x000E /* Cable quality/length */ +#define CIPHY_ECTL2_ANALOGLOOP 0x0001 /* 1000BT analog loopback */ + +#define CIPHY_CABLELEN_0TO10M 0x0000 +#define CIPHY_CABLELEN_10TO20M 0x0002 +#define CIPHY_CABLELEN_20TO40M 0x0004 +#define CIPHY_CABLELEN_40TO80M 0x0006 +#define CIPHY_CABLELEN_80TO100M 0x0008 +#define CIPHY_CABLELEN_100TO140M 0x000A +#define CIPHY_CABLELEN_140TO180M 0x000C +#define CIPHY_CABLELEN_OVER180M 0x000E + +/* Interrupt mask register */ +#define CIPHY_MII_IMR 0x19 +#define CIPHY_IMR_PINENABLE 0x8000 /* Interrupt pin enable */ +#define CIPHY_IMR_SPEED 0x4000 /* speed changed event */ +#define CIPHY_IMR_LINK 0x2000 /* link change/ActiPHY event */ +#define CIPHY_IMR_DPX 0x1000 /* duplex change event */ +#define CIPHY_IMR_ANEGERR 0x0800 /* autoneg error event */ +#define CIPHY_IMR_ANEGDONE 0x0400 /* autoneg done event */ +#define CIPHY_IMR_NPRX 0x0200 /* page received event */ +#define CIPHY_IMR_SYMERR 0x0100 /* symbol error event */ +#define CIPHY_IMR_LOCKERR 0x0080 /* descrambler lock lost event */ +#define CIPHY_IMR_XOVER 0x0040 /* MDI crossover change event */ +#define CIPHY_IMR_POLARITY 0x0020 /* polarity change event */ +#define CIPHY_IMR_JABBER 0x0010 /* jabber detect event */ +#define CIPHY_IMR_SSDERR 0x0008 /* false carrier detect event */ +#define CIPHY_IMR_ESDERR 0x0004 /* parallel detect error event */ +#define CIPHY_IMR_MASTERSLAVE 0x0002 /* master/slave resolve done event */ +#define CIPHY_IMR_RXERR 0x0001 /* RX error event */ + +/* Interrupt status register */ +#define CIPHY_MII_ISR 0x1A +#define CIPHY_ISR_IPENDING 0x8000 /* Interrupt is pending */ +#define CIPHY_ISR_SPEED 0x4000 /* speed changed event */ +#define CIPHY_ISR_LINK 0x2000 /* link change/ActiPHY event */ +#define CIPHY_ISR_DPX 0x1000 /* duplex change event */ +#define CIPHY_ISR_ANEGERR 0x0800 /* autoneg error event */ +#define CIPHY_ISR_ANEGDONE 0x0400 /* autoneg done event */ +#define CIPHY_ISR_NPRX 0x0200 /* page received event */ +#define CIPHY_ISR_SYMERR 0x0100 /* symbol error event */ +#define CIPHY_ISR_LOCKERR 0x0080 /* descrambler lock lost event */ +#define CIPHY_ISR_XOVER 0x0040 /* MDI crossover change event */ +#define CIPHY_ISR_POLARITY 0x0020 /* polarity change event */ +#define CIPHY_ISR_JABBER 0x0010 /* jabber detect event */ +#define CIPHY_ISR_SSDERR 0x0008 /* false carrier detect event */ +#define CIPHY_ISR_ESDERR 0x0004 /* parallel detect error event */ +#define CIPHY_ISR_MASTERSLAVE 0x0002 /* master/slave resolve done event */ +#define CIPHY_ISR_RXERR 0x0001 /* RX error event */ + +/* LED control register */ +#define CIPHY_MII_LED 0x1B +#define CIPHY_LED_LINK10FORCE 0x8000 /* Force on link10 LED */ +#define CIPHY_LED_LINK10DIS 0x4000 /* Disable link10 LED */ +#define CIPHY_LED_LINK100FORCE 0x2000 /* Force on link10 LED */ +#define CIPHY_LED_LINK100DIS 0x1000 /* Disable link100 LED */ +#define CIPHY_LED_LINK1000FORCE 0x0800 /* Force on link1000 LED */ +#define CIPHY_LED_LINK1000DIS 0x0400 /* Disable link1000 LED */ +#define CIPHY_LED_FDXFORCE 0x0200 /* Force on duplex LED */ +#define CIPHY_LED_FDXDIS 0x0100 /* Disable duplex LED */ +#define CIPHY_LED_ACTFORCE 0x0080 /* Force on activity LED */ +#define CIPHY_LED_ACTDIS 0x0040 /* Disable activity LED */ +#define CIPHY_LED_PULSE 0x0008 /* LED pulse enable */ +#define CIPHY_LED_LINKACTBLINK 0x0004 /* enable link/activity LED blink */ +#define CIPHY_LED_BLINKRATE 0x0002 /* blink rate 0=10hz, 1=5hz */ + +/* Auxilliary control and status register */ +#define CIPHY_MII_AUXCSR 0x1C +#define CIPHY_AUXCSR_ANEGDONE 0x8000 /* Autoneg complete */ +#define CIPHY_AUXCSR_ANEGOFF 0x4000 /* Autoneg disabled */ +#define CIPHY_AUXCSR_XOVER 0x2000 /* MDI/MDI-X crossover indication */ +#define CIPHY_AUXCSR_PAIRSWAP 0x1000 /* pair swap indication */ +#define CIPHY_AUXCSR_APOLARITY 0x0800 /* polarity inversion pair A */ +#define CIPHY_AUXCSR_BPOLARITY 0x0400 /* polarity inversion pair B */ +#define CIPHY_AUXCSR_CPOLARITY 0x0200 /* polarity inversion pair C */ +#define CIPHY_AUXCSR_DPOLARITY 0x0100 /* polarity inversion pair D */ +#define CIPHY_AUXCSR_FDX 0x0020 /* duplex 1=full, 0=half */ +#define CIPHY_AUXCSR_SPEED 0x0018 /* speed */ +#define CIPHY_AUXCSR_MDPPS 0x0004 /* No idea, not documented */ +#define CIPHY_AUXCSR_STICKYREST 0x0002 /* reset clears sticky bits */ + +#define CIPHY_SPEED10 0x0000 +#define CIPHY_SPEED100 0x0008 +#define CIPHY_SPEED1000 0x0010 + +/* Delay skew status register */ +#define CIPHY_MII_DSKEW 0x1D +#define CIPHY_DSKEW_PAIRA 0x7000 /* Pair A skew in symbol times */ +#define CIPHY_DSKEW_PAIRB 0x0700 /* Pair B skew in symbol times */ +#define CIPHY_DSKEW_PAIRC 0x0070 /* Pair C skew in symbol times */ +#define CIPHY_DSKEW_PAIRD 0x0007 /* Pair D skew in symbol times */ + +#endif /* _DEV_CIPHY_MIIREG_H_ */ Added: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/miidevs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/miidevs.h 2007-11-03 11:55:57 UTC (rev 22810) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/miidevs.h 2007-11-03 12:07:26 UTC (rev 22811) @@ -0,0 +1,18 @@ +/* + * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _FBSD_MII_DEVS_H +#define _FBSD_MII_DEVS_H + +#define MII_OUI_CICADA 0x0003f1 + +#define MII_MODEL_CICADA_CS8201 0x0001 +#define MII_MODEL_CICADA_CS8201A 0x0020 +#define MII_MODEL_CICADA_CS8201B 0x0021 + +#define MII_STR_CICADA_CS8201 "Cicada CS8201 10/100/1000TX PHY" +#define MII_STR_CICADA_CS8201A MII_STR_CICADA_CS8201 +#define MII_STR_CICADA_CS8201B MII_STR_CICADA_CS8201 + +#endif /* _FBSD_MII_DEVS_H */ Added: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ukphy.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ukphy.c 2007-11-03 11:55:57 UTC (rev 22810) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ukphy.c 2007-11-03 12:07:26 UTC (rev 22811) @@ -0,0 +1,227 @@ +/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ + +/*- + * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center, and by Frank van der Linden. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*- + * Copyright (c) 1997 Manuel Bouyer. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Manuel Bouyer. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.17 2005/01/06 01:42:56 imp Exp $"); + +/* + * driver for generic unknown PHYs + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "miibus_if.h" + +static int ukphy_probe(device_t); +static int ukphy_attach(device_t); + +static device_method_t ukphy_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, ukphy_probe), + DEVMETHOD(device_attach, ukphy_attach), + DEVMETHOD(device_detach, mii_phy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + { 0, 0 } +}; + +static devclass_t ukphy_devclass; + +static driver_t ukphy_driver = { + "ukphy", + ukphy_methods, + sizeof(struct mii_softc) +}; + +DRIVER_MODULE(ukphy, miibus, ukphy_driver, ukphy_devclass, 0, 0); + +static int ukphy_service(struct mii_softc *, struct mii_data *, int); + +static int +ukphy_probe(dev) + device_t dev; +{ + + /* + * We know something is here, so always match at a low priority. + */ + device_set_desc(dev, "Generic IEEE 802.3u media interface"); + return (-100); +} + +static int +ukphy_attach(dev) + device_t dev; +{ [... truncated: 2630 lines follow ...] From axeld at mail.berlios.de Sat Nov 3 14:00:16 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 3 Nov 2007 14:00:16 +0100 Subject: [Haiku-commits] r22812 - in haiku/trunk/src/libs/compat/freebsd_network: . compat/sys Message-ID: <200711031300.lA3D0GRS028983@sheep.berlios.de> Author: axeld Date: 2007-11-03 14:00:12 +0100 (Sat, 03 Nov 2007) New Revision: 22812 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22812&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h haiku/trunk/src/libs/compat/freebsd_network/device.c Log: * Added miibus_linkchg and miibus_mediainit methods to device_set_driver(); this was the actual reason the MII bus did not work as mediainit was never called. * Got rid of the delayed MII bus scanning again; not only did it not solve the problem, it was also completely unnecessary. * Minor cleanup. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2007-11-03 12:07:26 UTC (rev 22811) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2007-11-03 13:00:12 UTC (rev 22812) @@ -54,7 +54,6 @@ extern const char gDriverName[]; driver_t *__haiku_select_miibus_driver(device_t dev); driver_t *__haiku_probe_miibus(device_t dev, driver_t *drivers[], int count); -void __haiku_scan_miibus(device_t dev); /* we define the driver methods with HAIKU_FBSD_DRIVER_GLUE to * force the rest of the stuff to be linked back with the driver. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-03 12:07:26 UTC (rev 22811) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-03 13:00:12 UTC (rev 22812) @@ -1,5 +1,6 @@ /* * Copyright 2007, Hugo Santos, hugosantos at gmail.com. All Rights Reserved. + * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All Rights Reserved. * Copyright 2004, Marcus Overhagen. All Rights Reserved. * * Distributed under the terms of the MIT License. @@ -310,6 +311,10 @@ dev->methods.miibus_writereg = (void *)mth->method; else if (strcmp(mth->name, "miibus_statchg") == 0) dev->methods.miibus_statchg = (void *)mth->method; + else if (!strcmp(mth->name, "miibus_linkchg")) + dev->methods.miibus_linkchg = (void *)mth->method; + else if (!strcmp(mth->name, "miibus_mediainit")) + dev->methods.miibus_mediainit = (void *)mth->method; } return 0; @@ -393,19 +398,11 @@ void -__haiku_scan_miibus(device_t dev) +bus_generic_attach(device_t dev) { - device_t miibus = NULL; device_t child = NULL; - // find miibus - - while ((miibus = list_get_next_item(&dev->children, miibus)) != NULL) { - if (miibus->driver == &miibus_driver) - break; - } - - while ((child = list_get_next_item(&miibus->children, child)) != NULL) { + while ((child = list_get_next_item(&dev->children, child)) != NULL) { if (child->driver == NULL) { driver_t *driver = __haiku_select_miibus_driver(child); if (driver) { @@ -417,18 +414,7 @@ device_printf(dev, "No PHY module found (%x/%x)!\n", ma->mii_id1, ma->mii_id2); } - } - } -} - - -void -bus_generic_attach(device_t dev) -{ - device_t child = NULL; - - while ((child = list_get_next_item(&dev->children, child)) != NULL) { - if (child->driver == &miibus_driver) + } else if (child->driver == &miibus_driver) child->methods.probe(child); if (child->driver != NULL) Modified: haiku/trunk/src/libs/compat/freebsd_network/device.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-03 12:07:26 UTC (rev 22811) +++ haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-03 13:00:12 UTC (rev 22812) @@ -1,11 +1,8 @@ /* * Copyright 2007, Hugo Santos. All Rights Reserved. - * Distributed under the terms of the MIT License. + * Copyright 2004, Marcus Overhagen. All Rights Reserved. * - * Authors: - * Hugo Santos, hugosantos at gmail.com - * - * Some of this code is based on previous work by Marcus Overhagen. + * Distributed under the terms of the MIT License. */ #include "device.h" @@ -127,8 +124,6 @@ struct ifnet *ifp = dev->ifp; struct ifreq ifr; - __haiku_scan_miibus(DEVNET(dev)); - ifp->if_flags &= ~IFF_UP; ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); From superstippi at gmx.de Sat Nov 3 14:08:04 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 03 Nov 2007 14:08:04 +0100 Subject: [Haiku-commits] r22809 - in haiku/trunk: . src/add-ons/kernel/network/stack In-Reply-To: <200711031136.lA3Bap98027586@sheep.berlios.de> References: <200711031136.lA3Bap98027586@sheep.berlios.de> Message-ID: <20071103140804.13059.1@stippis.WG> hugosantos at mail.berlios.de wrote (2007-11-03, 12:36:51 [+0100]): > Author: hugosantos > Date: 2007-11-03 12:36:02 +0100 (Sat, 03 Nov 2007) New Revision: 22809 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22809&view=rev > > Modified: > haiku/trunk/ > haiku/trunk/src/add-ons/kernel/network/stack/routes.cpp > Log: > r10168 at haiku-devel: hugo | 2007-11-03 12:35:29 +0100 find_route() is > not really IPv4 specific. Yippie! Welcome back, Hugo! Best regards, -Stephan From korli at users.berlios.de Sat Nov 3 14:26:13 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Sat, 3 Nov 2007 14:26:13 +0100 Subject: [Haiku-commits] r22809 - in haiku/trunk: . src/add-ons/kernel/network/stack In-Reply-To: <200711031136.lA3Bap98027586@sheep.berlios.de> References: <200711031136.lA3Bap98027586@sheep.berlios.de> Message-ID: Hi Hugo (willkommen!), 2007/11/3, hugosantos at mail.berlios.de : > Property changes on: haiku/trunk > ___________________________________________________________________ > Name: svk:merge > + 6868e255-f64d-48ee-a222-11b7e48ea3cc:/local/haiku:10168 > I didn't know svk before. Could you explain your motivations to use it ? Bye, J?r?me From axeld at mail.berlios.de Sat Nov 3 14:39:40 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 3 Nov 2007 14:39:40 +0100 Subject: [Haiku-commits] r22813 - haiku/trunk/src/libs/compat/freebsd_network/compat/sys Message-ID: <200711031339.lA3DdeFa031757@sheep.berlios.de> Author: axeld Date: 2007-11-03 14:39:39 +0100 (Sat, 03 Nov 2007) New Revision: 22813 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22813&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/systm.h Log: Made DELAY() fall back to spin() for times below 1000 usecs; it's often used that way, and snooze() just wouldn't work right then. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/systm.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/systm.h 2007-11-03 13:00:12 UTC (rev 22812) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/systm.h 2007-11-03 13:39:39 UTC (rev 22813) @@ -1,3 +1,7 @@ +/* + * Copyright 2007, Hugo Santos. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _FBSD_COMPAT_SYS_SYSTM_H_ #define _FBSD_COMPAT_SYS_SYSTM_H_ @@ -10,6 +14,12 @@ #include #include -#define DELAY(n) snooze(n) +#define DELAY(n) \ + do { \ + if (n < 1000) \ + spin(n); \ + else \ + snooze(n); \ + } while (0) -#endif +#endif /* _FBSD_COMPAT_SYS_SYSTM_H_ */ From hugosantos at gmail.com Sat Nov 3 14:56:40 2007 From: hugosantos at gmail.com (Hugo Santos) Date: Sat, 3 Nov 2007 14:56:40 +0100 Subject: [Haiku-commits] r22809 - in haiku/trunk: . src/add-ons/kernel/network/stack In-Reply-To: References: <200711031136.lA3Bap98027586@sheep.berlios.de> Message-ID: <9c46321e0711030656h160232afg28713f97929c7c59@mail.gmail.com> Hey, Thanks Stephan. Jerome, i don't have a decent connection at home. And i don't want to commit 1000 line diffs each time, so i prefer being able to do small incremental commits locally, and then push them to the svn. I used to use git-svn, but i still haven't been able to download the tree using it since i left Portugal. Only today i was finally able to download everything with svk, and i'm using it now (i only have a phone EDGE data connection at home...). The svk:merge prop was not intended though, and i'm trying to find a way to avoid it to be uploaded. Hope this helps, Hugo On 11/3/07, J?r?me Duval wrote: > Hi Hugo (willkommen!), > > 2007/11/3, hugosantos at mail.berlios.de : > > Property changes on: haiku/trunk > > ___________________________________________________________________ > > Name: svk:merge > > + 6868e255-f64d-48ee-a222-11b7e48ea3cc:/local/haiku:10168 > > > > I didn't know svk before. Could you explain your motivations to use it ? > > Bye, > J?r?me > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > From axeld at mail.berlios.de Sat Nov 3 16:10:22 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 3 Nov 2007 16:10:22 +0100 Subject: [Haiku-commits] r22814 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711031510.lA3FAM5q005274@sheep.berlios.de> Author: axeld Date: 2007-11-03 16:10:22 +0100 (Sat, 03 Nov 2007) New Revision: 22814 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22814&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/if.c Log: The MAC address might need to be copied to the arpcom structure as well (the 3com driver needs this, for example). Modified: haiku/trunk/src/libs/compat/freebsd_network/if.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/if.c 2007-11-03 13:39:39 UTC (rev 22813) +++ haiku/trunk/src/libs/compat/freebsd_network/if.c 2007-11-03 15:10:22 UTC (rev 22814) @@ -289,7 +289,7 @@ void -ether_ifattach(struct ifnet *ifp, const uint8_t *mac_address) +ether_ifattach(struct ifnet *ifp, const uint8_t *macAddress) { ifp->if_addrlen = ETHER_ADDR_LEN; ifp->if_hdrlen = ETHER_HDR_LEN; @@ -300,8 +300,13 @@ ifp->if_resolvemulti = NULL; /* done in the stack */ ifp->if_lladdr.sdl_family = AF_LINK; - memcpy(IF_LLADDR(ifp), mac_address, ETHER_ADDR_LEN); + memcpy(IF_LLADDR(ifp), macAddress, ETHER_ADDR_LEN); + // TODO: according to FreeBSD's if_ethersubr.c, this should be removed + // once all drivers are cleaned up. + if (macAddress != IFP2ENADDR(ifp)) + memcpy(IFP2ENADDR(ifp), macAddress, ETHER_ADDR_LEN); + ifp->if_init(ifp->if_softc); } From axeld at mail.berlios.de Sat Nov 3 17:43:28 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 3 Nov 2007 17:43:28 +0100 Subject: [Haiku-commits] r22815 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711031643.lA3GhSmT010033@sheep.berlios.de> Author: axeld Date: 2007-11-03 17:43:28 +0100 (Sat, 03 Nov 2007) New Revision: 22815 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22815&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c Log: I accidently didn't revert the delayed MII bus scan correctly which resulted in callling the device's attach() method twice - this would let every network device that found a MII PHY fall into an endless loop on start. In other words 3com and VIA Rhine should now work fine. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-03 15:10:22 UTC (rev 22814) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-03 16:43:28 UTC (rev 22815) @@ -405,15 +405,13 @@ while ((child = list_get_next_item(&dev->children, child)) != NULL) { if (child->driver == NULL) { driver_t *driver = __haiku_select_miibus_driver(child); - if (driver) { - device_set_driver(child, driver); - child->methods.attach(child); - } else { + if (driver == NULL) { struct mii_attach_args *ma = device_get_ivars(child); device_printf(dev, "No PHY module found (%x/%x)!\n", ma->mii_id1, ma->mii_id2); - } + } else + device_set_driver(child, driver); } else if (child->driver == &miibus_driver) child->methods.probe(child); From axeld at mail.berlios.de Sat Nov 3 17:45:49 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 3 Nov 2007 17:45:49 +0100 Subject: [Haiku-commits] r22816 - haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci Message-ID: <200711031645.lA3Gjnec010283@sheep.berlios.de> Author: axeld Date: 2007-11-03 17:45:49 +0100 (Sat, 03 Nov 2007) New Revision: 22816 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22816&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c Log: The promiscuous work-around is no longer needed; the MAC address is now set correctly in the filter, so that we can receive all of our packets. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c 2007-11-03 16:43:28 UTC (rev 22815) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c 2007-11-03 16:45:49 UTC (rev 22816) @@ -2875,8 +2875,7 @@ rxfilt |= XL_RXFILTER_INDIVIDUAL; /* If we want promiscuous mode, set the allframes bit. */ -// TODO: temporarily set IFF_PROMISC, as the driver doesn't seem to work with the usual filtering - if (1/*ifp->if_flags & IFF_PROMISC*/) { + if (ifp->if_flags & IFF_PROMISC) { rxfilt |= XL_RXFILTER_ALLFRAMES; CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_FILT|rxfilt); } else { From axeld at mail.berlios.de Sat Nov 3 17:51:44 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 3 Nov 2007 17:51:44 +0100 Subject: [Haiku-commits] r22817 - in haiku/trunk/src/add-ons/kernel/drivers/network/3com: dev/mii pci Message-ID: <200711031651.lA3GpihE010543@sheep.berlios.de> Author: axeld Date: 2007-11-03 17:51:44 +0100 (Sat, 03 Nov 2007) New Revision: 22817 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22817&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/ukphy.c Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c Log: Added ukphy fallback MII PHY driver for 3com as well. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/Jamfile 2007-11-03 16:45:49 UTC (rev 22816) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/Jamfile 2007-11-03 16:51:44 UTC (rev 22817) @@ -11,6 +11,7 @@ : bmtphy.c exphy.c + ukphy.c ukphy_subr.c ; Copied: haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/ukphy.c (from rev 22814, haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ukphy.c) =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/ukphy.c 2007-11-03 15:10:22 UTC (rev 22814) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/ukphy.c 2007-11-03 16:51:44 UTC (rev 22817) @@ -0,0 +1,232 @@ +/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ + +/*- + * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center, and by Frank van der Linden. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*- + * Copyright (c) 1997 Manuel Bouyer. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Manuel Bouyer. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.17 2005/01/06 01:42:56 imp Exp $"); + +/* + * driver for generic unknown PHYs + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "miibus_if.h" + +static int ukphy_probe(device_t); +static int ukphy_attach(device_t); + +static device_method_t ukphy_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, ukphy_probe), + DEVMETHOD(device_attach, ukphy_attach), + DEVMETHOD(device_detach, mii_phy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + { 0, 0 } +}; + +static devclass_t ukphy_devclass; + +static driver_t ukphy_driver = { + "ukphy", + ukphy_methods, + sizeof(struct mii_softc) +}; + +DRIVER_MODULE(ukphy, miibus, ukphy_driver, ukphy_devclass, 0, 0); + +static int ukphy_service(struct mii_softc *, struct mii_data *, int); + +static int +ukphy_probe(dev) + device_t dev; +{ + + /* + * We know something is here, so always match at a low priority. + */ + device_set_desc(dev, "Generic IEEE 802.3u media interface"); + return (-100); +} + +static int +ukphy_attach(dev) + device_t dev; +{ + struct mii_softc *sc; + struct mii_attach_args *ma; + struct mii_data *mii; + +static int ppp; +if (ppp++ > 0) + panic("oops"); + sc = device_get_softc(dev); + ma = device_get_ivars(dev); + sc->mii_dev = device_get_parent(dev); + mii = device_get_softc(sc->mii_dev); +device_printf(dev, "insert into %p\n", mii); +device_printf(sc->mii_dev, "this is the parent\n"); + LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); + + if (bootverbose) + device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n", + MII_OUI(ma->mii_id1, ma->mii_id2), + MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2)); + + sc->mii_inst = mii->mii_instance; + sc->mii_phy = ma->mii_phyno; + sc->mii_service = ukphy_service; + sc->mii_pdata = mii; + + mii->mii_instance++; + + sc->mii_flags |= MIIF_NOISOLATE; + + mii_phy_reset(sc); + + sc->mii_capabilities = + PHY_READ(sc, MII_BMSR) & ma->mii_capmask; + if (sc->mii_capabilities & BMSR_EXTSTAT) + sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); + device_printf(dev, " "); + mii_phy_add_media(sc); + printf("\n"); + + MIIBUS_MEDIAINIT(sc->mii_dev); + mii_phy_setmedia(sc); + + return(0); +} + +static int +ukphy_service(sc, mii, cmd) + struct mii_softc *sc; + struct mii_data *mii; + int cmd; +{ + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; + int reg; + + switch (cmd) { + case MII_POLLSTAT: + /* + * If we're not polling our PHY instance, just return. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) + return (0); + break; + + case MII_MEDIACHG: + /* + * If the media indicates a different PHY instance, + * isolate ourselves. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) { + reg = PHY_READ(sc, MII_BMCR); + PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); + return (0); + } + + /* + * If the interface is not up, don't do anything. + */ + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + break; + + mii_phy_setmedia(sc); + break; + + case MII_TICK: + /* + * If we're not currently selected, just return. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) + return (0); + if (mii_phy_tick(sc) == EJUSTRETURN) + return (0); + break; + } + + /* Update the media status. */ + ukphy_status(sc); + + /* Callback if something changed. */ + mii_phy_update(sc, cmd); + return (0); +} Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c 2007-11-03 16:45:49 UTC (rev 22816) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c 2007-11-03 16:51:44 UTC (rev 22817) @@ -14,6 +14,7 @@ extern driver_t *DRIVER_MODULE_NAME(bmtphy, miibus); extern driver_t *DRIVER_MODULE_NAME(xlphy, miibus); +extern driver_t *DRIVER_MODULE_NAME(ukphy, miibus); driver_t * @@ -21,10 +22,11 @@ { driver_t *drivers[] = { DRIVER_MODULE_NAME(bmtphy, miibus), - DRIVER_MODULE_NAME(xlphy, miibus) + DRIVER_MODULE_NAME(xlphy, miibus), + DRIVER_MODULE_NAME(ukphy, miibus) }; - return __haiku_probe_miibus(dev, drivers, 2); + return __haiku_probe_miibus(dev, drivers, 3); } From axeld at mail.berlios.de Sat Nov 3 18:32:15 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 3 Nov 2007 18:32:15 +0100 Subject: [Haiku-commits] r22818 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711031732.lA3HWFi7016511@sheep.berlios.de> Author: axeld Date: 2007-11-03 18:32:14 +0100 (Sat, 03 Nov 2007) New Revision: 22818 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22818&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/device.c Log: * Calmed down the FreeBSD drivers even more - compat_{read|write}() no longer print anything. * Added (commented out) debug output to compat_control(). * Renamed variables "len" to "length" where possible. * Minor cleanup. Modified: haiku/trunk/src/libs/compat/freebsd_network/device.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-03 16:51:44 UTC (rev 22817) +++ haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-03 17:32:14 UTC (rev 22818) @@ -177,16 +177,16 @@ static status_t -compat_read(void *cookie, off_t position, void *buf, size_t *numBytes) +compat_read(void *cookie, off_t position, void *buffer, size_t *numBytes) { struct network_device *dev = cookie; uint32 semFlags = B_CAN_INTERRUPT; status_t status; struct mbuf *mb; - size_t len; + size_t length; - device_printf(DEVNET(dev), "compat_read(%lld, %p, [%lu])\n", position, buf, - *numBytes); + //device_printf(DEVNET(dev), "compat_read(%lld, %p, [%lu])\n", position, + // buffer, *numBytes); if (DEVNET(dev)->flags & DEVICE_CLOSED) return B_INTERRUPTED; @@ -208,7 +208,7 @@ IF_DEQUEUE(&dev->receive_queue, mb); } while (mb == NULL); - len = min_c(max_c((size_t)mb->m_len, 0), *numBytes); + length = min_c(max_c((size_t)mb->m_len, 0), *numBytes); #if 0 mb = m_defrag(mb, 0); @@ -218,8 +218,8 @@ } #endif - memcpy(buf, mtod(mb, const void *), len); - *numBytes = len; + memcpy(buffer, mtod(mb, const void *), length); + *numBytes = length; m_freem(mb); return B_OK; @@ -233,8 +233,8 @@ struct network_device *dev = cookie; struct mbuf *mb; - device_printf(DEVNET(dev), "compat_write(%lld, %p, [%lu])\n", position, - buffer, *numBytes); + //device_printf(DEVNET(dev), "compat_write(%lld, %p, [%lu])\n", position, + // buffer, *numBytes); mb = m_getcl(0, MT_DATA, M_PKTHDR); if (mb == NULL) @@ -250,11 +250,14 @@ static status_t -compat_control(void *cookie, uint32 op, void *arg, size_t len) +compat_control(void *cookie, uint32 op, void *arg, size_t length) { struct network_device *dev = cookie; struct ifnet *ifp = dev->ifp; + //device_printf(DEVNET(dev), "compat_control(op %lu, %p, [%lu])\n", op, + // arg, length); + switch (op) { case ETHER_INIT: return B_OK; @@ -265,7 +268,7 @@ case ETHER_NONBLOCK: { int32 value; - if (len < 4) + if (length < 4) return B_BAD_VALUE; if (user_memcpy(&value, arg, sizeof(int32)) < B_OK) return B_BAD_ADDRESS; @@ -279,7 +282,7 @@ case ETHER_SETPROMISC: { int32 value; - if (len < 4) + if (length < 4) return B_BAD_VALUE; if (user_memcpy(&value, arg, sizeof(int32)) < B_OK) return B_BAD_ADDRESS; @@ -293,7 +296,7 @@ case ETHER_GETFRAMESIZE: { uint32 frame_size; - if (len < 4) + if (length < 4) return B_BAD_VALUE; frame_size = dev->ifp->if_mtu + ETHER_HDR_LEN; return user_memcpy(arg, &frame_size, 4); @@ -313,8 +316,8 @@ if (op == ETHER_ADDMULTI) return if_addmulti(ifp, (struct sockaddr *)&address, NULL); - else - return if_delmulti(ifp, (struct sockaddr *)&address); + + return if_delmulti(ifp, (struct sockaddr *)&address); } case ETHER_GET_LINK_STATE: @@ -323,7 +326,7 @@ ether_link_state_t state; status_t status; - if (len < sizeof(ether_link_state_t)) + if (length < sizeof(ether_link_state_t)) return EINVAL; memset(&mediareq, 0, sizeof(mediareq)); From korli at mail.berlios.de Sat Nov 3 20:13:43 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 3 Nov 2007 20:13:43 +0100 Subject: [Haiku-commits] r22819 - haiku/trunk/src/bin/network/telnetd Message-ID: <200711031913.lA3JDhFN002934@sheep.berlios.de> Author: korli Date: 2007-11-03 20:13:42 +0100 (Sat, 03 Nov 2007) New Revision: 22819 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22819&view=rev Modified: haiku/trunk/src/bin/network/telnetd/ext.h Log: added Haiku for telnetd login Modified: haiku/trunk/src/bin/network/telnetd/ext.h =================================================================== --- haiku/trunk/src/bin/network/telnetd/ext.h 2007-11-03 17:32:14 UTC (rev 22818) +++ haiku/trunk/src/bin/network/telnetd/ext.h 2007-11-03 19:13:42 UTC (rev 22819) @@ -212,7 +212,11 @@ # ifdef __FreeBSD__ # define DEFAULT_IM "\r\n\r\nFreeBSD (%h) (%t)\r\n\r\r\n\r" # else -# define DEFAULT_IM "\r\n\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r" +# ifdef __HAIKU__ +# define DEFAULT_IM "\r\n\r\nHaiku (%h) (%t)\r\n\r\r\n\r" +# else +# define DEFAULT_IM "\r\n\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r" +# endif # endif # endif #endif From geist at foobox.com Sat Nov 3 20:51:31 2007 From: geist at foobox.com (Travis Geiselbrecht) Date: Sat, 3 Nov 2007 12:51:31 -0700 Subject: [Haiku-commits] r22809 - in haiku/trunk: . src/add-ons/kernel/network/stack In-Reply-To: <9c46321e0711030656h160232afg28713f97929c7c59@mail.gmail.com> References: <200711031136.lA3Bap98027586@sheep.berlios.de> <9c46321e0711030656h160232afg28713f97929c7c59@mail.gmail.com> Message-ID: <41A1FF95-BF03-419E-814F-EA975A173408@foobox.com> Yes, svk is also great for large merges (though doesn't look like any of that is going on here), because it tracks more metadata about what has and hasn't been branched, though it does it by sticking these little properties around in the svn depot. I've been using svk here as well, I just haven't been committing anything :) Travis On Nov 3, 2007, at 6:56 AM, Hugo Santos wrote: > Hey, > > Thanks Stephan. > > Jerome, i don't have a decent connection at home. And i don't want > to commit 1000 line diffs each time, so i prefer being able to do > small incremental commits locally, and then push them to the svn. I > used to use git-svn, but i still haven't been able to download the > tree using it since i left Portugal. Only today i was finally able to > download everything with svk, and i'm using it now (i only have a > phone EDGE data connection at home...). > > The svk:merge prop was not intended though, and i'm trying to find a > way to avoid it to be uploaded. > > Hope this helps, > Hugo > > On 11/3/07, J?r?me Duval wrote: >> Hi Hugo (willkommen!), >> >> 2007/11/3, hugosantos at mail.berlios.de : >>> Property changes on: haiku/trunk >>> ___________________________________________________________________ >>> Name: svk:merge >>> + 6868e255-f64d-48ee-a222-11b7e48ea3cc:/local/haiku:10168 >>> >> >> I didn't know svk before. Could you explain your motivations to use >> it ? >> >> Bye, >> J?r?me >> _______________________________________________ >> Haiku-commits mailing list >> Haiku-commits at lists.berlios.de >> https://lists.berlios.de/mailman/listinfo/haiku-commits >> > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits From axeld at mail.berlios.de Sat Nov 3 21:49:46 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 3 Nov 2007 21:49:46 +0100 Subject: [Haiku-commits] r22820 - haiku/trunk/build/jam Message-ID: <200711032049.lA3KnkJY008336@sheep.berlios.de> Author: axeld Date: 2007-11-03 21:49:46 +0100 (Sat, 03 Nov 2007) New Revision: 22820 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22820&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: * Replaced old VIA Rhine driver with the new one from FreeBSD. * Added the FreeBSD 3com driver to the image. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-03 19:13:42 UTC (rev 22819) +++ haiku/trunk/build/jam/HaikuImage 2007-11-03 20:49:46 UTC (rev 22820) @@ -115,8 +115,8 @@ $(X86_ONLY)s3savage $(X86_ONLY)via vesa #$(X86_ONLY)vmware ; BEOS_ADD_ONS_DRIVERS_MIDI = emuxki ; -BEOS_ADD_ONS_DRIVERS_NET = etherpci ipro1000 rtl8139 rtl8169 sis900 - via-rhine wb840 net_stack #vlance +BEOS_ADD_ONS_DRIVERS_NET = 3com etherpci ipro1000 rtl8139 rtl8169 sis900 + via_rhine wb840 net_stack #vlance $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; #BEOS_ADD_ONS_DRIVERS_ACPI = $(X86_ONLY)acpi_button ; From mmu_man at mail.berlios.de Sat Nov 3 22:02:04 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 3 Nov 2007 22:02:04 +0100 Subject: [Haiku-commits] r22821 - haiku/trunk/headers/private/kernel/arch/m68k Message-ID: <200711032102.lA3L24FE008992@sheep.berlios.de> Author: mmu_man Date: 2007-11-03 22:02:03 +0100 (Sat, 03 Nov 2007) New Revision: 22821 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22821&view=rev Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_cpu.h haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel_args.h haiku/trunk/headers/private/kernel/arch/m68k/arch_mmu.h haiku/trunk/headers/private/kernel/arch/m68k/arch_thread.h haiku/trunk/headers/private/kernel/arch/m68k/arch_vm.h Log: WIP Abstracted cpu and mmu version dependant stuff (compatibility where are you) into ops like func arrays. Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_cpu.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_cpu.h 2007-11-03 20:49:46 UTC (rev 22820) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_cpu.h 2007-11-03 21:02:03 UTC (rev 22821) @@ -219,12 +219,18 @@ } #endif -/* flushes insn pipeline */ -#define m68k_nop() asm volatile("nop") -/* no FC bit needed */ -#define pflush(addr) asm volatile("pflush #0,#0,(%0)" :: "a" (addr)) -#define pflusha() asm volatile("pflusha") +struct m68k_cpu_ops { + void (*flush_insn_pipeline)(void); + void (*flush_atc_all)(void); + void (*flush_atc_user)(void); + void (*flush_atc_addr)(void *addr); + void (*flush_dcache)(void *address, size_t len); + void (*flush_icache)(void *address, size_t len); + void (*idle)(void); +}; +extern struct m68k_cpu_ops cpu_ops; + //#define #if 0 @@ -234,51 +240,56 @@ #define ppc_sync() asm volatile("sync") #define tlbia() asm volatile("tlbia") #define tlbie(addr) asm volatile("tlbie %0" :: "r" (addr)) +#endif - -// PowerPC processor version (the upper 16 bits of the PVR). +// m68k processor version. enum m68k_processor_version { - MPC601 = 0x0001, - MPC603 = 0x0003, - MPC604 = 0x0004, - MPC602 = 0x0005, - MPC603e = 0x0006, - MPC603ev = 0x0007, - MPC750 = 0x0008, - MPC604ev = 0x0009, - MPC7400 = 0x000c, - MPC620 = 0x0014, - IBM403 = 0x0020, - IBM401A1 = 0x0021, - IBM401B2 = 0x0022, - IBM401C2 = 0x0023, - IBM401D2 = 0x0024, - IBM401E2 = 0x0025, - IBM401F2 = 0x0026, - IBM401G2 = 0x0027, - IBMPOWER3 = 0x0041, - MPC860 = 0x0050, - MPC8240 = 0x0081, - IBM405GP = 0x4011, - IBM405L = 0x4161, - IBM750FX = 0x7000, - MPC7450 = 0x8000, - MPC7455 = 0x8001, - MPC7457 = 0x8002, - MPC7447A = 0x8003, - MPC7448 = 0x8004, - MPC7410 = 0x800c, - MPC8245 = 0x8081, + /* those two we don't support */ + CPU_68000 = 0x0000, + CPU_68010 = 0x0001, + /* maybe with a pmmu and fpu */ + CPU_68020 = 0x0002, + /* should work */ + CPU_68030 = 0x0003, + CPU_68040 = 0x0004, + CPU_68060 = 0x0006, + /* mask */ + CPU_MASK = 0x000F }; -#endif +enum m68k_fpu_version { + /* we don't support */ + FPU_NONE = 0x0000, + FPU_68881 = 0x0010, + FPU_68882 = 0x0020, + FPU_030 = 0x0030, + FPU_040 = 0x0040, + FPU_060 = 0x0060, + FPU_MASK = 0x00F0 +}; +enum m68k_mmu_version { + MMU_NONE = 0x0000, + MMU_68551 = 0x0100, + MMU_68030 = 0x0300, + MMU_68040 = 0x0400, + MMU_68060 = 0x0600, + MMU_MASK = 0x0F00 +}; + +extern int arch_cpu_type; +extern int arch_fpu_type; +extern int arch_mmu_type; +extern int arch_platform; + /* Use of (some) special purpose registers. + XXX: those regs aren't implemented/accessed the same way on different cpus... SRP[63-32]: current struct thread* SRP[31-0] : CAAR : can we use it ?? + MSP : PPC: SPRG0: per CPU physical address pointer to an ppc_cpu_exception_context Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel_args.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel_args.h 2007-11-03 20:49:46 UTC (rev 22820) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel_args.h 2007-11-03 21:02:03 UTC (rev 22821) @@ -15,6 +15,10 @@ // kernel args typedef struct { + int cpu_type; + int fpu_type; + int mmu_type; + int platform; // architecture specific uint64 cpu_frequency; uint64 bus_frequency; Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_mmu.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_mmu.h 2007-11-03 20:49:46 UTC (rev 22820) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_mmu.h 2007-11-03 21:02:03 UTC (rev 22821) @@ -11,139 +11,114 @@ #include +/* + * cf. + * "mc68030 Enhanced 32-bit Microprocessor User's Manual" + * (3rd edition), Section 9 + * "mc68040 Enhanced 32-bit Microprocessor User's Manual" + * Section 9 + * + * The 030 pmmu can support up to 6-level translation tree, + * each level using an size-selectable index from the + * virtual address, short (4-bit) and long (8-bit) page table + * and page entry descriptors, early tree termination, and selectable + * page size from 256 bytes to 32K. + * There is optionally a separate Supervisor Root Pointer to separate + * the user and kernel trees. + * + * The 040 pmmu however is way more limited in its abilities. + * It has a fixed 3-level page tree, with 7/7/6 bit splitting for + * 4K pages. The opcodes are also different so we will need specific + * routines. Both supervisor and root pointers must be used so we can't + * reuse one of them. + * + * + * We settle to: + * - 1 bit index for the first level to easily split kernel and user + * part of the tree, with the possibility to force supervisor only for + * the kernel tree. The use of SRP to point to a 2nd tree is avoided as + * it is not available on 68060, plus that makes a spare 64bit reg to + * stuff things in. + * - 9 bit page directory + * - 10 bit page tables + * - 12 bit page index (4K pages, a common value). + */ -/*** BAT - block address translation ***/ -enum bat_length { - BAT_LENGTH_128kB = 0x0000, - BAT_LENGTH_256kB = 0x0001, - BAT_LENGTH_512kB = 0x0003, - BAT_LENGTH_1MB = 0x0007, - BAT_LENGTH_2MB = 0x000f, - BAT_LENGTH_4MB = 0x001f, - BAT_LENGTH_8MB = 0x003f, - BAT_LENGTH_16MB = 0x007f, - BAT_LENGTH_32MB = 0x00ff, - BAT_LENGTH_64MB = 0x01ff, - BAT_LENGTH_128MB = 0x03ff, - BAT_LENGTH_256MB = 0x07ff, -}; -enum bat_protection { - BAT_READ_ONLY = 1, - BAT_READ_WRITE = 2, +enum descriptor_types { + DT_INVALID = 0, // invalid entry + DT_PAGE, // page descriptor + DT_VALID_4, // short page table descriptor + DT_VALID_8, // long page table descriptor }; -struct block_address_translation { - // upper 32 bit - uint32 page_index : 15; // BEPI, block effective page index - uint32 _reserved0 : 4; - uint32 length : 11; - uint32 kernel_valid : 1; // Vs, Supervisor-state valid - uint32 user_valid : 1; // Vp, User-state valid - // lower 32 bit - uint32 physical_block_number : 15; // BPRN - uint32 write_through : 1; // WIMG - uint32 caching_inhibited : 1; - uint32 memory_coherent : 1; - uint32 guarded : 1; - uint32 _reserved1 : 1; - uint32 protection : 2; +#if 0 +/* This is the normal layout of the descriptors, as per documentation. + * When page size > 256, several bits are unused in the LSB of page + * addresses, which we can use in addition of other unused bits. + * the structs dedlared later reflect this for 4K pages. + */ - block_address_translation() - { - Clear(); - } - - void SetVirtualAddress(void *address) - { - page_index = uint32(address) >> 17; - } - - void SetPhysicalAddress(void *address) - { - physical_block_number = uint32(address) >> 17; - } - - void Clear() - { - memset((void *)this, 0, sizeof(block_address_translation)); - } +struct short_page_directory_entry { + // upper 32 bits + uint32 type : 2; + uint32 write_protect : 1; + uint32 used : 1; + uint32 address : 28; }; -struct segment_descriptor { - uint32 type : 1; // 0 for page translation descriptors - uint32 kernel_protection_key : 1; // Ks, Supervisor-state protection key - uint32 user_protection_key : 1; // Kp, User-state protection key - uint32 no_execute_protection : 1; - uint32 _reserved : 4; - uint32 virtual_segment_id : 24; - - segment_descriptor() - { - Clear(); - } - - segment_descriptor(uint32 value) - { - *((uint32 *)this) = value; - } - - void Clear() - { - memset((void *)this, 0, sizeof(segment_descriptor)); - } +struct long_page_directory_entry { + // upper 32 bits + uint32 type : 2; + uint32 write_protect : 1; + uint32 used : 1; + uint32 _zero1 : 4; + uint32 supervisor : 1; + uint32 _zero2 : 1; + uint32 _ones : 6; + uint32 limit : 15; + uint32 low_up : 1; // limit is lower(1)/upper(0) + // lower 32 bits + uint32 unused : 4; // + uint32 address : 28; }; - -/*** PTE - page table entry ***/ - -enum pte_protection { - PTE_READ_ONLY = 3, - PTE_READ_WRITE = 2, +struct short_page_table_entry { + uint32 type : 2; + uint32 write_protect : 1; + uint32 used : 1; + uint32 modified : 1; + uint32 _zero1 : 1; + uint32 cache_inhibit : 1; + uint32 _zero2 : 1; + uint32 address : 24; }; -struct page_table_entry { - // upper 32 bit - uint32 valid : 1; - uint32 virtual_segment_id : 24; - uint32 secondary_hash : 1; - uint32 abbr_page_index : 6; - // lower 32 bit - uint32 physical_page_number : 20; - uint32 _reserved0 : 3; - uint32 referenced : 1; - uint32 changed : 1; - uint32 write_through : 1; // WIMG - uint32 caching_inhibited : 1; - uint32 memory_coherent : 1; - uint32 guarded : 1; - uint32 _reserved1 : 1; - uint32 page_protection : 2; - - static uint32 PrimaryHash(uint32 virtualSegmentID, uint32 virtualAddress); - static uint32 SecondaryHash(uint32 virtualSegmentID, uint32 virtualAddress); - static uint32 SecondaryHash(uint32 primaryHash); +struct long_page_table_entry { + // upper 32 bits + uint32 type : 2; + uint32 write_protect : 1; + uint32 used : 1; + uint32 modified : 1; + uint32 _zero1 : 1; + uint32 cache_inhibit : 1; + uint32 _zero2 : 1; + uint32 supervisor : 1; + uint32 _zero3 : 1; + uint32 _ones : 6; + // limit only used on early table terminators, else unused + uint32 limit : 15; + uint32 low_up : 1; // limit is lower(1)/upper(0) + // lower 32 bits + uint32 unused : 8; // + uint32 address : 24; }; +#endif -struct page_table_entry_group { - struct page_table_entry entry[8]; -}; extern void m68k_get_page_table(page_table_entry_group **_pageTable, size_t *_size); extern void m68k_set_page_table(page_table_entry_group *pageTable, size_t size); -static inline segment_descriptor -m68k_get_segment_register(void *virtualAddress) -{ - return (segment_descriptor)get_sr(virtualAddress); -} - -static inline void -m68k_set_segment_register(void *virtualAddress, segment_descriptor segment) -{ - set_sr(virtualAddress, *(uint32 *)&segment); -} - #endif /* _KERNEL_ARCH_M68K_MMU_H */ Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_thread.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_thread.h 2007-11-03 20:49:46 UTC (rev 22820) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_thread.h 2007-11-03 21:02:03 UTC (rev 22821) @@ -19,10 +19,28 @@ void m68k_pop_iframe(struct iframe_stack *stack); struct iframe *m68k_get_user_iframe(void); +/* as we won't support SMP on m68k (yet?) we can use a global here */ +extern struct thread *gCurrentThread; extern inline struct thread * arch_thread_get_current_thread(void) { + return gCurrentThread; +} + + +extern inline void +arch_thread_set_current_thread(struct thread *t) +{ + gCurrentThread = t; +} + +#if 0 +/* this would only work on 030... */ + +extern inline struct thread * +arch_thread_get_current_thread(void) +{ uint64 v = 0; asm volatile("pmove %%srp,(%0)" : : "a"(&v)); return (struct thread *)(uint32)(v & 0xffffffff); @@ -37,8 +55,8 @@ "move %1,(4,%0)\n" \ "pmove (%0),%%srp" : : "a"(&v), "d"(t)); } +#endif - #ifdef __cplusplus } #endif Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_vm.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_vm.h 2007-11-03 20:49:46 UTC (rev 22820) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_vm.h 2007-11-03 21:02:03 UTC (rev 22821) @@ -12,4 +12,24 @@ #define PAGE_SHIFT 12 + +struct m68k_vm_ops { + void *(*m68k_translation_map_get_pgdir)(vm_translation_map *map); + status_t (*arch_vm_translation_map_init_map)(vm_translation_map *map, bool kernel); + status_t (*arch_vm_translation_map_init_kernel_map_post_sem)(vm_translation_map *map); + status_t (*arch_vm_translation_map_init)(kernel_args *args); + status_t (*arch_vm_translation_map_init_post_area)(kernel_args *args); + status_t (*arch_vm_translation_map_init_post_sem)(kernel_args *args); + status_t (*arch_vm_translation_map_early_map)(kernel_args *ka, addr_t virtualAddress, addr_t physicalAddress, + uint8 attributes, addr_t (*get_free_page)(kernel_args *)); + status_t (*arch_vm_translation_map_early_query)(addr_t va, addr_t *out_physical); +#if 0 /* ppc stuff only ? */ + status_t (*m68k_map_address_range)(addr_t virtualAddress, addr_t physicalAddress, + size_t size); + void (*m68k_unmap_address_range)(addr_t virtualAddress, size_t size); + status_t (*m68k_remap_address_range)(addr_t *_virtualAddress, size_t size, bool unmap); +#endif +}; + + #endif /* ARCH_M68K_VM_H */ From mmu_man at mail.berlios.de Sat Nov 3 22:04:52 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 3 Nov 2007 22:04:52 +0100 Subject: [Haiku-commits] r22822 - haiku/trunk/src/system/kernel/arch/m68k Message-ID: <200711032104.lA3L4qEb009069@sheep.berlios.de> Author: mmu_man Date: 2007-11-03 22:04:42 +0100 (Sat, 03 Nov 2007) New Revision: 22822 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22822&view=rev Added: haiku/trunk/src/system/kernel/arch/m68k/arch_030_asm.S haiku/trunk/src/system/kernel/arch/m68k/arch_030_cpu.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_030_mmu.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp Modified: haiku/trunk/src/system/kernel/arch/m68k/Jamfile haiku/trunk/src/system/kernel/arch/m68k/arch_asm.S haiku/trunk/src/system/kernel/arch/m68k/arch_atomic.c haiku/trunk/src/system/kernel/arch/m68k/arch_cpu.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_debug_console.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_elf.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_int.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_mmu.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_platform.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_real_time_clock.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_smp.c haiku/trunk/src/system/kernel/arch/m68k/arch_system_info.c haiku/trunk/src/system/kernel/arch/m68k/arch_thread.c haiku/trunk/src/system/kernel/arch/m68k/arch_timer.c haiku/trunk/src/system/kernel/arch/m68k/arch_user_debugger.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_vm.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map.cpp Log: Ditto. cleanup Less ppc, more m68k :) Modified: haiku/trunk/src/system/kernel/arch/m68k/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/Jamfile 2007-11-03 21:02:03 UTC (rev 22821) +++ haiku/trunk/src/system/kernel/arch/m68k/Jamfile 2007-11-03 21:04:42 UTC (rev 22822) @@ -8,6 +8,24 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; +# cpu-specific stuff +KernelMergeObject arch_m68k_030.o : + arch_030_cpu.cpp + arch_030_mmu.cpp + arch_030_asm.S + : $(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused -m68030 +; + +KernelMergeObject arch_m68k_040.o : + arch_040.cpp + : $(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused -m68040 +; + +KernelMergeObject arch_m68k_060.o : + arch_060.cpp + : $(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused -m68060 +; + KernelStaticLibrary libm68k : arch_atomic.c arch_cpu.cpp @@ -30,6 +48,10 @@ arch_asm.S generic_vm_physical_page_mapper.cpp + + arch_m68k_030.o +# arch_m68k_040.a +# arch_m68k_060.a : $(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused ; Added: haiku/trunk/src/system/kernel/arch/m68k/arch_030_asm.S =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_030_asm.S 2007-11-03 21:02:03 UTC (rev 22821) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_030_asm.S 2007-11-03 21:04:42 UTC (rev 22822) @@ -0,0 +1,24 @@ + +#define FUNCTION(x) .global x; .type x, at function; x + +.text + + + /* that one can be inlined */ +FUNCTION(flush_insn_pipeline_030): + nop + rts + + /* flush all ATC entries */ +FUNCTION(flush_atc_all_030): + pflusha + rts + + /* flush all ATC entries */ +FUNCTION(flush_atc_addr_030): + move.l (4,%a7),%a0 + pflush #0,#0,(%a0) + rts + + + Added: haiku/trunk/src/system/kernel/arch/m68k/arch_030_cpu.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_030_cpu.cpp 2007-11-03 21:02:03 UTC (rev 22821) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_030_cpu.cpp 2007-11-03 21:04:42 UTC (rev 22822) @@ -0,0 +1,77 @@ +/* + * Copyright 2003-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ + +#include + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* from arch_030_asm.S */ +extern void flush_insn_pipeline_030(void); +extern void flush_atc_all_030(void); +extern void flush_atc_addr_030(void *addr); + +#ifdef __cplusplus +} +#endif + + + +#define CACHELINE 16 + +static void +sync_icache_030(void *address, size_t len) +{ + int l, off; + char *p; + uint32 cacr; + + off = (unsigned int)address & (CACHELINE - 1); + len += off; + + l = len; + p = (char *)address - off; + asm volatile ("nop"); + asm volatile ("movec %%cacr,%0" : "=r"(cacr):); + cacr |= 0x00000004; /* ClearInstructionCacheEntry */ + do { + /* the 030 invalidates only 1 long of the cache line */ + //XXX: what about 040 and 060 ? + asm volatile ("movec %0,%%caar\n" \ + "movec %1,%%cacr\n" \ + "addq.l #4,%0\n" \ + "movec %0,%%caar\n" \ + "movec %1,%%cacr\n" \ + "addq.l #4,%0\n" \ + "movec %0,%%caar\n" \ + "movec %1,%%cacr\n" \ + "addq.l #4,%0\n" \ + "movec %0,%%caar\n" \ + "movec %1,%%cacr\n" \ + :: "r"(p), "r"(cacr)); + p += CACHELINE; + } while ((l -= CACHELINE) > 0); + asm volatile ("nop"); +} + + +struct m68k_cpu_ops cpu_ops_030 = { + &flush_insn_pipeline_030, + &flush_atc_all_030, + &flush_atc_all_030, // no global flag, so no useronly flushing + &flush_atc_addr_030, + &sync_icache_030, // dcache is the same + &sync_icache_030, + NULL // idle +}; Added: haiku/trunk/src/system/kernel/arch/m68k/arch_030_mmu.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_030_mmu.cpp 2007-11-03 21:02:03 UTC (rev 22821) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_030_mmu.cpp 2007-11-03 21:04:42 UTC (rev 22822) @@ -0,0 +1,213 @@ +/* + * Copyright 2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ + +#include + + +#define ARCH_M68K_MMU_TYPE MMU_68030 + +enum descriptor_types { + DT_INVALID = 0, // invalid entry + DT_PAGE, // page descriptor + DT_VALID_4, // short page table descriptor + DT_VALID_8, // long page table descriptor +}; + + + // = names in MC user's manual + // or comments +struct short_page_directory_entry { + // upper 32 bits + uint32 type : 2; // DT_* + uint32 write_protect : 1; + uint32 accessed : 1; // = used + uint32 addr : 28; // address +}; + +struct long_page_directory_entry { + // upper 32 bits + uint32 type : 2; + uint32 write_protect : 1; + uint32 accessed : 1; // = used + uint32 _zero1 : 4; + uint32 supervisor : 1; + uint32 _zero2 : 1; + uint32 _ones : 6; + uint32 limit : 15; + uint32 low_up : 1; // limit is lower(1)/upper(0) + // lower 32 bits + uint32 unused : 4; // + uint32 addr : 28; // address +}; + +struct short_page_table_entry { + uint32 type : 2; + uint32 write_protect : 1; + uint32 accessed : 1; // = used + uint32 dirty : 1; // = modified + uint32 _zero1 : 1; + uint32 cache_disabled : 1; // = cache_inhibit + uint32 _zero2 : 1; + uint32 addr : 24; // address +}; + +struct long_page_table_entry { + // upper 32 bits + uint32 type : 2; + uint32 write_protect : 1; + uint32 accessed : 1; // = used + uint32 dirty : 1; // = modified + uint32 _zero1 : 1; + uint32 cache_disabled : 1; // = cache_inhibit + uint32 _zero2 : 1; + uint32 supervisor : 1; + uint32 _zero3 : 1; + uint32 _ones : 6; + // limit only used on early table terminators, else unused + uint32 limit : 15; + uint32 low_up : 1; // limit is lower(1)/upper(0) + // lower 32 bits + uint32 unused : 8; // + uint32 addr : 24; // address +}; + +/* rarely used */ +struct short_indirect_entry { + // upper 32 bits + uint32 type : 2; // DT_* + uint32 addr : 30; // address +}; + +struct long_indirect_entry { + // upper 32 bits + uint32 type : 2; + uint32 unused1 : 30; + // lower 32 bits + uint32 unused2 : 2; // + uint32 addr : 30; // address +}; + +/* for clarity: + - the top level page directory will be called "page root", (root or rtdir) + - the 2nd level will be "page directory" like on x86, (pgdir) + - the 3rd level is a "page table" as on x86. (pgtbl) +*/ + +typedef struct short_page_directory_entry page_root_entry; +typedef struct short_page_directory_entry page_directory_entry; +typedef struct long_page_table_entry page_table_entry; +typedef struct long_indirect_entry page_indirect_entry; + +/* scalar storage type that maps them */ +typedef uint32 page_root_entry_scalar; +typedef uint32 page_directory_entry_scalar; +typedef uint64 page_table_entry_scalar; +typedef uint64 page_indirect_entry_scalar; + +#define DT_ROOT DT_VALID_4 +#define DT_DIR DT_VALID_8 +//#define DT_PAGE DT_PAGE :) +#define DT_INDIRECT DT_VALID_8 + +/* default scalar values for entries */ +#define DFL_ROOTENT_VAL 0x00000000 +#define DFL_DIRENT_VAL 0x00000000 +// limit disabled, 6bits at 1 +// (limit isn't used on that level, but just in case) +#define DFL_PAGEENT_VAL 0x7FFFFC0000000000LL + +#define NUM_ROOTENT_PER_TBL 128 +#define NUM_DIRENT_PER_TBL 128 +#define NUM_PAGEENT_PER_TBL 64 + +/* unlike x86, the root/dir/page table sizes are different than B_PAGE_SIZE + * so we will have to fit more than one on a page to avoid wasting space. + * We will allocate a group of tables with the one we want inside, and + * add them from the aligned index needed, to make it easy to free them. + */ + +#define SIZ_ROOTTBL (128 * sizeof(page_root_entry)) +#define SIZ_DIRTBL (128 * sizeof(page_directory_entry)) +#define SIZ_PAGETBL (64 * sizeof(page_table_entry)) + +//#define NUM_ROOTTBL_PER_PAGE (B_PAGE_SIZE / SIZ_ROOTTBL) +#define NUM_DIRTBL_PER_PAGE (B_PAGE_SIZE / SIZ_DIRTBL) +#define NUM_PAGETBL_PER_PAGE (B_PAGE_SIZE / SIZ_PAGETBL) + +/* macros to get the physical page or table number and address of tables from + * descriptors */ +#if 0 +/* XXX: + suboptimal: + struct foo { + int a:2; + int b:30; + } v = {...}; + *(int *)0 = (v.b) << 2; + generates: + sarl $2, %eax + sall $2, %eax + We use a cast + bitmasking, since all address fields are already shifted +*/ +// from a root entry +#define PREA_TO_TA(a) ((a) << 4) +#define PREA_TO_PN(a) ((a) >> (12-4)) +#define PREA_TO_PA(a) ((a) << 4) +#define TA_TO_PREA(a) ((a) >> 4) +//... +#endif + +// TA: table address +// PN: page number +// PA: page address +// PO: page offset (offset of table in page) +// PI: page index (index of table relative to page start) + +// from a root entry +#define PRE_TO_TA(a) ((*(uint32 *)(&(a))) & ~((1<<4)-1)) +#define PRE_TO_PN(e) ((*(uint32 *)(&(e))) >> 12) +#define PRE_TO_PA(e) ((*(uint32 *)(&(e))) & ~((1<<12)-1)) +#define PRE_TO_PO(e) ((*(uint32 *)(&(e))) & ((1<<12)-1)) +#define PRE_TO_PI(e) (((*(uint32 *)(&(e))) & ((1<<12)-1)) / SIZ_DIRTBL) +#define TA_TO_PREA(a) ((a) >> 4) +// from a directory entry +#define PDE_TO_TA(a) ((*(uint32 *)(&(a))) & ~((1<<4)-1)) +#define PDE_TO_PN(e) ((*(uint32 *)(&(e))) >> 12) +#define PDE_TO_PA(e) ((*(uint32 *)(&(e))) & ~((1<<12)-1)) +#define PDE_TO_PO(e) ((*(uint32 *)(&(e))) & ((1<<12)-1)) +#define PDE_TO_PI(e) (((*(uint32 *)(&(e))) & ((1<<12)-1)) / SIZ_PAGETBL) +#define TA_TO_PDEA(a) ((a) >> 4) +// from a table entry +#define PTE_TO_TA(a) ((((uint32 *)(&(a)))[1]) & ~((1<<8)-1)) +#define PTE_TO_PN(e) ((((uint32 *)(&(e)))[1]) >> 12) +#define PTE_TO_PA(e) ((((uint32 *)(&(e)))[1]) & ~((1<<12)-1)) +#define TA_TO_PTEA(a) ((a) >> 8) +// from an indirect entry +#define PIE_TO_TA(a) ((((uint32 *)(&(a)))[1]) & ~((1<<2)-1)) +#define PIE_TO_PN(e) ((((uint32 *)(&(e)))[1]) >> 12) +#define PIE_TO_PA(e) ((((uint32 *)(&(e)))[1]) & ~((1<<12)-1)) +#define TA_TO_PIEA(a) ((a) >> 2) + + +#include "arch_vm_translation_map_impl.cpp" + +struct m68k_vm_ops m68030_vm_ops = { + m68k_translation_map_get_pgdir, + arch_vm_translation_map_init_map, + arch_vm_translation_map_init_kernel_map_post_sem, + arch_vm_translation_map_init, + arch_vm_translation_map_init_post_area, + arch_vm_translation_map_init_post_sem, + arch_vm_translation_map_early_map, + arch_vm_translation_map_early_query, +#if 0 + m68k_map_address_range, + m68k_unmap_address_range, + m68k_remap_address_range +#endif +}; Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_asm.S =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_asm.S 2007-11-03 21:02:03 UTC (rev 22821) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_asm.S 2007-11-03 21:04:42 UTC (rev 22822) @@ -14,184 +14,71 @@ // ToDo: fixme FUNCTION(reboot): - reset + reset /* void arch_int_enable_interrupts(void) */ FUNCTION(arch_int_enable_interrupts): - mfmsr %r3 // load msr + andi #0xf8ff,%sr + rts - li %r4, 1 - insrwi %r3, %r4, 1, 31 - MSR_EXCEPTIONS_ENABLED - // sets bit 15, EE - mtmsr %r3 // put it back into the msr - blr - - /* int arch_int_disable_interrupts(void) - * r3 */ FUNCTION(arch_int_disable_interrupts): - mfmsr %r4 // load msr + clr.l %d0 + move %sr,%d0 + move.l %d0,%d1 + ori.w #%x0700,%d1 + move %d1,%sr + // return value: previous IPM + lsr.l #8,%d0 + andi.l #7,%d0 + rts - mr %r3, %r4 // save old state - rlwinm %r4, %r4, 0, 32 - MSR_EXCEPTIONS_ENABLED, 30 - MSR_EXCEPTIONS_ENABLED - // clears bit 15, EE - mtmsr %r4 // put it back into the msr - blr - - /* void arch_int_restore_interrupts(int oldState) - * r3 */ FUNCTION(arch_int_restore_interrupts): - mfmsr %r4 + move.l (4,%a7),%d0 + // make sure we only have IPM bits + andi.w #7,%d0 + lsl.w #8,%d0 + move %sr,%d1 + andi.w #0xf8ff,%d1 + or.w %d0,%d1 + move %d1,%sr + rts - rlwimi %r4, %r3, 0, 31 - MSR_EXCEPTIONS_ENABLED, 31 - MSR_EXCEPTIONS_ENABLED - // clear or set bit 15, EE to the same state as in r3, oldState - mtmsr %r4 - blr - /* bool arch_int_are_interrupts_enabled(void) */ FUNCTION(arch_int_are_interrupts_enabled): - mfmsr %r3 // load msr - extrwi %r3, %r3, 1, 31 - MSR_EXCEPTIONS_ENABLED - // mask out the EE bit - blr + clr.l %d0 + move %sr,%d1 + andi.w 0x0700,%d1 + bne arch_int_are_interrupts_enabled_no + moveq.l #1,%d0 +arch_int_are_interrupts_enabled_no: + rts // ToDo: fixme FUNCTION(dbg_save_registers): - blr + rts + /* long long get_time_base(void) */ FUNCTION(get_time_base): -1: - mftbu %r3 // get the upper time base register - mftb %r4 // get the lower time base register - mftbu %r5 // get the upper again - cmpw %r5, %r3 // see if it changed while we were reading the lower - bne- 1b // if so, repeat - blr +#warning M68K: implement get_time_base! + clr.l %d0 + clr.l %d1 + //passed through a0 or d0:d1 ? + rts -/* void getibats(int bats[8]); */ -FUNCTION(getibats): - mfibatu %r0,0 - stw %r0,0(%r3) - mfibatl %r0,0 - stwu %r0,4(%r3) - mfibatu %r0,1 - stwu %r0,4(%r3) - mfibatl %r0,1 - stwu %r0,4(%r3) - mfibatu %r0,2 - stwu %r0,4(%r3) - mfibatl %r0,2 - stwu %r0,4(%r3) - mfibatu %r0,3 - stwu %r0,4(%r3) - mfibatl %r0,3 - stwu %r0,4(%r3) - blr -// void setibats(int bats[8]); -FUNCTION(setibats): - lwz %r0,0(%r3) - mtibatu 0,%r0 - isync - lwzu %r0,4(%r3) - mtibatl 0,%r0 - isync - lwzu %r0,4(%r3) - mtibatu 1,%r0 - isync - lwzu %r0,4(%r3) - mtibatl 1,%r0 - isync - lwzu %r0,4(%r3) - mtibatu 2,%r0 - isync - lwzu %r0,4(%r3) - mtibatl 2,%r0 - isync - lwzu %r0,4(%r3) - mtibatu 3,%r0 - isync - lwzu %r0,4(%r3) - mtibatl 3,%r0 - isync +// void m68k_context_switch(addr_t *old_sp, addr_t new_sp); +FUNCTION(m68k_context_switch): - blr - -// void getdbats(int bats[8]); -FUNCTION(getdbats): - mfdbatu %r0,0 - stw %r0,0(%r3) - mfdbatl %r0,0 - stwu %r0,4(%r3) - mfdbatu %r0,1 - stwu %r0,4(%r3) - mfdbatl %r0,1 - stwu %r0,4(%r3) - mfdbatu %r0,2 - stwu %r0,4(%r3) - mfdbatl %r0,2 - stwu %r0,4(%r3) - mfdbatu %r0,3 - stwu %r0,4(%r3) - mfdbatl %r0,3 - stwu %r0,4(%r3) - blr - -// void setdbats(int bats[8]); -FUNCTION(setdbats): - lwz %r0,0(%r3) - mtdbatu 0,%r0 - lwzu %r0,4(%r3) - mtdbatl 0,%r0 - lwzu %r0,4(%r3) - mtdbatu 1,%r0 - lwzu %r0,4(%r3) - mtdbatl 1,%r0 - lwzu %r0,4(%r3) - mtdbatu 2,%r0 - lwzu %r0,4(%r3) - mtdbatl 2,%r0 - lwzu %r0,4(%r3) - mtdbatu 3,%r0 - lwzu %r0,4(%r3) - mtdbatl 3,%r0 - sync - - blr - -// unsigned int gethid0(); -FUNCTION(gethid0): - mfspr %r3, 1008 - blr - -// void sethid0(unsigned int val); -FUNCTION(sethid0): - mtspr 1008, %r3 - blr - -// unsigned int getl2cr(); -FUNCTION(getl2cr): - mfspr %r3, 1017 - blr - -// void setl2cr(unsigned int val); -FUNCTION(setl2cr): - mtspr 1017, %r3 - blr - - -// void ppc_context_switch(addr_t *old_sp, addr_t new_sp); -FUNCTION(ppc_context_switch): - // regs to push on the stack: f13-f31, r13-r31, cr, r2, lr // push the old regs we need to save on the stack @@ -305,20 +192,20 @@ blr -// void ppc_switch_stack_and_call(addr_t newKstack, +// void m68k_switch_stack_and_call(addr_t newKstack, // void (*func)(void *), void *arg) -FUNCTION(ppc_switch_stack_and_call): +FUNCTION(m68k_switch_stack_and_call): mr %r1, %r3 // set the new stack pointer mtctr %r4 // move the target function into CTR mr %r3, %r5 // move the arg to this func to the new arg bctr -// ppc_kernel_thread_root(): parameters in r13-r15, the functions to call +// m68k_kernel_thread_root(): parameters in r13-r15, the functions to call // (in that order). The function is used when spawing threads. It usually calls // an initialization function, the actual thread function, and a function that // destroys the thread. -FUNCTION(ppc_kernel_thread_root): +FUNCTION(m68k_kernel_thread_root): mtlr %r13 blrl mtlr %r14 Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_atomic.c =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_atomic.c 2007-11-03 21:02:03 UTC (rev 22821) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_atomic.c 2007-11-03 21:04:42 UTC (rev 22822) @@ -1,4 +1,10 @@ /* + * Copyright 2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + * * Copyright 2003, Marcus Overhagen. All rights reserved. * Distributed under the terms of the OpenBeOS License. */ Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_cpu.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_cpu.cpp 2007-11-03 21:02:03 UTC (rev 22821) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_cpu.cpp 2007-11-03 21:04:42 UTC (rev 22822) @@ -1,4 +1,7 @@ /* + * Copyright 2007, Fran?ois Revol, revol at free.fr. + * Distributed under the terms of the MIT License. + * * Copyright 2003-2005, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * @@ -14,7 +17,17 @@ #include #include +extern struct m68k_cpu_ops cpu_ops_030; +extern struct m68k_cpu_ops cpu_ops_040; +extern struct m68k_cpu_ops cpu_ops_060; +struct m68k_cpu_ops cpu_ops; + +int cpu_type; +int fpu_type; +int mmu_type; +int platform; + status_t arch_cpu_preboot_init_percpu(kernel_args *args, int curr_cpu) { @@ -32,6 +45,47 @@ status_t arch_cpu_init(kernel_args *args) { + cpu_type = args->arch_args.cpu_type; + fpu_type = args->arch_args.fpu_type; + mmu_type = args->arch_args.mmu_type; + platform = args->arch_args.platform; + + switch (cpu_type) { + case CPU_68020: + case CPU_68030: + cpu_ops.flush_insn_pipeline = cpu_ops_030.flush_insn_pipeline; + cpu_ops.flush_atc_all = cpu_ops_030.flush_atc_all; + cpu_ops.flush_atc_user = cpu_ops_030.flush_atc_user; + cpu_ops.flush_atc_addr = cpu_ops_030.flush_atc_addr; + cpu_ops.flush_cache_line = cpu_ops_030.flush_cache_line; + cpu_ops.idle = cpu_ops_030.idle; // NULL + //cpu_ops. = cpu_ops_030.; + break; +#ifdef SUPPORTS_040 + case CPU_68040: + cpu_ops.flush_insn_pipeline = cpu_ops_040.flush_insn_pipeline; + cpu_ops.flush_atc_all = cpu_ops_040.flush_atc_all; + cpu_ops.flush_atc_user = cpu_ops_040.flush_atc_user; + cpu_ops.flush_atc_addr = cpu_ops_040.flush_atc_addr; + cpu_ops.flush_cache_line = cpu_ops_040.flush_cache_line; + cpu_ops.idle = cpu_ops_040.idle; // NULL + //cpu_ops. = cpu_ops_040.; + break; +#endif +#ifdef SUPPORTS_060 + case CPU_68060: + cpu_ops.flush_insn_pipeline = cpu_ops_060.flush_insn_pipeline; + cpu_ops.flush_atc_all = cpu_ops_060.flush_atc_all; + cpu_ops.flush_atc_user = cpu_ops_060.flush_atc_user; + cpu_ops.flush_atc_addr = cpu_ops_060.flush_atc_addr; + cpu_ops.flush_cache_line = cpu_ops_060.flush_cache_line; + cpu_ops.idle = cpu_ops_060.idle; + //cpu_ops. = cpu_ops_060.; + break; +#endif + default: + panic("unknown cpu_type 0x%08lx\n", args->arch_args.cpu_type); + } return B_OK; } @@ -48,53 +102,24 @@ return B_OK; } -#define CACHELINE 16 void arch_cpu_sync_icache(void *address, size_t len) { - int l, off; - char *p; - uint32 cacr; - - off = (unsigned int)address & (CACHELINE - 1); - len += off; - - l = len; - p = (char *)address - off; - asm volatile ("movec %%cacr,%0" : "=r"(cacr):); - cacr |= 0x00000004; /* ClearInstructionCacheEntry */ - do { - /* the 030 invalidates only 1 long of the cache line */ - //XXX: what about 040 and 060 ? - asm volatile ("movec %0,%%caar\n" \ - "movec %1,%%cacr\n" \ - "addq.l #4,%0\n" \ - "movec %0,%%caar\n" \ - "movec %1,%%cacr\n" \ - "addq.l #4,%0\n" \ - "movec %0,%%caar\n" \ - "movec %1,%%cacr\n" \ - "addq.l #4,%0\n" \ - "movec %0,%%caar\n" \ - "movec %1,%%cacr\n" \ - :: "r"(p), "r"(cacr)); - p += CACHELINE; - } while ((l -= CACHELINE) > 0); - m68k_nop(); + cpu_ops.flush_icache(address, len); } void arch_cpu_invalidate_TLB_range(addr_t start, addr_t end) { - m68k_nop(); + cpu_ops.flush_insn_pipeline(); while (start < end) { - pflush(start); - m68k_nop(); + cpu_ops.flush_atc_addr(start); + cpu_ops.flush_insn_pipeline(); start += B_PAGE_SIZE; } - m68k_nop(); + cpu_ops.flush_insn_pipeline(); } @@ -103,29 +128,30 @@ { int i; - m68k_nop(); + cpu_ops.flush_insn_pipeline(); for (i = 0; i < num_pages; i++) { - pflush(pages[i]); - m68k_nop(); + cpu_ops.flush_atc_addr(pages[i]); + cpu_ops.flush_insn_pipeline(); } - m68k_nop(); + cpu_ops.flush_insn_pipeline(); } void arch_cpu_global_TLB_invalidate(void) { - m68k_nop(); - pflusha(); - m68k_nop(); + cpu_ops.flush_insn_pipeline(); + cpu_ops.flush_atc_all(); + cpu_ops.flush_insn_pipeline(); } void arch_cpu_user_TLB_invalidate(void) { - // pflushfd ? - arch_cpu_global_TLB_invalidate(); + cpu_ops.flush_insn_pipeline(); + cpu_ops.flush_atc_user(); + cpu_ops.flush_insn_pipeline(); } @@ -224,6 +250,8 @@ void arch_cpu_idle(void) { + if (cpu_ops.idle) + cpu_ops.idle(); #warning M68K: use LPSTOP ? //asm volatile ("lpstop"); } Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp 2007-11-03 21:02:03 UTC (rev 22821) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp 2007-11-03 21:04:42 UTC (rev 22822) @@ -1,10 +1,11 @@ /* - * Copyright 2003-2006, Haiku Inc. All rights reserved. + * Copyright 2003-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Axel D?rfler * Ingo Weinhold + * Fran?ois Revol */ @@ -56,7 +57,8 @@ get_current_stack_frame() { stack_frame *frame; - asm volatile("mr %0, %%r1" : "=r"(frame)); +#warning M68K: a6 or a7 ? + asm volatile("move.l %%a6,%0" : "=r"(frame)); return frame; } @@ -69,7 +71,7 @@ // set fault handler, so that we can safely access user stacks if (thread) { - if (ppc_set_fault_handler(&thread->fault_handler, (addr_t)&&error)) + if (m68k_set_fault_handler(&thread->fault_handler, (addr_t)&&error)) goto error; } @@ -202,31 +204,23 @@ if (frame) { kprintf("iframe at %p\n", frame); - kprintf(" r0 0x%08lx r1 0x%08lx r2 0x%08lx r3 0x%08lx\n", - frame->r0, frame->r1, frame->r2, frame->r3); - kprintf(" r4 0x%08lx r5 0x%08lx r6 0x%08lx r7 0x%08lx\n", - frame->r4, frame->r5, frame->r6, frame->r7); - kprintf(" r8 0x%08lx r9 0x%08lx r10 0x%08lx r11 0x%08lx\n", - frame->r8, frame->r9, frame->r10, frame->r11); - kprintf(" r12 0x%08lx r13 0x%08lx r14 0x%08lx r15 0x%08lx\n", - frame->r12, frame->r13, frame->r14, frame->r15); - kprintf(" r16 0x%08lx r17 0x%08lx r18 0x%08lx r19 0x%08lx\n", - frame->r16, frame->r17, frame->r18, frame->r19); - kprintf(" r20 0x%08lx r21 0x%08lx r22 0x%08lx r23 0x%08lx\n", - frame->r20, frame->r21, frame->r22, frame->r23); - kprintf(" r24 0x%08lx r25 0x%08lx r26 0x%08lx r27 0x%08lx\n", - frame->r24, frame->r25, frame->r26, frame->r27); - kprintf(" r28 0x%08lx r29 0x%08lx r30 0x%08lx r31 0x%08lx\n", - frame->r28, frame->r29, frame->r30, frame->r31); - kprintf(" lr 0x%08lx cr 0x%08lx xer 0x%08lx ctr 0x%08lx\n", - frame->lr, frame->cr, frame->xer, frame->ctr); - kprintf("fpscr 0x%08lx\n", frame->fpscr); - kprintf(" srr0 0x%08lx srr1 0x%08lx dar 0x%08lx dsisr 0x%08lx\n", - frame->srr0, frame->srr1, frame->dar, frame->dsisr); - kprintf(" vector: 0x%lx\n", frame->vector); + kprintf(" d0 0x%08lx d1 0x%08lx d2 0x%08lx d3 0x%08lx\n", + frame->d0, frame->d1, frame->d2, frame->d3); + kprintf(" d4 0x%08lx d5 0x%08lx d6 0x%08lx d7 0x%08lx\n", + frame->d4, frame->d5, frame->d6, frame->d7); + kprintf(" a0 0x%08lx a1 0x%08lx a2 0x%08lx a3 0x%08lx\n", + frame->a0, frame->a1, frame->a2, frame->a3); + kprintf(" a4 0x%08lx a5 0x%08lx a6 0x%08lx a7 0x%08lx (sp)\n", + frame->a4, frame->a5, frame->a6, frame->a7); - print_stack_frame(thread, frame->srr0, framePointer, frame->r1); - framePointer = frame->r1; + /*kprintf(" pc 0x%08lx ccr 0x%02x\n", + frame->pc, frame->ccr);*/ + kprintf(" pc 0x%08lx sr 0x%04x\n", + frame->pc, frame->sr); +#warning M68K: missing regs + + print_stack_frame(thread, frame->pc, framePointer, frame->a6); + framePointer = frame->a6; } else { addr_t ip, nextFramePointer; Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_debug_console.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_debug_console.cpp 2007-11-03 21:02:03 UTC (rev 22821) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_debug_console.cpp 2007-11-03 21:04:42 UTC (rev 22822) @@ -1,4 +1,7 @@ /* + * Copyright 2007, Fran?ois Revol, revol at free.fr. + * Distributed under the terms of the MIT License. + * * Copyright 2003-2006, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_elf.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_elf.cpp 2007-11-03 21:02:03 UTC (rev 22821) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_elf.cpp 2007-11-03 21:04:42 UTC (rev 22822) @@ -1,4 +1,7 @@ /* + * Copyright 2007, Fran?ois Revol, revol at free.fr. + * Distributed under the terms of the MIT License. + * * Copyright 2005, Ingo Weinhold . * All rights reserved. Distributed under the terms of the MIT License. * @@ -7,6 +10,9 @@ * Distributed under the terms of the NewOS License. */ +#ifdef _BOOT_MODE +#include +#endif #include @@ -16,10 +22,15 @@ #define CHATTY 0 - +#ifdef _BOOT_MODE +status_t +boot_arch_elf_relocate_rel(struct preloaded_image *image, + struct Elf32_Rel *rel, int rel_len) +#else int arch_elf_relocate_rel(struct elf_image_info *image, const char *sym_prepend, struct elf_image_info *resolve_image, struct Elf32_Rel *rel, int rel_len) +#endif { // there are no rel entries in PPC elf return B_NO_ERROR; @@ -105,9 +116,15 @@ } +#ifdef _BOOT_MODE +status_t +boot_arch_elf_relocate_rela(struct preloaded_image *image, + struct Elf32_Rela *rel, int rel_len) +#else int arch_elf_relocate_rela(struct elf_image_info *image, const char *sym_prepend, struct elf_image_info *resolve_image, struct Elf32_Rela *rel, int rel_len) +#endif { int i; struct Elf32_Sym *sym; @@ -128,7 +145,7 @@ dprintf("arch_elf_relocate_rela(): Failed to get GOT address!\n"); \ return B_ERROR; \ } - + // TODO: Get the PLT address! #define REQUIRE_PLT \ if (L == 0) { \ @@ -172,12 +189,16 @@ case R_PPC_JMP_SLOT: sym = SYMBOL(image, ELF32_R_SYM(rel[i].r_info)); +#ifdef _BOOT_MODE + vlErr = boot_elf_resolve_symbol(image, sym, &S); +#else vlErr = elf_resolve_symbol(image, sym, resolve_image, sym_prepend, &S); +#endif [... truncated: 2432 lines follow ...] From axeld at mail.berlios.de Sun Nov 4 00:10:11 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 4 Nov 2007 00:10:11 +0100 Subject: [Haiku-commits] r22823 - in haiku/trunk: build/jam src/add-ons/kernel/drivers/network/via-rhine Message-ID: <200711032310.lA3NABmM015967@sheep.berlios.de> Author: axeld Date: 2007-11-04 00:10:10 +0100 (Sun, 04 Nov 2007) New Revision: 22823 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22823&view=rev Removed: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/cmd.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/entry.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/hook.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/mdio.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/pci.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/res.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/ring.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/util.c haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/via-rhine.h Modified: haiku/trunk/build/jam/NetBootArchive haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/Jamfile Log: * Replaced the VIA Rhine driver in the network boot archive as well. * Removed the old non-working VIA driver. Modified: haiku/trunk/build/jam/NetBootArchive =================================================================== --- haiku/trunk/build/jam/NetBootArchive 2007-11-03 21:04:42 UTC (rev 22822) +++ haiku/trunk/build/jam/NetBootArchive 2007-11-03 23:10:10 UTC (rev 22823) @@ -19,8 +19,8 @@ ipv4_datagram ; BEOS_NETWORK_PROTOCOLS = ipv4 tcp udp icmp ; -BEOS_ADD_ONS_DRIVERS_NET = etherpci ipro1000 rtl8139 rtl8169 sis900 - via-rhine wb840 net_stack vlance +BEOS_ADD_ONS_DRIVERS_NET = 3com etherpci ipro1000 rtl8139 rtl8169 sis900 + via_rhine wb840 net_stack vlance $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)isa ide scsi Modified: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/Jamfile 2007-11-03 21:04:42 UTC (rev 22822) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/Jamfile 2007-11-03 23:10:10 UTC (rev 22823) @@ -1,47 +1,4 @@ SubDir HAIKU_TOP src add-ons kernel drivers network via-rhine ; -SetSubDirSupportedPlatformsBeOSCompatible ; - -# set some additional flags -SubDirCcFlags -Wall ; - -# For ether_driver.h -UsePrivateHeaders net ; - -KernelAddon via-rhine : - entry.c - hook.c - cmd.c - mdio.c - pci.c - res.c - ring.c - util.c - ; - -# Package haiku-via-rhine-cvs : -# via-rhine : -# boot home config add-ons kernel drivers bin ; -# Package haiku-via-rhine-cvs : -# via-rhine : -# boot home config add-ons kernel drivers dev net ; - -Package haiku-networkingkit-cvs : - via-rhine : - boot home config add-ons kernel drivers bin ; -PackageDriverSymLink haiku-networkingkit-cvs : net via-rhine ; - - -# Installation - -HaikuInstall install-networking : /boot/home/config/add-ons/kernel/drivers/bin : - via-rhine -; - -HaikuInstallRelSymLink install-networking : /boot/home/config/add-ons/kernel/drivers/dev/net : - via-rhine : - installed-symlink -; - SubInclude HAIKU_TOP src add-ons kernel drivers network via-rhine dev ; SubInclude HAIKU_TOP src add-ons kernel drivers network via-rhine pci ; Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/cmd.c Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/entry.c Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/hook.c Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/mdio.c Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/pci.c Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/res.c Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/ring.c Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/util.c Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/via-rhine.h From axeld at mail.berlios.de Sun Nov 4 00:19:30 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 4 Nov 2007 00:19:30 +0100 Subject: [Haiku-commits] r22824 - in haiku/trunk/src/add-ons/kernel/drivers/network: . via_rhine via_rhine/dev via_rhine/dev/mii via_rhine/pci Message-ID: <200711032319.lA3NJUQm016723@sheep.berlios.de> Author: axeld Date: 2007-11-04 00:19:30 +0100 (Sun, 04 Nov 2007) New Revision: 22824 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22824&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/ Removed: haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/ Modified: haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/pci/Jamfile Log: Renamed via-rhine directory to via_rhine - that's how the driver is named now. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile 2007-11-03 23:10:10 UTC (rev 22823) +++ haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile 2007-11-03 23:19:30 UTC (rev 22824) @@ -8,7 +8,7 @@ SubInclude HAIKU_TOP src add-ons kernel drivers network rtl8169 ; SubInclude HAIKU_TOP src add-ons kernel drivers network sis900 ; SubInclude HAIKU_TOP src add-ons kernel drivers network stack ; -SubInclude HAIKU_TOP src add-ons kernel drivers network via-rhine ; +SubInclude HAIKU_TOP src add-ons kernel drivers network via_rhine ; SubInclude HAIKU_TOP src add-ons kernel drivers network vlance ; SubInclude HAIKU_TOP src add-ons kernel drivers network wb840 ; Copied: haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine (from rev 22823, haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine) Modified: haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/Jamfile 2007-11-03 23:10:10 UTC (rev 22823) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/Jamfile 2007-11-03 23:19:30 UTC (rev 22824) @@ -1,4 +1,4 @@ -SubDir HAIKU_TOP src add-ons kernel drivers network via-rhine ; +SubDir HAIKU_TOP src add-ons kernel drivers network via_rhine ; -SubInclude HAIKU_TOP src add-ons kernel drivers network via-rhine dev ; -SubInclude HAIKU_TOP src add-ons kernel drivers network via-rhine pci ; +SubInclude HAIKU_TOP src add-ons kernel drivers network via_rhine dev ; +SubInclude HAIKU_TOP src add-ons kernel drivers network via_rhine pci ; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/Jamfile 2007-11-03 23:10:10 UTC (rev 22823) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/Jamfile 2007-11-03 23:19:30 UTC (rev 22824) @@ -1,3 +1,3 @@ -SubDir HAIKU_TOP src add-ons kernel drivers network via-rhine dev ; +SubDir HAIKU_TOP src add-ons kernel drivers network via_rhine dev ; -SubInclude HAIKU_TOP src add-ons kernel drivers network via-rhine dev mii ; +SubInclude HAIKU_TOP src add-ons kernel drivers network via_rhine dev mii ; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/dev/mii/Jamfile 2007-11-03 23:10:10 UTC (rev 22823) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/Jamfile 2007-11-03 23:19:30 UTC (rev 22824) @@ -1,4 +1,4 @@ -SubDir HAIKU_TOP src add-ons kernel drivers network via-rhine dev mii ; +SubDir HAIKU_TOP src add-ons kernel drivers network via_rhine dev mii ; UsePrivateHeaders kernel net ; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/pci/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via-rhine/pci/Jamfile 2007-11-03 23:10:10 UTC (rev 22823) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/pci/Jamfile 2007-11-03 23:19:30 UTC (rev 22824) @@ -1,4 +1,4 @@ -SubDir HAIKU_TOP src add-ons kernel drivers network via-rhine pci ; +SubDir HAIKU_TOP src add-ons kernel drivers network via_rhine pci ; SubDirCcFlags -Wall ; From axeld at mail.berlios.de Sun Nov 4 15:21:12 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 4 Nov 2007 15:21:12 +0100 Subject: [Haiku-commits] r22825 - haiku/trunk/src/bin Message-ID: <200711041421.lA4ELCS6027647@sheep.berlios.de> Author: axeld Date: 2007-11-04 15:21:12 +0100 (Sun, 04 Nov 2007) New Revision: 22825 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22825&view=rev Modified: haiku/trunk/src/bin/listfont.cpp Log: * Applied our coding style. * Made output much more readable and useful (especially with 80 characters). * Removed useless -u option when built for Haiku. * Added a new option -t that shows the tunables. * Removed the hack to let be_app run - it works fine without on BeOS. * Improved parameter parsing (now uses getopt_long()), also added long names for all options. * I'm all for removing BeOS/Dano support completely from this app. Modified: haiku/trunk/src/bin/listfont.cpp =================================================================== --- haiku/trunk/src/bin/listfont.cpp 2007-11-03 23:19:30 UTC (rev 22824) +++ haiku/trunk/src/bin/listfont.cpp 2007-11-04 14:21:12 UTC (rev 22825) @@ -1,113 +1,165 @@ /* - * listfont - * (c) 2004, Fran?ois Revol. + * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2004, Fran?ois Revol. All rights reserved. + * Distributed under the terms of the MIT License. */ + +#include #include + #include #include #include -int32 th(void *) -{ - be_app->Lock(); - be_app->Run(); - return B_OK; -} -int usage(int ret) +static struct option const kLongOptions[] = { + {"styles", no_argument, 0, 's'}, + {"long", no_argument, 0, 'l'}, + {"tuned", no_argument, 0, 't'}, + {"help", no_argument, 0, 'h'}, + {NULL} +}; + +extern const char *__progname; +static const char *sProgramName = __progname; + + +void +usage(void) { - printf("listfont [-s] [-l]\n"); + printf("%s [-s] [-l]\n", sProgramName); printf("lists currently installed font families.\n"); - printf("\t-s list styles for each family\n"); - printf("\t-l long listing with more info\n"); - printf("\t-u update font families\n"); - return ret; + printf("\t-s --styles list styles for each family\n"); + printf("\t-l --long long listing with more info (spacing, encoding,\n" + "\t\t\theight (ascent/descent/leading), ...)\n"); + printf("\t-t --tuned display tuned fonts\n"); +#ifndef __HAIKU__ + printf("\t-u update font families\n"); +#endif } -int main(int argc, char **argv) + +int +main(int argc, char **argv) { - int32 family_count, f; - font_family family; - int32 style_count, s; - font_style style; - uint16 face; - uint32 flags; - int i; - bool display_styles = false; - bool display_long = false; - bool update_families = false; - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-u")) - update_families = true; - else if (!strcmp(argv[i], "-s")) - display_styles = true; - else if (!strcmp(argv[i], "-l")) { - display_long = true; - display_styles = true; - } else - return usage(1); + // parse command line parameters + + bool displayStyles = false; + bool displayLong = false; + bool displayTuned = false; +#ifndef __HAIKU__ + bool updateFamilies = false; +#endif + + int c; + while ((c = getopt_long(argc, argv, "sltuh", kLongOptions, NULL)) != -1) { + switch (c) { + case 0: + break; + case 'h': + usage(); + return 0; + default: + usage(); + return 1; + + case 't': + displayTuned = true; + case 'l': + displayLong = true; + case 's': + displayStyles = true; + break; +#ifndef __HAIKU__ + case 'u': + updateFamilies = true; + break; +#endif + } } - BApplication app("application/x-vnd.mmu_man.listfont"); - resume_thread(spawn_thread(th, "be_app", B_NORMAL_PRIORITY, NULL)); - be_app->Unlock(); - if (update_families) { + + BApplication app("application/x-vnd.Haiku-listfont"); + +#ifndef __HAIKU__ + if (updateFamilies) { bool changed = update_font_families(true); - printf("font families %schanged.\n", changed?"":"didn't "); + printf("font families %s.\n", changed ? "changed" : "did not change"); return 0; } - family_count = count_font_families(); - for (f = 0; f < family_count; f++) { +#endif + + int32 familyCount = count_font_families(); + + if (displayLong) { + printf("name/style face spc. enc. " + "height (a, d, l) flags\n\n"); + } + + for (int32 f = 0; f < familyCount; f++) { + font_family family; if (get_font_family(f, &family) < B_OK) continue; - if (!display_styles) { + if (!displayStyles) { printf("%s\n", family); continue; } - style_count = count_font_styles(family); - for (s = 0; s < style_count; s++) { + + int32 styleCount = count_font_styles(family); + + for (int32 s = 0; s < styleCount; s++) { + font_style style; + uint16 face; + uint32 flags; if (get_font_style(family, s, &style, &face, &flags) < B_OK) continue; - if (!display_long) { + + if (!displayLong) { printf("%s/%s\n", family, style); continue; } - BString fname; - fname << family << "/" << style; - printf("%-30s", fname.String()); - BFont fnt; - fnt.SetFamilyAndStyle(family, style); - //fnt.PrintToStream(); - printf("\tface=%08x ", face); + + BString fontName; + fontName << family << "/" << style; + printf("%-37s", fontName.String()); + + BFont font; + font.SetFamilyAndStyle(family, style); + printf(" 0x%02x %-4d %-4d", face, font.Spacing(), font.Encoding()); + font_height fh; - fnt.GetHeight(&fh); - printf("\theight={%f %f %f} ", fh.ascent, fh.descent, fh.leading); - printf("\t%s", (flags & B_IS_FIXED)?"fixed ":""); -#ifndef B_BEOS_VERSION_DANO + font.GetHeight(&fh); + printf(" %5.2f, %4.2f, %4.2f ", fh.ascent, fh.descent, fh.leading); + if ((flags & B_IS_FIXED) != 0) + printf("fixed"); + +#if B_BEOS_VERSION == B_BEOS_VERSION_5 /* seems R5 is broken there :-( locks up on 'a> recv' */ - printf("\t%s", (flags & B_HAS_TUNED_FONT)?"hastuned ":""); + printf("\t%s", (flags & B_HAS_TUNED_FONT) != 0 ? "hastuned " : ""); #else - if (flags & B_HAS_TUNED_FONT) { - int32 tunedcount = fnt.CountTuned(); - printf("%ld tuned: ", tunedcount); -//puts(""); -#if 1 - for (i = 0; i < tunedcount; i++) { - tuned_font_info tfi; - fnt.GetTunedInfo(i, &tfi); - printf("{%f, %f, %f, %08lx, %x} ", tfi.size, tfi.shear, tfi.rotation, tfi.flags, tfi.face); -//puts(""); + if ((flags & B_HAS_TUNED_FONT) != 0) { + if (displayTuned) + printf("\n "); + else if ((flags & B_IS_FIXED) != 0) + printf(", "); + + int32 tunedCount = font.CountTuned(); + printf("%ld tuned", tunedCount); + + if (displayTuned) { + printf(":"); + for (int32 i = 0; i < tunedCount; i++) { + tuned_font_info info; + font.GetTunedInfo(i, &info); + printf("\n\t(size %4.1f, shear %5.3f, rot. %5.3f, flags 0x%lx, face 0x%x)", + info.size, + info.shear, info.rotation, info.flags, info.face); + } } -#endif } #endif - //printf("\tFlags=%08lx ", fnt.Flags()); - printf("\tspacing=%d ", fnt.Spacing()); - printf("\tencoding=%d ", fnt.Encoding()); - puts(""); + putchar('\n'); } } - be_app->Lock(); - be_app->Quit(); return 0; } From bga at mail.berlios.de Sun Nov 4 18:17:42 2007 From: bga at mail.berlios.de (bga at BerliOS) Date: Sun, 4 Nov 2007 18:17:42 +0100 Subject: [Haiku-commits] r22826 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711041717.lA4HHgDI005462@sheep.berlios.de> Author: bga Date: 2007-11-04 18:17:41 +0100 (Sun, 04 Nov 2007) New Revision: 22826 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22826&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/device.c Log: First cut at a fix to the FreeBSD rtl9139 driver. Some drivers require softc to be initialized when probe(0 is called. The driver now loads and works for a while until it hangs. Looking into it. Modified: haiku/trunk/src/libs/compat/freebsd_network/device.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-04 14:21:12 UTC (rev 22825) +++ haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-04 17:17:41 UTC (rev 22826) @@ -390,6 +390,15 @@ memset(&fakeDevice, 0, sizeof(struct device)); + // Some drivers, like the rtl8139 one require softc to be initialized + // before probe() is called. + // TODO(bga): Check if the fact that whatever initialization that is + // made here is essential as fakeDevice is local to this function and + // ceases to exist after we return. + DEVNET(&fakeDevice)->softc = malloc(driver->softc_size); + if (DEVNET(&fakeDevice)->softc == NULL) + return B_NO_MEMORY; + for (i = 0; gPci->get_nth_pci_info(i, &fakeDevice.pci_info) == B_OK; i++) { int result; result = probe(DEVNET(&fakeDevice)); @@ -399,6 +408,9 @@ if (DEVNET(&fakeDevice)->flags & DEVICE_DESC_ALLOCED) free((char *)DEVNET(&fakeDevice)->description); put_module(B_PCI_MODULE_NAME); + + // Clean up softc. + free(DEVNET(&fakeDevice)->softc); return B_OK; } } @@ -406,6 +418,9 @@ dprintf("%s: no hardware found.\n", gDriverName); put_module(B_PCI_MODULE_NAME); + // Clean up softc. + free(DEVNET(&fakeDevice)->softc); + return B_ERROR; } From bonefish at mail.berlios.de Sun Nov 4 18:43:45 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 Nov 2007 18:43:45 +0100 Subject: [Haiku-commits] r22827 - haiku/trunk/headers/posix Message-ID: <200711041743.lA4HhjBH004881@sheep.berlios.de> Author: bonefish Date: 2007-11-04 18:43:44 +0100 (Sun, 04 Nov 2007) New Revision: 22827 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22827&view=rev Modified: haiku/trunk/headers/posix/signal.h Log: Removed inline versions of sigismember(), sigaddset(), and sigdelset(). They weren't in sync with the non-inline version in libroot anymore, and aren't really performance-critical anyway. Modified: haiku/trunk/headers/posix/signal.h =================================================================== --- haiku/trunk/headers/posix/signal.h 2007-11-04 17:17:41 UTC (rev 22826) +++ haiku/trunk/headers/posix/signal.h 2007-11-04 17:43:44 UTC (rev 22827) @@ -173,27 +173,6 @@ /* pthread extension : equivalent of sigprocmask() */ int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset); -extern inline int -sigismember(const sigset_t *set, int sig) -{ - sigset_t mask = (((sigset_t) 1) << (( sig ) - 1)) ; - return (*set & mask) ? 1 : 0 ; -} - -extern inline int -sigaddset(sigset_t *set, int sig) -{ - sigset_t mask = (((sigset_t) 1) << (( sig ) - 1)) ; - return ((*set |= mask), 0) ; -} - -extern inline int -sigdelset(sigset_t *set, int sig) -{ - sigset_t mask = (((sigset_t) 1) << (( sig ) - 1)) ; - return ((*set &= ~mask), 0) ; -} - #ifdef __cplusplus } #endif From bonefish at mail.berlios.de Sun Nov 4 18:46:09 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 Nov 2007 18:46:09 +0100 Subject: [Haiku-commits] r22828 - in haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces: . signal Message-ID: <200711041746.lA4Hk9JY007959@sheep.berlios.de> Author: bonefish Date: 2007-11-04 18:46:08 +0100 (Sun, 04 Nov 2007) New Revision: 22828 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22828&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/3-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/5-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/Jamfile Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile Log: Patch by Vasilis Kaoutsis: Added tests for signal(). Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-11-04 17:43:44 UTC (rev 22827) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-11-04 17:46:08 UTC (rev 22828) @@ -9,4 +9,5 @@ SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_setspecific ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigignore ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigprocmask ; +SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces signal ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigsuspend ; Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/1-1.c 2007-11-04 17:43:44 UTC (rev 22827) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/1-1.c 2007-11-04 17:46:08 UTC (rev 22828) @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that the default handling of the + signal shall occur if the value of the func parameter is SIG_DFL. + + How this program tests this assertion by setting up a handler + "myhandler" for SIGCHLD. Then another call to signal() is made about + SIGCHLD, this time with SIG_DFL as the value of the func parameter. + The default action for SIGCHLD is to be ignored, so unless myhandler + gets called when SIGCHLD is raised, the test passess, otherwise + returns failure. + +*/ + +#include +#include +#include +#include "posixtest.h" + +int handler_called = 0; + +void myhandler(int signo) +{ + printf("SIGCHLD called. Inside handler\n"); + handler_called = 1; +} + +int main() +{ + if (signal(SIGCHLD, myhandler) == SIG_ERR) { + perror("Unexpected error while using signal()"); + return PTS_UNRESOLVED; + } + + if (signal(SIGCHLD,SIG_DFL) != myhandler) { + perror("Unexpected error while using signal()"); + return PTS_UNRESOLVED; + } + + raise(SIGCHLD); + + if (handler_called == 1) { + printf("Test FAILED: handler was called even though default was expected\n"); + return PTS_FAIL; + } + printf("signal(): Test passed\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/2-1.c 2007-11-04 17:43:44 UTC (rev 22827) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/2-1.c 2007-11-04 17:46:08 UTC (rev 22828) @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that the signal shall be ignored + if the value of the func parameter is SIG_IGN. + + How this program tests this assertion is by setting up a handler + "myhandler" for SIGCHLD. Then another call to signal() is made about + SIGCHLD, this time with SIG_IGN as the value of the func parameter. + SIGCHLD should be ignored now, so unless myhandler gets called when + SIGCHLD is raised, the test passes, otherwise returns failure. + +*/ + +#include +#include +#include +#include "posixtest.h" + +int handler_called = 0; + +void myhandler(int signo) +{ + printf("SIGCHLD called. Inside handler\n"); + handler_called = 1; +} + +int main() +{ + if (signal(SIGCHLD, myhandler) == SIG_ERR) { + perror("Unexpected error while using signal()"); + return PTS_UNRESOLVED; + } + + if (signal(SIGCHLD,SIG_IGN) != myhandler) { + perror("Unexpected error while using signal()"); + return PTS_UNRESOLVED; + } + + raise(SIGCHLD); + + if (handler_called == 1) { + printf("Test FAILED: handler was called even though default was expected\n"); + return PTS_FAIL; + } + printf("signal(): Test passed\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/3-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/3-1.c 2007-11-04 17:43:44 UTC (rev 22827) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/3-1.c 2007-11-04 17:46:08 UTC (rev 22828) @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that the signal shall be ignored + if the value of the func parameter is SIG_IGN. + + How this program tests this assertion is by setting up a handler + "myhandler" for SIGCHLD, and then raising that signal. If the + handler_called variable is anything but 1, then fail, otherwise pass. + +*/ + +#include +#include +#include +#include "posixtest.h" + +int handler_called = 0; + +void myhandler(int signo) +{ + printf("SIGCHLD called. Inside handler\n"); + handler_called = 1; +} + +int main() +{ + if (signal(SIGCHLD, myhandler) == SIG_ERR) { + perror("Unexpected error while using signal()"); + return PTS_UNRESOLVED; + } + + raise(SIGCHLD); + + if (handler_called != 1) { + printf("Test FAILED: handler was called even though default was expected\n"); + return PTS_FAIL; + } + printf("signal(): Test passed\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/5-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/5-1.c 2007-11-04 17:43:44 UTC (rev 22827) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/5-1.c 2007-11-04 17:46:08 UTC (rev 22828) @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that the signal function shall return + the function name of the last signal handler that was associated with + sig. + + How this program tests this assertion is by setting up handlers + SIGUSR1_handler and SIGUSR2_handler for signals SIGUSR1 and SIGUSR2 + respectively. A third call to signal() is made regarding signal SIGUSR1. + If this call returns anything but SIGUSR1_handler, fail the test, + otherwise the test passes. + +*/ + +#include +#include +#include +#include "posixtest.h" + +void SIGUSR1_handler(int signo) +{ + printf("do nothing useful\n"); +} + +void SIGUSR2_handler(int signo) +{ + printf("do nothing useful\n"); +} + +int main() +{ + if (signal(SIGUSR1, SIGUSR1_handler) == SIG_ERR) { + perror("Unexpected error while using signal()"); + return PTS_UNRESOLVED; + } + + if (signal(SIGUSR2, SIGUSR2_handler) == SIG_ERR) { + perror("Unexpected error while using signal()"); + return PTS_UNRESOLVED; + } + + if (signal(SIGUSR1,SIG_IGN) != SIGUSR1_handler) { + printf("signal did not return the last handler that was associated with SIGUSR1\n"); + return PTS_FAIL; + } + printf("signal(): Test passed\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c 2007-11-04 17:43:44 UTC (rev 22827) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c 2007-11-04 17:46:08 UTC (rev 22828) @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that signal() shall return SIG_ERR + and set errno to a positive value if an invalid signal number was + passed to it. + +*/ + +#include +#include +#include +#include +#include "posixtest.h" + +void myhandler(int signo) +{ + printf("handler does nothing useful.\n"); +} + +int main() +{ + errno = -1; + + if (signal(-1, myhandler) != SIG_ERR) { + printf("Test FAILED: signal() didn't return SIG_ERR even though invalid signal number was passed to it\n"); + return PTS_FAIL; + } + + if (errno <= 0) { + printf("Test FAILED: errno wasn't set to a positive number even though invalid signal number was passed to the signal() function\n"); + return PTS_FAIL; + } + printf("signal(): Test passed\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c 2007-11-04 17:43:44 UTC (rev 22827) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c 2007-11-04 17:46:08 UTC (rev 22828) @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that signal() shall return SIG_ERR + and set errno to a positive value if an invalid signal number was + passed to it. + +*/ + +#include +#include +#include +#include +#include "posixtest.h" + +void myhandler(int signo) +{ + printf("handler does nothing useful.\n"); +} + +int main() +{ + errno = -1; + + if (signal(SIGKILL, myhandler) != SIG_ERR) { + printf("Test FAILED: signal() didn't return SIG_ERR even though a non-catchable signal was passed to it\n"); + return PTS_FAIL; + } + + if (errno <= 0) { + printf("Test FAILED: errno wasn't set to a positive number even though a non-catchable signal was passed to the signal() function\n"); + return PTS_FAIL; + } + printf("signal(): Test passed\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/Jamfile 2007-11-04 17:43:44 UTC (rev 22827) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/Jamfile 2007-11-04 17:46:08 UTC (rev 22828) @@ -0,0 +1,10 @@ +SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces signal ; + +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ; + +SimpleTest signal_1-1 : 1-1.c ; +SimpleTest signal_2-1 : 2-1.c ; +SimpleTest signal_3-1 : 3-1.c ; +SimpleTest signal_5-1 : 5-1.c ; +SimpleTest signal_6-1 : 6-1.c ; +SimpleTest signal_7-1 : 7-1.c ; From bga at mail.berlios.de Sun Nov 4 18:46:29 2007 From: bga at mail.berlios.de (bga at BerliOS) Date: Sun, 4 Nov 2007 18:46:29 +0100 Subject: [Haiku-commits] r22829 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci Message-ID: <200711041746.lA4HkT5e008495@sheep.berlios.de> Author: bga Date: 2007-11-04 18:46:28 +0100 (Sun, 04 Nov 2007) New Revision: 22829 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22829&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c Log: Added miibus initialization. The driver now seems to work flawleslly. Please test and report problems. Comming up next, enabling it by default. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c 2007-11-04 17:46:08 UTC (rev 22828) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c 2007-11-04 17:46:28 UTC (rev 22829) @@ -5,8 +5,18 @@ HAIKU_FBSD_DRIVER_GLUE(rtl8139exp, rl, pci); HAIKU_DRIVER_REQUIREMENTS(0); -HAIKU_FBSD_MII_DRIVER(rlphy); +extern driver_t *DRIVER_MODULE_NAME(rlphy, miibus); +driver_t * +__haiku_select_miibus_driver(device_t dev) +{ + driver_t *drivers[] = { + DRIVER_MODULE_NAME(rlphy, miibus) + }; + + return __haiku_probe_miibus(dev, drivers, 1); +} + int HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev) { struct rl_softc *sc = device_get_softc(dev); From bonefish at mail.berlios.de Sun Nov 4 18:48:57 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 Nov 2007 18:48:57 +0100 Subject: [Haiku-commits] r22830 - haiku/trunk/src/system/libroot/posix/signal Message-ID: <200711041748.lA4Hmvce011049@sheep.berlios.de> Author: bonefish Date: 2007-11-04 18:48:49 +0100 (Sun, 04 Nov 2007) New Revision: 22830 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22830&view=rev Modified: haiku/trunk/src/system/libroot/posix/signal/sigignore.cpp Log: Patch by Vasilis Kaoutsis: Removed redundant parameter check (sigaction() does it anyway). Modified: haiku/trunk/src/system/libroot/posix/signal/sigignore.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/signal/sigignore.cpp 2007-11-04 17:46:28 UTC (rev 22829) +++ haiku/trunk/src/system/libroot/posix/signal/sigignore.cpp 2007-11-04 17:48:49 UTC (rev 22830) @@ -4,23 +4,12 @@ */ -#include #include -#include - int sigignore(int signal) { - // check for invalid signals or for signals - // that can not be ignored (SIGKILL, SIGSTOP) - if (signal <= 0 || signal >= NSIG || signal == SIGKILL - || signal == SIGSTOP) { - errno = EINVAL; - return -1; - } - struct sigaction ignoreSignalAction; // create an action to ignore the signal From superstippi at gmx.de Sun Nov 4 19:37:07 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 04 Nov 2007 19:37:07 +0100 Subject: [Haiku-commits] r22829 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci In-Reply-To: <200711041746.lA4HkT5e008495@sheep.berlios.de> References: <200711041746.lA4HkT5e008495@sheep.berlios.de> Message-ID: <20071104193707.692.1@stippis.WG> bga at BerliOS wrote (2007-11-04, 18:46:29 [+0100]): > Author: bga > Date: 2007-11-04 18:46:28 +0100 (Sun, 04 Nov 2007) New Revision: 22829 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22829&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c > Log: > Added miibus initialization. The driver now seems to work flawleslly. > Please test and report problems. Comming up next, enabling it by default. Very cool, BGA! This is _very_ common hardware. I think every PC I have built for other people to run BeOS has one of these boards, including all the PCs running eXposer at my former film school. :-) Best regards, -Stephan From axeld at pinc-software.de Sun Nov 4 20:15:52 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 04 Nov 2007 20:15:52 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r22829_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/drivers/network/rtl8139/pci?= In-Reply-To: <200711041746.lA4HkT5e008495@sheep.berlios.de> Message-ID: <25034777361-BeMail@zon> bga at BerliOS wrote: > -HAIKU_FBSD_MII_DRIVER(rlphy); > +extern driver_t *DRIVER_MODULE_NAME(rlphy, miibus); > > +driver_t * > +__haiku_select_miibus_driver(device_t dev) > +{ > + driver_t *drivers[] = { > + DRIVER_MODULE_NAME(rlphy, miibus) > + }; > + > + return __haiku_probe_miibus(dev, drivers, 1); > +} Oh, then there is probably something wrong with the layer, as the HAIKU_FBSD_MII_DRIVER() macro should have expanded to that code exactly. I'll have a look. Bye, Axel. From bga at bug-br.org.br Sun Nov 4 21:24:11 2007 From: bga at bug-br.org.br (Bruno G. Albuquerque) Date: Sun, 04 Nov 2007 18:24:11 -0200 EDT Subject: [Haiku-commits] r22829 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci In-Reply-To: <25034777361-BeMail@zon> Message-ID: <9870592410-BeMail@guglielmo> On Sun, 04 Nov 2007 20:15:52 +0100 CET, Axel D?rfler said: > > -HAIKU_FBSD_MII_DRIVER(rlphy); > > +extern driver_t *DRIVER_MODULE_NAME(rlphy, miibus); > > > > +driver_t * > > +__haiku_select_miibus_driver(device_t dev) > > +{ > > + driver_t *drivers[] = { > > + DRIVER_MODULE_NAME(rlphy, miibus) > > + }; > > + > > + return __haiku_probe_miibus(dev, drivers, 1); > > +} > > Oh, then there is probably something wrong with the layer, as the > HAIKU_FBSD_MII_DRIVER() macro should have expanded to that code > exactly. I'll have a look. Yep, that's exactly what I thought. Replacing it by the expanded code was just a "what if" attempt so I am not sure why it worked, but it did. I am still investigating. -Bruno -- Fortune Cookie Says: After a number of decimal places, nobody gives a damn. From revol at free.fr Sun Nov 4 18:10:28 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 04 Nov 2007 18:10:28 +0100 CET Subject: [Haiku-commits] r22825 - haiku/trunk/src/bin In-Reply-To: <200711041421.lA4ELCS6027647@sheep.berlios.de> Message-ID: <372983889-BeMail@laptop> > Modified: > haiku/trunk/src/bin/listfont.cpp > Log: > * Applied our coding style. Cool now I have a good example to study ;) > * Made output much more readable and useful (especially with 80 > characters). > * Removed useless -u option when built for Haiku. > * Added a new option -t that shows the tunables. > * Removed the hack to let be_app run - it works fine without on BeOS. > * Improved parameter parsing (now uses getopt_long()), also added > long names > for all options. Thanks :) > * I'm all for removing BeOS/Dano support completely from this app. It's probably ok to remove it, it'll be kept in the history anyway. Fran?ois. From bonefish at mail.berlios.de Mon Nov 5 01:30:15 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 5 Nov 2007 01:30:15 +0100 Subject: [Haiku-commits] r22831 - in haiku/trunk: headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager Message-ID: <200711050030.lA50UFLC002913@sheep.berlios.de> Author: bonefish Date: 2007-11-05 01:30:14 +0100 (Mon, 05 Nov 2007) New Revision: 22831 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22831&view=rev Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp Log: Added IsBusy(bool) version, which optionally also checks the descendants. Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-11-04 17:48:49 UTC (rev 22830) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-11-05 00:30:14 UTC (rev 22831) @@ -52,6 +52,7 @@ void SetBusy(bool busy); bool IsBusy() const; + bool IsBusy(bool includeDescendants); bool CheckAndMarkBusy(bool includeDescendants); void UnmarkBusy(bool includeDescendants); Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2007-11-04 17:48:49 UTC (rev 22830) +++ haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2007-11-05 00:30:14 UTC (rev 22831) @@ -247,23 +247,32 @@ } +// IsBusy +bool +KPartition::IsBusy(bool includeDescendants) +{ + if (!includeDescendants) + return IsBusy(); + + struct IsBusyVisitor : KPartitionVisitor { + virtual bool VisitPre(KPartition* partition) + { + return partition->IsBusy(); + } + } checkVisitor; + + return VisitEachDescendant(&checkVisitor) != NULL; +} + + // CheckAndMarkBusy bool KPartition::CheckAndMarkBusy(bool includeDescendants) { + if (IsBusy(includeDescendants)) + return false; + if (includeDescendants) { - // check - struct IsBusyVisitor : KPartitionVisitor { - virtual bool VisitPre(KPartition* partition) - { - return partition->IsBusy(); - } - } checkVisitor; - - if (VisitEachDescendant(&checkVisitor)) - return false; - - // mark busy struct MarkBusyVisitor : KPartitionVisitor { virtual bool VisitPre(KPartition* partition) { @@ -273,12 +282,8 @@ } markVisitor; VisitEachDescendant(&markVisitor); - } else { - if (IsBusy()) - return false; - + } else SetBusy(true); - } return true; } @@ -1014,65 +1019,78 @@ return fChangeCounter; } + // UninitializeContents status_t KPartition::UninitializeContents(bool logChanges) { if (DiskSystem()) { uint32 flags = B_PARTITION_CHANGED_INITIALIZATION - | B_PARTITION_CHANGED_CONTENT_TYPE - | B_PARTITION_CHANGED_STATUS - | B_PARTITION_CHANGED_FLAGS; + | B_PARTITION_CHANGED_CONTENT_TYPE + | B_PARTITION_CHANGED_STATUS + | B_PARTITION_CHANGED_FLAGS; + // children if (CountChildren() > 0) { if (!RemoveAllChildren()) return B_ERROR; flags |= B_PARTITION_CHANGED_CHILDREN; } + // volume if (VolumeID() >= 0) { +// TODO: Unmount? SetVolumeID(-1); flags |= B_PARTITION_CHANGED_VOLUME; } + // content name if (ContentName()) { SetContentName(NULL); flags |= B_PARTITION_CHANGED_CONTENT_NAME; } + // content parameters if (ContentParameters()) { SetContentParameters(NULL); flags |= B_PARTITION_CHANGED_CONTENT_PARAMETERS; } + // content size if (ContentSize() > 0) { SetContentSize(0); flags |= B_PARTITION_CHANGED_CONTENT_SIZE; } + // block size if (Parent() && Parent()->BlockSize() != BlockSize()) { SetBlockSize(Parent()->BlockSize()); flags |= B_PARTITION_CHANGED_BLOCK_SIZE; } + // disk system DiskSystem()->FreeContentCookie(this); SetDiskSystem(NULL); + // status SetStatus(B_PARTITION_UNINITIALIZED); + // flags ClearFlags(B_PARTITION_FILE_SYSTEM | B_PARTITION_PARTITIONING_SYSTEM); if (!Device()->IsReadOnlyMedia()) ClearFlags(B_PARTITION_READ_ONLY); + // log changes if (logChanges) { Changed(flags, B_PARTITION_CHANGED_DEFRAGMENTATION - | B_PARTITION_CHANGED_CHECK - | B_PARTITION_CHANGED_REPAIR); + | B_PARTITION_CHANGED_CHECK | B_PARTITION_CHANGED_REPAIR); } } + return B_OK; } + // SetAlgorithmData void KPartition::SetAlgorithmData(uint32 data) From bonefish at mail.berlios.de Mon Nov 5 01:42:48 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 5 Nov 2007 01:42:48 +0100 Subject: [Haiku-commits] r22832 - in haiku/trunk: headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager Message-ID: <200711050042.lA50gmPw003277@sheep.berlios.de> Author: bonefish Date: 2007-11-05 01:42:47 +0100 (Mon, 05 Nov 2007) New Revision: 22832 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22832&view=rev Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp haiku/trunk/src/system/kernel/disk_device_manager/KFileSystem.cpp haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp Log: * Added back and partially reimplemented the K{Disk,File,Partitioning}System writing methods. It is now required that the caller has marked the concerned partitions busy, hence we can (read-)access them without needing a lock. The module interfaces will will be changed to take advantage of the fact as well. The methods take a disk_job_id instead of a KDiskDeviceJob* now, though I haven't quite decided, whether we need it at all or just want to add a special handling in the cases where notifications during the operation make sense. * Reimplemented the disk device write support syscalls (save _user_move_partition() for which other module hooks are needed). They call the KDiskSystem methods, now. Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h 2007-11-05 00:30:14 UTC (rev 22831) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h 2007-11-05 00:42:47 UTC (rev 22832) @@ -3,114 +3,116 @@ * Distributed under the terms of the MIT License. * * Authors: - * Ingo Weinhold + * Ingo Weinhold */ #ifndef _K_DISK_DEVICE_SYSTEM_H #define _K_DISK_DEVICE_SYSTEM_H #include "disk_device_manager.h" + struct user_disk_system_info; + namespace BPrivate { namespace DiskDevice { -//class KDiskDeviceJob; + class KPartition; + //! \brief Common ancestor for disk system add-on wrappers class KDiskSystem { public: - KDiskSystem(const char *name); - virtual ~KDiskSystem(); + KDiskSystem(const char *name); + virtual ~KDiskSystem(); - virtual status_t Init(); + virtual status_t Init(); -// void SetID(disk_system_id id); - disk_system_id ID() const; - const char *Name() const; - const char *PrettyName(); - uint32 Flags() const; +// void SetID(disk_system_id id); + disk_system_id ID() const; - bool IsFileSystem() const; - bool IsPartitioningSystem() const; + const char* Name() const; + const char* PrettyName(); + uint32 Flags() const; - void GetInfo(user_disk_system_info *info); + bool IsFileSystem() const; + bool IsPartitioningSystem() const; + void GetInfo(user_disk_system_info* info); + // manager will be locked - status_t Load(); // load/unload -- can be nested - void Unload(); // - bool IsLoaded() const; + status_t Load(); // load/unload -- can be nested + void Unload(); // + bool IsLoaded() const; // Scanning // Device must be write locked. - virtual float Identify(KPartition *partition, void **cookie); - virtual status_t Scan(KPartition *partition, void *cookie); - virtual void FreeIdentifyCookie(KPartition *partition, void *cookie); - virtual void FreeCookie(KPartition *partition); - virtual void FreeContentCookie(KPartition *partition); + virtual float Identify(KPartition* partition, void** cookie); + virtual status_t Scan(KPartition* partition, void* cookie); + virtual void FreeIdentifyCookie(KPartition* partition, + void* cookie); + virtual void FreeCookie(KPartition* partition); + virtual void FreeContentCookie(KPartition* partition); // Writing - // Device should not be locked. + // Device should not be locked, but all affected partitions are marked + // busy, meaning that no one else is allowed to modify it (and we only, + // if we get a write lock). -#if 0 - virtual status_t Defragment(KPartition *partition, KDiskDeviceJob *job); - virtual status_t Repair(KPartition *partition, bool checkOnly, - KDiskDeviceJob *job); - virtual status_t Resize(KPartition *partition, off_t size, - KDiskDeviceJob *job); - virtual status_t ResizeChild(KPartition *child, off_t size, - KDiskDeviceJob *job); - virtual status_t Move(KPartition *partition, off_t offset, - KDiskDeviceJob *job); - virtual status_t MoveChild(KPartition *child, off_t offset, - KDiskDeviceJob *job); - virtual status_t SetName(KPartition *partition, char *name, - KDiskDeviceJob *job); - virtual status_t SetContentName(KPartition *partition, char *name, - KDiskDeviceJob *job); - virtual status_t SetType(KPartition *partition, char *type, - KDiskDeviceJob *job); - virtual status_t SetParameters(KPartition *partition, - const char *parameters, - KDiskDeviceJob *job); - virtual status_t SetContentParameters(KPartition *partition, - const char *parameters, - KDiskDeviceJob *job); - virtual status_t Initialize(KPartition *partition, const char *name, - const char *parameters, KDiskDeviceJob *job); - virtual status_t CreateChild(KPartition *partition, off_t offset, - off_t size, const char *type, - const char *parameters, KDiskDeviceJob *job, - KPartition **child = NULL, - partition_id childID = -1); - virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job); -// The KPartition* parameters for the writing methods are a bit `volatile', -// since the device will not be locked, when they are called. The KPartition -// is registered though, so that it is at least guaranteed that the object -// won't go away. -#endif // 0 + virtual status_t Defragment(KPartition* partition, + disk_job_id job); + virtual status_t Repair(KPartition* partition, bool checkOnly, + disk_job_id job); + virtual status_t Resize(KPartition* partition, off_t size, + disk_job_id job); + virtual status_t ResizeChild(KPartition* child, off_t size, + disk_job_id job); + virtual status_t Move(KPartition* partition, off_t offset, + disk_job_id job); + virtual status_t MoveChild(KPartition* child, off_t offset, + disk_job_id job); + virtual status_t SetName(KPartition* partition, const char* name, + disk_job_id job); + virtual status_t SetContentName(KPartition* partition, + const char* name, disk_job_id job); + virtual status_t SetType(KPartition* partition, const char* type, + disk_job_id job); + virtual status_t SetParameters(KPartition* partition, + const char* parameters, disk_job_id job); + virtual status_t SetContentParameters(KPartition* partition, + const char* parameters, disk_job_id job); + virtual status_t Initialize(KPartition* partition, + const char* name, const char* parameters, + disk_job_id job); + virtual status_t CreateChild(KPartition* partition, off_t offset, + off_t size, const char* type, + const char* name, const char* parameters, + disk_job_id job, KPartition** child = NULL, + partition_id childID = -1); + virtual status_t DeleteChild(KPartition* child, disk_job_id job); protected: - virtual status_t LoadModule(); - virtual void UnloadModule(); + virtual status_t LoadModule(); + virtual void UnloadModule(); - status_t SetPrettyName(const char *name); - void SetFlags(uint32 flags); + status_t SetPrettyName(const char* name); + void SetFlags(uint32 flags); - static int32 _NextID(); + static int32 _NextID(); private: - disk_system_id fID; - char *fName; - char *fPrettyName; - uint32 fFlags; - int32 fLoadCounter; + disk_system_id fID; + char* fName; + char* fPrettyName; + uint32 fFlags; + int32 fLoadCounter; - static int32 fNextID; + static int32 fNextID; }; + } // namespace DiskDevice } // namespace BPrivate Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h 2007-11-05 00:30:14 UTC (rev 22831) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h 2007-11-05 00:42:47 UTC (rev 22832) @@ -6,60 +6,63 @@ * Ingo Weinhold * * KFileSystem implements the KDiskSystem interface for file systems. - * It works with the FS API. */ #ifndef _K_FILE_DISK_DEVICE_SYSTEM_H #define _K_FILE_DISK_DEVICE_SYSTEM_H #include "KDiskSystem.h" + struct file_system_module_info; + namespace BPrivate { namespace DiskDevice { + //! \brief Wrapper for the C interface of a filesystem add-on. class KFileSystem : public KDiskSystem { public: - KFileSystem(const char *name); - virtual ~KFileSystem(); + KFileSystem(const char* name); + virtual ~KFileSystem(); - virtual status_t Init(); + virtual status_t Init(); // Scanning - virtual float Identify(KPartition *partition, void **cookie); - virtual status_t Scan(KPartition *partition, void *cookie); - virtual void FreeIdentifyCookie(KPartition *partition, void *cookie); - virtual void FreeContentCookie(KPartition *partition); + virtual float Identify(KPartition* partition, void** cookie); + virtual status_t Scan(KPartition* partition, void* cookie); + virtual void FreeIdentifyCookie(KPartition* partition, + void* cookie); + virtual void FreeContentCookie(KPartition* partition); // Writing -#if 0 - virtual status_t Defragment(KPartition *partition, KDiskDeviceJob *job); - virtual status_t Repair(KPartition *partition, bool checkOnly, - KDiskDeviceJob *job); - virtual status_t Resize(KPartition *partition, off_t size, - KDiskDeviceJob *job); - virtual status_t Move(KPartition *partition, off_t offset, - KDiskDeviceJob *job); - virtual status_t SetContentName(KPartition *partition, char *name, - KDiskDeviceJob *job); - virtual status_t SetContentParameters(KPartition *partition, - const char *parameters, - KDiskDeviceJob *job); - virtual status_t Initialize(KPartition *partition, const char *name, - const char *parameters, KDiskDeviceJob *job); -#endif // 0 + virtual status_t Defragment(KPartition* partition, + disk_job_id job); + virtual status_t Repair(KPartition* partition, bool checkOnly, + disk_job_id job); + virtual status_t Resize(KPartition* partition, off_t size, + disk_job_id job); + virtual status_t Move(KPartition* partition, off_t offset, + disk_job_id job); + virtual status_t SetContentName(KPartition* partition, + const char* name, disk_job_id job); + virtual status_t SetContentParameters(KPartition* partition, + const char* parameters, disk_job_id job); + virtual status_t Initialize(KPartition* partition, + const char* name, const char* parameters, + disk_job_id job); protected: - virtual status_t LoadModule(); - virtual void UnloadModule(); + virtual status_t LoadModule(); + virtual void UnloadModule(); private: - file_system_module_info *fModule; + file_system_module_info* fModule; }; + } // namespace DiskDevice } // namespace BPrivate Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h 2007-11-05 00:30:14 UTC (rev 22831) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h 2007-11-05 00:42:47 UTC (rev 22832) @@ -10,11 +10,14 @@ #include "KDiskSystem.h" + struct partition_module_info; + namespace BPrivate { namespace DiskDevice { + /** * \brief Wrapper for the C interface of a partitioning system add-on. * @@ -22,62 +25,61 @@ */ class KPartitioningSystem : public KDiskSystem { public: - KPartitioningSystem(const char *name); - virtual ~KPartitioningSystem(); + KPartitioningSystem(const char* name); + virtual ~KPartitioningSystem(); - virtual status_t Init(); + virtual status_t Init(); // Scanning - virtual float Identify(KPartition *partition, void **cookie); - virtual status_t Scan(KPartition *partition, void *cookie); - virtual void FreeIdentifyCookie(KPartition *partition, void *cookie); - virtual void FreeCookie(KPartition *partition); - virtual void FreeContentCookie(KPartition *partition); + virtual float Identify(KPartition* partition, void** cookie); + virtual status_t Scan(KPartition* partition, void* cookie); + virtual void FreeIdentifyCookie(KPartition* partition, + void* cookie); + virtual void FreeCookie(KPartition* partition); + virtual void FreeContentCookie(KPartition* partition); // Writing -#if 0 - virtual status_t Repair(KPartition *partition, bool checkOnly, - KDiskDeviceJob *job); - virtual status_t Resize(KPartition *partition, off_t size, - KDiskDeviceJob *job); - virtual status_t ResizeChild(KPartition *child, off_t size, - KDiskDeviceJob *job); - virtual status_t Move(KPartition *partition, off_t offset, - KDiskDeviceJob *job); - virtual status_t MoveChild(KPartition *child, off_t offset, - KDiskDeviceJob *job); - virtual status_t SetName(KPartition *partition, char *name, - KDiskDeviceJob *job); - virtual status_t SetContentName(KPartition *partition, char *name, - KDiskDeviceJob *job); - virtual status_t SetType(KPartition *partition, char *type, - KDiskDeviceJob *job); - virtual status_t SetParameters(KPartition *partition, - const char *parameters, - KDiskDeviceJob *job); - virtual status_t SetContentParameters(KPartition *partition, - const char *parameters, - KDiskDeviceJob *job); - virtual status_t CreateChild(KPartition *partition, off_t offset, - off_t size, const char *type, - const char *parameters, KDiskDeviceJob *job, - KPartition **child = NULL, - partition_id childID = -1); - virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job); - virtual status_t Initialize(KPartition *partition, const char *name, - const char *parameters, KDiskDeviceJob *job); -#endif // 0 + virtual status_t Repair(KPartition* partition, bool checkOnly, + disk_job_id job); + virtual status_t Resize(KPartition* partition, off_t size, + disk_job_id job); + virtual status_t ResizeChild(KPartition* child, off_t size, + disk_job_id job); + virtual status_t Move(KPartition* partition, off_t offset, + disk_job_id job); + virtual status_t MoveChild(KPartition* child, off_t offset, + disk_job_id job); + virtual status_t SetName(KPartition* partition, const char* name, + disk_job_id job); + virtual status_t SetContentName(KPartition* partition, + const char* name, disk_job_id job); + virtual status_t SetType(KPartition* partition, const char* type, + disk_job_id job); + virtual status_t SetParameters(KPartition* partition, + const char* parameters, disk_job_id job); + virtual status_t SetContentParameters(KPartition* partition, + const char* parameters, disk_job_id job); + virtual status_t Initialize(KPartition* partition, + const char* name, const char* parameters, + disk_job_id job); + virtual status_t CreateChild(KPartition* partition, off_t offset, + off_t size, const char* type, + const char* name, const char* parameters, + disk_job_id job, KPartition** child = NULL, + partition_id childID = -1); + virtual status_t DeleteChild(KPartition* child, disk_job_id job); protected: - virtual status_t LoadModule(); - virtual void UnloadModule(); + virtual status_t LoadModule(); + virtual void UnloadModule(); private: - partition_module_info *fModule; + partition_module_info* fModule; }; + } // namespace DiskDevice } // namespace BPrivate Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp 2007-11-05 00:30:14 UTC (rev 22831) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp 2007-11-05 00:42:47 UTC (rev 22832) @@ -190,11 +190,9 @@ } -#if 0 - // Defragment status_t -KDiskSystem::Defragment(KPartition *partition, KDiskDeviceJob *job) +KDiskSystem::Defragment(KPartition* partition, disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -203,8 +201,7 @@ // Repair status_t -KDiskSystem::Repair(KPartition *partition, bool checkOnly, - KDiskDeviceJob *job) +KDiskSystem::Repair(KPartition* partition, bool checkOnly, disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -213,7 +210,7 @@ // Resize status_t -KDiskSystem::Resize(KPartition *partition, off_t size, KDiskDeviceJob *job) +KDiskSystem::Resize(KPartition* partition, off_t size, disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -222,7 +219,7 @@ // ResizeChild status_t -KDiskSystem::ResizeChild(KPartition *child, off_t size, KDiskDeviceJob *job) +KDiskSystem::ResizeChild(KPartition* child, off_t size, disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -231,7 +228,7 @@ // Move status_t -KDiskSystem::Move(KPartition *partition, off_t offset, KDiskDeviceJob *job) +KDiskSystem::Move(KPartition* partition, off_t offset, disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -240,7 +237,7 @@ // MoveChild status_t -KDiskSystem::MoveChild(KPartition *child, off_t offset, KDiskDeviceJob *job) +KDiskSystem::MoveChild(KPartition* child, off_t offset, disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -249,7 +246,7 @@ // SetName status_t -KDiskSystem::SetName(KPartition *partition, char *name, KDiskDeviceJob *job) +KDiskSystem::SetName(KPartition* partition, const char* name, disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -258,8 +255,8 @@ // SetContentName status_t -KDiskSystem::SetContentName(KPartition *partition, char *name, - KDiskDeviceJob *job) +KDiskSystem::SetContentName(KPartition* partition, const char* name, + disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -268,7 +265,7 @@ // SetType status_t -KDiskSystem::SetType(KPartition *partition, char *type, KDiskDeviceJob *job) +KDiskSystem::SetType(KPartition* partition, const char *type, disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -277,8 +274,8 @@ // SetParameters status_t -KDiskSystem::SetParameters(KPartition *partition, const char *parameters, - KDiskDeviceJob *job) +KDiskSystem::SetParameters(KPartition* partition, const char* parameters, + disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -287,8 +284,8 @@ // SetContentParameters status_t -KDiskSystem::SetContentParameters(KPartition *partition, - const char *parameters, KDiskDeviceJob *job) +KDiskSystem::SetContentParameters(KPartition* partition, + const char* parameters, disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -297,8 +294,8 @@ // Initialize status_t -KDiskSystem::Initialize(KPartition *partition, const char *name, - const char *parameters, KDiskDeviceJob *job) +KDiskSystem::Initialize(KPartition* partition, const char* name, + const char* parameters, disk_job_id job) { // to be implemented by derived classes return B_ERROR; @@ -307,10 +304,9 @@ // CreateChild status_t -KDiskSystem::CreateChild(KPartition *partition, off_t offset, off_t size, - const char *type, const char *parameters, - KDiskDeviceJob *job, KPartition **child, - partition_id childID) +KDiskSystem::CreateChild(KPartition* partition, off_t offset, off_t size, + const char* type, const char* name, const char* parameters, disk_job_id job, + KPartition **child, partition_id childID) { // to be implemented by derived classes return B_ERROR; @@ -319,15 +315,13 @@ // DeleteChild status_t -KDiskSystem::DeleteChild(KPartition *child, KDiskDeviceJob *job) +KDiskSystem::DeleteChild(KPartition* child, disk_job_id job) { // to be implemented by derived classes return B_ERROR; } -#endif // 0 - // LoadModule status_t KDiskSystem::LoadModule() Modified: haiku/trunk/src/system/kernel/disk_device_manager/KFileSystem.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KFileSystem.cpp 2007-11-05 00:30:14 UTC (rev 22831) +++ haiku/trunk/src/system/kernel/disk_device_manager/KFileSystem.cpp 2007-11-05 00:42:47 UTC (rev 22832) @@ -97,11 +97,9 @@ } -#if 0 - // Defragment status_t -KFileSystem::Defragment(KPartition *partition, KDiskDeviceJob *job) +KFileSystem::Defragment(KPartition* partition, disk_job_id job) { // to be implemented return B_ERROR; @@ -110,7 +108,7 @@ // Repair status_t -KFileSystem::Repair(KPartition *partition, bool checkOnly, KDiskDeviceJob *job) +KFileSystem::Repair(KPartition* partition, bool checkOnly, disk_job_id job) { // to be implemented return B_ERROR; @@ -119,7 +117,7 @@ // Resize status_t -KFileSystem::Resize(KPartition *partition, off_t size, KDiskDeviceJob *job) +KFileSystem::Resize(KPartition* partition, off_t size, disk_job_id job) { // to be implemented return B_ERROR; @@ -128,7 +126,7 @@ // Move status_t -KFileSystem::Move(KPartition *partition, off_t offset, KDiskDeviceJob *job) +KFileSystem::Move(KPartition* partition, off_t offset, disk_job_id job) { // to be implemented return B_ERROR; @@ -137,59 +135,51 @@ // SetContentName status_t -KFileSystem::SetContentName(KPartition *partition, char *name, - KDiskDeviceJob *job) +KFileSystem::SetContentName(KPartition* partition, const char* name, + disk_job_id job) { // to be implemented return B_ERROR; } +// SetContentParameters status_t -KFileSystem::SetContentParameters(KPartition *partition, - const char *parameters, KDiskDeviceJob *job) +KFileSystem::SetContentParameters(KPartition* partition, + const char* parameters, disk_job_id job) { // to be implemented return B_ERROR; } +// Initialize status_t -KFileSystem::Initialize(KPartition *partition, const char *name, - const char *parameters, KDiskDeviceJob *job) +KFileSystem::Initialize(KPartition* partition, const char* name, + const char* parameters, disk_job_id job) { // check parameters - if (!partition || !job || !fModule) + if (!partition || !fModule) return B_BAD_VALUE; if (!fModule->initialize) return B_NOT_SUPPORTED; - // open partition device (we need a temporary read-lock) - KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - if (!manager->ReadLockPartition(partition->ID())) - return B_ERROR; - DeviceReadLocker locker(partition->Device(), true); - + // open partition device int fd = -1; status_t result = partition->Open(O_RDWR, &fd); if (result != B_OK) return result; - off_t partitionSize = partition->Size(); - - locker.Unlock(); - - // call the module hook + // let the module do its job result = fModule->initialize(fd, partition->ID(), name, parameters, - partitionSize, job->ID()); + partition->Size(), job); + // cleanup and return close(fd); return result; } -#endif // 0 - // LoadModule status_t KFileSystem::LoadModule() Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp 2007-11-05 00:30:14 UTC (rev 22831) +++ haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp 2007-11-05 00:42:47 UTC (rev 22832) @@ -127,13 +127,11 @@ } -#if 0 - // Repair //! Repairs a partition status_t -KPartitioningSystem::Repair(KPartition *partition, bool checkOnly, - KDiskDeviceJob *job) +KPartitioningSystem::Repair(KPartition* partition, bool checkOnly, + disk_job_id job) { // to be implemented return B_ERROR; @@ -143,34 +141,22 @@ // Resize //! Resizes a partition status_t -KPartitioningSystem::Resize(KPartition *partition, off_t size, - KDiskDeviceJob *job) +KPartitioningSystem::Resize(KPartition* partition, off_t size, disk_job_id job) { // check parameters - if (!partition || !job || size < 0) + if (!partition || size < 0 || !fModule) return B_BAD_VALUE; if (!fModule->resize) - return B_ENTRY_NOT_FOUND; + return B_NOT_SUPPORTED; - // lock partition and open partition device - KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - KPartition *_partition = manager->WriteLockPartition(partition->ID()); - if (!_partition) - return B_ERROR; + // open partition device int fd = -1; - { - PartitionRegistrar registrar(_partition, true); - PartitionRegistrar deviceRegistrar(_partition->Device(), true); - DeviceWriteLocker locker(_partition->Device(), true); - if (partition != _partition) - return B_ERROR; - status_t result = partition->Open(O_RDWR, &fd); - if (result != B_OK) - return result; - } + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; // let the module do its job - status_t result = fModule->resize(fd, partition->ID(), size, job->ID()); + result = fModule->resize(fd, partition->ID(), size, job); // cleanup and return close(fd); @@ -181,35 +167,22 @@ // ResizeChild //! Resizes child of a partition status_t -KPartitioningSystem::ResizeChild(KPartition *child, off_t size, - KDiskDeviceJob *job) +KPartitioningSystem::ResizeChild(KPartition* child, off_t size, disk_job_id job) { // check parameters - if (!child || !job || !child->Parent() || size < 0) + if (!child || !child->Parent() || size < 0 || !fModule) return B_BAD_VALUE; if (!fModule->resize_child) - return B_ENTRY_NOT_FOUND; + return B_NOT_SUPPORTED; - // lock partition and open (parent) partition device - KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - KPartition *_partition = manager->WriteLockPartition(child->ID()); - KPartition *_parent = manager->WriteLockPartition(child->Parent()->ID()); - if (!_partition) - return B_ERROR; + // open partition device int fd = -1; - { - PartitionRegistrar registrar(_partition, true); - PartitionRegistrar deviceRegistrar(_partition->Device(), true); - DeviceWriteLocker locker(_partition->Device(), true); - if (child != _partition) - return B_ERROR; - status_t result = child->Parent()->Open(O_RDWR, &fd); - if (result != B_OK) - return result; - } + status_t result = child->Parent()->Open(O_RDWR, &fd); + if (result != B_OK) + return result; // let the module do its job - status_t result = fModule->resize_child(fd, child->ID(), size, job->ID()); + result = fModule->resize_child(fd, child->ID(), size, job); // cleanup and return close(fd); @@ -220,34 +193,22 @@ // Move //! Moves a partition status_t -KPartitioningSystem::Move(KPartition *partition, off_t offset, - KDiskDeviceJob *job) +KPartitioningSystem::Move(KPartition* partition, off_t offset, disk_job_id job) { // check parameters - if (!partition || !job) + if (!partition) return B_BAD_VALUE; if (!fModule->move) - return B_ENTRY_NOT_FOUND; + return B_NOT_SUPPORTED; - // lock partition and open partition device - KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - KPartition *_partition = manager->WriteLockPartition(partition->ID()); - if (!_partition) - return B_ERROR; + // open partition device int fd = -1; - { - PartitionRegistrar registrar(_partition, true); - PartitionRegistrar deviceRegistrar(_partition->Device(), true); - DeviceWriteLocker locker(_partition->Device(), true); - if (partition != _partition) - return B_ERROR; - status_t result = partition->Open(O_RDWR, &fd); - if (result != B_OK) - return result; - } + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; // let the module do its job - status_t result = fModule->move(fd, partition->ID(), offset, job->ID()); + result = fModule->move(fd, partition->ID(), offset, job); // cleanup and return close(fd); @@ -258,36 +219,23 @@ // MoveChild //! Moves child of a partition status_t -KPartitioningSystem::MoveChild(KPartition *child, off_t offset, - KDiskDeviceJob *job) +KPartitioningSystem::MoveChild(KPartition* child, off_t offset, disk_job_id job) { // check parameters - if (!child || !job || !child->Parent()) + if (!child || !child->Parent() || !fModule) return B_BAD_VALUE; if (!fModule->move_child) - return B_ENTRY_NOT_FOUND; + return B_NOT_SUPPORTED; - // lock partition and open (parent) partition device - KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - KPartition *_partition = manager->WriteLockPartition(child->ID()); - KPartition *_parent = manager->WriteLockPartition(child->Parent()->ID()); - if (!_partition) - return B_ERROR; + // open partition device int fd = -1; - { - PartitionRegistrar registrar(_partition, true); - PartitionRegistrar deviceRegistrar(_partition->Device(), true); - DeviceWriteLocker locker(_partition->Device(), true); - if (child != _partition) - return B_ERROR; - status_t result = child->Parent()->Open(O_RDWR, &fd); - if (result != B_OK) - return result; - } + status_t result = child->Parent()->Open(O_RDWR, &fd); + if (result != B_OK) + return result; // let the module do its job - status_t result = fModule->move_child(fd, child->Parent()->ID(), - child->ID(), offset, job->ID()); + result = fModule->move_child(fd, child->Parent()->ID(), child->ID(), offset, + job); // cleanup and return close(fd); @@ -298,34 +246,24 @@ // SetName //! Sets name of a partition status_t -KPartitioningSystem::SetName(KPartition *partition, char *name, - KDiskDeviceJob *job) +KPartitioningSystem::SetName(KPartition* child, const char* name, + disk_job_id job) { // check parameters - if (!partition || !job || !name) + if (!child || !child->Parent() || !fModule) return B_BAD_VALUE; if (!fModule->set_name) - return B_ENTRY_NOT_FOUND; + return B_NOT_SUPPORTED; - // lock partition and open partition device - KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - KPartition *_partition = manager->WriteLockPartition(partition->ID()); - if (!_partition) - return B_ERROR; + // open partition device int fd = -1; - { - PartitionRegistrar registrar(_partition, true); - PartitionRegistrar deviceRegistrar(_partition->Device(), true); - DeviceWriteLocker locker(_partition->Device(), true); - if (partition != _partition) - return B_ERROR; - status_t result = partition->Open(O_RDWR, &fd); - if (result != B_OK) - return result; - } + status_t result = child->Parent()->Open(O_RDWR, &fd); + if (result != B_OK) + return result; // let the module do its job - status_t result = fModule->set_name(fd, partition->ID(), name, job->ID()); + result = fModule->set_name(fd, child->ID(), name, job); +// TODO: Change hook interface! // cleanup and return close(fd); @@ -336,35 +274,23 @@ // SetContentName //! Sets name of the content of a partition status_t -KPartitioningSystem::SetContentName(KPartition *partition, char *name, - KDiskDeviceJob *job) +KPartitioningSystem::SetContentName(KPartition* partition, const char* name, + disk_job_id job) { // check parameters - if (!partition || !job || !name) + if (!partition || !fModule) return B_BAD_VALUE; if (!fModule->set_content_name) - return B_ENTRY_NOT_FOUND; + return B_NOT_SUPPORTED; - // lock partition and open partition device - KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - KPartition *_partition = manager->WriteLockPartition(partition->ID()); - if (!_partition) - return B_ERROR; + // open partition device int fd = -1; - { - PartitionRegistrar registrar(_partition, true); - PartitionRegistrar deviceRegistrar(_partition->Device(), true); - DeviceWriteLocker locker(_partition->Device(), true); - if (partition != _partition) - return B_ERROR; - status_t result = partition->Open(O_RDWR, &fd); - if (result != B_OK) - return result; - } + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; // let the module do its job - status_t result = fModule->set_content_name(fd, partition->ID(), name, - job->ID()); + result = fModule->set_content_name(fd, partition->ID(), name, job); // cleanup and return close(fd); @@ -375,34 +301,24 @@ // SetType //! Sets type of a partition status_t -KPartitioningSystem::SetType(KPartition *partition, char *type, - KDiskDeviceJob *job) +KPartitioningSystem::SetType(KPartition* child, const char* type, + disk_job_id job) { // check parameters - if (!partition || !job || !type) + if (!child || !child->Parent() || !type || !fModule) return B_BAD_VALUE; if (!fModule->set_type) - return B_ENTRY_NOT_FOUND; + return B_NOT_SUPPORTED; - // lock partition and open partition device - KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - KPartition *_partition = manager->WriteLockPartition(partition->ID()); - if (!_partition) - return B_ERROR; + // open partition device int fd = -1; - { - PartitionRegistrar registrar(_partition, true); [... truncated: 1556 lines follow ...] From bga at mail.berlios.de Mon Nov 5 12:13:28 2007 From: bga at mail.berlios.de (bga at BerliOS) Date: Mon, 5 Nov 2007 12:13:28 +0100 Subject: [Haiku-commits] r22833 - in haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139: . dev/mii pci Message-ID: <200711051113.lA5BDSJf019044@sheep.berlios.de> Author: bga Date: 2007-11-05 12:13:27 +0100 (Mon, 05 Nov 2007) New Revision: 22833 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22833&view=rev Removed: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/driver.c haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/registers.h haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/util.c haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/util.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c Log: Made the FreeBSD rtl8139 driver the default one and removed the other driver. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/Jamfile 2007-11-05 00:42:47 UTC (rev 22832) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/Jamfile 2007-11-05 11:13:27 UTC (rev 22833) @@ -1,59 +1,4 @@ SubDir HAIKU_TOP src add-ons kernel drivers network rtl8139 ; -SetSubDirSupportedPlatformsBeOSCompatible ; - -# set some additional flags -SubDirCcFlags -Wall ; - -# For ether_driver.h -UsePrivateHeaders net ; - -KernelAddon rtl8139 : - driver.c - util.c - ; - -Package haiku-rtl8139-cvs : - rtl8139 : - boot home config add-ons kernel drivers bin ; -PackageDriverSymLink haiku-rtl8139-cvs : net rtl8139 ; - -# Package haiku-rtl8139-cvs : -# rtl8139.settings : -# boot home config settings kernel drivers sample ; - - - -rule InstallRTL8139 -{ - Depends $(<) : $(>) ; -} - -actions ignore InstallRTL8139 -{ - cp $(>) /boot/home/config/add-ons/kernel/drivers/bin/ -} - -#InstallRTL8139 install : rtl8139 ; - -# Installation - -HaikuInstall install-networking : /boot/home/config/add-ons/kernel/drivers/bin : - rtl8139 -; - -HaikuInstallRelSymLink install-networking : /boot/home/config/add-ons/kernel/drivers/dev/net : - rtl8139 : - installed-symlink -; - -Package haiku-networkingkit-cvs : - rtl8139 : - boot home config add-ons kernel drivers bin ; -PackageDriverSymLink haiku-networkingkit-cvs : net rtl8139 ; -# Package haiku-networkingkit-cvs : -# rtl8139.settings : -# boot home config settings kernel drivers sample ; - SubInclude HAIKU_TOP src add-ons kernel drivers network rtl8139 dev ; SubInclude HAIKU_TOP src add-ons kernel drivers network rtl8139 pci ; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/dev/mii/Jamfile 2007-11-05 00:42:47 UTC (rev 22832) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/dev/mii/Jamfile 2007-11-05 11:13:27 UTC (rev 22833) @@ -7,7 +7,7 @@ SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ; -KernelStaticLibrary rtl8139exp_mii.a +KernelStaticLibrary rtl8139_mii.a : rlphy.c ; Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/driver.c Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/Jamfile 2007-11-05 00:42:47 UTC (rev 22832) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/Jamfile 2007-11-05 11:13:27 UTC (rev 22833) @@ -7,9 +7,9 @@ SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ; -KernelAddon rtl8139exp : +KernelAddon rtl8139 : if_rl.c glue.c - : libfreebsd_network.a rtl8139exp_mii.a + : libfreebsd_network.a rtl8139_mii.a ; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c 2007-11-05 00:42:47 UTC (rev 22832) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c 2007-11-05 11:13:27 UTC (rev 22833) @@ -2,7 +2,7 @@ #include -HAIKU_FBSD_DRIVER_GLUE(rtl8139exp, rl, pci); +HAIKU_FBSD_DRIVER_GLUE(rtl8139, rl, pci); HAIKU_DRIVER_REQUIREMENTS(0); extern driver_t *DRIVER_MODULE_NAME(rlphy, miibus); Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/registers.h Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/util.c Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/util.h From axeld at mail.berlios.de Mon Nov 5 12:37:03 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 5 Nov 2007 12:37:03 +0100 Subject: [Haiku-commits] r22834 - haiku/trunk/src/system/kernel/vm Message-ID: <200711051137.lA5Bb32D006258@sheep.berlios.de> Author: axeld Date: 2007-11-05 12:37:02 +0100 (Mon, 05 Nov 2007) New Revision: 22834 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22834&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: * If steal_pages() stole more than originally asked for, it might have lost those pages in the non-reserve case. * vm_page_allocate_page() could also lose a stolen page in case more free pages were available after steal_pages() was called. Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-11-05 11:13:27 UTC (rev 22833) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-11-05 11:37:02 UTC (rev 22834) @@ -974,7 +974,7 @@ break; if (steal_page(page, false)) { - if (reserve) { + if (reserve || stolen >= maxCount) { InterruptsSpinLocker _(sPageLock); enqueue_page(&sFreePageQueue, page); page->state = PAGE_STATE_FREE; @@ -1374,10 +1374,8 @@ size_t stolen = steal_pages(&page, 1, false); locker.Lock(); - if (stolen == 0) { - // just try again - continue; - } + if (stolen > 0) + break; } if (page->cache != NULL) From stefano.ceccherini at gmail.com Mon Nov 5 12:43:34 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 5 Nov 2007 12:43:34 +0100 Subject: [Haiku-commits] r22787 - in haiku/trunk/src/kits/interface: . textview_support In-Reply-To: <20071102162218.8103.5@stippis.WG> References: <25395053474-BeMail@zon> <20071101173718.50513.1@stippis.WG> <894b9700711020722n3af7c53bnde8ae81744d1942f@mail.gmail.com> <20071102162218.8103.5@stippis.WG> Message-ID: <894b9700711050343n75206991w2aa98c554967aa1a@mail.gmail.com> 2007/11/2, Stephan Assmus : > Thanks for clearing this up. Hm. Why are there even two implementations? As > for Copy/Cut()... why would an application call those methods (local), > which exposes a password to the system clipboard? It just doesn't make > sense to me, but at the time I did those changes, I wasn't even aware that > there is another implementation in the message handling code. I don't mean there is another implementation. The message handling code just calls Copy() and Cut(). There I added a check if typing is hidden. But I think you are right, "locally" an application would just call Text() to get the real text. There is no reason to call Copy() or Cut(). From stippi at mail.berlios.de Mon Nov 5 16:29:25 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 5 Nov 2007 16:29:25 +0100 Subject: [Haiku-commits] r22835 - haiku/trunk/src/kits/interface Message-ID: <200711051529.lA5FTPFX027446@sheep.berlios.de> Author: stippi Date: 2007-11-05 16:29:25 +0100 (Mon, 05 Nov 2007) New Revision: 22835 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22835&view=rev Modified: haiku/trunk/src/kits/interface/ListView.cpp Log: * use BListItem::Height() consistently (clicking a nick in Vision now selects that same nick, not a different one) * performance improvement in Draw() (using ItemFrame() in the inner loop scales really bad) * fixed scroll range for when BListItem::Height() is non-integer (scrolling all the way to the bottom in Visions nick list works now) Modified: haiku/trunk/src/kits/interface/ListView.cpp =================================================================== --- haiku/trunk/src/kits/interface/ListView.cpp 2007-11-05 11:37:02 UTC (rev 22834) +++ haiku/trunk/src/kits/interface/ListView.cpp 2007-11-05 15:29:25 UTC (rev 22835) @@ -187,11 +187,19 @@ void BListView::Draw(BRect updateRect) { - for (int i = 0; i < CountItems(); i++) { - BRect itemFrame = ItemFrame(i); + int32 count = CountItems(); + if (count == 0) + return; + BRect itemFrame(Bounds().left, 0, Bounds().right, -1); + for (int i = 0; i < count; i++) { + BListItem* item = ItemAt(i); + itemFrame.bottom = itemFrame.top + ceilf(item->Height()) - 1; + if (itemFrame.Intersects(updateRect)) - DrawItem(((BListItem*)ItemAt(i)), itemFrame); + DrawItem(item, itemFrame); + + itemFrame.top = itemFrame.bottom + 1; } } @@ -696,7 +704,7 @@ // TODO: somehow binary search, but items don't know their frame for (int i = 0; i < fList.CountItems(); i++) { - y += ItemAt(i)->Height(); + y += ceilf(ItemAt(i)->Height()); if (point.y < y) return i; @@ -1010,7 +1018,7 @@ BRect BListView::ItemFrame(int32 index) { - BRect frame(0, 0, Bounds().Width(), -1); + BRect frame(Bounds().left, 0, Bounds().right, -1); if (index < 0 || index >= CountItems()) return frame; @@ -1018,7 +1026,7 @@ // TODO: this is very expensive, the (last) offsets could be cached for (int32 i = 0; i <= index; i++) { frame.top = frame.bottom + 1; - frame.bottom += (float)ceil(ItemAt(i)->Height()); + frame.bottom = frame.top + ceilf(ItemAt(i)->Height()) - 1; } return frame; @@ -1200,9 +1208,8 @@ int32 count = CountItems(); float itemHeight = 0; - for (int32 i = 0; BListItem* item = ItemAt(i); i++) { - itemHeight += item->Height(); - } + for (int32 i = 0; i < count; i++) + itemHeight += ceilf(ItemAt(i)->Height()); if (bounds.Height() > itemHeight) { // no scrolling @@ -1218,10 +1225,8 @@ } } - if (count != 0) { - vertScroller->SetSteps((float)ceil(FirstItem()->Height()), - bounds.Height()); - } + if (count != 0) + vertScroller->SetSteps(ceilf(FirstItem()->Height()), bounds.Height()); } // _InvalidateFrom From bga at bug-br.org.br Mon Nov 5 16:47:24 2007 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Mon, 05 Nov 2007 13:47:24 -0200 Subject: [Haiku-commits] r22835 - haiku/trunk/src/kits/interface In-Reply-To: <200711051529.lA5FTPFX027446@sheep.berlios.de> References: <200711051529.lA5FTPFX027446@sheep.berlios.de> Message-ID: <472F3B0C.9050802@bug-br.org.br> stippi at BerliOS wrote: > * performance improvement in Draw() (using ItemFrame() in the inner loop scales > really bad) This reminds me: One thing that still makes Haiku not look as polished as it could be is the fact that there is flicker everywhere when things get updated on screen. Examples are the Media Player slider and the ftp progress bar (text mode in Terminal). I don't know if this is lack of double buffering or whatnot but this really brings the general Haiku perception down. Any ideas? -Bruno From stefano.ceccherini at gmail.com Mon Nov 5 16:52:40 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 5 Nov 2007 16:52:40 +0100 Subject: [Haiku-commits] r22835 - haiku/trunk/src/kits/interface In-Reply-To: <472F3B0C.9050802@bug-br.org.br> References: <200711051529.lA5FTPFX027446@sheep.berlios.de> <472F3B0C.9050802@bug-br.org.br> Message-ID: <894b9700711050752q9f3860pf0ab481de646610f@mail.gmail.com> 2007/11/5, Bruno Albuquerque : > This reminds me: One thing that still makes Haiku not look as polished > as it could be is the fact that there is flicker everywhere when things > get updated on screen. Examples are the Media Player slider and the > ftp progress bar (text mode in Terminal). I don't know if this is lack > of double buffering or whatnot but this really brings the general Haiku > perception down. Well haiku is not double buffered at all (unless you use a video mode with a depth other than 32 bit). By the way, in vesa mode, 16 bit double buffered mode is much smoother (faster, even) than 32 bit mode. At least on my system. Moreover, our BSlider class is not double buffered, unlike R5 one (but there's a define in the code which re-enables double buffering). From superstippi at gmx.de Mon Nov 5 17:02:06 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 05 Nov 2007 17:02:06 +0100 Subject: [Haiku-commits] r22835 - haiku/trunk/src/kits/interface In-Reply-To: <472F3B0C.9050802@bug-br.org.br> References: <200711051529.lA5FTPFX027446@sheep.berlios.de> <472F3B0C.9050802@bug-br.org.br> Message-ID: <20071105170206.938.1@stippis.WG> Bruno Albuquerque wrote (2007-11-05, 16:47:24 [+0100]): > stippi at BerliOS wrote: > > > * performance improvement in Draw() (using ItemFrame() in the inner > > loop scales > > really bad) > > This reminds me: One thing that still makes Haiku not look as polished as > it could be is the fact that there is flicker everywhere when things > get updated on screen. Examples are the Media Player slider and the > ftp progress bar (text mode in Terminal). I don't know if this is lack of > double buffering or whatnot but this really brings the general Haiku > perception down. Any ideas? Yes, in fact I do have a plan for that since a long time. I documented it ones on the app_server list (sorry, can't be bothered to dig out a link... :-). But it means changing the accelerant API. Maybe I will do that some time in the future, at first for a driver that works with a board I own. As far as the accelerant API is concerned, I would like to change it from taking parameters which reference the frame buffer geometry (coordinates) to parameters that support a custom layout of the graphics board's memory. I don't want to sacrifice hardware acceleration for double buffering, but doing that is currently the only way to get double buffering on BeOS R5 or Haiku. Best regards, -Stephan From axeld at mail.berlios.de Mon Nov 5 18:45:32 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 5 Nov 2007 18:45:32 +0100 Subject: [Haiku-commits] r22836 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200711051745.lA5HjWV0002221@sheep.berlios.de> Author: axeld Date: 2007-11-05 18:45:31 +0100 (Mon, 05 Nov 2007) New Revision: 22836 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22836&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c Log: * Added the device/vendor pair of the ICH7 used in the MacBooks, courtesy of "chrisjp", see bug #1599. * Minor cleanup. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c 2007-11-05 15:29:25 UTC (rev 22835) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c 2007-11-05 17:45:31 UTC (rev 22836) @@ -20,8 +20,7 @@ device_manager_info *gDeviceManager; -device_info sSupportedDevices[] = -{ +const device_info kSupportedDevices[] = { { 0x1002, 0x4380, "ATI SB600" }, { 0x1002, 0x4390, "ATI SB700/800" }, { 0x1002, 0x4391, "ATI IXP700" }, @@ -92,6 +91,7 @@ { 0x8086, 0x2683, "Intel ESB2" }, { 0x8086, 0x27c1, "Intel ICH7R (AHCI mode)" }, { 0x8086, 0x27c3, "Intel ICH7R (RAID mode)" }, + { 0x8086, 0x27c4, "Intel ICH7 (AHCI mode)" }, { 0x8086, 0x27c5, "Intel ICH7-M (AHCI mode)" }, { 0x8086, 0x27c6, "Intel ICH7-M DH (RAID mode)" }, { 0x8086, 0x2821, "Intel ICH8 (AHCI mode)" }, @@ -116,10 +116,11 @@ status_t -get_device_info(uint16 vendorID, uint16 deviceID, const char **name, uint32 *flags) +get_device_info(uint16 vendorID, uint16 deviceID, const char **name, + uint32 *flags) { - device_info *info; - for (info = sSupportedDevices; info->vendor; info++) { + const device_info *info; + for (info = kSupportedDevices; info->vendor; info++) { if (info->vendor == vendorID && info->device == deviceID) { if (name) *name = info->name; @@ -170,6 +171,7 @@ // #pragma mark - + static float ahci_supports_device(device_node_handle parent, bool *_noConnection) { From michael.pfeiffer at utanet.at Mon Nov 5 21:12:20 2007 From: michael.pfeiffer at utanet.at (Michael Pfeiffer) Date: Mon, 5 Nov 2007 21:12:20 +0100 Subject: [Haiku-commits] r22835 - haiku/trunk/src/kits/interface In-Reply-To: <472F3B0C.9050802@bug-br.org.br> References: <200711051529.lA5FTPFX027446@sheep.berlios.de> <472F3B0C.9050802@bug-br.org.br> Message-ID: <7EB8DA40-F1D2-4577-AA57-FF8315FF1CC4@utanet.at> Am 05.11.2007 um 16:47 schrieb Bruno Albuquerque: > stippi at BerliOS wrote: > >> * performance improvement in Draw() (using ItemFrame() in the inner >> loop scales >> really bad) > > This reminds me: One thing that still makes Haiku not look as polished > as it could be is the fact that there is flicker everywhere when > things > get updated on screen. Examples are the Media Player slider and the > ftp progress bar (text mode in Terminal). I don't know if this is lack > of double buffering or whatnot but this really brings the general > Haiku > perception down. Any ideas? I hope my observations are at least new to one reader on this list. Flickering is caused by overwriting the same pixels with different colors very quickly. A BView that implements Draw() per default typically flickers when drawn, because before the Draw() method gets called the view update area is filled either with its background color or(/and?) the view image. After that the drawing operations in Draw() overwrite the previously drawn background. An application that wants to avoid flickering has to set the background color of a (drawing) BView to B_TRANSPARENT_COLOR and draw the _entire_ update area when requested. This way you can avoid flickering at all if each pixel is drawn only once (for example using double buffering). At least flickering can be reduced, if the number of overwritten pixels is very small. My changes in the Haiku version of Sudoku should reduce the flickering while resizing its window, if not it's the app_servers fault ;-) - Michael From anevilyak at gmail.com Mon Nov 5 21:24:15 2007 From: anevilyak at gmail.com (Rene Gollent) Date: Mon, 5 Nov 2007 14:24:15 -0600 Subject: [Haiku-commits] Haiku-commits Digest, Vol 17, Issue 17 In-Reply-To: References: Message-ID: > I hope my observations are at least new to one reader on this list. > > Flickering is caused by overwriting the same pixels with different > colors very quickly. > > A BView that implements Draw() per default typically flickers when > drawn, because before the Draw() method gets called the view update > area is filled either with its background color or(/and?) the view > image. After that the drawing operations in Draw() overwrite the > previously drawn background. > > An application that wants to avoid flickering has to set the > background color of a (drawing) BView to B_TRANSPARENT_COLOR and draw > the _entire_ update area when requested. This way you can avoid > flickering at all if each pixel is drawn only once (for example using > double buffering). At least flickering can be reduced, if the number > of overwritten pixels is very small. > > My changes in the Haiku version of Sudoku should reduce the flickering > while resizing its window, if not it's the app_servers fault ;-) > > - Michael If it helps, Vision's text view uses this exact same approach, I'd need to go look at how effective it is at being flicker-free on Haiku though, and my box is currently a poor example to test with since HW acceleration is somewhat limited on my chipset due to some driver issues. Rene From korli at mail.berlios.de Mon Nov 5 22:54:13 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 5 Nov 2007 22:54:13 +0100 Subject: [Haiku-commits] r22837 - haiku/trunk/src/servers/media Message-ID: <200711052154.lA5LsD1d002659@sheep.berlios.de> Author: korli Date: 2007-11-05 22:54:12 +0100 (Mon, 05 Nov 2007) New Revision: 22837 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22837&view=rev Modified: haiku/trunk/src/servers/media/DefaultManager.cpp Log: create media settings directory before saving default nodes Modified: haiku/trunk/src/servers/media/DefaultManager.cpp =================================================================== --- haiku/trunk/src/servers/media/DefaultManager.cpp 2007-11-05 17:45:31 UTC (rev 22836) +++ haiku/trunk/src/servers/media/DefaultManager.cpp 2007-11-05 21:54:12 UTC (rev 22837) @@ -3,14 +3,15 @@ * Distributed under the terms of the MIT License. */ #include -#include +#include +#include +#include #include #include +#include +#include #include #include -#include -#include -#include #include "DefaultManager.h" #include "DormantNodeManager.h" #include "NodeManager.h" @@ -36,7 +37,8 @@ const char *kDefaultManagerPath = "be:_path"; const char *kDefaultManagerInput = "be:_input_id"; -const char *kDefaultManagerSettings = "Media/MDefaultManager"; +const char *kDefaultManagerSettingsDirectory = "Media"; +const char *kDefaultManagerSettingsFile = "MDefaultManager"; DefaultManager::DefaultManager() @@ -73,12 +75,13 @@ if((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path))!=B_OK) return err; - path.Append(kDefaultManagerSettings); + path.Append(kDefaultManagerSettingsDirectory); + path.Append(kDefaultManagerSettingsFile); BFile file(path.Path(), B_READ_ONLY); uint32 category_count; - if (file.Read(fBeginHeader, sizeof(uint32)*3) < (int32)sizeof(uint32)*3) + if (file.Read(fBeginHeader, sizeof(uint32)*3) < (int32)sizeof(uint32)*3) return B_ERROR; TRACE("0x%08lx %ld\n", fBeginHeader[0], fBeginHeader[0]); TRACE("0x%08lx %ld\n", fBeginHeader[1], fBeginHeader[1]); @@ -110,16 +113,18 @@ status_t err = B_OK; BPath path; BList list; - if((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path))!=B_OK) + if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)) != B_OK) return err; - - path.Append(kDefaultManagerSettings); + path.Append(kDefaultManagerSettingsDirectory); + if ((err = create_directory(path.Path(), 0755)) != B_OK) + return err; + path.Append(kDefaultManagerSettingsFile); BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); uint32 default_types[] = {kMsgTypeVideoIn, kMsgTypeVideoOut, kMsgTypeAudioIn, kMsgTypeAudioOut}; uint32 media_node_ids[] = {fPhysicalVideoIn, fPhysicalVideoOut, fPhysicalAudioIn, fPhysicalAudioOut}; - for(uint32 i=0; iAddInt32(kDefaultManagerType, default_types[i]); @@ -150,7 +155,7 @@ if (file.Write(fBeginHeader, sizeof(uint32)*3) < (int32)sizeof(uint32)*3) return B_ERROR; int32 category_count = list.CountItems(); - if (file.Write(&category_count, sizeof(uint32)) < (int32)sizeof(uint32)) + if (file.Write(&category_count, sizeof(uint32)) < (int32)sizeof(uint32)) return B_ERROR; for (int32 i = 0; i < category_count; i++) { From axeld at mail.berlios.de Mon Nov 5 23:28:04 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 5 Nov 2007 23:28:04 +0100 Subject: [Haiku-commits] r22838 - haiku/trunk/src/add-ons/kernel/busses/scsi/usb Message-ID: <200711052228.lA5MS4s6005152@sheep.berlios.de> Author: axeld Date: 2007-11-05 23:28:03 +0100 (Mon, 05 Nov 2007) New Revision: 22838 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22838&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/usb/Jamfile haiku/trunk/src/add-ons/kernel/busses/scsi/usb/scsi_commands.h haiku/trunk/src/add-ons/kernel/busses/scsi/usb/transform_procs.c Log: * Made at least scsi_cmd_rw_10 the same as the one in private/drivers/scsi_cmds.h; ideally, we would only have one file and no copies - later. * That also changed how READ/WRITE_6 commands are translated to READ/WRITE_10 commands, but it was obviously correct before, at least I can still reproduce bug #1577 (so it has to be something else). * Spotted a few suspicious uses of transform_6_10() vs. transform_cmd_6_10(); at least the FreeBSD driver seem to work differently here, anyway (it always uses 12 byte commands for most of these). * Cleaned up the file. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/usb/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/usb/Jamfile 2007-11-05 21:54:12 UTC (rev 22837) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/usb/Jamfile 2007-11-05 22:28:03 UTC (rev 22838) @@ -6,6 +6,8 @@ UsePublicHeaders [ FDirName drivers ] ; } +UsePrivateHeaders drivers ; + KernelAddon usb_scsi : usb_scsi.c tracing.c Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/usb/scsi_commands.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/usb/scsi_commands.h 2007-11-05 21:54:12 UTC (rev 22837) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/usb/scsi_commands.h 2007-11-05 22:28:03 UTC (rev 22838) @@ -1,20 +1,17 @@ -/** +/* + * Copyright 2004-2007, Haiku, Inc. All RightsReserved. + * Distributed under the terms of the MIT License. * - * TODO: description - * - * This file is a part of USB SCSI CAM for Haiku OS. - * May be used under terms of the MIT License - * - * Author(s): - * Siarzhuk Zharski - * - * + * Author: + * Siarzhuk Zharski */ -/** definitions for SCSI commands, structures etc. */ - #ifndef _SCSI_COMMANDS_H_ - #define _SCSI_COMMANDS_H_ +#define _SCSI_COMMANDS_H_ +/*! Definitions for SCSI commands, structures etc. */ + +#include + /* References: * http://www.t10.org/ftp/t10/drafts/rbc/rbc-r10a.pdf * http://www.t10.org/ftp/t10/drafts/rbc/rbc-a101.pdf @@ -189,18 +186,23 @@ }scsi_cmd_generic_12; /* READ_6 / WRITE_6 */ typedef scsi_cmd_generic_6 scsi_cmd_rw_6; + /* READ_10 / WRITE_10 */ -typedef struct{ +typedef struct { uint8 opcode; - uint8 byte2; -#define CMD_RW_10_RELADDR 0x01 -#define CMD_RW_10_FUA 0x08 -#define CMD_RW_10_DPO 0x10 - uint8 addr[4]; - uint8 reserved; - uint8 len[2]; - uint8 ctrl; -}scsi_cmd_rw_10; + LBITFIELD8_5( + relative_address : 1, // relative address + _res1_1 : 2, + force_unit_access : 1, // force unit access (1 = safe, cacheless access) + disable_page_out : 1, // disable page out (1 = not worth caching) + lun : 3 + ); + uint32 lba; // big endian + uint8 _reserved; + uint16 length; // big endian + uint8 control; +} scsi_cmd_rw_10; + /* MODE_SELECT_6 */ typedef struct{ uint8 opcode; Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/usb/transform_procs.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/usb/transform_procs.c 2007-11-05 21:54:12 UTC (rev 22837) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/usb/transform_procs.c 2007-11-05 22:28:03 UTC (rev 22838) @@ -1,225 +1,241 @@ -/** +/* + * Copyright 2004-2007, Haiku, Inc. All RightsReserved. + * Distributed under the terms of the MIT License. * - * TODO: description - * - * This file is a part of USB SCSI CAM for Haiku OS. - * May be used under terms of the MIT License - * - * Author(s): - * Siarzhuk Zharski - * - * + * Author: + * Siarzhuk Zharski */ -/** SCSI commands transformations support */ -#include "usb_scsi.h" +/*! SCSI commands transformations support */ -#include "device_info.h" -#include "transform_procs.h" -#include "tracing.h" -#include "scsi_commands.h" -//#include "proto_common.h" +#include "usb_scsi.h" + +#include "device_info.h" +#include "transform_procs.h" +#include "tracing.h" +#include "scsi_commands.h" #include "settings.h" #include "strings.h" -#define UFI_COMMAND_LEN 12 -#define ATAPI_COMMAND_LEN 12 +#define UFI_COMMAND_LEN 12 +#define ATAPI_COMMAND_LEN 12 -static status_t -scsi_transform(usb_device_info *udi, uint8 *cmd, - uint8 len, uint8 **rcmd, uint8 *rlen); -static status_t rbc_transform(usb_device_info *udi, uint8 *cmd, - uint8 len, uint8 **rcmd, uint8 *rlen); -static status_t ufi_transform(usb_device_info *udi, uint8 *cmd, - uint8 len, uint8 **rcmd, uint8 *rlen); -static status_t atapi_transform(usb_device_info *udi, uint8 *cmd, - uint8 len, uint8 **rcmd, uint8 *rlen); -static status_t qic157_transform(usb_device_info *udi, uint8 *cmd, - uint8 len, uint8 **rcmd, uint8 *rlen); -/** - \fn:transform_6_to_10 + +/*! Transforms a 6-byte command to 10-byte one if required. Transformed command + is returned in rcmd parameter. In case if no transformation was performed + the return buffer is untouched. + \param cmd: SCSI command buffer to be transformed \param len: length of buffer, pointed by cmd parameter \param rcmd: a place for buffer pointer with transformed command \param rlen: a place for length of transformed command \return: true if transformation was performed - transforms a 6-byte command to 10-byte one if required.Transformed command is - returned in rcmd parameter. In case if no transformation was performed the return - buffer is untouched. */ -static bool transform_6_to_10(uint8 *cmd, uint8 len, - uint8 **rcmd, uint8 *rlen) +static void +transform_6_to_10(uint8 *cmd, uint8 len, uint8 **rcmd, uint8 *rlen) { - bool transformed = true; scsi_cmd_generic_6 *from = (scsi_cmd_generic_6 *)cmd; - memset(*rcmd, 0, *rlen); - switch (from->opcode){ + + *rlen = 10; + memset(*rcmd, 0, 10); + + switch (from->opcode) { case READ_6: - case WRITE_6:{ - scsi_cmd_rw_10 *to = (scsi_cmd_rw_10 *)(*rcmd); - to->opcode = (from->opcode == READ_6) ? READ_10 : WRITE_10; - memcpy(to->addr + 1, from->addr, 3); - to->byte2 = from->addr[0]; - to->byte2 &= ~CMD_GEN_6_ADDR; - to->addr[1] &= CMD_GEN_6_ADDR; - to->len[1] = from->len; - to->ctrl = from->ctrl; - if(0 == from->len){ /* special case! in 6-byte R/W commands */ - to->len[0] = 1; /* the length 0x00 assume transfering 0x100 blocks! */ - } - }break; + case WRITE_6: + { + scsi_cmd_rw_10 *to = (scsi_cmd_rw_10 *)(*rcmd); + + to->opcode = (from->opcode == READ_6) ? READ_10 : WRITE_10; + to->lba = B_HOST_TO_BENDIAN_INT32(((from->addr[0] & 0x1f) << 16) + | (from->addr[1] << 8) | from->addr[0]); + to->lun = (from->addr[0] & CMD_LUN) >> CMD_LUN_SHIFT; + to->control = from->ctrl; + if (from->len == 0) { + /* special case! in 6-byte R/W commands */ + /* the length 0x00 assume transfering 0x100 blocks! */ + to->length = B_HOST_TO_BENDIAN_INT16((uint16)256); + } else + to->length = B_HOST_TO_BENDIAN_INT16((uint16)from->len); + } + case MODE_SENSE_6: - case MODE_SELECT_6:{ - scsi_cmd_generic_10 *to = (scsi_cmd_generic_10 *)(*rcmd); - if(from->opcode == MODE_SENSE_6){ + case MODE_SELECT_6: + { + scsi_cmd_generic_10 *to = (scsi_cmd_generic_10 *)(*rcmd); + + if (from->opcode == MODE_SENSE_6) { to->opcode = MODE_SENSE_10; - ((scsi_cmd_mode_sense_10 *)to)->byte3 = - ((scsi_cmd_mode_sense_6 *)from)->byte3; - }else + ((scsi_cmd_mode_sense_10 *)to)->byte3 + = ((scsi_cmd_mode_sense_6 *)from)->byte3; + } else to->opcode = MODE_SELECT_10; - to->byte2 = from->addr[0]; - to->len[1] = from->len + 4; /*TODO: hardcoded length*/ - to->ctrl = from->ctrl; - }break; - default:{ /* no transformation needed */ - transformed = false; - }break; + to->byte2 = from->addr[0]; + to->len[1] = from->len + 4; /*TODO: hardcoded length*/ + to->ctrl = from->ctrl; + } + + default: + /* no transformation needed */ + break; } - return transformed; } -/** - \fn:transform_cmd_6_to_10 + + +/*! Transforms a 6-byte command to 10-byte depending on information provided + with udi object. + \param udi: usb_device_info object for wich transformation is requested \param cmd: SCSI command buffer to be transformed \param len: length of buffer, pointed by cmd parameter \param rcmd: a place for buffer pointer with transformed command \param rlen: a place for length of transformed command \return: true if transformation was performed - transforms a 6-byte command to 10-byte depending on information provided with - udi object. */ -static bool transform_cmd_6_to_10(usb_device_info *udi, uint8 *cmd, - uint8 len, uint8 **rcmd, uint8 *rlen) +static bool +transform_cmd_6_to_10(usb_device_info *udi, uint8 *cmd, uint8 len, + uint8 **rcmd, uint8 *rlen) { - bool transformed = true; scsi_cmd_generic_6 *from = (scsi_cmd_generic_6 *)cmd; - switch (from->opcode){ + + switch (from->opcode) { case READ_6: - case WRITE_6:{ -// if(!(HAS_FEATURES(udi->descr.properties, PROP_FORCE_TO_6))){ - if(!HAS_FIXES(udi->properties, FIX_FORCE_RW_TO_6)){ - if((transformed = transform_6_to_10(cmd, len, rcmd, rlen)) == true) - *rlen = 10; - }else - transformed = false; - }break; + case WRITE_6: + { + if (!HAS_FIXES(udi->properties, FIX_FORCE_RW_TO_6)) { + transform_6_to_10(cmd, len, rcmd, rlen); + return true; + } + break; + } + case MODE_SENSE_6: - case MODE_SELECT_6:{ -// if(HAS_FEATURES(udi->descr.properties, PROP_USE_MODESENSE_10)){ - if(HAS_FIXES(udi->properties, FIX_FORCE_MS_TO_10)){ - if((transformed = transform_6_to_10(cmd, len, rcmd, rlen)) == true) - *rlen = 10; - }else - transformed = false; + case MODE_SELECT_6: + { + if (HAS_FIXES(udi->properties, FIX_FORCE_MS_TO_10)) { + transform_6_to_10(cmd, len, rcmd, rlen); + return true; + } + break; } } - return transformed; + + return false; } -/** - \fn:transform_cmd_test_unit_ready + + +/*! Transforms a TEST_UNIT_COMAND SCSI command to START_STOP_UNIT one depending + on properties provided with udi object. + \param udi: usb_device_info object for wich transformation is requested \param cmd: SCSI command buffer to be transformed \param len: length of buffer, pointed by cmd parameter \param rcmd: a place for buffer pointer with transformed command \param rlen: a place for length of transformed command \return: true if transformation was performed - transforms a TEST_UNIT_COMAND SCSI command to START_STOP_UNIT one depending - on properties provided with udi object. */ -static bool transform_cmd_test_unit_ready(usb_device_info *udi, - uint8 *cmd, uint8 len, - uint8 **rcmd, uint8 *rlen) +static bool +transform_cmd_test_unit_ready(usb_device_info *udi, uint8 *cmd, uint8 len, + uint8 **rcmd, uint8 *rlen) { - bool transformed = false; - if(HAS_FIXES(udi->properties, FIX_TRANS_TEST_UNIT)){ - scsi_cmd_start_stop_unit *command = (scsi_cmd_start_stop_unit *)(*rcmd); - memset(*rcmd, 0, *rlen); - command->opcode = START_STOP_UNIT; - command->start_loej = CMD_SSU_START; - *rlen = 6; - transformed = true; - } - return transformed; + scsi_cmd_start_stop_unit *command = (scsi_cmd_start_stop_unit *)(*rcmd); + + if (!HAS_FIXES(udi->properties, FIX_TRANS_TEST_UNIT)) + return false; + + memset(*rcmd, 0, *rlen); + command->opcode = START_STOP_UNIT; + command->start_loej = CMD_SSU_START; + *rlen = 6; + + return true; } -/** - \fn:scsi_transform + + +// #pragma mark - + + +/*! This is the "transformation procedure" for transparent SCSI (0x06) USB + subclass. It performs all SCSI commands transformations required by this + protocol. Additionally it tries to make some workarounds for "broken" USB + devices. If no transformation was performed resulting command buffer + points to original one. + \param udi: usb_device_info object for wich transformation is requested \param cmd: SCSI command buffer to be transformed \param len: length of buffer, pointed by cmd parameter \param rcmd: a place for buffer pointer with transformed command \param rlen: a place for length of transformed command \return: B_OK if transformation was successfull, B_ERROR otherwise - this is the "transformation procedure" for transparent SCSI (0x06) USB subclass.It - performs all SCSI commands transformations required by this protocol. Additionally - it tries to make some workarounds for "brocken" USB devices. If no transformation - was performed resulting command buffer points to original one. */ -status_t -scsi_transform(usb_device_info *udi, uint8 *cmd, - uint8 len, uint8 **rcmd, uint8 *rlen) +static status_t +scsi_transform(usb_device_info *udi, uint8 *cmd, uint8 len, uint8 **rcmd, + uint8 *rlen) { - status_t status = B_OK; bool transformed = false; scsi_cmd_generic *command = (scsi_cmd_generic *)cmd; TRACE_SCSI_COMMAND(cmd, len); - switch(command->opcode){ + + switch (command->opcode) { case READ_6: case WRITE_6: case MODE_SENSE_6: case MODE_SELECT_6: transformed = transform_cmd_6_to_10(udi, cmd, len, rcmd, rlen); break; + case TEST_UNIT_READY: - transformed = transform_cmd_test_unit_ready(udi, cmd, len, rcmd, rlen); + transformed = transform_cmd_test_unit_ready(udi, cmd, len, rcmd, + rlen); break; - default: break; + + default: + break; } - if(!transformed){ /* transformation was not required */ + + if (!transformed) { + /* transformation was not required */ *rcmd = cmd; *rlen = len; - }else + } else TRACE_SCSI_COMMAND_HLIGHT(*rcmd, *rlen); - return status; + + return B_OK; } -/** - \fn:rbc_transform + + +/*! This is the "transformation procedure" for RBC USB subclass (0x01). It + performs all SCSI commands transformations required by this protocol. + Additionally it tries to make some workarounds for "broken" USB devices. + If no transformation was performed resulting command buffer points to + original one. + \param udi: usb_device_info object for wich transformation is requested \param cmd: SCSI command buffer to be transformed \param len: length of buffer, pointed by cmd parameter \param rcmd: a place for buffer pointer with transformed command \param rlen: a place for length of transformed command \return: B_OK if transformation was successfull, B_ERROR otherwise - this is the "transformation procedure" for RBC USB subclass (0x01).It - performs all SCSI commands transformations required by this protocol. Additionally - it tries to make some workarounds for "brocken" USB devices. If no transformation - was performed resulting command buffer points to original one. */ -status_t rbc_transform(usb_device_info *udi, uint8 *cmd, - uint8 len, uint8 **rcmd, uint8 *rlen) +static status_t +rbc_transform(usb_device_info *udi, uint8 *cmd, uint8 len, uint8 **rcmd, + uint8 *rlen) { - status_t status = B_OK; bool transformed = false; scsi_cmd_generic *command = (scsi_cmd_generic *)cmd; TRACE_SCSI_COMMAND(cmd, len); - switch(command->opcode){ + + switch (command->opcode) { case TEST_UNIT_READY: transformed = transform_cmd_test_unit_ready(udi, cmd, len, rcmd, rlen); break; + case READ_6: case WRITE_6: /* there are no such command in list of allowed - transform*/ transformed = transform_cmd_6_to_10(udi, cmd, len, rcmd, rlen); break; - case FORMAT_UNIT: /* TODO: all following ones are not checked against specs !!!*/ + + /* TODO: all following ones are not checked against specs !!!*/ + case FORMAT_UNIT: case INQUIRY: /*TODO: check !!! */ case MODE_SELECT_6: /*TODO: check !!! */ case MODE_SENSE_6: /*TODO: check !!! */ @@ -235,222 +251,251 @@ case SYNCHRONIZE_CACHE: /*TODO: check !!! */ case VERIFY: /*TODO: check !!! */ case WRITE_10: /*TODO: check !!! */ - case WRITE_BUFFER:/*TODO Check correctnes of such translation!*/ + case WRITE_BUFFER: /*TODO Check correctnes of such translation!*/ *rcmd = cmd; /* No need to copy */ *rlen = len; /*TODO: check !!! */ + break; + default: TRACE_ALWAYS("An unsupported RBC command: %08x\n", command->opcode); - status = B_ERROR; - break; + return B_ERROR; } - if(transformed) + + if (transformed) TRACE_SCSI_COMMAND_HLIGHT(*rcmd, *rlen); - return status; + + return B_OK; } -/** - \fn:ufi_transform + + +/*! This is the "transformation procedure" for UFI USB subclass (0x04). It + performs all SCSI commands transformations required by this protocol. + Additionally it tries to make some workarounds for "broken" USB devices. + If no transformation was performed resulting command buffer points to + the original one. + \param udi: usb_device_info object for wich transformation is requested \param cmd: SCSI command buffer to be transformed \param len: length of buffer, pointed by cmd parameter \param rcmd: a place for buffer pointer with transformed command \param rlen: a place for length of transformed command \return: B_OK if transformation was successfull, B_ERROR otherwise - this is the "transformation procedure" for UFI USB subclass (0x04).It - performs all SCSI commands transformations required by this protocol. Additionally - it tries to make some workarounds for "brocken" USB devices. If no transformation - was performed resulting command buffer points to original one. */ -status_t ufi_transform(usb_device_info *udi, - uint8 *cmd, - uint8 len, - uint8 **rcmd, - uint8 *rlen) +static status_t +ufi_transform(usb_device_info *udi, uint8 *cmd, uint8 len, uint8 **rcmd, + uint8 *rlen) { + scsi_cmd_generic *command = (scsi_cmd_generic *)cmd; status_t status = B_OK; + TRACE_SCSI_COMMAND(cmd, len); memset(*rcmd, 0, UFI_COMMAND_LEN); - if(!transform_6_to_10(cmd, len, rcmd, rlen)){ /* was not transformed ?*/ - scsi_cmd_generic *command = (scsi_cmd_generic *)cmd; - switch(command->opcode){ - case TEST_UNIT_READY: - if(transform_cmd_test_unit_ready(udi, cmd, len, rcmd, rlen)){ - break; /* if TEST UNIT READY was transformed*/ - } - case FORMAT_UNIT: /* TODO: mismatch */ - case INQUIRY: - case START_STOP_UNIT: - case MODE_SELECT_10: - case MODE_SENSE_10: - case PREVENT_ALLOW_MEDIA_REMOVAL: - case READ_10: - case READ_12: - case READ_CAPACITY: - case READ_FORMAT_CAPACITY: /* TODO: not in the SCSI-2 specs */ - case REQUEST_SENSE: - case REZERO_UNIT: - case SEEK_10: - case SEND_DIAGNOSTICS: /* TODO: parameter list len mismatch */ - case VERIFY: - case WRITE_10: - case WRITE_12: /* TODO: EBP. mismatch */ - case WRITE_AND_VERIFY: - memcpy(*rcmd, cmd, len); /*TODO what about control? ignored in UFI?*/ - break; - default: - TRACE_ALWAYS("An unsupported UFI command: %08x\n", command->opcode); - status = B_ERROR; - break; - } + + switch (command->opcode) { + case READ_6: + case WRITE_6: + case MODE_SENSE_6: + case MODE_SELECT_6: + // TODO: not transform_cmd_*()? + transform_6_to_10(cmd, len, rcmd, rlen); + break; + case TEST_UNIT_READY: + if (transform_cmd_test_unit_ready(udi, cmd, len, rcmd, rlen)) + break; /* if TEST UNIT READY was transformed*/ + case FORMAT_UNIT: /* TODO: mismatch */ + case INQUIRY: + case START_STOP_UNIT: + case MODE_SELECT_10: + case MODE_SENSE_10: + case PREVENT_ALLOW_MEDIA_REMOVAL: + case READ_10: + case READ_12: + case READ_CAPACITY: + case READ_FORMAT_CAPACITY: /* TODO: not in the SCSI-2 specs */ + case REQUEST_SENSE: + case REZERO_UNIT: + case SEEK_10: + case SEND_DIAGNOSTICS: /* TODO: parameter list len mismatch */ + case VERIFY: + case WRITE_10: + case WRITE_12: /* TODO: EBP. mismatch */ + case WRITE_AND_VERIFY: + memcpy(*rcmd, cmd, len); + /*TODO what about control? ignored in UFI?*/ + break; + default: + TRACE_ALWAYS("An unsupported UFI command: %08x\n", + command->opcode); + status = B_ERROR; + break; } + *rlen = UFI_COMMAND_LEN; /* override any value set in transform funcs !!!*/ - if(status == B_OK) + + if (status == B_OK) TRACE_SCSI_COMMAND_HLIGHT(*rcmd, *rlen); + return status; } -/** - \fn:atapi_transform + + +/*! This is the "transformation procedure" for SFF8020I and SFF8070I + USB subclassses (0x02 and 0x05). It performs all SCSI commands + transformations required by this protocol. Additionally it tries to make + some workarounds for "broken" USB devices. If no transformation was + performed resulting command buffer points to the original one. + \param udi: usb_device_info object for wich transformation is requested \param cmd: SCSI command buffer to be transformed \param len: length of buffer, pointed by cmd parameter \param rcmd: a place for buffer pointer with transformed command \param rlen: a place for length of transformed command \return: B_OK if transformation was successfull, B_ERROR otherwise - this is the "transformation procedure" for SFF8020I and SFF8070I - USB subclassses (0x02 and 0x05). It performs all SCSI commands transformations - required by this protocol. Additionally it tries to make some workarounds for - "broken" USB devices. If no transformation was performed resulting command - buffer points to original one. */ -status_t atapi_transform(usb_device_info *udi, - uint8 *cmd, - uint8 len, - uint8 **rcmd, - uint8 *rlen) +static status_t +atapi_transform(usb_device_info *udi, uint8 *cmd, uint8 len, uint8 **rcmd, + uint8 *rlen) { + scsi_cmd_generic *command = (scsi_cmd_generic *)cmd; status_t status = B_OK; + TRACE_SCSI_COMMAND(cmd, len); memset(*rcmd, 0, ATAPI_COMMAND_LEN); - if(!transform_6_to_10(cmd, len, rcmd, rlen)){ /* was not transformed ?*/ - scsi_cmd_generic *command = (scsi_cmd_generic *)cmd; - switch(command->opcode){ - case TEST_UNIT_READY: - if(transform_cmd_test_unit_ready(udi, cmd, len, rcmd, rlen)){ - break; /* if TEST UNIT READY was transformed*/ - } - case FORMAT_UNIT: - case INQUIRY: - case MODE_SELECT_10: - case MODE_SENSE_10: - case PREVENT_ALLOW_MEDIA_REMOVAL: - case READ_10: - case READ_12: /* mismatch in byte 1 */ - case READ_CAPACITY: /* mismatch. no transf len defined... */ - case READ_FORMAT_CAPACITY: /* TODO: check!!! */ - case REQUEST_SENSE: - case SEEK_10: - case START_STOP_UNIT: - case VERIFY: /* mismatch DPO */ - case WRITE_10: /* mismatch in byte 1 */ - case WRITE_12: /* mismatch in byte 1 */ - case WRITE_AND_VERIFY: /* mismatch byte 1 */ - case PAUSE_RESUME: - case PLAY_AUDIO: - case PLAY_AUDIO_MSF: - case REWIND: - case PLAY_AUDIO_TRACK: - /* are in FreeBSD driver but no in 8070/8020 specs ... - //case REZERO_UNIT: - //case SEND_DIAGNOSTIC: - //case POSITION_TO_ELEMENT: */ - case GET_CONFIGURATION: - case SYNCHRONIZE_CACHE: - case READ_BUFFER: - case READ_SUBCHANNEL: - case READ_TOC: /* some mismatch */ - case READ_HEADER: - case READ_DISK_INFO: - case READ_TRACK_INFO: - case SEND_OPC: - case READ_MASTER_CUE: - case CLOSE_TR_SESSION: - case READ_BUFFER_CAP: - case SEND_CUE_SHEET: - case BLANK: - case EXCHANGE_MEDIUM: - case READ_DVD_STRUCTURE: - case SET_CD_SPEED: - case DVD_REPORT_KEY: + + switch (command->opcode) { + case READ_6: + case WRITE_6: + case MODE_SENSE_6: + case MODE_SELECT_6: + // TODO: not transform_cmd_*()? + transform_6_to_10(cmd, len, rcmd, rlen)) + break; + case TEST_UNIT_READY: + if (transform_cmd_test_unit_ready(udi, cmd, len, rcmd, rlen)) + break; + case FORMAT_UNIT: + case INQUIRY: + case MODE_SELECT_10: + case MODE_SENSE_10: + case PREVENT_ALLOW_MEDIA_REMOVAL: + case READ_10: + case READ_12: /* mismatch in byte 1 */ + case READ_CAPACITY: /* mismatch. no transf len defined... */ + case READ_FORMAT_CAPACITY: /* TODO: check!!! */ + case REQUEST_SENSE: + case SEEK_10: + case START_STOP_UNIT: + case VERIFY: /* mismatch DPO */ + case WRITE_10: /* mismatch in byte 1 */ + case WRITE_12: /* mismatch in byte 1 */ + case WRITE_AND_VERIFY: /* mismatch byte 1 */ + case PAUSE_RESUME: + case PLAY_AUDIO: + case PLAY_AUDIO_MSF: + case REWIND: + case PLAY_AUDIO_TRACK: + /* are in FreeBSD driver but no in 8070/8020 specs ... + //case REZERO_UNIT: + //case SEND_DIAGNOSTIC: + //case POSITION_TO_ELEMENT: */ + case GET_CONFIGURATION: + case SYNCHRONIZE_CACHE: + case READ_BUFFER: + case READ_SUBCHANNEL: + case READ_TOC: /* some mismatch */ + case READ_HEADER: + case READ_DISK_INFO: + case READ_TRACK_INFO: + case SEND_OPC: + case READ_MASTER_CUE: + case CLOSE_TR_SESSION: + case READ_BUFFER_CAP: + case SEND_CUE_SHEET: + case BLANK: + case EXCHANGE_MEDIUM: + case READ_DVD_STRUCTURE: + case SET_CD_SPEED: + case DVD_REPORT_KEY: case DVD_SEND_KEY: -// case 0xe5: /* READ_TRACK_INFO_PHILIPS *//* TODO: check!!! */ - memcpy(*rcmd, cmd, len); /* TODO: check!!! */ - break; - default: - TRACE_ALWAYS("An unsupported (?) ATAPI command: %08x\n", command->opcode); - status = B_ERROR; - break; - } + //case 0xe5: /* READ_TRACK_INFO_PHILIPS *//* TODO: check!!! */ + memcpy(*rcmd, cmd, len); /* TODO: check!!! */ + break; + + default: + TRACE_ALWAYS("An unsupported (?) ATAPI command: %08x\n", + command->opcode); + status = B_ERROR; + break; } + *rlen = ATAPI_COMMAND_LEN; - if(status == B_OK) + + if (status == B_OK) TRACE_SCSI_COMMAND_HLIGHT(*rcmd, *rlen); + return status; } -/** - \fn:qic157_transform + + +/*! This is the "transformation procedure" for QIC157 USB subclass (0x03). It + performs all SCSI commands transformations required by this protocol. + Additionally it tries to make some workarounds for "broken" USB devices. + If no transformation was performed the resulting command buffer points to + the original one. + \param udi: usb_device_info object for wich transformation is requested \param cmd: SCSI command buffer to be transformed \param len: length of buffer, pointed by cmd parameter \param rcmd: a place for buffer pointer with transformed command \param rlen: a place for length of transformed command \return: B_OK if transformation was successfull, B_ERROR otherwise - this is the "transformation procedure" for QIC157 USB subclass (0x03).It - performs all SCSI commands transformations required by this protocol. Additionally - it tries to make some workarounds for "brocken" USB devices. If no transformation - was performed resulting command buffer points to original one. */ -status_t qic157_transform(usb_device_info *udi, - uint8 *cmd, - uint8 len, - uint8 **rcmd, - uint8 *rlen) +static status_t +qic157_transform(usb_device_info *udi, uint8 *cmd, uint8 len, uint8 **rcmd, + uint8 *rlen) { + scsi_cmd_generic *command = (scsi_cmd_generic *)cmd; status_t status = B_OK; + TRACE_SCSI_COMMAND(cmd, len); *rlen = ATAPI_COMMAND_LEN; memset(*rcmd, 0, *rlen); - if(!transform_6_to_10(cmd, len, rcmd, rlen)){ // was not transformed ? - scsi_cmd_generic *command = (scsi_cmd_generic *)cmd; - switch(command->opcode){ - case TEST_UNIT_READY: - if(transform_cmd_test_unit_ready(udi, cmd, len, rcmd, rlen)){ - break; // if TEST UNIT READY was transformed - } - case ERASE: /*TODO: check !!! */ - case INQUIRY: /*TODO: check !!! */ - case LOAD_UNLOAD: /*TODO: check !!! */ - case LOCATE: /*TODO: check !!! */ - case LOG_SELECT: /*TODO: check !!! */ - case LOG_SENSE: /*TODO: check !!! */ - case MODE_SELECT_6: /*TODO: check !!! */ - case MODE_SENSE_6: /*TODO: check !!! */ - case READ_6: /*TODO: check !!! */ - case READ_POSITION: /*TODO: check !!! */ - case REQUEST_SENSE: /*TODO: check !!! */ - case REWIND: /*TODO: check !!! */ - case SPACE: /*TODO: check !!! */ - case WRITE_6: /*TODO: check !!! */ - case WRITE_FILEMARK: /*TODO: check !!! */ - *rcmd = cmd; /*TODO: check !!! */ - *rlen = len; - break; - default: - TRACE_ALWAYS("An unsupported QIC-157 command: %08x\n", command->opcode); - status = B_ERROR; - break; - } + + switch (command->opcode) { + case READ_6: + case WRITE_6: + case MODE_SENSE_6: + case MODE_SELECT_6: + // TODO: not transform_cmd_*()? + transform_6_to_10(cmd, len, rcmd, rlen); + break; + case TEST_UNIT_READY: + if (transform_cmd_test_unit_ready(udi, cmd, len, rcmd, rlen)) + break; // if TEST UNIT READY was transformed + case ERASE: /*TODO: check !!! */ + case INQUIRY: /*TODO: check !!! */ + case LOAD_UNLOAD: /*TODO: check !!! */ + case LOCATE: /*TODO: check !!! */ + case LOG_SELECT: /*TODO: check !!! */ + case LOG_SENSE: /*TODO: check !!! */ + case READ_POSITION: /*TODO: check !!! */ + case REQUEST_SENSE: /*TODO: check !!! */ + case REWIND: /*TODO: check !!! */ + case SPACE: /*TODO: check !!! */ + case WRITE_FILEMARK: /*TODO: check !!! */ + *rcmd = cmd; /*TODO: check !!! */ + *rlen = len; + break; + default: + TRACE_ALWAYS("An unsupported QIC-157 command: %08x\n", + command->opcode); + status = B_ERROR; + break; } - if(status == B_OK) + + if (status == B_OK) TRACE_SCSI_COMMAND_HLIGHT(*rcmd, *rlen); + return status; } From axeld at mail.berlios.de Mon Nov 5 23:35:38 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 5 Nov 2007 23:35:38 +0100 Subject: [Haiku-commits] r22839 - haiku/trunk/src/add-ons/kernel/busses/scsi/usb Message-ID: <200711052235.lA5MZc40005600@sheep.berlios.de> Author: axeld Date: 2007-11-05 23:35:38 +0100 (Mon, 05 Nov 2007) New Revision: 22839 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22839&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/usb/transform_procs.c Log: DO NOT MAKE UNTESTED LAST MINUTE CHANGES (and also don't forget about them before committing :-)) - this fixes the build. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/usb/transform_procs.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/usb/transform_procs.c 2007-11-05 22:28:03 UTC (rev 22838) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/usb/transform_procs.c 2007-11-05 22:35:38 UTC (rev 22839) @@ -368,7 +368,7 @@ case MODE_SENSE_6: case MODE_SELECT_6: // TODO: not transform_cmd_*()? - transform_6_to_10(cmd, len, rcmd, rlen)) + transform_6_to_10(cmd, len, rcmd, rlen); break; case TEST_UNIT_READY: if (transform_cmd_test_unit_ready(udi, cmd, len, rcmd, rlen)) From axeld at mail.berlios.de Tue Nov 6 00:08:58 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 6 Nov 2007 00:08:58 +0100 Subject: [Haiku-commits] r22840 - haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112 Message-ID: <200711052308.lA5N8w2O007266@sheep.berlios.de> Author: axeld Date: 2007-11-06 00:08:58 +0100 (Tue, 06 Nov 2007) New Revision: 22840 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22840&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c Log: * My changes to the ide_adapter.h broke the silicon_image_3112 which I didn't notice until now. Fixed again. * Cleanup. Modified: haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c 2007-11-05 22:35:38 UTC (rev 22839) +++ haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c 2007-11-05 23:08:58 UTC (rev 22840) @@ -3,11 +3,13 @@ * Distributed under the terms of the MIT License. */ -#include #include #include + +#include #include #include + #include #include @@ -25,16 +27,18 @@ ASIC_SI3114 = 1, }; +#if 0 static const char *adapter_asic_names[] = { "si3112", "si3114", NULL }; +#endif static const struct { uint16 channel_count; uint32 mmio_bar_size; -} asic_data[2] = { +} kASICData[2] = { { 2, 0x200 }, { 4, 0x400 }, }; @@ -46,7 +50,7 @@ uint16 sien; uint16 stat; const char *name; -} controller_channel_data[] = { +} kControllerChannelData[] = { { 0x80, 0x8A, 0x00, 0x148, 0xA0, "Primary Channel" }, { 0xC0, 0xCA, 0x08, 0x1C8, 0xE0, "Secondary Channel" }, { 0x280, 0x28A, 0x200, 0x348, 0x2A0, "Tertiary Channel" }, @@ -66,7 +70,7 @@ pci_device device; device_node_handle node; - + struct channel_data *channel[4]; // XXX only for interrupt workaround int channel_count; // XXX only for interrupt workaround @@ -75,14 +79,13 @@ area_id mmio_area; uint32 mmio_addr; - + uint32 lost; // != 0 if device got removed, i.e. if it must not // be accessed anymore } controller_data; typedef struct channel_data { - pci_device_module_info *pci; device_node_handle node; pci_device device; @@ -103,7 +106,6 @@ void * prdt_phys; uint32 dma_active; uint32 lost; - } channel_data; @@ -114,13 +116,14 @@ static status_t device_control_write(void *channel_cookie, uint8 val); static int32 handle_interrupt(void *arg); + static float controller_supports(device_node_handle parent, bool *_noConnection) { char *bus; - uint16 vendor_id; - uint16 device_id; - + uint16 vendorID; + uint16 deviceID; + // get the bus (should be PCI) if (dm->get_attr_string(parent, B_DRIVER_BUS, &bus, false) != B_OK) return B_ERROR; @@ -129,16 +132,15 @@ return B_ERROR; } free(bus); - + // get vendor and device ID - if (dm->get_attr_uint16(parent, PCI_DEVICE_VENDOR_ID_ITEM, &vendor_id, false) != B_OK - || dm->get_attr_uint16(parent, PCI_DEVICE_DEVICE_ID_ITEM, &device_id, false) != B_OK) { + if (dm->get_attr_uint16(parent, PCI_DEVICE_VENDOR_ID_ITEM, &vendorID, false) != B_OK + || dm->get_attr_uint16(parent, PCI_DEVICE_DEVICE_ID_ITEM, &deviceID, false) != B_OK) { return B_ERROR; } - - #define ID(v,d) (((v)<< 16) | (d)) - switch (ID(vendor_id, device_id)) { + #define ID(v, d) (((v) << 16) | (d)) + switch (ID(vendorID, deviceID)) { case ID(0x1095, 0x3112): case ID(0x1095, 0x3114): break; @@ -146,7 +148,7 @@ return 0.0f; } - TRACE("controller found! vendor 0x%04x, device 0x%04x\n", vendor_id, device_id); + TRACE("controller found! vendor 0x%04x, device 0x%04x\n", vendorID, deviceID); return 0.8f; } @@ -158,41 +160,42 @@ pci_device device; pci_device_module_info *pci; device_node_handle controller_node; - uint32 mmio_base; - uint16 device_id; - uint8 int_num; - int asic_index; - int chan_index; + uint32 mmioBase; + uint16 deviceID; + uint8 interruptNumber; + int asicIndex; + int channelIndex; status_t res; TRACE("controller_probe\n"); - if (dm->init_driver(parent, NULL, (driver_module_info **)&pci, (void **)&device) != B_OK) + if (dm->init_driver(parent, NULL, (driver_module_info **)&pci, + (void **)&device) != B_OK) return B_ERROR; - - device_id = pci->read_pci_config(device, PCI_device_id, 2); - int_num = pci->read_pci_config(device, PCI_interrupt_line, 1); - mmio_base = pci->read_pci_config(device, PCI_base_registers + 20, 4); - mmio_base &= PCI_address_io_mask; - - switch (device_id) { + + deviceID = pci->read_pci_config(device, PCI_device_id, 2); + interruptNumber = pci->read_pci_config(device, PCI_interrupt_line, 1); + mmioBase = pci->read_pci_config(device, PCI_base_registers + 20, 4) + & PCI_address_io_mask; + + switch (deviceID) { case 0x3112: - asic_index = ASIC_SI3112; + asicIndex = ASIC_SI3112; break; case 0x3114: - asic_index = ASIC_SI3114; + asicIndex = ASIC_SI3114; break; default: TRACE("unsupported asic\n"); goto err; } - if (!mmio_base) { + if (!mmioBase) { TRACE("mmio not configured\n"); goto err; } - if (int_num == 0 || int_num == 0xff) { + if (interruptNumber == 0 || interruptNumber == 0xff) { TRACE("irq not configured\n"); goto err; } @@ -200,7 +203,7 @@ { io_resource_handle resource_handles[2]; io_resource resources[2] = { - { IO_MEM, mmio_base, asic_data[asic_index].mmio_bar_size }, + { IO_MEM, mmioBase, kASICData[asicIndex].mmio_bar_size }, {} }; @@ -219,7 +222,7 @@ // there are always max. 2 devices // (unless this is a Compact Flash Card with a built-in IDE controller, // which has exactly 1 device) - { IDE_CONTROLLER_MAX_DEVICES_ITEM, B_UINT8_TYPE, { ui8: asic_data[asic_index].channel_count }}, + { IDE_CONTROLLER_MAX_DEVICES_ITEM, B_UINT8_TYPE, { ui8: kASICData[asicIndex].channel_count }}, // of course we can DMA { IDE_CONTROLLER_CAN_DMA_ITEM, B_UINT8_TYPE, { ui8: true }}, // command queuing always works @@ -239,9 +242,9 @@ { B_BLOCK_DEVICE_MAX_SG_BLOCKS, B_UINT32_TYPE, { ui32: IDE_ADAPTER_MAX_SG_COUNT }}, // private data to find controller - { "silicon_image_3112/asic_index", B_UINT32_TYPE, { ui32: asic_index }}, - { "silicon_image_3112/mmio_base", B_UINT32_TYPE, { ui32: mmio_base }}, - { "silicon_image_3112/int_num", B_UINT32_TYPE, { ui32: int_num }}, + { "silicon_image_3112/asic_index", B_UINT32_TYPE, { ui32: asicIndex }}, + { "silicon_image_3112/mmio_base", B_UINT32_TYPE, { ui32: mmioBase }}, + { "silicon_image_3112/int_num", B_UINT32_TYPE, { ui32: interruptNumber }}, { NULL } }; @@ -256,23 +259,23 @@ } // publish channel nodes - for (chan_index = 0; chan_index < asic_data[asic_index].channel_count; chan_index++) { + for (channelIndex = 0; channelIndex < kASICData[asicIndex].channel_count; channelIndex++) { device_attr channel_attrs[] = { // info about ourself and our consumer { B_DRIVER_MODULE, B_STRING_TYPE, { string: CHANNEL_MODULE_NAME }}, { B_DRIVER_PRETTY_NAME, B_STRING_TYPE, { string: DRIVER_PRETTY_NAME }}, - { PNP_DRIVER_CONNECTION, B_STRING_TYPE, { string: controller_channel_data[chan_index].name }}, + { PNP_DRIVER_CONNECTION, B_STRING_TYPE, { string: kControllerChannelData[channelIndex].name }}, { B_DRIVER_FIXED_CHILD, B_STRING_TYPE, { string: IDE_FOR_CONTROLLER_MODULE_NAME }}, // private data to identify channel { IDE_CONTROLLER_CAN_DMA_ITEM, B_UINT8_TYPE, { ui8: true }}, - { "silicon_image_3112/chan_index", B_UINT32_TYPE, { ui32: chan_index }}, + { "silicon_image_3112/chan_index", B_UINT32_TYPE, { ui32: channelIndex }}, { NULL } }; device_node_handle channel_node; - TRACE("publishing %s\n", controller_channel_data[chan_index].name ); + TRACE("publishing %s\n", kControllerChannelData[channelIndex].name ); dm->register_device(controller_node, channel_attrs, resource_handles, &channel_node); } @@ -293,27 +296,28 @@ static status_t -controller_init(device_node_handle node, void *user_cookie, void **controller_cookie) +controller_init(device_node_handle node, void *userCookie, + void **_controllerCookie) { controller_data *controller; pci_device_module_info *pci; pci_device device; - uint32 asic_index; - uint32 mmio_base; - uint32 mmio_addr; - area_id mmio_area; - uint32 int_num; + uint32 asicIndex; + uint32 mmioBase; + uint32 mmioAddr; + area_id mmioArea; + uint32 interruptNumber; status_t res; uint32 temp; int i; TRACE("controller_init\n"); - if (dm->get_attr_uint32(node, "silicon_image_3112/asic_index", &asic_index, false) != B_OK) + if (dm->get_attr_uint32(node, "silicon_image_3112/asic_index", &asicIndex, false) != B_OK) return B_ERROR; - if (dm->get_attr_uint32(node, "silicon_image_3112/mmio_base", &mmio_base, false) != B_OK) + if (dm->get_attr_uint32(node, "silicon_image_3112/mmio_base", &mmioBase, false) != B_OK) return B_ERROR; - if (dm->get_attr_uint32(node, "silicon_image_3112/int_num", &int_num, false) != B_OK) + if (dm->get_attr_uint32(node, "silicon_image_3112/int_num", &interruptNumber, false) != B_OK) return B_ERROR; controller = malloc(sizeof(controller_data)); @@ -322,10 +326,10 @@ FLOW("controller %p\n", controller); - mmio_area = map_physical_memory("Silicon Image SATA regs", (void *)mmio_base, - asic_data[asic_index].mmio_bar_size, - B_ANY_KERNEL_ADDRESS, 0, (void **)&mmio_addr); - if (mmio_area < B_OK) { + mmioArea = map_physical_memory("Silicon Image SATA regs", + (void *)mmioBase, kASICData[asicIndex].mmio_bar_size, + B_ANY_KERNEL_ADDRESS, 0, (void **)&mmioAddr); + if (mmioArea < B_OK) { TRACE("controller_init: mapping memory failed\n"); free(controller); return B_ERROR; @@ -334,56 +338,56 @@ if (dm->init_driver(dm->get_parent(node), NULL, (driver_module_info **)&pci, (void **)&device) < B_OK) { TRACE("controller_init: init parent failed\n"); - delete_area(mmio_area); + delete_area(mmioArea); free(controller); return B_ERROR; } - TRACE("asic %ld\n", asic_index); - TRACE("int_num %ld\n", int_num); - TRACE("mmio_addr %p\n", (void *)mmio_addr); + TRACE("asic %ld\n", asicIndex); + TRACE("int_num %ld\n", interruptNumber); + TRACE("mmio_addr %p\n", (void *)mmioAddr); - controller->pci = pci; - controller->device = device; - controller->node = node; - controller->asic_index = asic_index; - controller->int_num = int_num; - controller->mmio_area = mmio_area; - controller->mmio_addr = mmio_addr; - controller->lost = 0; + controller->pci = pci; + controller->device = device; + controller->node = node; + controller->asic_index = asicIndex; + controller->int_num = interruptNumber; + controller->mmio_area = mmioArea; + controller->mmio_addr = mmioAddr; + controller->lost = 0; - controller->channel_count = asic_data[asic_index].channel_count; - for (i = 0; i < asic_data[asic_index].channel_count; i++) + controller->channel_count = kASICData[asicIndex].channel_count; + for (i = 0; i < kASICData[asicIndex].channel_count; i++) controller->channel[i] = 0; - if (asic_index == ASIC_SI3114) { + if (asicIndex == ASIC_SI3114) { // I put a magic spell on you - temp = *(volatile uint32 *)(mmio_addr + SI_BMDMA2); - *(volatile uint32 *)(mmio_addr + SI_BMDMA2) = temp | SI_INT_STEERING; - *(volatile uint32 *)(mmio_addr + SI_BMDMA2); // flush + temp = *(volatile uint32 *)(mmioAddr + SI_BMDMA2); + *(volatile uint32 *)(mmioAddr + SI_BMDMA2) = temp | SI_INT_STEERING; + *(volatile uint32 *)(mmioAddr + SI_BMDMA2); // flush } // disable all sata phy interrupts - for (i = 0; i < asic_data[asic_index].channel_count; i++) - *(volatile uint32 *)(mmio_addr + controller_channel_data[i].sien) = 0; - *(volatile uint32 *)(mmio_addr + controller_channel_data[0].sien); // flush + for (i = 0; i < kASICData[asicIndex].channel_count; i++) + *(volatile uint32 *)(mmioAddr + kControllerChannelData[i].sien) = 0; + *(volatile uint32 *)(mmioAddr + kControllerChannelData[0].sien); // flush // install interrupt handler - res = install_io_interrupt_handler(int_num, handle_interrupt, controller, 0); + res = install_io_interrupt_handler(interruptNumber, handle_interrupt, controller, 0); if (res < B_OK) { TRACE("controller_init: installing interrupt handler failed\n"); dm->uninit_driver(dm->get_parent(node)); - delete_area(mmio_area); + delete_area(mmioArea); free(controller); } // unmask interrupts - temp = *(volatile uint32 *)(mmio_addr + SI_SYSCFG); - temp &= (asic_index == ASIC_SI3114) ? (~SI_MASK_4PORT) : (~SI_MASK_2PORT); - *(volatile uint32 *)(mmio_addr + SI_SYSCFG) = temp; - *(volatile uint32 *)(mmio_addr + SI_SYSCFG); // flush + temp = *(volatile uint32 *)(mmioAddr + SI_SYSCFG); + temp &= (asicIndex == ASIC_SI3114) ? (~SI_MASK_4PORT) : (~SI_MASK_2PORT); + *(volatile uint32 *)(mmioAddr + SI_SYSCFG) = temp; + *(volatile uint32 *)(mmioAddr + SI_SYSCFG); // flush - *controller_cookie = controller; + *_controllerCookie = controller; TRACE("controller_init success\n"); return B_OK; @@ -391,9 +395,9 @@ static status_t -controller_uninit(void *controller_cookie) +controller_uninit(void *controllerCookie) { - controller_data *controller = controller_cookie; + controller_data *controller = controllerCookie; uint32 temp; TRACE("controller_uninit enter\n"); @@ -416,9 +420,9 @@ static void -controller_removed(device_node_handle node, void *controller_cookie) +controller_removed(device_node_handle node, void *controllerCookie) { - controller_data *controller = controller_cookie; + controller_data *controller = controllerCookie; controller->lost = 1; } @@ -435,14 +439,14 @@ static status_t -channel_init(device_node_handle node, void *user_cookie, void **channel_cookie) +channel_init(device_node_handle node, void *userCookie, void **_channelCookie) { - ide_channel ide_channel = user_cookie; + ide_channel ide_channel = userCookie; controller_data *controller; channel_data *channel; - physical_entry pe[1]; - size_t prdt_size; - uint32 chan_index; + physical_entry entry; + size_t prdtSize; + uint32 channelIndex; TRACE("channel_init enter\n"); @@ -452,11 +456,11 @@ TRACE("channel %p\n", channel); - if (dm->get_attr_uint32(node, "silicon_image_3112/chan_index", &chan_index, false) != B_OK) + if (dm->get_attr_uint32(node, "silicon_image_3112/chan_index", &channelIndex, false) != B_OK) goto err; - TRACE("channel_index %ld\n", chan_index); - TRACE("channel name: %s\n", controller_channel_data[chan_index].name); + TRACE("channel_index %ld\n", channelIndex); + TRACE("channel name: %s\n", kControllerChannelData[channelIndex].name); if (dm->init_driver(dm->get_parent(node), NULL, NULL, (void **)&controller) != B_OK) goto err; @@ -465,45 +469,43 @@ TRACE("mmio_addr %p\n", (void *)controller->mmio_addr); // PRDT must be contiguous, dword-aligned and must not cross 64K boundary - prdt_size = (IDE_ADAPTER_MAX_SG_COUNT * sizeof(prd_entry) + (B_PAGE_SIZE - 1)) & ~(B_PAGE_SIZE - 1); - channel->prd_area = create_area("prd", (void **)&channel->prdt, B_ANY_KERNEL_ADDRESS, prdt_size, B_FULL_LOCK | B_CONTIGUOUS, 0); + prdtSize = (IDE_ADAPTER_MAX_SG_COUNT * sizeof(prd_entry) + (B_PAGE_SIZE - 1)) & ~(B_PAGE_SIZE - 1); + channel->prd_area = create_area("prd", (void **)&channel->prdt, B_ANY_KERNEL_ADDRESS, prdtSize, B_FULL_LOCK | B_CONTIGUOUS, 0); if (channel->prd_area < B_OK) { TRACE("creating prd_area failed\n"); goto err2; } - get_memory_map(channel->prdt, prdt_size, pe, 1); - channel->prdt_phys = (void *)(uint32)pe[0].address; + get_memory_map(channel->prdt, prdtSize, &entry, 1); + channel->prdt_phys = entry.address; channel->pci = controller->pci; channel->device = controller->device; channel->node = node; channel->ide_channel = ide_channel; - channel->task_file = (volatile uint8 *)(controller->mmio_addr + controller_channel_data[chan_index].cmd + 1); - channel->control_block = (volatile uint8 *)(controller->mmio_addr + controller_channel_data[chan_index].ctl); - channel->command_block = (volatile uint8 *)(controller->mmio_addr + controller_channel_data[chan_index].cmd); - channel->dev_ctrl = (volatile uint8 *)(controller->mmio_addr + controller_channel_data[chan_index].ctl); - channel->bm_prdt_address = (volatile uint32 *)(controller->mmio_addr + controller_channel_data[chan_index].bmdma + ide_bm_prdt_address); - channel->bm_status_reg = (volatile uint8 *)(controller->mmio_addr + controller_channel_data[chan_index].bmdma + ide_bm_status_reg); - channel->bm_command_reg = (volatile uint8 *)(controller->mmio_addr + controller_channel_data[chan_index].bmdma + ide_bm_command_reg); - channel->stat = (volatile uint32 *)(controller->mmio_addr + controller_channel_data[chan_index].stat); + channel->task_file = (volatile uint8 *)(controller->mmio_addr + kControllerChannelData[channelIndex].cmd + 1); + channel->control_block = (volatile uint8 *)(controller->mmio_addr + kControllerChannelData[channelIndex].ctl); + channel->command_block = (volatile uint8 *)(controller->mmio_addr + kControllerChannelData[channelIndex].cmd); + channel->dev_ctrl = (volatile uint8 *)(controller->mmio_addr + kControllerChannelData[channelIndex].ctl); + channel->bm_prdt_address = (volatile uint32 *)(controller->mmio_addr + kControllerChannelData[channelIndex].bmdma + IDE_BM_PRDT_ADDRESS); + channel->bm_status_reg = (volatile uint8 *)(controller->mmio_addr + kControllerChannelData[channelIndex].bmdma + IDE_BM_STATUS_REG); + channel->bm_command_reg = (volatile uint8 *)(controller->mmio_addr + kControllerChannelData[channelIndex].bmdma + IDE_BM_COMMAND_REG); + channel->stat = (volatile uint32 *)(controller->mmio_addr + kControllerChannelData[channelIndex].stat); channel->lost = 0; channel->dma_active = 0; - controller->channel[chan_index] = channel; + controller->channel[channelIndex] = channel; // enable interrupts so the channel is ready to run device_control_write(channel, ide_devctrl_bit3); - *channel_cookie = channel; + *_channelCookie = channel; TRACE("channel_init leave\n"); return B_OK; -err3: - delete_area(channel->prd_area); err2: dm->uninit_driver(dm->get_parent(node)); err: @@ -513,9 +515,9 @@ static status_t -channel_uninit(void *channel_cookie) +channel_uninit(void *channelCookie) { - channel_data *channel = channel_cookie; + channel_data *channel = channelCookie; TRACE("channel_uninit enter\n"); @@ -538,17 +540,17 @@ static void -channel_removed(device_node_handle node, void *channel_cookie) +channel_removed(device_node_handle node, void *channelCookie) { - channel_data *channel = channel_cookie; + channel_data *channel = channelCookie; channel->lost = 1; } static status_t -task_file_write(void *channel_cookie, ide_task_file *tf, ide_reg_mask mask) +task_file_write(void *channelCookie, ide_task_file *tf, ide_reg_mask mask) { - channel_data *channel = channel_cookie; + channel_data *channel = channelCookie; int i; FLOW("task_file_write\n"); @@ -574,9 +576,9 @@ static status_t -task_file_read(void *channel_cookie, ide_task_file *tf, ide_reg_mask mask) +task_file_read(void *channelCookie, ide_task_file *tf, ide_reg_mask mask) { - channel_data *channel = channel_cookie; + channel_data *channel = channelCookie; int i; FLOW("task_file_read\n"); @@ -596,9 +598,9 @@ static uint8 -altstatus_read(void *channel_cookie) +altstatus_read(void *channelCookie) { - channel_data *channel = channel_cookie; + channel_data *channel = channelCookie; FLOW("altstatus_read\n"); @@ -610,9 +612,9 @@ static status_t -device_control_write(void *channel_cookie, uint8 val) +device_control_write(void *channelCookie, uint8 val) { - channel_data *channel = channel_cookie; + channel_data *channel = channelCookie; FLOW("device_control_write %x\n", val); @@ -627,9 +629,9 @@ static status_t -pio_write(void *channel_cookie, uint16 *data, int count, bool force_16bit) +pio_write(void *channelCookie, uint16 *data, int count, bool force_16bit) { - channel_data *channel = channel_cookie; + channel_data *channel = channelCookie; if (channel->lost) return B_ERROR; @@ -655,9 +657,9 @@ static status_t -pio_read(void *channel_cookie, uint16 *data, int count, bool force_16bit) +pio_read(void *channelCookie, uint16 *data, int count, bool force_16bit) { - channel_data *channel = channel_cookie; + channel_data *channel = channelCookie; if (channel->lost) return B_ERROR; @@ -683,48 +685,56 @@ static status_t -dma_prepare(void *channel_cookie, const physical_entry *sg_list, size_t sg_list_count, bool write) +dma_prepare(void *channelCookie, const physical_entry *sg_list, + size_t sg_list_count, bool write) { - channel_data *channel = channel_cookie; + channel_data *channel = channelCookie; pci_device_module_info *pci = channel->pci; pci_device device = channel->device; prd_entry *prd = channel->prdt; - ide_bm_command command; - ide_bm_status status; + uint8 command; + uint8 status; uint32 temp; int i; - + FLOW("dma_prepare enter\n"); - - for (i = sg_list_count - 1, prd = channel->prdt; i >= 0; --i, ++prd, ++sg_list ) { - prd->address = B_HOST_TO_LENDIAN_INT32(pci->ram_address(device, sg_list->address)); - // 0 means 64K - this is done automatically be discarding upper 16 bits + + for (i = sg_list_count - 1, prd = channel->prdt; i >= 0; + --i, ++prd, ++sg_list ) { + prd->address = B_HOST_TO_LENDIAN_INT32(pci->ram_address(device, + sg_list->address)); + + // 0 means 64K - this is done automatically by discarding upper 16 bits prd->count = B_HOST_TO_LENDIAN_INT16((uint16)sg_list->size); prd->EOT = i == 0; - - FLOW("%x, %x, %d\n", (int)prd->address, prd->count, prd->EOT ); + + FLOW("%x, %x, %d\n", (int)prd->address, prd->count, prd->EOT); } // XXX move this to chan init? temp = (*channel->bm_prdt_address) & 3; - temp |= B_HOST_TO_LENDIAN_INT32(pci->ram_address(device, (void *)channel->prdt_phys)) & ~3; + temp |= B_HOST_TO_LENDIAN_INT32(pci->ram_address(device, + (void *)channel->prdt_phys)) & ~3; *channel->bm_prdt_address = temp; *channel->dev_ctrl; // read altstatus to flush // reset interrupt and error signal - *(uint8 *)&status = *channel->bm_status_reg; - status.interrupt = 1; - status.error = 1; - *channel->bm_status_reg = *(uint8 *)&status; + status = *channel->bm_status_reg | IDE_BM_STATUS_INTERRUPT + | IDE_BM_STATUS_ERROR; + *channel->bm_status_reg = status; *channel->dev_ctrl; // read altstatus to flush - + // set data direction - *(uint8 *)&command = *channel->bm_command_reg; - command.from_device = !write; - *channel->bm_command_reg = *(uint8 *)&command; + command = *channel->bm_command_reg; + if (write) + command &= ~IDE_BM_COMMAND_READ_FROM_DEVICE; + else + command |= IDE_BM_COMMAND_READ_FROM_DEVICE; + *channel->bm_command_reg = command; + *channel->dev_ctrl; // read altstatus to flush FLOW("dma_prepare leave\n"); @@ -734,20 +744,17 @@ static status_t -dma_start(void *channel_cookie) +dma_start(void *channelCookie) { - channel_data *channel = channel_cookie; - ide_bm_command command; + channel_data *channel = channelCookie; + uint8 command; FLOW("dma_start enter\n"); - - *(uint8 *)&command = *channel->bm_command_reg; - command.start_stop = 1; + command = *channel->bm_command_reg | IDE_BM_COMMAND_START_STOP; channel->dma_active = true; + *channel->bm_command_reg = command; - *channel->bm_command_reg = *(uint8 *)&command; - *channel->dev_ctrl; // read altstatus to flush FLOW("dma_start leave\n"); @@ -757,38 +764,33 @@ static status_t -dma_finish(void *channel_cookie) +dma_finish(void *channelCookie) { - channel_data *channel = channel_cookie; - ide_bm_command command; - ide_bm_status status, new_status; + channel_data *channel = channelCookie; + uint8 command; + uint8 status; FLOW("dma_finish enter\n"); - *(uint8 *)&command = *channel->bm_command_reg; - - command.start_stop = 0; + command = *channel->bm_command_reg & ~IDE_BM_COMMAND_START_STOP; channel->dma_active = false; - - *channel->bm_command_reg = *(uint8 *)&command; - *(uint8 *)&status = *channel->bm_status_reg; + *channel->bm_command_reg = command; - new_status = status; - new_status.interrupt = 1; - new_status.error = 1; + status = *channel->bm_status_reg; - *channel->bm_status_reg = *(uint8 *)&new_status; + *channel->bm_status_reg = status | IDE_BM_STATUS_INTERRUPT + | IDE_BM_STATUS_ERROR; *channel->dev_ctrl; // read altstatus to flush - if (status.error) { + if ((status & IDE_BM_STATUS_ERROR) != 0) { FLOW("dma_finish: failed\n"); return B_ERROR; } - if (!status.interrupt) { - if (status.active) { + if ((status & IDE_BM_STATUS_INTERRUPT) == 0) { + if ((status & IDE_BM_STATUS_ACTIVE) != 0) { FLOW("dma_finish: transfer aborted\n"); return B_ERROR; } else { @@ -796,7 +798,7 @@ return B_DEV_DATA_UNDERRUN; } } else { - if (status.active) { + if ((status & IDE_BM_STATUS_ACTIVE) != 0) { FLOW("dma_finish: buffer too large\n"); return B_DEV_DATA_OVERRUN; } else { @@ -811,7 +813,6 @@ handle_interrupt(void *arg) { controller_data *controller = arg; - ide_bm_status bm_status; uint8 status; int32 result, ret; int i; @@ -826,11 +827,11 @@ continue; if (channel->dma_active) { - *(uint8 *)&bm_status = *channel->bm_status_reg; - if (!bm_status.interrupt) + if ((*channel->bm_status_reg & IDE_BM_STATUS_INTERRUPT) == 0) continue; } else { - // for PIO, read the "Task File Configuration + Status" Interrupt status + // for PIO, read the "Task File Configuration + Status" Interrupt + // status if (!(*channel->stat & (1 << 11))) continue; } @@ -877,24 +878,24 @@ std_ops }, - .supports_device = NULL, - .register_device = NULL, - .init_driver = &channel_init, - .uninit_driver = &channel_uninit, - .device_removed = &channel_removed, - .device_cleanup = NULL, - .get_supported_paths = NULL, + .supports_device = NULL, + .register_device = NULL, + .init_driver = &channel_init, + .uninit_driver = &channel_uninit, + .device_removed = &channel_removed, + .device_cleanup = NULL, + .get_supported_paths = NULL, }, - .write_command_block_regs = &task_file_write, - .read_command_block_regs = &task_file_read, - .get_altstatus = &altstatus_read, - .write_device_control = &device_control_write, - .write_pio = &pio_write, - .read_pio = &pio_read, - .prepare_dma = &dma_prepare, - .start_dma = &dma_start, - .finish_dma = &dma_finish, + .write_command_block_regs = &task_file_write, + .read_command_block_regs = &task_file_read, + .get_altstatus = &altstatus_read, + .write_device_control = &device_control_write, + .write_pio = &pio_write, + .read_pio = &pio_read, + .prepare_dma = &dma_prepare, + .start_dma = &dma_start, + .finish_dma = &dma_finish, }; @@ -905,13 +906,13 @@ std_ops }, - .supports_device = &controller_supports, - .register_device = &controller_probe, - .init_driver = &controller_init, - .uninit_driver = &controller_uninit, - .device_removed = &controller_removed, - .device_cleanup = NULL, - .get_supported_paths = &controller_get_paths, + .supports_device = &controller_supports, + .register_device = &controller_probe, + .init_driver = &controller_init, + .uninit_driver = &controller_uninit, + .device_removed = &controller_removed, + .device_cleanup = NULL, + .get_supported_paths = &controller_get_paths, }; module_info *modules[] = { From bonefish at mail.berlios.de Tue Nov 6 02:07:22 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 6 Nov 2007 02:07:22 +0100 Subject: [Haiku-commits] r22841 - haiku/trunk/src/system/kernel/vm Message-ID: <200711060107.lA617M4J032387@sheep.berlios.de> Author: bonefish Date: 2007-11-06 02:07:13 +0100 (Tue, 06 Nov 2007) New Revision: 22841 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22841&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: * Added opt-in debugging feature: Recent allocation-related operations on pages are recorded in a history and can be printed via the "page_allocations" command. * Fixed a problem in the page scrubber. It temporarily removed pages from the free list, which could have been reserved by someone else. When actually allocating the reserved pages, that someone could find free and clear lists empty and would therefore rightfully panic ("Had reserved page, but there is none!"). Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-11-05 23:08:58 UTC (rev 22840) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-11-06 01:07:13 UTC (rev 22841) @@ -37,6 +37,10 @@ # define TRACE(x) ; #endif +//#define TRACK_PAGE_ALLOCATIONS 1 + // [Debugging feature] Enables a small history of page allocation operations + // that can be listed in KDL via "page_allocations". + #define SCRUB_SIZE 16 // this many pages will be cleared at once in the page scrubber thread @@ -64,6 +68,114 @@ static sem_id sWriterWaitSem; +#if TRACK_PAGE_ALLOCATIONS + + +enum { + NO_PAGE_OPERATION = 0, + RESERVE_PAGES, + UNRESERVE_PAGES, + ALLOCATE_PAGE, + ALLOCATE_PAGE_RUN, + FREE_PAGE, + SCRUBBING_PAGES, + SCRUBBED_PAGES, + STOLEN_PAGE +}; + + +struct allocation_history_entry { + bigtime_t time; + thread_id thread; + uint32 operation; + uint32 count; + uint32 flags; + uint32 free; + uint32 reserved; +}; + + +static const int kAllocationHistoryCapacity = 512; +static allocation_history_entry sAllocationHistory[kAllocationHistoryCapacity]; +static int kAllocationHistoryIndex = 0; + + +/*! sPageLock must be held. +*/ +static void +add_allocation_history_entry(uint32 operation, uint32 count, uint32 flags) +{ + allocation_history_entry& entry + = sAllocationHistory[kAllocationHistoryIndex]; + kAllocationHistoryIndex = (kAllocationHistoryIndex + 1) + % kAllocationHistoryCapacity; + + entry.time = system_time(); + entry.thread = find_thread(NULL); + entry.operation = operation; + entry.count = count; + entry.flags = flags; + entry.free = sFreePageQueue.count + sClearPageQueue.count; + entry.reserved = sReservedPages; +} + + +static int +dump_page_allocations(int argc, char **argv) +{ + kprintf("thread operation count flags free reserved time\n"); + kprintf("---------------------------------------------------------------\n"); + + for (int i = 0; i < kAllocationHistoryCapacity; i++) { + int index = (kAllocationHistoryIndex + i) % kAllocationHistoryCapacity; + allocation_history_entry& entry = sAllocationHistory[index]; + + const char* operation; + switch (entry.operation) { + case NO_PAGE_OPERATION: + operation = "no op"; + break; + case RESERVE_PAGES: + operation = "reserve"; + break; + case UNRESERVE_PAGES: + operation = "unreserve"; + break; + case ALLOCATE_PAGE: + operation = "alloc"; + break; + case ALLOCATE_PAGE_RUN: + operation = "alloc run"; + break; + case FREE_PAGE: + operation = "free"; + break; + case SCRUBBING_PAGES: + operation = "scrubbing"; + break; + case SCRUBBED_PAGES: + operation = "scrubbed"; + break; + case STOLEN_PAGE: + operation = "stolen"; + break; + default: + operation = "invalid"; + break; + } + + kprintf("%6ld %-9s %5ld %5lx %8ld %8ld %10lld\n", + entry.thread, operation, entry.count, entry.flags, entry.free, + entry.reserved, entry.time); + } + + return 0; +} + + +#endif // TRACK_PAGE_ALLOCATIONS + + /*! Dequeues a page from the head of the given queue */ static vm_page * dequeue_page(page_queue *queue) @@ -548,6 +660,14 @@ panic("to be freed page %p has cache", page); } +#if TRACK_PAGE_ALLOCATIONS + if ((pageState == PAGE_STATE_CLEAR || pageState == PAGE_STATE_FREE) + && page->state != PAGE_STATE_CLEAR && page->state != PAGE_STATE_FREE) { + add_allocation_history_entry(FREE_PAGE, 1, 0); + + } +#endif // TRACK_PAGE_ALLOCATIONS + page->state = pageState; move_page_to_queue(fromQueue, toQueue, page); @@ -614,20 +734,37 @@ state = disable_interrupts(); acquire_spinlock(&sPageLock); - for (i = 0; i < SCRUB_SIZE; i++) { + // Since we temporarily remove pages from the free pages reserve, + // we must make sure we don't cause a violation of the page + // reservation warranty. The following is usually stricter than + // necessary, because we don't have information on how many of the + // reserved pages have already been allocated. + scrubCount = SCRUB_SIZE; + uint32 freeCount = free_page_queue_count(); + if (freeCount < sReservedPages) + scrubCount = 0; + else if ((uint32)scrubCount > freeCount - sReservedPages) + scrubCount = freeCount - sReservedPages; + + for (i = 0; i < scrubCount; i++) { page[i] = dequeue_page(&sFreePageQueue); if (page[i] == NULL) break; page[i]->state = PAGE_STATE_BUSY; } + scrubCount = i; + +#if TRACK_PAGE_ALLOCATIONS + if (scrubCount > 0) + add_allocation_history_entry(SCRUBBING_PAGES, scrubCount, 0); +#endif + release_spinlock(&sPageLock); restore_interrupts(state); // clear them - scrubCount = i; - for (i = 0; i < scrubCount; i++) { clear_page(page[i]); } @@ -642,6 +779,11 @@ enqueue_page(&sClearPageQueue, page[i]); } +#if TRACK_PAGE_ALLOCATIONS + if (scrubCount > 0) + add_allocation_history_entry(SCRUBBED_PAGES, scrubCount, 0); +#endif + release_spinlock(&sPageLock); restore_interrupts(state); } @@ -978,6 +1120,10 @@ InterruptsSpinLocker _(sPageLock); enqueue_page(&sFreePageQueue, page); page->state = PAGE_STATE_FREE; + +#if TRACK_PAGE_ALLOCATIONS + add_allocation_history_entry(STOLEN_PAGE, 1, 0); +#endif } else if (stolen < maxCount) { pages[stolen] = page; } @@ -1193,6 +1339,10 @@ add_debugger_command("page_queue", &dump_page_queue, "Dump page queue"); add_debugger_command("find_page", &find_page, "Find out which queue a page is actually in"); +#if TRACK_PAGE_ALLOCATIONS + add_debugger_command("page_allocations", &dump_page_allocations, + "Dump page allocation history"); +#endif return B_OK; } @@ -1292,6 +1442,10 @@ InterruptsSpinLocker locker(sPageLock); ASSERT(sReservedPages >= count); +#if TRACK_PAGE_ALLOCATIONS + add_allocation_history_entry(UNRESERVE_PAGES, count, 0); +#endif + sReservedPages -= count; if (sPageDeficit > 0) @@ -1312,6 +1466,10 @@ InterruptsSpinLocker locker(sPageLock); +#if TRACK_PAGE_ALLOCATIONS + add_allocation_history_entry(RESERVE_PAGES, count, 0); +#endif + sReservedPages += count; size_t freePages = free_page_queue_count(); if (sReservedPages <= freePages) @@ -1347,6 +1505,10 @@ InterruptsSpinLocker locker(sPageLock); +#if TRACK_PAGE_ALLOCATIONS + add_allocation_history_entry(ALLOCATE_PAGE, 1, reserved ? 1 : 0); +#endif + vm_page *page = NULL; while (true) { if (reserved || sReservedPages < free_page_queue_count()) { @@ -1464,6 +1626,10 @@ } } +#if TRACK_PAGE_ALLOCATIONS + add_allocation_history_entry(ALLOCATE_PAGE_RUN, length, 0); +#endif + locker.Unlock(); if (firstPage != NULL && pageState == PAGE_STATE_CLEAR) { From axeld at pinc-software.de Tue Nov 6 02:22:07 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 06 Nov 2007 02:22:07 +0100 CET Subject: [Haiku-commits] r22841 - haiku/trunk/src/system/kernel/vm In-Reply-To: <200711060107.lA617M4J032387@sheep.berlios.de> Message-ID: <26949451709-BeMail@zon> bonefish at BerliOS wrote: > Log: > * Added opt-in debugging feature: Recent allocation-related > operations > on pages are recorded in a history and can be printed via the > "page_allocations" command. Pretty cool! > * Fixed a problem in the page scrubber. It temporarily removed pages > from the free list, which could have been reserved by someone else. > When actually allocating the reserved pages, that someone could > find > free and clear lists empty and would therefore rightfully panic > ("Had reserved page, but there is none!"). My hero, thanks a lot! :-) Bye, Axel. From axeld at mail.berlios.de Tue Nov 6 03:26:45 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 6 Nov 2007 03:26:45 +0100 Subject: [Haiku-commits] r22842 - in haiku/trunk: headers/private/drivers src/add-ons/kernel/generic/ide_adapter Message-ID: <200711060226.lA62Qj0p005158@sheep.berlios.de> Author: axeld Date: 2007-11-06 03:26:44 +0100 (Tue, 06 Nov 2007) New Revision: 22842 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22842&view=rev Modified: haiku/trunk/headers/private/drivers/ide_adapter.h haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c Log: No wonder no one noticed that the silicon_image_3112 driver was broken; I actually forgot to commit the changes I made to the ide_adapter... * the IDE bus master command/status stuff is now used via flags; it's no bitfield anymore. * Changed a few constants to upper case. Modified: haiku/trunk/headers/private/drivers/ide_adapter.h =================================================================== --- haiku/trunk/headers/private/drivers/ide_adapter.h 2007-11-06 01:07:13 UTC (rev 22841) +++ haiku/trunk/headers/private/drivers/ide_adapter.h 2007-11-06 02:26:44 UTC (rev 22842) @@ -1,5 +1,5 @@ /* - * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Copyright 2002-04, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. @@ -11,7 +11,7 @@ IDE adapter library Module to simplify writing an IDE adapter driver. - + The interface is not very abstract, i.e. the actual driver is free to access any controller or channel data of this library. */ @@ -36,47 +36,33 @@ ); } prd_entry; +// IDE bus master command register +#define IDE_BM_COMMAND_START_STOP 0x01 +#define IDE_BM_COMMAND_READ_FROM_DEVICE 0x08 -// command register -typedef struct ide_bm_command { - LBITFIELD8_4( - start_stop : 1, // start BM by changing from 0 to 1; - // stop BM by changing from 1 to 0 - res0_1 : 2, - from_device : 1, // true - read from device, false - write to device - res0_4 : 4 - ); -} ide_bm_command; +// IDE bus master status register +#define IDE_BM_STATUS_ACTIVE 0x01 +#define IDE_BM_STATUS_ERROR 0x02 +#define IDE_BM_STATUS_INTERRUPT 0x04 +#define IDE_BM_STATUS_MASTER_DMA 0x20 +#define IDE_BM_STATUS_SLAVE_DMA 0x40 +#define IDE_BM_STATUS_SIMPLEX_DMA 0x80 - -// status register -typedef struct ide_bm_status { - LBITFIELD8_7( - active : 1, // 1, if BM is active - error : 1, // 1, if error occured; write 1 to reset - interrupt : 1, // 1, if INTRQ was raised, write 1 to reset - res0_3 : 2, - device0_dma : 1, // 1, if BIOS/driver has setup DMA for device 0 - device1_dma : 1, // 1, if BIOS/driver has setup DMA for device 1 - simplex : 1 // 1, if only one channel can use DMA at a time - ); -} ide_bm_status; - - // offset of bus master registers enum { - ide_bm_command_reg = 0, // see ide_bm_command - ide_bm_status_reg = 2, // see ide_bm_status - ide_bm_prdt_address = 4 // offset of PRDT register; content must be dword-aligned + IDE_BM_COMMAND_REG = 0, + IDE_BM_STATUS_REG = 2, + IDE_BM_PRDT_ADDRESS = 4 + // offset of PRDT register; content must be dword-aligned }; // bit mask in class_api of PCI configuration // (for adapters that can run in compatability mode) enum { - ide_api_primary_native = 1, // primary channel is in native mode - ide_api_primary_fixed = 2, // primary channel can be switched to native mode - ide_api_secondary_native = 4, // secondary channel is in native mode - ide_api_secondary_fixed = 8 // secondary channel can be switched to native mode + IDE_API_PRIMARY_NATIVE = 1, // primary channel is in native mode + IDE_API_PRIMARY_FIXED = 2, // primary channel can be switched to native mode + IDE_API_SECONDARY_NATIVE = 4, // secondary channel is in native mode + IDE_API_SECONDARY_FIXED = 8 // secondary channel can be switched to native mode }; Modified: haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c 2007-11-06 01:07:13 UTC (rev 22841) +++ haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c 2007-11-06 02:26:44 UTC (rev 22842) @@ -180,10 +180,9 @@ ide_adapter_channel_info *channel = (ide_adapter_channel_info *)arg; pci_device_module_info *pci = channel->pci; pci_device device = channel->device; - ide_bm_status bm_status; uint8 status; - SHOW_FLOW0( 3, "" ); + SHOW_FLOW0(3, ""); if (channel->lost) return B_UNHANDLED_INTERRUPT; @@ -192,10 +191,9 @@ if (channel->dmaing) { // in DMA mode, there is a safe test // in PIO mode, this don't work - *(uint8 *)&bm_status = pci->read_io_8(device, - channel->bus_master_base + ide_bm_status_reg); - - if (!bm_status.interrupt) + status = pci->read_io_8(device, channel->bus_master_base + + IDE_BM_STATUS_REG); + if ((status & IDE_BM_STATUS_INTERRUPT) == 0) return B_UNHANDLED_INTERRUPT; } @@ -207,48 +205,46 @@ static status_t -ide_adapter_prepare_dma(ide_adapter_channel_info *channel, const physical_entry *sg_list, - size_t sg_list_count, bool to_device) +ide_adapter_prepare_dma(ide_adapter_channel_info *channel, + const physical_entry *sgList, size_t sgListCount, bool writeToDevice) { pci_device_module_info *pci = channel->pci; pci_device device = channel->device; - ide_bm_command command; - ide_bm_status status; + uint8 command; + uint8 status; prd_entry *prd = channel->prdt; int i; - for (i = sg_list_count - 1, prd = channel->prdt; i >= 0; --i, ++prd, ++sg_list) { - prd->address = B_HOST_TO_LENDIAN_INT32(pci->ram_address(device, sg_list->address)); + for (i = sgListCount - 1, prd = channel->prdt; i >= 0; --i, ++prd, ++sgList) { + prd->address = B_HOST_TO_LENDIAN_INT32(pci->ram_address(device, sgList->address)); // 0 means 64K - this is done automatically be discarding upper 16 bits - prd->count = B_HOST_TO_LENDIAN_INT16((uint16)sg_list->size); + prd->count = B_HOST_TO_LENDIAN_INT16((uint16)sgList->size); prd->EOT = i == 0; SHOW_FLOW( 4, "%x, %x, %d", (int)prd->address, prd->count, prd->EOT); } - pci->write_io_32(device, channel->bus_master_base + ide_bm_prdt_address, - (pci->read_io_32(device, channel->bus_master_base + ide_bm_prdt_address) & 3) + pci->write_io_32(device, channel->bus_master_base + IDE_BM_PRDT_ADDRESS, + (pci->read_io_32(device, channel->bus_master_base + IDE_BM_PRDT_ADDRESS) & 3) | (B_HOST_TO_LENDIAN_INT32(pci->ram_address(device, (void *)channel->prdt_phys)) & ~3)); // reset interrupt and error signal - *(uint8 *)&status = pci->read_io_8(device, - channel->bus_master_base + ide_bm_status_reg); - - status.interrupt = 1; - status.error = 1; - + status = pci->read_io_8(device, channel->bus_master_base + + IDE_BM_STATUS_REG) | IDE_BM_STATUS_INTERRUPT | IDE_BM_STATUS_ERROR; pci->write_io_8(device, - channel->bus_master_base + ide_bm_status_reg, *(uint8 *)&status); + channel->bus_master_base + IDE_BM_STATUS_REG, status); // set data direction - *(uint8 *)&command = pci->read_io_8(device, - channel->bus_master_base + ide_bm_command_reg); + command = pci->read_io_8(device, channel->bus_master_base + + IDE_BM_COMMAND_REG); + if (writeToDevice) + command &= ~IDE_BM_COMMAND_READ_FROM_DEVICE; + else + command |= IDE_BM_COMMAND_READ_FROM_DEVICE; - command.from_device = !to_device; + pci->write_io_8(device, channel->bus_master_base + IDE_BM_COMMAND_REG, + command); - pci->write_io_8(device, - channel->bus_master_base + ide_bm_command_reg, *(uint8 *)&command); - return B_OK; } @@ -258,14 +254,16 @@ { pci_device_module_info *pci = channel->pci; pci_device device = channel->device; - ide_bm_command command; + uint8 command; - *(uint8 *)&command = pci->read_io_8(device, channel->bus_master_base + ide_bm_command_reg); + command = pci->read_io_8(device, channel->bus_master_base + + IDE_BM_COMMAND_REG); - command.start_stop = 1; + command |= IDE_BM_COMMAND_START_STOP; channel->dmaing = true; - pci->write_io_8(device, channel->bus_master_base + ide_bm_command_reg, *(uint8 *)&command); + pci->write_io_8(device, channel->bus_master_base + IDE_BM_COMMAND_REG, + command); return B_OK; } @@ -276,30 +274,31 @@ { pci_device_module_info *pci = channel->pci; pci_device device = channel->device; - ide_bm_command command; - ide_bm_status status, new_status; + uint8 command; + uint8 status, newStatus; - *(uint8 *)&command = pci->read_io_8(device, channel->bus_master_base + ide_bm_command_reg); + command = pci->read_io_8(device, channel->bus_master_base + + IDE_BM_COMMAND_REG); - command.start_stop = 0; + command &= ~IDE_BM_COMMAND_START_STOP; channel->dmaing = false; - pci->write_io_8(device, channel->bus_master_base + ide_bm_command_reg, *(uint8 *)&command); + pci->write_io_8(device, channel->bus_master_base + IDE_BM_COMMAND_REG, + command); - *(uint8 *)&status = pci->read_io_8(device, channel->bus_master_base + ide_bm_status_reg); + status = pci->read_io_8(device, channel->bus_master_base + + IDE_BM_STATUS_REG); - new_status = status; - new_status.interrupt = 1; - new_status.error = 1; + // reset interrupt/error flags + newStatus = status | IDE_BM_STATUS_INTERRUPT | IDE_BM_STATUS_ERROR; + pci->write_io_8(device, channel->bus_master_base + IDE_BM_STATUS_REG, + newStatus); - pci->write_io_8(device, channel->bus_master_base + ide_bm_status_reg, - *(uint8 *)&new_status); - - if (status.error) + if ((status & IDE_BM_STATUS_ERROR) != 0) return B_ERROR; - if (!status.interrupt) { - if (status.active) { + if ((status & IDE_BM_STATUS_INTERRUPT) == 0) { + if ((status & IDE_BM_STATUS_ACTIVE) != 0) { SHOW_ERROR0( 2, "DMA transfer aborted" ); return B_ERROR; } @@ -308,7 +307,7 @@ return B_DEV_DATA_UNDERRUN; } - if (status.active) { + if ((status & IDE_BM_STATUS_ACTIVE) != 0) { SHOW_ERROR0( 2, "DMA transfer: buffer too large" ); return B_DEV_DATA_OVERRUN; } @@ -473,7 +472,6 @@ device_node_handle *node, bool supports_compatibility_mode) { uint8 api; - ide_bm_status status; io_resource_handle resource_handles[3]; SHOW_FLOW0( 3, "" ); @@ -482,12 +480,12 @@ api = pci->read_pci_config(pci_device, PCI_class_api, 1); if (supports_compatibility_mode - && is_primary && (api & ide_api_primary_native) == 0) { + && is_primary && (api & IDE_API_PRIMARY_NATIVE) == 0) { command_block_base = 0x1f0; control_block_base = 0x3f6; intnum = 14; } else if (supports_compatibility_mode - && !is_primary && (api & ide_api_primary_native) == 0) { + && !is_primary && (api & IDE_API_PRIMARY_NATIVE) == 0) { command_block_base = 0x170; control_block_base = 0x376; intnum = 15; @@ -509,9 +507,10 @@ if (supports_compatibility_mode) { // read status of primary(!) channel to detect simplex - *(uint8 *)&status = pci->read_io_8(pci_device, bus_master_base + ide_bm_status_reg); + uint8 status = pci->read_io_8(pci_device, bus_master_base + + IDE_BM_STATUS_REG); - if (status.simplex && !is_primary) { + if (status & IDE_BM_STATUS_SIMPLEX_DMA && !is_primary) { // in simplex mode, channels cannot operate independantly of each other; // we simply disable bus mastering of second channel to satisfy that; // better were to use a controller lock, but this had to be done in the IDE @@ -588,9 +587,10 @@ static void -ide_adapter_controller_removed(device_node_handle node, ide_adapter_controller_info *controller) +ide_adapter_controller_removed(device_node_handle node, + ide_adapter_controller_info *controller) { - SHOW_FLOW0( 3, "" ); + SHOW_FLOW0(3, ""); if (controller != NULL) // disable access instantly; unit_device takes care of unregistering ioports From superstippi at gmx.de Tue Nov 6 09:59:49 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Tue, 06 Nov 2007 09:59:49 +0100 Subject: [Haiku-commits] r22838 - haiku/trunk/src/add-ons/kernel/busses/scsi/usb In-Reply-To: <200711052228.lA5MS4s6005152@sheep.berlios.de> References: <200711052228.lA5MS4s6005152@sheep.berlios.de> Message-ID: <20071106095949.516.2@stippis.WG> axeld at BerliOS wrote (2007-11-05, 23:28:04 [+0100]): > Author: axeld > Date: 2007-11-05 23:28:03 +0100 (Mon, 05 Nov 2007) New Revision: 22838 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22838&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/busses/scsi/usb/Jamfile > haiku/trunk/src/add-ons/kernel/busses/scsi/usb/scsi_commands.h > haiku/trunk/src/add-ons/kernel/busses/scsi/usb/transform_procs.c > Log: > * Made at least scsi_cmd_rw_10 the same as the one in > private/drivers/scsi_cmds.h; > ideally, we would only have one file and no copies - later. > * That also changed how READ/WRITE_6 commands are translated to > READ/WRITE_10 > commands, but it was obviously correct before, at least I can still > reproduce bug #1577 (so it has to be something else). > * Spotted a few suspicious uses of transform_6_10() vs. > transform_cmd_6_10(); > at least the FreeBSD driver seem to work differently here, anyway (it > always uses 12 byte commands for most of these). > * Cleaned up the file. Is this driver still compilable for R5? Is it working already on Haiku? Best regards, -Stephan From mmlr at mlotz.ch Tue Nov 6 10:36:59 2007 From: mmlr at mlotz.ch (Michael Lotz) Date: Tue, 6 Nov 2007 10:36:59 +0100 Subject: [Haiku-commits] r22838 - haiku/trunk/src/add-ons/kernel/busses/scsi/usb In-Reply-To: <20071106095949.516.2@stippis.WG> References: <200711052228.lA5MS4s6005152@sheep.berlios.de> <20071106095949.516.2@stippis.WG> Message-ID: <20071106093125.M66519@mlotz.ch> On Tue, 06 Nov 2007 09:59:49 +0100, Stephan Assmus wrote > axeld at BerliOS wrote (2007-11-05, 23:28:04 [+0100]): > > Author: axeld > > Date: 2007-11-05 23:28:03 +0100 (Mon, 05 Nov 2007) New Revision: 22838 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22838&view=rev > > > > Modified: > > haiku/trunk/src/add-ons/kernel/busses/scsi/usb/Jamfile > > haiku/trunk/src/add-ons/kernel/busses/scsi/usb/scsi_commands.h > > haiku/trunk/src/add-ons/kernel/busses/scsi/usb/transform_procs.c > > Is this driver still compilable for R5? Is it working already on Haiku? It is not compatible to R5 anymore. You can get it to work either by uncommenting the mostly commented R5 SCSI parts or by reverting to r18783 IIRC. Regards Michael From axeld at pinc-software.de Tue Nov 6 12:11:41 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 06 Nov 2007 12:11:41 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r22838_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/busses/scsi/usb?= In-Reply-To: <20071106093125.M66519@mlotz.ch> Message-ID: <728816408-BeMail@zon> "Michael Lotz" wrote: > On Tue, 06 Nov 2007 09:59:49 +0100, Stephan Assmus wrote > > axeld at BerliOS wrote (2007-11-05, 23:28:04 [+0100]): > > > Author: axeld > > > Date: 2007-11-05 23:28:03 +0100 (Mon, 05 Nov 2007) New Revision: > > > 22838 > > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22838&view=rev > > > > > > Modified: > > > haiku/trunk/src/add-ons/kernel/busses/scsi/usb/Jamfile > > > haiku/trunk/src/add-ons/kernel/busses/scsi/usb/scsi_commands.h > > > haiku/trunk/src/add-ons/kernel/busses/scsi/usb/ > > > transform_procs.c > > Is this driver still compilable for R5? Is it working already on > > Haiku? > It is not compatible to R5 anymore. You can get it to work either by > uncommenting the mostly commented R5 SCSI parts or by reverting to > r18783 IIRC. That's exactly what I'm doing to test it :-) Siarzhuk wanted to work on Haiku support in a few weeks, and we're not in a hurry :) Bye, Axel. From axeld at mail.berlios.de Tue Nov 6 14:45:33 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 6 Nov 2007 14:45:33 +0100 Subject: [Haiku-commits] r22843 - haiku/trunk/src/apps/sudoku Message-ID: <200711061345.lA6DjXHu021816@sheep.berlios.de> Author: axeld Date: 2007-11-06 14:45:32 +0100 (Tue, 06 Nov 2007) New Revision: 22843 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22843&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuWindow.cpp haiku/trunk/src/apps/sudoku/SudokuWindow.h Log: Now allows you to store a state of the current puzzle, and to restore it later on. Modified: haiku/trunk/src/apps/sudoku/SudokuWindow.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuWindow.cpp 2007-11-06 02:26:44 UTC (rev 22842) +++ haiku/trunk/src/apps/sudoku/SudokuWindow.cpp 2007-11-06 13:45:32 UTC (rev 22843) @@ -37,6 +37,8 @@ const uint32 kMsgSudokuGenerated = 'sugn'; const uint32 kMsgMarkInvalid = 'minv'; const uint32 kMsgMarkValidHints = 'mvht'; +const uint32 kMsgStoreState = 'stst'; +const uint32 kMsgRestoreState = 'rest'; const uint32 kMsgNew = 'new '; const uint32 kMsgStartAgain = 'stag'; const uint32 kMsgExportAsText = 'extx'; @@ -133,7 +135,8 @@ SudokuWindow::SudokuWindow() : BWindow(BRect(100, 100, 500, 520), "Sudoku", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS), - fGenerator(NULL) + fGenerator(NULL), + fStoredState(NULL) { BMessage settings; _LoadSettings(settings); @@ -146,6 +149,14 @@ } else frame = Bounds(); + if (settings.HasMessage("stored state")) { + fStoredState = new BMessage; + if (settings.FindMessage("stored state", fStoredState) != B_OK) { + delete fStoredState; + fStoredState = NULL; + } + } + // create GUI BMenuBar* menuBar = new BMenuBar(Bounds(), "menu"); @@ -167,6 +178,7 @@ // add menu + // "File" menu BMenu* menu = new BMenu("File"); menu->AddItem(new BMenuItem("New", new BMessage(kMsgNew))); menu->AddItem(new BMenuItem("Start Again", new BMessage(kMsgStartAgain))); @@ -204,6 +216,7 @@ item->SetTarget(be_app); menuBar->AddItem(menu); + // "View" menu menu = new BMenu("View"); menu->AddItem(item = new BMenuItem("Mark Invalid Values", new BMessage(kMsgMarkInvalid))); @@ -216,7 +229,14 @@ menu->SetTargetForItems(this); menuBar->AddItem(menu); + // "Help" menu menu = new BMenu("Help"); + menu->AddItem(new BMenuItem("Store Current", new BMessage(kMsgStoreState))); + menu->AddItem(fRestoreStateItem = new BMenuItem("Restore Saved", + new BMessage(kMsgRestoreState))); + fRestoreStateItem->SetEnabled(fStoredState != NULL); + menu->AddSeparatorItem(); + menu->AddItem(new BMenuItem("Solve", new BMessage(kMsgSolveSudoku))); menu->AddItem(new BMenuItem("Solve Single Field", new BMessage(kMsgSolveSingle))); @@ -282,6 +302,8 @@ status = settings.AddRect("window frame", Frame()); if (status == B_OK) status = fSudokuView->SaveState(settings); + if (status == B_OK && fStoredState != NULL) + status = settings.AddMessage("stored state", fStoredState); if (status == B_OK) status = settings.Flatten(&file); @@ -290,6 +312,15 @@ void +SudokuWindow::_ResetStoredState() +{ + delete fStoredState; + fStoredState = NULL; + fRestoreStateItem->SetEnabled(false); +} + + +void SudokuWindow::_MessageDropped(BMessage* message) { status_t status = B_MESSAGE_NOT_UNDERSTOOD; @@ -344,6 +375,8 @@ fSudokuView->SetEditable(false); fProgressWindow->Start(this); + _ResetStoredState(); + fGenerator = new GenerateSudoku(*fSudokuView->Field(), level, fProgressWindow, this); } @@ -417,6 +450,7 @@ } case kMsgNew: + _ResetStoredState(); fSudokuView->ClearAll(); break; @@ -442,6 +476,23 @@ break; } + case kMsgStoreState: + delete fStoredState; + fStoredState = new BMessage; + fSudokuView->Field()->Archive(fStoredState, true); + fRestoreStateItem->SetEnabled(true); + break; + + case kMsgRestoreState: + { + if (fStoredState == NULL) + break; + + SudokuField* field = new SudokuField(fStoredState); + fSudokuView->SetTo(field); + break; + } + case kMsgSudokuSolved: (new BAlert("Sudoku request", "Sudoku solved - congratulations!", "Ok", NULL, NULL, Modified: haiku/trunk/src/apps/sudoku/SudokuWindow.h =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuWindow.h 2007-11-06 02:26:44 UTC (rev 22842) +++ haiku/trunk/src/apps/sudoku/SudokuWindow.h 2007-11-06 13:45:32 UTC (rev 22843) @@ -10,6 +10,7 @@ class BFile; class BFilePanel; +class BMenuItem; class GenerateSudoku; class ProgressWindow; class SudokuView; @@ -28,6 +29,7 @@ status_t _LoadSettings(BMessage& settings); status_t _SaveSettings(); + void _ResetStoredState(); void _MessageDropped(BMessage *message); void _Generate(int32 level); @@ -36,6 +38,8 @@ ProgressWindow* fProgressWindow; SudokuView* fSudokuView; GenerateSudoku* fGenerator; + BMenuItem* fRestoreStateItem; + BMessage* fStoredState; }; #endif // SUDOKU_WINDOW_H From hugosantos at mail.berlios.de Tue Nov 6 17:45:15 2007 From: hugosantos at mail.berlios.de (hugosantos at mail.berlios.de) Date: Tue, 6 Nov 2007 17:45:15 +0100 Subject: [Haiku-commits] r22844 - in haiku/trunk/src: add-ons/kernel/drivers/network/rtl8139/pci libs/compat/freebsd_network/compat/sys Message-ID: <200711061645.lA6GjFSr031461@sheep.berlios.de> Author: hugosantos Date: 2007-11-06 17:45:10 +0100 (Tue, 06 Nov 2007) New Revision: 22844 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22844&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h Log: try to hide the gruesome details from the glue code as much as possible. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c 2007-11-06 13:45:32 UTC (rev 22843) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c 2007-11-06 16:45:10 UTC (rev 22844) @@ -3,20 +3,9 @@ #include HAIKU_FBSD_DRIVER_GLUE(rtl8139, rl, pci); +HAIKU_FBSD_MII_DRIVER(rlphy); HAIKU_DRIVER_REQUIREMENTS(0); -extern driver_t *DRIVER_MODULE_NAME(rlphy, miibus); - -driver_t * -__haiku_select_miibus_driver(device_t dev) -{ - driver_t *drivers[] = { - DRIVER_MODULE_NAME(rlphy, miibus) - }; - - return __haiku_probe_miibus(dev, drivers, 1); -} - int HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev) { struct rl_softc *sc = device_get_softc(dev); Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2007-11-06 13:45:32 UTC (rev 22843) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2007-11-06 16:45:10 UTC (rev 22844) @@ -89,8 +89,13 @@ #define HAIKU_FBSD_MII_DRIVER(name) \ extern driver_t *DRIVER_MODULE_NAME(name, miibus); \ - HAIKU_FBSD_RETURN_MII_DRIVER( \ - &DRIVER_MODULE_NAME(name, miibus), 1) + driver_t *__haiku_select_miibus_driver(device_t dev) \ + { \ + driver_t *drivers[] = { \ + DRIVER_MODULE_NAME(name, miibus) \ + }; \ + return __haiku_probe_miibus(dev, drivers, 1); \ + } #define NO_HAIKU_FBSD_MII_DRIVER() \ HAIKU_FBSD_RETURN_MII_DRIVER(NULL, 0) From bonefish at mail.berlios.de Tue Nov 6 23:06:40 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 6 Nov 2007 23:06:40 +0100 Subject: [Haiku-commits] r22845 - haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal Message-ID: <200711062206.lA6M6ejQ005339@sheep.berlios.de> Author: bonefish Date: 2007-11-06 23:06:40 +0100 (Tue, 06 Nov 2007) New Revision: 22845 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22845&view=rev Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c Log: Patch by Vasilis Kaoutsis: The Open Group Base Specs for signal() require errno to be set to a positive value on error, but since BeOS error codes are negative numbers, we can't comply. Changed the tests accordingly to check for the expected error code (EINVAL) instead. Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c 2007-11-06 16:45:10 UTC (rev 22844) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c 2007-11-06 22:06:40 UTC (rev 22845) @@ -24,15 +24,15 @@ int main() { - errno = -1; + errno = 0; if (signal(-1, myhandler) != SIG_ERR) { printf("Test FAILED: signal() didn't return SIG_ERR even though invalid signal number was passed to it\n"); return PTS_FAIL; } - if (errno <= 0) { - printf("Test FAILED: errno wasn't set to a positive number even though invalid signal number was passed to the signal() function\n"); + if (errno != EINVAL) { + printf("Test FAILED: errno wasn't set to EINVAL even though invalid signal number was passed to the signal() function\n"); return PTS_FAIL; } printf("signal(): Test passed\n"); Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c 2007-11-06 16:45:10 UTC (rev 22844) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c 2007-11-06 22:06:40 UTC (rev 22845) @@ -24,15 +24,15 @@ int main() { - errno = -1; + errno = 0; if (signal(SIGKILL, myhandler) != SIG_ERR) { printf("Test FAILED: signal() didn't return SIG_ERR even though a non-catchable signal was passed to it\n"); return PTS_FAIL; } - if (errno <= 0) { - printf("Test FAILED: errno wasn't set to a positive number even though a non-catchable signal was passed to the signal() function\n"); + if (errno != EINVAL) { + printf("Test FAILED: errno wasn't set to EINVAL even though a non-catchable signal was passed to the signal() function\n"); return PTS_FAIL; } printf("signal(): Test passed\n"); From bonefish at mail.berlios.de Tue Nov 6 23:11:44 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 6 Nov 2007 23:11:44 +0100 Subject: [Haiku-commits] r22846 - in haiku/trunk: headers/posix src/system/libroot/posix/signal Message-ID: <200711062211.lA6MBiac005582@sheep.berlios.de> Author: bonefish Date: 2007-11-06 23:11:43 +0100 (Tue, 06 Nov 2007) New Revision: 22846 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22846&view=rev Added: haiku/trunk/src/system/libroot/posix/signal/sighold.cpp Modified: haiku/trunk/headers/posix/signal.h haiku/trunk/src/system/libroot/posix/signal/Jamfile Log: Patch by Vasilis Kaoutsis: Implemented sighold(). Modified: haiku/trunk/headers/posix/signal.h =================================================================== --- haiku/trunk/headers/posix/signal.h 2007-11-06 22:06:40 UTC (rev 22845) +++ haiku/trunk/headers/posix/signal.h 2007-11-06 22:11:43 UTC (rev 22846) @@ -164,6 +164,7 @@ int sigdelset(sigset_t *set, int signo); int sigismember(const sigset_t *set, int signo); int sigignore(int signo); +int sighold(int signo); const char *strsignal(int sig); Modified: haiku/trunk/src/system/libroot/posix/signal/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/signal/Jamfile 2007-11-06 22:06:40 UTC (rev 22845) +++ haiku/trunk/src/system/libroot/posix/signal/Jamfile 2007-11-06 22:11:43 UTC (rev 22846) @@ -10,6 +10,7 @@ set_signal_stack.c sigaction.c sigaltstack.c + sighold.cpp sigignore.cpp signal.c sigpending.c Added: haiku/trunk/src/system/libroot/posix/signal/sighold.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/signal/sighold.cpp 2007-11-06 22:06:40 UTC (rev 22845) +++ haiku/trunk/src/system/libroot/posix/signal/sighold.cpp 2007-11-06 22:11:43 UTC (rev 22846) @@ -0,0 +1,22 @@ +/* + * Copyright 2007, Vasilis Kaoutsis, kaoutsis at sch.gr + * Distributed under the terms of the MIT License. + */ + + +#include + + +int +sighold(int signal) +{ + // make an empty set + // and add the signal + sigset_t tempSignalSet; + sigemptyset(&tempSignalSet); + if (sigaddset(&tempSignalSet, signal) == -1) + return -1; + + // add the signal to the calling process' signal mask + return sigprocmask(SIG_BLOCK, &tempSignalSet, NULL); +} From bonefish at mail.berlios.de Tue Nov 6 23:14:01 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 6 Nov 2007 23:14:01 +0100 Subject: [Haiku-commits] r22847 - in haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces: . sighold Message-ID: <200711062214.lA6ME11v005647@sheep.berlios.de> Author: bonefish Date: 2007-11-06 23:14:01 +0100 (Tue, 06 Nov 2007) New Revision: 22847 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22847&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/3-core-buildonly.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/Jamfile Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile Log: Patch by Vasilis Kaoutsis: Added posixtestsuite tests for sighold(). Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-11-06 22:11:43 UTC (rev 22846) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-11-06 22:14:01 UTC (rev 22847) @@ -7,6 +7,7 @@ SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_key_delete ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_getspecific ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_setspecific ; +SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sighold ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigignore ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigprocmask ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces signal ; Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/1-1.c 2007-11-06 22:11:43 UTC (rev 22846) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/1-1.c 2007-11-06 22:14:01 UTC (rev 22847) @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Steps: + 1. Set up a handler for signal SIGABRT, such that it is called if signal is ever raised. + 2. Call sighold on that SIGABRT. + 3. Raise a SIGABRT and verify that the signal handler was not called. + + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include "posixtest.h" + +int handler_called = 0; + +void handler(int signo) +{ + handler_called = 1; +} + +int main() +{ + struct sigaction act; + + act.sa_handler = handler; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + if (sigaction(SIGABRT, &act, 0) == -1) { + perror("Unexpected error while attempting to setup test " + "pre-conditions"); + return PTS_UNRESOLVED; + } + + if (sighold(SIGABRT) == -1) { + perror("Unexpected error while attempting to setup test " + "pre-conditions"); + return PTS_UNRESOLVED; + } + + if (raise(SIGABRT) == -1) { + perror("Unexpected error while attempting to setup test " + "pre-conditions"); + return PTS_UNRESOLVED; + } + + sleep(1); + if (handler_called) { + printf("FAIL: Signal was not blocked\n"); + return PTS_FAIL; + } + + printf("sighold(): Test PASSED: signal was blocked\n"); + return PTS_PASS; +} + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/2-1.c 2007-11-06 22:11:43 UTC (rev 22846) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/2-1.c 2007-11-06 22:14:01 UTC (rev 22847) @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Simply, if sighold returns a 0 here, test passes. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include "posixtest.h" + +int main() +{ + + if ((int)sighold(SIGABRT) != 0) { + perror("sighold failed -- returned -- test aborted"); + return PTS_UNRESOLVED; + } + printf("sighold passed\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/3-core-buildonly.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/3-core-buildonly.c 2007-11-06 22:11:43 UTC (rev 22846) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/3-core-buildonly.c 2007-11-06 22:14:01 UTC (rev 22847) @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Testing passing an invalid signals to sighold(). + After sighold is called on an invalid signal, sighold() should return -1 and set + errno to EINVAL + + The invalid signal passed to sighold() depends on the argument passed to this program. + There are currently 4 invalid signals. + */ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include +#include +#include "posixtest.h" + +jmp_buf sig11_recover; +void sig11_handler(int sig); + +int main(int argc, char *argv[]) +{ + int signo, TEST_RETURN; + struct sigaction sa, osa; + + if (argc < 2) { + printf("Usage: %s [1|2|3|4]\n", argv[0]); + return PTS_UNRESOLVED; + } + + /* + Various error conditions + */ + switch (argv[1][0]) { + case '1': + signo=-1; + break; + case '2': + signo=-10000; + break; + case '3': + signo=INT32_MIN+1; + break; + case '4': + signo=INT32_MIN; + break; + default: + printf("Usage: %s [1|2|3|4]\n", argv[0]); + return PTS_UNRESOLVED; + } + + /* special sig11 case */ + sa.sa_handler = &sig11_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + + sigaction(SIGSEGV, NULL, &osa); + sigaction(SIGSEGV, &sa, NULL); + + if (setjmp(sig11_recover)) { + errno = EINVAL; + TEST_RETURN=-2; + } else { + TEST_RETURN=sighold(signo); + } + sigaction(SIGSEGV, &osa, NULL); + + if (TEST_RETURN == -1) { + if (EINVAL == errno) { + printf ("errno set to EINVAL\n"); + printf("sighold(): Test passed\n"); + return PTS_PASS; + } else { + printf ("errno not set to EINVAL\n"); + return PTS_FAIL; + } + } + if (TEST_RETURN == -2) { + printf ("test received SIGSEGV\n"); + return PTS_UNRESOLVED; + } + + printf("sighold did not return -1\n"); + return PTS_FAIL; +} + +/****************************************************************** + * sig11_handler() - our segfault recover hack + ******************************************************************/ +void +sig11_handler(int sig) +{ + longjmp(sig11_recover, 1); +} + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/Jamfile 2007-11-06 22:11:43 UTC (rev 22846) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/Jamfile 2007-11-06 22:14:01 UTC (rev 22847) @@ -0,0 +1,7 @@ +SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sighold ; + +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ; + +SimpleTest sighold_1-1 : 1-1.c ; +SimpleTest sighold_2-1 : 2-1.c ; +SimpleTest sighold_3-core-buildonly : 3-core-buildonly.c ; From korli at mail.berlios.de Wed Nov 7 00:35:09 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 7 Nov 2007 00:35:09 +0100 Subject: [Haiku-commits] r22848 - haiku/trunk/src/preferences/backgrounds Message-ID: <200711062335.lA6NZ9QD019931@sheep.berlios.de> Author: korli Date: 2007-11-07 00:35:07 +0100 (Wed, 07 Nov 2007) New Revision: 22848 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22848&view=rev Modified: haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp Log: clean the background for all workspaces when no image is selected this fixes bug #1602 Modified: haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp =================================================================== --- haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp 2007-11-06 22:14:01 UTC (rev 22847) +++ haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp 2007-11-06 23:35:07 UTC (rev 22848) @@ -607,13 +607,15 @@ fCurrentInfo = NULL; } } - } else if (fLastImageIndex > -1) { + } else { fCurrent->RemoveAll(); - fCurrentInfo = new BackgroundImage::BackgroundImageInfo( - B_ALL_WORKSPACES, fLastImageIndex, mode, offset, - textWidgetLabelOutline, fCurrent->GetShowingImageSet(), - fCurrentInfo->fCacheMode); - fCurrent->Add(fCurrentInfo); + if (fLastImageIndex > -1) { + fCurrentInfo = new BackgroundImage::BackgroundImageInfo( + B_ALL_WORKSPACES, fLastImageIndex, mode, offset, + textWidgetLabelOutline, fCurrent->GetShowingImageSet(), + fCurrentInfo->fCacheMode); + fCurrent->Add(fCurrentInfo); + } } } else if (fLastImageIndex > -1) { if (fWorkspaceMenu->FindItem(kMsgCurrentWorkspace)->IsMarked()) { From jackburton at mail.berlios.de Wed Nov 7 10:38:56 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 7 Nov 2007 10:38:56 +0100 Subject: [Haiku-commits] r22849 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200711070938.lA79cu1D012531@sheep.berlios.de> Author: jackburton Date: 2007-11-07 10:38:55 +0100 (Wed, 07 Nov 2007) New Revision: 22849 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22849&view=rev Modified: haiku/trunk/headers/os/interface/Menu.h haiku/trunk/src/kits/interface/Menu.cpp haiku/trunk/src/kits/interface/MenuItem.cpp Log: Reverted r21395. Many people didn't like the change, and after all I too think it wasn't a really good idea. The alignment of shortcut charachters and submenu symbols could use some more work, though. Modified: haiku/trunk/headers/os/interface/Menu.h =================================================================== --- haiku/trunk/headers/os/interface/Menu.h 2007-11-06 23:35:07 UTC (rev 22848) +++ haiku/trunk/headers/os/interface/Menu.h 2007-11-07 09:38:55 UTC (rev 22849) @@ -259,7 +259,7 @@ LayoutData* fLayoutData; - int32 fSubmenus; + int32 _reserved; char fTrigger; bool fResizeToFit; Modified: haiku/trunk/src/kits/interface/Menu.cpp =================================================================== --- haiku/trunk/src/kits/interface/Menu.cpp 2007-11-06 23:35:07 UTC (rev 22848) +++ haiku/trunk/src/kits/interface/Menu.cpp 2007-11-07 09:38:55 UTC (rev 22849) @@ -189,7 +189,6 @@ fMaxContentWidth(0.0f), fInitMatrixSize(NULL), fExtraMenuData(NULL), - fSubmenus(0), fTrigger(0), fResizeToFit(true), fUseCachedMenuLayout(false), @@ -223,7 +222,6 @@ fMaxContentWidth(0.0f), fInitMatrixSize(NULL), fExtraMenuData(NULL), - fSubmenus(0), fTrigger(0), fResizeToFit(true), fUseCachedMenuLayout(false), @@ -270,7 +268,6 @@ fMaxContentWidth(0.0f), fInitMatrixSize(NULL), fExtraMenuData(NULL), - fSubmenus(0), fTrigger(0), fResizeToFit(true), fUseCachedMenuLayout(false), @@ -1089,7 +1086,6 @@ fMaxContentWidth(0.0f), fInitMatrixSize(NULL), fExtraMenuData(NULL), - fSubmenus(0), fTrigger(0), fResizeToFit(resizeToFit), fUseCachedMenuLayout(false), @@ -1734,8 +1730,7 @@ item->fBounds.bottom = item->fBounds.top + iHeight + fPad.top + fPad.bottom; - if (fSubmenus) - iWidth += item->Frame().Height(); + iWidth += item->Frame().Height(); frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right); frame.bottom = item->fBounds.bottom + 1.0f; Modified: haiku/trunk/src/kits/interface/MenuItem.cpp =================================================================== --- haiku/trunk/src/kits/interface/MenuItem.cpp 2007-11-06 23:35:07 UTC (rev 22848) +++ haiku/trunk/src/kits/interface/MenuItem.cpp 2007-11-07 09:38:55 UTC (rev 22849) @@ -640,10 +640,6 @@ debugger("Error - can't add menu or menu item to more than 1 container (either menu or menubar)."); if (fSubmenu != NULL) { - if (super) - super->fSubmenus++; - else if (fSuper) - fSuper->fSubmenus--; fSubmenu->fSuper = super; } @@ -715,8 +711,9 @@ menu->GetFont(&font); BPoint where = ContentLocation(); where.x = fBounds.right - font.Size(); - if (menu->fSubmenus) - where.x -= fBounds.Height() - 4; + + if (fSubmenu) + where.x -= fBounds.Height() - 3; switch (fShortcutChar) { case B_DOWN_ARROW: From revol at free.fr Wed Nov 7 12:50:15 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 07 Nov 2007 12:50:15 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r22845_-_haiku/trunk/src/tests/s?= =?windows-1252?q?ystem/libroot/posix/posixtestsuite/conformance/interface?= =?windows-1252?q?s/signal?= In-Reply-To: <200711062206.lA6M6ejQ005339@sheep.berlios.de> Message-ID: <628130681-BeMail@laptop> > Author: bonefish > Date: 2007-11-06 23:06:40 +0100 (Tue, 06 Nov 2007) > New Revision: 22845 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22845&view=rev > > Modified: > haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/ > conformance/interfaces/signal/6-1.c > haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/ > conformance/interfaces/signal/7-1.c > Log: > Patch by Vasilis Kaoutsis: The Open Group Base Specs for signal() > require > errno to be set to a positive value on error, but since BeOS error > codes are > negative numbers, we can't comply. Changed the tests accordingly to > check for > the expected error code (EINVAL) instead. Yes actually they aren't consistent with themselves on that. Some pages say !=0, some >0... One page indicates they actually updated it to match C99 and changed from !=0 to >0, but they didn't change the other pages. And can they expect OSes written before the change to ever comply to the new spec anyway ? That's the source of common porting issues, with braindead Unix coders doing things like return -EFOO; Where the only way is to #define a macro depending on the sign of EINVAL. Fran?ois. From axeld at mail.berlios.de Wed Nov 7 15:24:09 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 7 Nov 2007 15:24:09 +0100 Subject: [Haiku-commits] r22850 - haiku/trunk/src/kits/interface Message-ID: <200711071424.lA7EO9Rx028996@sheep.berlios.de> Author: axeld Date: 2007-11-07 15:24:09 +0100 (Wed, 07 Nov 2007) New Revision: 22850 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22850&view=rev Modified: haiku/trunk/src/kits/interface/Menu.cpp Log: * Fixed _ComputeColumnLayout() optimization introduced in r22658: it actually never worked correctly for any case which was very visible in Tracker (and especially so if you had "sorting apps" turned on). * Removed superfluous white space at the end of lines. Modified: haiku/trunk/src/kits/interface/Menu.cpp =================================================================== --- haiku/trunk/src/kits/interface/Menu.cpp 2007-11-07 09:38:55 UTC (rev 22849) +++ haiku/trunk/src/kits/interface/Menu.cpp 2007-11-07 14:24:09 UTC (rev 22850) @@ -77,12 +77,12 @@ static property_info sPropList[] = { { "Enabled", { B_GET_PROPERTY, 0 }, { B_DIRECT_SPECIFIER, 0 }, "Returns true if menu or menu item is enabled; false " - "otherwise.", + "otherwise.", 0, { B_BOOL_TYPE } }, { "Enabled", { B_SET_PROPERTY, 0 }, - { B_DIRECT_SPECIFIER, 0 }, "Enables or disables menu or menu item.", + { B_DIRECT_SPECIFIER, 0 }, "Enables or disables menu or menu item.", 0, { B_BOOL_TYPE } }, @@ -98,7 +98,7 @@ { "Mark", { B_GET_PROPERTY, 0 }, { B_DIRECT_SPECIFIER, 0 }, "Returns true if the menu item or the menu's superitem " - "is marked; false otherwise.", + "is marked; false otherwise.", 0, { B_BOOL_TYPE } }, @@ -111,9 +111,9 @@ { B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 }, "Adds a new menu item at the specified index with the text label found in \"data\" " "and the int32 command found in \"what\" (used as the what field in the CMessage " - "sent by the item)." , 0, {}, + "sent by the item)." , 0, {}, { {{{"data", B_STRING_TYPE}}} - } + } }, { "Menu", { B_DELETE_PROPERTY, 0 }, @@ -136,7 +136,7 @@ { B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 }, "Adds a new menu item at the specified index with the text label found in \"data\" " "and the int32 command found in \"what\" (used as the what field in the CMessage " - "sent by the item).", 0, {}, + "sent by the item).", 0, {}, { { {{"data", B_STRING_TYPE }, {"be:invoke_message", B_MESSAGE_TYPE}, {"what", B_INT32_TYPE}, @@ -146,18 +146,18 @@ { "MenuItem", { B_DELETE_PROPERTY, 0 }, { B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 }, - "Removes the specified menu item from its parent menu." + "Removes the specified menu item from its parent menu." }, { "MenuItem", { B_EXECUTE_PROPERTY, 0 }, { B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 }, - "Invokes the specified menu item." + "Invokes the specified menu item." }, { "MenuItem", { }, { B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 }, "Directs scripting message to the specified menu, first popping the current " - "specifier off the stack." + "specifier off the stack." }, {} @@ -244,7 +244,7 @@ _DeleteMenuWindow(); RemoveItems(0, CountItems(), true); - + delete fInitMatrixSize; delete fExtraMenuData; delete fLayoutData; @@ -339,8 +339,8 @@ BView::AttachedToWindow(); sAltAsCommandKey = true; - key_map *keys = NULL; - char *chars = NULL; + key_map *keys = NULL; + char *chars = NULL; get_key_map(&keys, &chars); if (keys == NULL || keys->left_command_key != 0x5d || keys->right_command_key != 0x5f) @@ -398,7 +398,7 @@ _LayoutItems(index); _UpdateWindowViewSize(false); Invalidate(); - } + } UnlockLooper(); } return true; @@ -411,10 +411,10 @@ if (fLayout != B_ITEMS_IN_MATRIX) debugger("BMenu::AddItem(BMenuItem *, BRect) this method can only " "be called if the menu layout is B_ITEMS_IN_MATRIX"); - + if (!item) return false; - + item->fBounds = frame; int32 index = CountItems(); @@ -426,7 +426,7 @@ if (!Window()->IsHidden()) { _LayoutItems(index); Invalidate(); - } + } UnlockLooper(); } @@ -434,13 +434,13 @@ } -bool +bool BMenu::AddItem(BMenu *submenu) { BMenuItem *item = new (nothrow) BMenuItem(submenu); if (!item) return false; - + if (!AddItem(item, CountItems())) { item->fSubmenu = NULL; delete item; @@ -461,7 +461,7 @@ BMenuItem *item = new (nothrow) BMenuItem(submenu); if (!item) return false; - + if (!AddItem(item, index)) { item->fSubmenu = NULL; delete item; @@ -478,7 +478,7 @@ if (fLayout != B_ITEMS_IN_MATRIX) debugger("BMenu::AddItem(BMenu *, BRect) this method can only " "be called if the menu layout is B_ITEMS_IN_MATRIX"); - + BMenuItem *item = new (nothrow) BMenuItem(submenu); if (!item) return false; @@ -499,7 +499,7 @@ // TODO: test this function, it's not documented in the bebook. if (list == NULL) return false; - + bool locked = LockLooper(); int32 numItems = list->CountItems(); @@ -510,13 +510,13 @@ break; } } - + InvalidateLayout(); - if (locked && Window() != NULL && !Window()->IsHidden()) { + if (locked && Window() != NULL && !Window()->IsHidden()) { // Make sure we update the layout if needed. _LayoutItems(index); _UpdateWindowViewSize(false); - Invalidate(); + Invalidate(); } if (locked) @@ -660,7 +660,7 @@ } -status_t +status_t BMenu::SetTargetForItems(BHandler *handler) { status_t status = B_OK; @@ -669,7 +669,7 @@ if (status < B_OK) break; } - + return status; } @@ -695,7 +695,7 @@ return; fEnabled = enabled; - + if (fSuperitem) fSuperitem->SetEnabled(enabled); } @@ -1030,18 +1030,18 @@ if (err < B_OK) return err; - + BPropertyInfo propertyInfo(sPropList); err = data->AddFlat("messages", &propertyInfo); if (err < B_OK) return err; - + return BView::GetSupportedSuites(data); } -status_t +status_t BMenu::Perform(perform_code d, void *arg) { return BView::Perform(d, arg); @@ -1157,13 +1157,13 @@ BMenuItem * BMenu::Track(bool sticky, BRect *clickToOpenRect) -{ +{ if (sticky && LockLooper()) { //RedrawAfterSticky(Bounds()); // the call above didn't do anything, so I've removed it for now UnlockLooper(); } - + if (clickToOpenRect != NULL && LockLooper()) { fExtraRect = clickToOpenRect; ConvertFromScreen(fExtraRect); @@ -1172,10 +1172,10 @@ int action; BMenuItem *menuItem = _Track(&action); - + _SetStickyMode(false); fExtraRect = NULL; - + return menuItem; } @@ -1277,7 +1277,7 @@ fSuperbounds = fSuper->ConvertToScreen(fSuper->Bounds()); window = fSuper->_MenuWindow(); } - + // Otherwise, create a new one // This happens for "stand alone" BPopUpMenus // (i.e. not within a BMenuField) @@ -1330,11 +1330,11 @@ BMenuWindow *window = static_cast(Window()); if (window == NULL || !window->Lock()) return; - + if (fSelected != NULL) _SelectItem(NULL); - window->Hide(); + window->Hide(); window->DetachMenu(); // we don't want to be deleted when the window is removed @@ -1351,16 +1351,16 @@ const bigtime_t kHysteresis = 200000; // TODO: Test and reduce if needed. - + BMenuItem * BMenu::_Track(int *action, long start) { // TODO: cleanup BMenuItem *item = NULL; bigtime_t openTime = system_time(); - bigtime_t closeTime = 0; - + bigtime_t closeTime = 0; + fState = MENU_STATE_TRACKING; if (fSuper != NULL) fSuper->fState = MENU_STATE_TRACKING_SUBMENU; @@ -1368,7 +1368,7 @@ while (true) { if (_CustomTrackingWantsToQuit()) break; - + bool locked = LockLooper(); if (!locked) break; @@ -1506,12 +1506,12 @@ for(; supermenu; supermenu = supermenu->Supermenu()) supermenu->_SetStickyMode(false); _SetStickyMode(false); - } + } } else if (buttons == 0 && !_IsStickyMode()) { if (fExtraRect != NULL && fExtraRect->Contains(where)) { _SetStickyMode(true); fExtraRect = NULL; - // This code should be executed only once + // This code should be executed only once } else fState = MENU_STATE_CLOSED; } @@ -1528,7 +1528,7 @@ if (!fItems.AddItem(item, index)) return false; - // install the item on the supermenu's window + // install the item on the supermenu's window // or onto our window, if we are a root menu BWindow* window = NULL; if (Superitem() != NULL) @@ -1558,7 +1558,7 @@ if (fItems.RemoveItem(item)) { if (item == fSelected && window != NULL) _SelectItem(NULL); - item->Uninstall(); + item->Uninstall(); item->SetSuper(NULL); if (deleteItems) delete item; @@ -1652,9 +1652,8 @@ // Recalculate only the needed items, // not the whole layout every time - BRect frame(0, 0, 0, 0); - if (index > 0) - frame = Bounds(); + BRect frame; + switch (fLayout) { case B_ITEMS_IN_COLUMN: _ComputeColumnLayout(index, bestFit, moveItems, frame); @@ -1665,7 +1664,7 @@ break; case B_ITEMS_IN_MATRIX: - _ComputeMatrixLayout(frame); + _ComputeMatrixLayout(frame); break; default: @@ -1694,7 +1693,7 @@ if (bestFit) fLayoutData->preferred = size; - + if (moveItems) fUseCachedMenuLayout = true; } @@ -1709,41 +1708,46 @@ bool command = false; bool control = false; bool shift = false; - for (int32 i = index; i < fItems.CountItems(); i++) { - BMenuItem *item = ItemAt(i); - if (item != NULL) { - float iWidth, iHeight; - item->GetContentSize(&iWidth, &iHeight); - if (item->fModifiers && item->fShortcutChar) { - iWidth += font.Size(); - if (item->fModifiers & B_COMMAND_KEY) - command = true; - if (item->fModifiers & B_CONTROL_KEY) - control = true; - if (item->fModifiers & B_SHIFT_KEY) - shift = true; - } + if (index > 0) + frame = ItemAt(index - 1)->Frame(); + else + frame.Set(0, 0, 0, 0); - item->fBounds.left = 0.0f; - item->fBounds.top = frame.bottom; - item->fBounds.bottom = item->fBounds.top + iHeight + fPad.top - + fPad.bottom; + for (; index < fItems.CountItems(); index++) { + BMenuItem *item = ItemAt(index); - iWidth += item->Frame().Height(); - - frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right); - frame.bottom = item->fBounds.bottom + 1.0f; + float width, height; + item->GetContentSize(&width, &height); + + if (item->fModifiers && item->fShortcutChar) { + width += font.Size(); + if (item->fModifiers & B_COMMAND_KEY) + command = true; + if (item->fModifiers & B_CONTROL_KEY) + control = true; + if (item->fModifiers & B_SHIFT_KEY) + shift = true; } + + item->fBounds.left = 0.0f; + item->fBounds.top = frame.bottom + (index > 0 ? 1.0f : 0.0f); + item->fBounds.bottom = item->fBounds.top + height + fPad.top + + fPad.bottom; + + width += item->Frame().Height(); + + frame.right = max_c(frame.right, width + fPad.left + fPad.right); + frame.bottom = item->fBounds.bottom; } - + if (command) frame.right += 17; if (control) frame.right += 17; if (shift) - frame.right += 22; - + frame.right += 22; + if (fMaxContentWidth > 0) frame.right = min_c(frame.right, fMaxContentWidth); @@ -1751,8 +1755,9 @@ for (int32 i = 0; i < fItems.CountItems(); i++) ItemAt(i)->fBounds.right = frame.right; } + + frame.top = 0; frame.right = ceilf(frame.right); - frame.bottom--; } @@ -1762,28 +1767,28 @@ { font_height fh; GetFontHeight(&fh); - frame = BRect(0.0f, 0.0f, 0.0f, ceilf(fh.ascent + fh.descent + fPad.top - + fPad.bottom)); + frame.Set(0.0f, 0.0f, 0.0f, ceilf(fh.ascent + fh.descent + fPad.top + + fPad.bottom)); for (int32 i = 0; i < fItems.CountItems(); i++) { BMenuItem *item = ItemAt(i); - float iWidth, iHeight; + float width, height; if (item != NULL) { - item->GetContentSize(&iWidth, &iHeight); + item->GetContentSize(&width, &height); item->fBounds.left = frame.right; item->fBounds.top = 0.0f; - item->fBounds.right = item->fBounds.left + iWidth + fPad.left + item->fBounds.right = item->fBounds.left + width + fPad.left + fPad.right; frame.right = item->Frame().right + 1.0f; - frame.bottom = max_c(frame.bottom, iHeight + fPad.top + fPad.bottom); + frame.bottom = max_c(frame.bottom, height + fPad.top + fPad.bottom); } } if (moveItems) { for (int32 i = 0; i < fItems.CountItems(); i++) - ItemAt(i)->fBounds.bottom = frame.bottom; + ItemAt(i)->fBounds.bottom = frame.bottom; } if (bestFit) @@ -1804,8 +1809,8 @@ frame.right = max_c(frame.right, item->Frame().right); frame.top = min_c(frame.top, item->Frame().top); frame.bottom = max_c(frame.bottom, item->Frame().bottom); - } - } + } + } } @@ -1883,9 +1888,9 @@ frame.OffsetBy(0, screenFrame.bottom - frame.bottom); } else { if (frame.bottom > screenFrame.bottom) { - if (scrollOn != NULL && superMenu != NULL && - dynamic_cast(superMenu) != NULL && - frame.top < (screenFrame.bottom - 80)) { + if (scrollOn != NULL && superMenu != NULL + && dynamic_cast(superMenu) != NULL + && frame.top < (screenFrame.bottom - 80)) { *scrollOn = true; } else { frame.OffsetBy(0, -superItem->Frame().Height() - frame.Height() - 3); @@ -1907,7 +1912,7 @@ for (int32 i = 0; i < itemCount; i++) { BMenuItem *item = ItemAt(i); if (item->Frame().Intersects(updateRect)) - item->Draw(); + item->Draw(); } } @@ -1920,7 +1925,7 @@ if (fSelected != NULL && fSelected->Submenu() != NULL) return fSelected->Submenu()->State(item); - + return fState; } @@ -1939,10 +1944,10 @@ snooze(50000); item->Select(false); Sync(); - snooze(50000); + snooze(50000); item->Select(true); Sync(); - snooze(50000); + snooze(50000); item->Select(false); Sync(); UnlockLooper(); @@ -2077,15 +2082,15 @@ void BMenu::_SelectItem(BMenuItem* menuItem, bool showSubmenu, bool selectFirstItem) -{ +{ // Avoid deselecting and then reselecting the same item // which would cause flickering - if (menuItem != fSelected) { + if (menuItem != fSelected) { if (fSelected != NULL) { fSelected->Select(false); BMenu *subMenu = fSelected->Submenu(); if (subMenu != NULL && subMenu->Window() != NULL) - subMenu->_Hide(); + subMenu->_Hide(); } fSelected = menuItem; @@ -2106,7 +2111,7 @@ } -bool +bool BMenu::_SelectNextItem(BMenuItem *item, bool forward) { BMenuItem *nextItem = _NextItem(item, forward); @@ -2141,7 +2146,7 @@ } -void +void BMenu::_SetIgnoreHidden(bool on) { fIgnoreHidden = on; @@ -2160,7 +2165,7 @@ menuBar->_StealFocus(); menuBar->UnlockLooper(); } - + fStickyMode = on; } @@ -2242,7 +2247,7 @@ void BMenu::_UpdateWindowViewSize(bool updatePosition) { - BMenuWindow *window = static_cast(Window()); + BMenuWindow *window = static_cast(Window()); if (window == NULL) return; @@ -2270,7 +2275,7 @@ window->ResizeTo(Bounds().Width() + 2, screen.Frame().bottom); frame.top = 0; } else { - // Or, in case our parent was a BMenuBar enable scrolling with + // Or, in case our parent was a BMenuBar enable scrolling with // normal size. window->ResizeTo(Bounds().Width() + 2, screen.Frame().bottom - frame.top); @@ -2348,7 +2353,7 @@ BPrivate::AppServerLink link; link.StartMessage(AS_SET_MENU_INFO); link.Attach(*info); - + status_t status = B_ERROR; if (link.FlushWithReply(status) == B_OK && status == B_OK) BMenu::sMenuInfo = *info; @@ -2363,13 +2368,13 @@ { if (!info) return B_BAD_VALUE; - + BPrivate::AppServerLink link; link.StartMessage(AS_GET_MENU_INFO); - + status_t status = B_ERROR; if (link.FlushWithReply(status) == B_OK && status == B_OK) link.Read(info); - + return status; } From axeld at mail.berlios.de Wed Nov 7 15:42:08 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 7 Nov 2007 15:42:08 +0100 Subject: [Haiku-commits] r22851 - haiku/trunk/src/apps/sudoku Message-ID: <200711071442.lA7Eg8bB030263@sheep.berlios.de> Author: axeld Date: 2007-11-07 15:42:07 +0100 (Wed, 07 Nov 2007) New Revision: 22851 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22851&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp Log: Keyboard navigation only worked after the first field was set. Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2007-11-07 14:24:09 UTC (rev 22850) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2007-11-07 14:42:07 UTC (rev 22851) @@ -33,6 +33,8 @@ fShowHintX(~0UL), fLastHintValue(~0UL), fLastField(~0UL), + fKeyboardX(0), + fKeyboardY(0), fShowKeyboardFocus(false), fEditable(true) { From axeld at mail.berlios.de Wed Nov 7 18:09:08 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 7 Nov 2007 18:09:08 +0100 Subject: [Haiku-commits] r22852 - haiku/trunk/src/system/kernel/vm Message-ID: <200711071709.lA7H98H0008125@sheep.berlios.de> Author: axeld Date: 2007-11-07 18:09:05 +0100 (Wed, 07 Nov 2007) New Revision: 22852 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22852&view=rev Modified: haiku/trunk/src/system/kernel/vm/PageCacheLocker.h haiku/trunk/src/system/kernel/vm/vm_daemons.cpp haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: * Made page_writer() use a marker page as well, so that it won't try to get the same pages over and over. * Increased the priority of the page writer a bit, so that it is higher than the one of the page daemon. * Added a sModifiedTemporaryPages counter to let the page_writer decide how many pages are there to write back (temporary pages would go to the swap file and are only written back when memory is low). * In case there are more than 1024 modified (non-temporary) pages around, the page writer will constantly write out pages, not only when being pushed. * The page writer now temporarily always leave out temporary pages (as long as we don't have a swap file). * Shuffled functions around a bit. Modified: haiku/trunk/src/system/kernel/vm/PageCacheLocker.h =================================================================== --- haiku/trunk/src/system/kernel/vm/PageCacheLocker.h 2007-11-07 14:42:07 UTC (rev 22851) +++ haiku/trunk/src/system/kernel/vm/PageCacheLocker.h 2007-11-07 17:09:05 UTC (rev 22852) @@ -13,12 +13,12 @@ class PageCacheLocker { public: - PageCacheLocker(vm_page* page); + PageCacheLocker(vm_page* page, bool dontWait = true); ~PageCacheLocker(); bool IsLocked() { return fPage != NULL; } - bool Lock(vm_page* page); + bool Lock(vm_page* page, bool dontWait = true); void Unlock(); private: Modified: haiku/trunk/src/system/kernel/vm/vm_daemons.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_daemons.cpp 2007-11-07 14:42:07 UTC (rev 22851) +++ haiku/trunk/src/system/kernel/vm/vm_daemons.cpp 2007-11-07 17:09:05 UTC (rev 22852) @@ -27,7 +27,7 @@ static uint32 sNumPages; -PageCacheLocker::PageCacheLocker(vm_page* page) +PageCacheLocker::PageCacheLocker(vm_page* page, bool dontWait) : fPage(NULL) { @@ -55,7 +55,7 @@ bool -PageCacheLocker::Lock(vm_page* page) +PageCacheLocker::Lock(vm_page* page, bool dontWait) { if (_IgnorePage(page)) return false; @@ -65,14 +65,13 @@ if (cache == NULL) return false; -#if 0 - mutex_lock(&cache->lock); -#else - if (mutex_trylock(&cache->lock) != B_OK) { - vm_cache_release_ref(cache); - return false; - } -#endif + if (dontWait) { + if (mutex_trylock(&cache->lock) != B_OK) { + vm_cache_release_ref(cache); + return false; + } + } else + mutex_lock(&cache->lock); if (cache != page->cache || _IgnorePage(page)) { mutex_unlock(&cache->lock); Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-11-07 14:42:07 UTC (rev 22851) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-11-07 17:09:05 UTC (rev 22852) @@ -61,6 +61,7 @@ static size_t sNumPages; static size_t sReservedPages; static vint32 sPageDeficit; +static size_t sModifiedTemporaryPages; static ConditionVariable sFreePageCondition; static spinlock sPageLock; @@ -596,6 +597,9 @@ static status_t set_page_state_nolock(vm_page *page, int pageState) { + if (pageState == page->state) + return B_OK; + page_queue *fromQueue = NULL; page_queue *toQueue = NULL; @@ -658,7 +662,10 @@ if (pageState != PAGE_STATE_INACTIVE && page->cache != NULL) panic("to be freed page %p has cache", page); - } + } else if (pageState == PAGE_STATE_MODIFIED && page->cache->temporary) + sModifiedTemporaryPages++; + else if (page->state == PAGE_STATE_MODIFIED && page->cache->temporary) + sModifiedTemporaryPages--; #if TRACK_PAGE_ALLOCATIONS if ((pageState == PAGE_STATE_CLEAR || pageState == PAGE_STATE_FREE) @@ -690,6 +697,8 @@ page->state = state; enqueue_page(state == PAGE_STATE_ACTIVE ? &sActivePageQueue : &sInactivePageQueue, page); + if (page->cache->temporary) + sModifiedTemporaryPages--; } else set_page_state_nolock(page, state); } @@ -823,6 +832,61 @@ } +static void +remove_page_marker(struct vm_page &marker) +{ + if (marker.state == PAGE_STATE_UNUSED) + return; + + page_queue *queue; + vm_page *page; + + switch (marker.state) { + case PAGE_STATE_ACTIVE: + queue = &sActivePageQueue; + break; + case PAGE_STATE_INACTIVE: + queue = &sInactivePageQueue; + break; + case PAGE_STATE_MODIFIED: + queue = &sModifiedPageQueue; + break; + + default: + return; + } + + remove_page_from_queue(queue, &marker); + marker.state = PAGE_STATE_UNUSED; +} + + +static vm_page * +next_modified_page(struct vm_page &marker) +{ + InterruptsSpinLocker locker(sPageLock); + vm_page *page; + + if (marker.state == PAGE_STATE_MODIFIED) { + page = marker.queue_next; + remove_page_from_queue(&sModifiedPageQueue, &marker); + marker.state = PAGE_STATE_UNUSED; + } else + page = sModifiedPageQueue.head; + + for (; page != NULL; page = page->queue_next) { + if (page->type != PAGE_TYPE_DUMMY && page->state != PAGE_STATE_BUSY) { + // insert marker + marker.state = PAGE_STATE_MODIFIED; + insert_page_after(&sModifiedPageQueue, page, &marker); + return page; + } + } + + return NULL; +} + + /*! The page writer continuously takes some pages from the modified queue, writes them back, and moves them back to the active queue. It runs in its own thread, and is only there to keep the number @@ -832,14 +896,22 @@ status_t page_writer(void* /*unused*/) { + vm_page marker; + marker.type = PAGE_TYPE_DUMMY; + marker.cache = NULL; + marker.state = PAGE_STATE_UNUSED; + while (true) { - int32 count = 0; - get_sem_count(sWriterWaitSem, &count); - if (count == 0) - count = 1; + if (sModifiedPageQueue.count - sModifiedTemporaryPages < 1024 + || free_page_queue_count() > 1024) { + int32 count = 0; + get_sem_count(sWriterWaitSem, &count); + if (count == 0) + count = 1; - acquire_sem_etc(sWriterWaitSem, count, B_RELATIVE_TIMEOUT, 3000000); - // all 3 seconds when no one triggers us + acquire_sem_etc(sWriterWaitSem, count, B_RELATIVE_TIMEOUT, 3000000); + // all 3 seconds when no one triggers us + } const uint32 kNumPages = 32; ConditionVariable busyConditions[kNumPages]; @@ -855,38 +927,31 @@ // collect pages to be written while (numPages < kNumPages) { - InterruptsSpinLocker locker(sPageLock); - - vm_page *page = sModifiedPageQueue.head; - while (page != NULL && page->state == PAGE_STATE_BUSY) { - // skip busy pages - page = page->queue_next; - } + vm_page *page = next_modified_page(marker); if (page == NULL) break; - locker.Unlock(); - - PageCacheLocker cacheLocker(page); + PageCacheLocker cacheLocker(page, false); if (!cacheLocker.IsLocked()) continue; vm_cache *cache = page->cache; + // TODO: write back temporary ones as soon as we have swap file support + if (cache->temporary/* && vm_low_memory_state() == B_NO_LOW_MEMORY*/) + continue; + if (cache->store->ops->acquire_unreferenced_ref != NULL) { // we need our own reference to the store, as it might // currently be destructed if (cache->store->ops->acquire_unreferenced_ref(cache->store) != B_OK) { - // put it to the tail of the queue, then, so that we - // won't touch it too soon again - vm_page_requeue(page, true); cacheLocker.Unlock(); thread_yield(); continue; } } - locker.Lock(); + InterruptsSpinLocker locker(sPageLock); remove_page_from_queue(&sModifiedPageQueue, page); page->state = PAGE_STATE_BUSY; @@ -938,10 +1003,63 @@ } } + remove_page_marker(marker); return B_OK; } +static vm_page * +find_page_candidate(struct vm_page &marker, bool stealActive) +{ + InterruptsSpinLocker locker(sPageLock); + page_queue *queue; + vm_page *page; + + switch (marker.state) { + case PAGE_STATE_ACTIVE: + queue = &sActivePageQueue; + page = marker.queue_next; + remove_page_from_queue(queue, &marker); + marker.state = PAGE_STATE_UNUSED; + break; + case PAGE_STATE_INACTIVE: + queue = &sInactivePageQueue; + page = marker.queue_next; + remove_page_from_queue(queue, &marker); + marker.state = PAGE_STATE_UNUSED; + break; + default: + queue = &sInactivePageQueue; + page = sInactivePageQueue.head; + if (page == NULL && stealActive) { + queue = &sActivePageQueue; + page = sActivePageQueue.head; + } + break; + } + + while (page != NULL) { + if (page->type != PAGE_TYPE_DUMMY + && (page->state == PAGE_STATE_INACTIVE + || (stealActive && page->state == PAGE_STATE_ACTIVE + && page->wired_count == 0))) { + // insert marker + marker.state = queue == &sActivePageQueue ? PAGE_STATE_ACTIVE : PAGE_STATE_INACTIVE; + insert_page_after(queue, page, &marker); + return page; + } + + page = page->queue_next; + if (page == NULL && stealActive && queue != &sActivePageQueue) { + queue = &sActivePageQueue; + page = sActivePageQueue.head; + } + } + + return NULL; +} + + static bool steal_page(vm_page *page, bool stealActive) { @@ -1018,84 +1136,6 @@ } -static void -remove_page_marker(struct vm_page &marker) -{ - if (marker.state == PAGE_STATE_UNUSED) - return; - - page_queue *queue; - vm_page *page; - - switch (marker.state) { - case PAGE_STATE_ACTIVE: - queue = &sActivePageQueue; - break; - case PAGE_STATE_INACTIVE: - queue = &sInactivePageQueue; - break; - - default: - return; - } - - remove_page_from_queue(queue, &marker); - marker.state = PAGE_STATE_UNUSED; -} - - -static vm_page * -find_page_candidate(struct vm_page &marker, bool stealActive) -{ - InterruptsSpinLocker locker(sPageLock); - page_queue *queue; - vm_page *page; - - switch (marker.state) { - case PAGE_STATE_ACTIVE: - queue = &sActivePageQueue; - page = marker.queue_next; - remove_page_from_queue(queue, &marker); - marker.state = PAGE_STATE_UNUSED; - break; - case PAGE_STATE_INACTIVE: - queue = &sInactivePageQueue; - page = marker.queue_next; - remove_page_from_queue(queue, &marker); - marker.state = PAGE_STATE_UNUSED; - break; - default: - queue = &sInactivePageQueue; - page = sInactivePageQueue.head; - if (page == NULL && stealActive) { - queue = &sActivePageQueue; - page = sActivePageQueue.head; - } - break; - } - - while (page != NULL) { - if (page->type != PAGE_TYPE_DUMMY - && (page->state == PAGE_STATE_INACTIVE - || (stealActive && page->state == PAGE_STATE_ACTIVE - && page->wired_count == 0))) { - // insert marker - marker.state = queue == &sActivePageQueue ? PAGE_STATE_ACTIVE : PAGE_STATE_INACTIVE; - insert_page_after(queue, page, &marker); - return page; - } - - page = page->queue_next; - if (page == NULL && stealActive && queue != &sActivePageQueue) { - queue = &sActivePageQueue; - page = sActivePageQueue.head; - } - } - - return NULL; -} - - static size_t steal_pages(vm_page **pages, size_t count, bool reserve) { @@ -1351,21 +1391,21 @@ status_t vm_page_init_post_thread(kernel_args *args) { + new (&sFreePageCondition) ConditionVariable; + sFreePageCondition.Publish(&sFreePageQueue, "free page"); + // create a kernel thread to clear out pages thread_id thread = spawn_kernel_thread(&page_scrubber, "page scrubber", B_LOWEST_ACTIVE_PRIORITY, NULL); send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE); - new (&sFreePageCondition) ConditionVariable; - sFreePageCondition.Publish(&sFreePageQueue, "free page"); + // start page writer - // start page writer and page thief - sWriterWaitSem = create_sem(0, "page writer"); thread = spawn_kernel_thread(&page_writer, "page writer", - B_NORMAL_PRIORITY, NULL); + B_NORMAL_PRIORITY + 1, NULL); send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE); return B_OK; @@ -1593,6 +1633,7 @@ InterruptsSpinLocker locker(sPageLock); if (sFreePageQueue.count + sClearPageQueue.count - sReservedPages < length) { + // TODO: add more tries, ie. free some inactive, ... // no free space return NULL; } From stippi at mail.berlios.de Wed Nov 7 21:10:19 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 7 Nov 2007 21:10:19 +0100 Subject: [Haiku-commits] r22853 - in haiku/trunk/src: apps/installer preferences/drivesetup Message-ID: <200711072010.lA7KAJg7002665@sheep.berlios.de> Author: stippi Date: 2007-11-07 21:10:19 +0100 (Wed, 07 Nov 2007) New Revision: 22853 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22853&view=rev Removed: haiku/trunk/src/preferences/drivesetup/PosSettings.cpp haiku/trunk/src/preferences/drivesetup/PosSettings.h Modified: haiku/trunk/src/apps/installer/InstallerWindow.cpp haiku/trunk/src/preferences/drivesetup/DriveSetup.rdef haiku/trunk/src/preferences/drivesetup/Jamfile haiku/trunk/src/preferences/drivesetup/MainWindow.cpp haiku/trunk/src/preferences/drivesetup/MainWindow.h haiku/trunk/src/preferences/drivesetup/PartitionList.cpp haiku/trunk/src/preferences/drivesetup/PartitionList.h haiku/trunk/src/preferences/drivesetup/main.cpp haiku/trunk/src/preferences/drivesetup/main.h Log: cleaned up the code: * conforming app signature * tracked down copyright info * removed too technical list columns * reimplemented storing/restoring settings (removed PosSettings) * relayouted/simplified menu structure * rewrote rdef * enabled debug output for now Modified: haiku/trunk/src/apps/installer/InstallerWindow.cpp =================================================================== --- haiku/trunk/src/apps/installer/InstallerWindow.cpp 2007-11-07 17:09:05 UTC (rev 22852) +++ haiku/trunk/src/apps/installer/InstallerWindow.cpp 2007-11-07 20:10:19 UTC (rev 22853) @@ -19,7 +19,7 @@ #include "InstallerWindow.h" #include "PartitionMenuItem.h" -#define DRIVESETUP_SIG "application/x-vnd.Be-DRV$" +#define DRIVESETUP_SIG "application/x-vnd.Haiku-DriveSetup" const uint32 BEGIN_MESSAGE = 'iBGN'; const uint32 SHOW_BOTTOM_MESSAGE = 'iSBT'; Modified: haiku/trunk/src/preferences/drivesetup/DriveSetup.rdef =================================================================== --- haiku/trunk/src/preferences/drivesetup/DriveSetup.rdef 2007-11-07 17:09:05 UTC (rev 22852) +++ haiku/trunk/src/preferences/drivesetup/DriveSetup.rdef 2007-11-07 20:10:19 UTC (rev 22853) @@ -1,8 +1,24 @@ -resource(1, "BEOS:FILE_TYPES") message; +resource app_signature "application/x-vnd.Haiku-DriveSetup"; -resource(101, "BEOS:L:STD_ICON") #'ICON' array -{ +resource app_version { + major = 1, + middle = 0, + minor = 0, + + /* 0 = development 1 = alpha 2 = beta + 3 = gamma 4 = golden master 5 = final */ + variety = 0, + + internal = 0, + + short_info = "DriveSetup", + long_info = "DriveSetup ?2002-2007 Haiku" +}; + +resource app_flags B_SINGLE_LAUNCH; + +resource large_icon { $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" @@ -37,8 +53,7 @@ $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" }; -resource(101, "BEOS:M:STD_ICON") #'MICN' array -{ +resource mini_icon { $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" $"FF0000FFFFFF0000FFFFFFFFFF0000FF" @@ -57,32 +72,3 @@ $"FFFFFFFFFFFFFF0000000E0FFFFFFFFF" }; -resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.MSM-DriveSetupPrefPanel"; - -resource(1, "BEOS:APP_VERSION") #'APPV' array -{ - $"0000000000000000010000000000000000000000564D20507265660000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000447269766553657475702050" - $"7265666572656E636573204170706C6574000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000010000000100000001000000" - $"0100000001000000010000000100000001000000680200007202000001000000" - $"3600000020000000200000002000000020000000200000002000000020000000" - $"2000000020000000200000002000000020000000200000002000000020000000" - $"FC000000420000008000000046000000480000004A000000BC0000004C000000" - $"540000005000000052000000BE00000056000000100000000A00000002000000" - $"16000000010000005E000000540000005A00000012000000E2000000EE000000" - $"CA000000E4000000E8000000F2000000EA000000D2000000DE000000E0000000" - $"F6000000FA000000F8000000FE00000008000000180000006E00000070000000" - $"720000005600000001000000C2000000E6000000C8000000CC000000CE000000" - $"D0000000D4000000D6000000D800000074000000440000001400000068000000" - $"6A0000006C000000" -}; - -resource(1, "BEOS:APP_FLAGS") #'APPF' $"00000000"; Modified: haiku/trunk/src/preferences/drivesetup/Jamfile =================================================================== --- haiku/trunk/src/preferences/drivesetup/Jamfile 2007-11-07 17:09:05 UTC (rev 22852) +++ haiku/trunk/src/preferences/drivesetup/Jamfile 2007-11-07 20:10:19 UTC (rev 22853) @@ -1,9 +1,15 @@ SubDir HAIKU_TOP src preferences drivesetup ; +SetSubDirSupportedPlatformsBeOSCompatible ; + UsePrivateHeaders interface storage shared ; AddResources DriveSetup : DriveSetup.rdef ; -Preference DriveSetup : main.cpp MainWindow.cpp PartitionList.cpp PosSettings.cpp ; - -LinkAgainst DriveSetup : be ; +Preference DriveSetup : + main.cpp + MainWindow.cpp + PartitionList.cpp + : + be +; Modified: haiku/trunk/src/preferences/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/MainWindow.cpp 2007-11-07 17:09:05 UTC (rev 22852) +++ haiku/trunk/src/preferences/drivesetup/MainWindow.cpp 2007-11-07 20:10:19 UTC (rev 22853) @@ -1,36 +1,38 @@ -/*! \file MainWindow.cpp - * \brief Code for the MainWindow class. - * - * Displays the main window, the essence of the app. +/* + * Copyright 2002-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. * -*/ - + * Authors: + * Erik Jaesler + * Ithamar R. Adema + * Stephan A?mus + */ #include "MainWindow.h" #include "PartitionList.h" -#include "PosSettings.h" -#include -#include -#include +#include -#include -#include +#include +#include +#include +#include +#include -#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -class DriveVisitor : public BDiskDeviceVisitor -{ +class DriveVisitor : public BDiskDeviceVisitor { public: DriveVisitor(PartitionListView* list); - bool Visit(BDiskDevice *device); - bool Visit(BPartition *partition, int32 level); + virtual bool Visit(BDiskDevice* device); + virtual bool Visit(BPartition* partition, int32 level); + private: PartitionListView* fPartitionList; }; @@ -62,7 +64,7 @@ return string; } -#if DEBUG + static void dump_partition_info(BPartition* partition) { @@ -86,187 +88,202 @@ printf("\tContentType(): %s\n", partition->ContentType()); printf("\tID(): %lx\n\n", partition->ID()); } -#endif -/** - * Constructor. - * @param frame The size to make the window. - */ -MainWindow::MainWindow(BRect frame, PosSettings *Settings) - : BWindow(frame, "DriveSetup", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) + +enum { + MSG_MOUNT_ALL = 'mnta', + MSG_MOUNT = 'mnts', + MSG_UNMOUNT = 'unmt', + MSG_FORMAT = 'frmt', + MSG_INITIALIZE = 'init', + MSG_EJECT = 'ejct', + MSG_SURFACE_TEST = 'sfct', + MSG_RESCAN = 'rscn', +}; + + +MainWindow::MainWindow(BRect frame) + : BWindow(frame, "DriveSetup", B_DOCUMENT_WINDOW, + B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) { - BMenu *partitionMenu, *initMenu; - BMenu *menu; + BMenuBar* rootMenu = new BMenuBar(Bounds(), "root menu"); - fSettings = Settings; - - BMenuBar* rootMenu = new BMenuBar(Bounds(), "root menu"); - //Setup Mount menu - menu = new BMenu("Mount"); - menu->AddItem(new BMenuItem("Mount All Partitions", new BMessage(MOUNT_MOUNT_ALL_MSG), 'M')); - menu->AddSeparatorItem(); + // Disk menu + BMenu* menu = new BMenu("Disk"); + menu->AddItem(new BMenuItem("Format", new BMessage(MSG_FORMAT), 'F')); + menu->AddItem(new BMenuItem("Eject", new BMessage(MSG_EJECT), 'E')); + menu->AddItem(new BMenuItem("Surface Test", + new BMessage(MSG_SURFACE_TEST), 'T')); + menu->AddSeparatorItem(); + menu->AddItem(new BMenuItem("Rescan", new BMessage(MSG_RESCAN))); rootMenu->AddItem(menu); - - //Setup Unmount menu - menu = new BMenu("Unmount"); - rootMenu->AddItem(menu); - - //Setup Setup menu - menu = new BMenu("Setup"); - menu->AddItem(new BMenuItem("Format", new BMessage(SETUP_FORMAT_MSG), 'F')); - partitionMenu = new BMenu("Partition"); - menu->AddItem(partitionMenu); - initMenu = new BMenu("Initialize"); - //add menu for formats + + // Parition menu + menu = new BMenu("Partition"); + BMenu* initMenu = new BMenu("Initialize"); menu->AddItem(initMenu); + menu->AddSeparatorItem(); + menu->AddItem(new BMenuItem("Mount", new BMessage(MSG_MOUNT), 'M')); + menu->AddItem(new BMenuItem("Unmount", new BMessage(MSG_UNMOUNT), 'U')); + menu->AddSeparatorItem(); + menu->AddItem(new BMenuItem("Mount All", + new BMessage(MSG_MOUNT_ALL), 'M', B_SHIFT_KEY)); rootMenu->AddItem(menu); - - //Setup Options menu - menu = new BMenu("Options"); - menu->AddItem(new BMenuItem("Eject", new BMessage(OPTIONS_EJECT_MSG), 'E')); - menu->AddItem(new BMenuItem("Surface Test", new BMessage(OPTIONS_SURFACE_TEST_MSG), 'T')); - rootMenu->AddItem(menu); - - //Setup Rescan menu - menu = new BMenu("Rescan"); - menu->AddItem(new BMenuItem("IDE", new BMessage(RESCAN_IDE_MSG))); - menu->AddItem(new BMenuItem("SCSI", new BMessage(RESCAN_SCSI_MSG))); - rootMenu->AddItem(menu); - + AddChild(rootMenu); BRect r(Bounds()); - r.top = rootMenu->Frame().bottom +1; + r.top = rootMenu->Frame().bottom + 1; fListView = new PartitionListView(r); AddChild(fListView); - // Now update filesystem/partition menus with values + // Populate the Initialiaze menu with the available file systems BDiskSystem diskSystem; fDDRoster.RewindDiskSystems(); while(fDDRoster.GetNextDiskSystem(&diskSystem) == B_OK) { - if (diskSystem.IsPartitioningSystem()) { - BMessage* msg = new BMessage(SETUP_PARTITION_SELECTED_MSG); - msg->AddString("bdisksystem:name", diskSystem.Name()); - partitionMenu->AddItem(new BMenuItem(diskSystem.PrettyName(), msg)); - } else if (diskSystem.IsFileSystem()) { - BMessage* msg = new BMessage(SETUP_INITIALIZE_MSG); - msg->AddString("bdisksystem:name", diskSystem.Name()); - initMenu->AddItem(new BMenuItem(diskSystem.PrettyName(), msg)); + if (diskSystem.IsFileSystem()) { + BMessage* message = new BMessage(MSG_INITIALIZE); + message->AddString("format", diskSystem.Name()); + BString label = diskSystem.PrettyName(); + label << B_UTF8_ELLIPSIS; + initMenu->AddItem(new BMenuItem(label.String(), message)); } } - // Now visit all disks in the system and show their contents - DriveVisitor driveVisitor(fListView); - BPartition *partition = NULL; - BDiskDevice device; - fDDRoster.VisitEachPartition(&driveVisitor, &device, &partition); + // Visit all disks in the system and show their contents + _ScanDrives(); } -/** - * Handles messages. - * @param message The message recieved by the window. - */ -void MainWindow::MessageReceived(BMessage *message){ - switch(message->what){ - - case MOUNT_MOUNT_ALL_MSG: - - printf("MOUNT_MOUNT_ALL_MSG\n"); +void +MainWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + case MSG_MOUNT_ALL: + printf("MSG_MOUNT_ALL\n"); break; - case MOUNT_MOUNT_SELECTED_MSG: - - printf("MOUNT_MOUNT_SELECTED_MSG\n"); + case MSG_MOUNT: + printf("MSG_MOUNT\n"); break; - case UNMOUNT_UNMOUNT_SELECTED_MSG: - - printf("UNMOUNT_UNMOUNT_SELECTED_MSG\n"); + case MSG_UNMOUNT: + printf("MSG_UNMOUNT\n"); break; - case SETUP_FORMAT_MSG: - - printf("SETUP_FORMAT_MSG\n"); + case MSG_FORMAT: + printf("MSG_FORMAT\n"); break; - case SETUP_INITIALIZE_MSG: - - printf("SETUP_INITIALIZE_MSG\n"); + case MSG_INITIALIZE: + printf("MSG_INITIALIZE\n"); break; - case OPTIONS_EJECT_MSG: - - printf("OPTIONS_EJECT_MSG\n"); + case MSG_EJECT: + printf("MSG_EJECT\n"); break; - case OPTIONS_SURFACE_TEST_MSG: - - printf("OPTIONS_SURFACE_TEST_MSG\n"); + case MSG_SURFACE_TEST: + printf("MSG_SURFACE_TEST\n"); break; - case RESCAN_IDE_MSG: - - printf("RESCAN_IDE_MSG\n"); + case MSG_RESCAN: + _ScanDrives(); break; - case RESCAN_SCSI_MSG: - - printf("RESCAN_SCSI_MSG\n"); - break; - default: - BWindow::MessageReceived(message); - - }//switch - + break; + } } -/** - * Quits and Saves settings. - */ + bool MainWindow::QuitRequested() { - bool accepted = BWindow::QuitRequested(); - if (accepted) { - fSettings->SetWindowPosition(Frame()); - be_app->PostMessage(B_QUIT_REQUESTED); + // TODO: ask about any unsaved changes + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} + + +// #pragma mark - + + +status_t +MainWindow::StoreSettings(BMessage* archive) const +{ + if (archive->ReplaceRect("window frame", Frame()) < B_OK) + archive->AddRect("window frame", Frame()); + // TODO: store column list settings + return B_OK; +} + + +status_t +MainWindow::RestoreSettings(BMessage* archive) +{ + BRect frame; + if (archive->FindRect("window frame", &frame) == B_OK) { + BScreen screen(this); + if (frame.Intersects(screen.Frame())) { + MoveTo(frame.LeftTop()); + ResizeTo(frame.Width(), frame.Height()); + } } - - return accepted; + // TODO: restore column list settings + return B_OK; } + +// #pragma mark - + + +void +MainWindow::_ScanDrives() +{ + DriveVisitor driveVisitor(fListView); + BPartition* partition = NULL; + BDiskDevice device; + fDDRoster.VisitEachPartition(&driveVisitor, &device, &partition); +} + + +// #pragma mark - DriveVisitor + + DriveVisitor::DriveVisitor(PartitionListView* list) : fPartitionList(list) { + // start with an empty list + int32 rows = fPartitionList->CountRows(); + for (int32 i = rows - 1; i >= 0; i--) { + BRow* row = fPartitionList->RowAt(i); + fPartitionList->RemoveRow(row); + delete row; + } } + bool DriveVisitor::Visit(BDiskDevice* device) { - if (fPartitionList != NULL) - fPartitionList->AddPartition(device); + fPartitionList->AddPartition(device); -DEBUG_ONLY( printf("Visit(%p)\n", device); dump_partition_info(device); -); return false; // Don't stop yet! } + bool DriveVisitor::Visit(BPartition* partition, int32 level) { - if (fPartitionList != NULL) - fPartitionList->AddPartition(partition); + fPartitionList->AddPartition(partition); -DEBUG_ONLY( - printf("Visit(%p, %d)\n", partition, level); + printf("Visit(%p, %ld)\n", partition, level); dump_partition_info(partition); -); return false; // Don't stop yet! } Modified: haiku/trunk/src/preferences/drivesetup/MainWindow.h =================================================================== --- haiku/trunk/src/preferences/drivesetup/MainWindow.h 2007-11-07 17:09:05 UTC (rev 22852) +++ haiku/trunk/src/preferences/drivesetup/MainWindow.h 2007-11-07 20:10:19 UTC (rev 22853) @@ -1,52 +1,45 @@ -/*! \file MainWindow.h - \brief Header for the MainWindow class. - -*/ - +/* + * Copyright 2002-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. + */ #ifndef MAIN_WINDOW_H #define MAIN_WINDOW_H - #define MOUNT_MOUNT_ALL_MSG 'mall' - #define MOUNT_MOUNT_SELECTED_MSG 'msel' - #define UNMOUNT_UNMOUNT_SELECTED_MSG 'usel' - #define SETUP_FORMAT_MSG 'sfor' - #define SETUP_PARTITION_SELECTED_MSG 'spsl' - #define SETUP_INITIALIZE_MSG 'sini' - #define OPTIONS_EJECT_MSG 'oeje' - #define OPTIONS_SURFACE_TEST_MSG 'osut' - #define RESCAN_IDE_MSG 'ride' - #define RESCAN_SCSI_MSG 'rscs' - #include - #include +#include +#include - // Forward declarations - class PosSettings; - class BPartition; - class BDiskDevice; - class PartitionListView; - - /** - * The main window of the app. - * - * Sets up and displays everything you need for the app. - */ - class MainWindow : public BWindow - { - private: - PosSettings* fSettings; - BDiskDeviceRoster fDDRoster; - PartitionListView* fListView; - public: - MainWindow(BRect frame, PosSettings *fSettings); - - bool QuitRequested(); - void MessageReceived(BMessage *message); - - // These are public for visitor.... - void AddPartition(BPartition* partition, int32 level); - void AddDrive(BDiskDevice* device); - }; - -#endif +class PosSettings; +class BPartition; +class BDiskDevice; +class PartitionListView; + + +class MainWindow : public BWindow { +public: + MainWindow(BRect frame); + + // BWindow interface + virtual bool QuitRequested(); + virtual void MessageReceived(BMessage* message); + + // MainWindow + status_t StoreSettings(BMessage* archive) const; + status_t RestoreSettings(BMessage* archive); + + // These are public for visitor.... + void AddPartition(BPartition* partition, + int32 level); + void AddDrive(BDiskDevice* device); + +private: + void _ScanDrives(); + + + BDiskDeviceRoster fDDRoster; + PartitionListView* fListView; +}; + + +#endif // MAIN_WINDOW_H Modified: haiku/trunk/src/preferences/drivesetup/PartitionList.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/PartitionList.cpp 2007-11-07 17:09:05 UTC (rev 22852) +++ haiku/trunk/src/preferences/drivesetup/PartitionList.cpp 2007-11-07 20:10:19 UTC (rev 22853) @@ -1,15 +1,23 @@ +/* + * Copyright 2006-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. + * + * Authors: + * Ithamar R. Adema + */ #include "PartitionList.h" -#include -#include +#include +#include + extern const char* - SizeAsString(off_t size, char *string);; //FIXME: from MainWindow.cpp +SizeAsString(off_t size, char* string); //FIXME: from MainWindow.cpp PartitionListRow::PartitionListRow(BPartition* partition) - : Inherited(), - fPartitionID(partition->ID()) + : Inherited() + , fPartitionID(partition->ID()) { BPath path; char size[1024]; @@ -23,50 +31,47 @@ else SetField(new BStringField(""), 1); - if (partition->ContainsPartitioningSystem()) { - SetField(new BStringField(partition->ContentType()), 2); - } else { - SetField(new BStringField("n/a"), 2); - } +// if (partition->ContainsPartitioningSystem()) { +// SetField(new BStringField(partition->ContentType()), 2); +// } else { +// SetField(new BStringField("n/a"), 2); +// } - // For now, Partition type is always empty (as we do not care) - SetField(new BStringField(""), 3); - if (partition->ContainsFileSystem()) { - SetField(new BStringField(partition->ContentType()), 4); // Filesystem - SetField(new BStringField(partition->ContentName()), 5); // Volume Name + SetField(new BStringField(partition->ContentType()), 2); // Filesystem + SetField(new BStringField(partition->ContentName()), 3); // Volume Name } else { - SetField(new BStringField(""), 4); - SetField(new BStringField(""), 5); + SetField(new BStringField(""), 2); + SetField(new BStringField(""), 3); } if (partition->IsMounted() && partition->GetMountPoint(&path) == B_OK) { - SetField(new BStringField(path.Path()), 6); + SetField(new BStringField(path.Path()), 4); } else { - SetField(new BStringField(""), 6); + SetField(new BStringField(""), 4); } - SetField(new BStringField(SizeAsString(partition->Size(), size)), 7); + SetField(new BStringField(SizeAsString(partition->Size(), size)), 5); } + PartitionListView::PartitionListView(const BRect& frame) - : Inherited(frame, "storagelist", B_FOLLOW_ALL, 0, B_PLAIN_BORDER, true) + : Inherited(frame, "storagelist", B_FOLLOW_ALL, 0, B_NO_BORDER, true) { AddColumn(new BBitmapColumn("", 20, 20, 100, B_ALIGN_CENTER), 0); AddColumn(new BStringColumn("Device", 100, 50, 500, B_TRUNCATE_MIDDLE), 1); - AddColumn(new BStringColumn("Map style", 100, 50, 500, B_TRUNCATE_MIDDLE), 2); - AddColumn(new BStringColumn("Partition Type", 100, 50, 500, B_TRUNCATE_MIDDLE), 3); - AddColumn(new BStringColumn("Filesystem", 100, 50, 500, B_TRUNCATE_MIDDLE), 4); - AddColumn(new BStringColumn("Volume Name", 100, 50, 500, B_TRUNCATE_MIDDLE), 5); - AddColumn(new BStringColumn("Mounted At", 100, 50, 500, B_TRUNCATE_MIDDLE), 6); - AddColumn(new BStringColumn("Size", 100, 50, 500, B_TRUNCATE_END), 7); + AddColumn(new BStringColumn("Filesystem", 100, 50, 500, B_TRUNCATE_MIDDLE), 2); + AddColumn(new BStringColumn("Volume Name", 100, 50, 500, B_TRUNCATE_MIDDLE), 3); + AddColumn(new BStringColumn("Mounted At", 100, 50, 500, B_TRUNCATE_MIDDLE), 4); + AddColumn(new BStringColumn("Size", 100, 50, 500, B_TRUNCATE_END), 5); } + PartitionListRow* PartitionListView::FindRow(partition_id id) { - for (int32 idx=0; idx < CountRows(); idx++) { - PartitionListRow* item = dynamic_cast(RowAt(idx)); + for (int32 i = 0; i < CountRows(); i++) { + PartitionListRow* item = dynamic_cast(RowAt(i)); if (item != NULL && item->ID() == id) return item; } @@ -74,6 +79,7 @@ return NULL; } + PartitionListRow* PartitionListView::AddPartition(BPartition* partition) { @@ -81,7 +87,7 @@ PartitionListRow* partitionrow = NULL; // Forget about it if this partition is already in the listview - if ((partitionrow=FindRow(partition->ID())) != NULL) + if ((partitionrow = FindRow(partition->ID())) != NULL) return partitionrow; // Create the row for this partition @@ -89,6 +95,7 @@ // If this partition has a parent... if (partition->Parent() != NULL) { +printf("partition has parent\n"); // check if it is in the listview parent = FindRow(partition->Parent()->ID()); // If parent of this partition is not yet in the list @@ -97,6 +104,7 @@ // Now it is ok to add this partition under its parent AddRow(partitionrow, parent); } else { +printf("partition has NO parent\n"); // If this partition has no parent, add it in the 'root' AddRow(partitionrow); } Modified: haiku/trunk/src/preferences/drivesetup/PartitionList.h =================================================================== --- haiku/trunk/src/preferences/drivesetup/PartitionList.h 2007-11-07 17:09:05 UTC (rev 22852) +++ haiku/trunk/src/preferences/drivesetup/PartitionList.h 2007-11-07 20:10:19 UTC (rev 22853) @@ -1,34 +1,41 @@ +/* + * Copyright 2006-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. + */ #ifndef PARTITIONLIST_H #define PARTITIONLIST_H + class PartitionListRow; class PartitionListView; -#include -#include -// Forward declarations +#include +#include + + class BPartition; -class PartitionListRow : public BRow -{ + +class PartitionListRow : public BRow { typedef BRow Inherited; public: - PartitionListRow(BPartition* partition); + PartitionListRow(BPartition* partition); - partition_id ID() { return fPartitionID; } + partition_id ID() { return fPartitionID; } private: - partition_id fPartitionID; + partition_id fPartitionID; }; -class PartitionListView : public BColumnListView -{ + +class PartitionListView : public BColumnListView { typedef BColumnListView Inherited; public: - PartitionListView(const BRect& frame); + PartitionListView(const BRect& frame); - PartitionListRow* FindRow(partition_id id); - PartitionListRow* AddPartition(BPartition* partition); + PartitionListRow* FindRow(partition_id id); + PartitionListRow* AddPartition(BPartition* partition); }; -#endif /* PARTITIONLIST_H */ + +#endif // PARTITIONLIST_H Deleted: haiku/trunk/src/preferences/drivesetup/PosSettings.cpp Deleted: haiku/trunk/src/preferences/drivesetup/PosSettings.h Modified: haiku/trunk/src/preferences/drivesetup/main.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/main.cpp 2007-11-07 17:09:05 UTC (rev 22852) +++ haiku/trunk/src/preferences/drivesetup/main.cpp 2007-11-07 20:10:19 UTC (rev 22853) @@ -1,53 +1,138 @@ -/*! \file main.cpp - * \brief Code for the main class. - * - * This file contains the code for the main class. This class sets up all - * of the initial conditions for the app. +/* + * Copyright 2002-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. * -*/ - + * Authors: + * Erik Jaesler + * Ithamar R. Adema + * Stephan A?mus + */ +#include "main.h" #include "MainWindow.h" -#include "main.h" -#include "PosSettings.h" +#include +#include -/** - * Main method. - * - * Starts the whole thing. - */ -int main(int, char**){ +#include +#include +#include - /** - * An instance of the application. - */ - DriveSetup dsApp; - - dsApp.Run(); - - return(0); - + +int +main(int, char**) +{ + DriveSetup app; + app.Run(); + return 0; } -/* - * Constructor. - * - * Provides a contstructor for the application. - */ + +// #pragma mark - + + DriveSetup::DriveSetup() - : BApplication("application/x-vnd.MSM-DriveSetupPrefPanel") + : BApplication("application/x-vnd.Haiku-DriveSetup") + , fWindow(NULL) + , fSettings(0UL) { - - fSettings = new PosSettings(); - - /* - * The main interface window. - */ - MainWindow *Main = new MainWindow(fSettings->WindowPosition(), fSettings); - Main->Show(); } + DriveSetup::~DriveSetup() { - delete fSettings; } + + +void +DriveSetup::ReadyToRun() +{ + fWindow = new MainWindow(BRect(50, 50, 600, 450)); + _RestoreSettings(); + fWindow->Show(); +} + + +bool +DriveSetup::QuitRequested() +{ + _StoreSettings(); + + if (fWindow->Lock()) { + fWindow->Quit(); + fWindow = NULL; + } + + return true; +} + + +// #pragma mark - + + +status_t +DriveSetup::_StoreSettings() +{ + status_t ret = B_ERROR; + if (fWindow->Lock()) { + ret = fWindow->StoreSettings(&fSettings); + fWindow->Unlock(); + } + + if (ret < B_OK) + return ret; + + BFile file; + ret = _GetSettingsFile(file, true); + if (ret < B_OK) + return ret; + + return fSettings.Flatten(&file); +} + + +status_t +DriveSetup::_RestoreSettings() +{ + BFile file; + status_t ret = _GetSettingsFile(file, false); + + if (ret >= B_OK) + ret = fSettings.Unflatten(&file); + + if (ret >= B_OK) + ret = fWindow->RestoreSettings(&fSettings); + + return ret; +} + + +status_t +DriveSetup::_GetSettingsFile(BFile& file, bool forWriting) const +{ + BPath path; + status_t ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path); + if (ret != B_OK) { + fprintf(stderr, "failed to get user settings folder: %s\n", + strerror(ret)); + return ret; + } + + ret = path.Append("DriveSetup"); + if (ret != B_OK) { + fprintf(stderr, "failed to construct path: %s\n", strerror(ret)); + return ret; + } + + uint32 writeFlags = B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY; + uint32 readFlags = B_READ_ONLY; + + ret = file.SetTo(path.Path(), forWriting ? writeFlags : readFlags); + if (ret != B_OK) { + fprintf(stderr, "failed to init file: %s\n", strerror(ret)); + return ret; + } + + return B_OK; +} + + Modified: haiku/trunk/src/preferences/drivesetup/main.h =================================================================== --- haiku/trunk/src/preferences/drivesetup/main.h 2007-11-07 17:09:05 UTC (rev 22852) +++ haiku/trunk/src/preferences/drivesetup/main.h 2007-11-07 20:10:19 UTC (rev 22853) @@ -1,33 +1,37 @@ -/*! \file main.h - \brief Header file for the main class. - -*/ - [... truncated: 62 lines follow ...] From stippi at mail.berlios.de Wed Nov 7 21:11:58 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 7 Nov 2007 21:11:58 +0100 Subject: [Haiku-commits] r22854 - haiku/trunk/src/preferences/drivesetup Message-ID: <200711072011.lA7KBwwF002766@sheep.berlios.de> Author: stippi Date: 2007-11-07 21:11:56 +0100 (Wed, 07 Nov 2007) New Revision: 22854 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22854&view=rev Added: haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp haiku/trunk/src/preferences/drivesetup/DriveSetup.h Removed: haiku/trunk/src/preferences/drivesetup/main.cpp haiku/trunk/src/preferences/drivesetup/main.h Modified: haiku/trunk/src/preferences/drivesetup/Jamfile Log: * renamed main.cpp to DriveSetup.cpp Copied: haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp (from rev 22853, haiku/trunk/src/preferences/drivesetup/main.cpp) =================================================================== --- haiku/trunk/src/preferences/drivesetup/main.cpp 2007-11-07 20:10:19 UTC (rev 22853) +++ haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp 2007-11-07 20:11:56 UTC (rev 22854) @@ -0,0 +1,138 @@ +/* + * Copyright 2002-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. + * + * Authors: + * Erik Jaesler + * Ithamar R. Adema + * Stephan A?mus + */ +#include "DriveSetup.h" +#include "MainWindow.h" + +#include +#include + +#include +#include +#include + + +int +main(int, char**) +{ + DriveSetup app; + app.Run(); + return 0; +} + + +// #pragma mark - + + +DriveSetup::DriveSetup() + : BApplication("application/x-vnd.Haiku-DriveSetup") + , fWindow(NULL) + , fSettings(0UL) +{ +} + + +DriveSetup::~DriveSetup() +{ +} + + +void +DriveSetup::ReadyToRun() +{ + fWindow = new MainWindow(BRect(50, 50, 600, 450)); + _RestoreSettings(); + fWindow->Show(); +} + + +bool +DriveSetup::QuitRequested() +{ + _StoreSettings(); + + if (fWindow->Lock()) { + fWindow->Quit(); + fWindow = NULL; + } + + return true; +} + + +// #pragma mark - + + +status_t +DriveSetup::_StoreSettings() +{ + status_t ret = B_ERROR; + if (fWindow->Lock()) { + ret = fWindow->StoreSettings(&fSettings); + fWindow->Unlock(); + } + + if (ret < B_OK) + return ret; + + BFile file; + ret = _GetSettingsFile(file, true); + if (ret < B_OK) + return ret; + + return fSettings.Flatten(&file); +} + + +status_t +DriveSetup::_RestoreSettings() +{ + BFile file; + status_t ret = _GetSettingsFile(file, false); + + if (ret >= B_OK) + ret = fSettings.Unflatten(&file); + + if (ret >= B_OK) + ret = fWindow->RestoreSettings(&fSettings); + + return ret; +} + + +status_t +DriveSetup::_GetSettingsFile(BFile& file, bool forWriting) const +{ + BPath path; + status_t ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path); + if (ret != B_OK) { + fprintf(stderr, "failed to get user settings folder: %s\n", + strerror(ret)); + return ret; + } + + ret = path.Append("DriveSetup"); + if (ret != B_OK) { + fprintf(stderr, "failed to construct path: %s\n", strerror(ret)); + return ret; + } + + uint32 writeFlags = B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY; + uint32 readFlags = B_READ_ONLY; + + ret = file.SetTo(path.Path(), forWriting ? writeFlags : readFlags); + if (ret != B_OK) { + fprintf(stderr, "failed to init file: %s\n", strerror(ret)); + return ret; + } + + return B_OK; +} + + Copied: haiku/trunk/src/preferences/drivesetup/DriveSetup.h (from rev 22853, haiku/trunk/src/preferences/drivesetup/main.h) Modified: haiku/trunk/src/preferences/drivesetup/Jamfile =================================================================== --- haiku/trunk/src/preferences/drivesetup/Jamfile 2007-11-07 20:10:19 UTC (rev 22853) +++ haiku/trunk/src/preferences/drivesetup/Jamfile 2007-11-07 20:11:56 UTC (rev 22854) @@ -7,7 +7,7 @@ AddResources DriveSetup : DriveSetup.rdef ; Preference DriveSetup : - main.cpp + DriveSetup.cpp MainWindow.cpp PartitionList.cpp : Deleted: haiku/trunk/src/preferences/drivesetup/main.cpp Deleted: haiku/trunk/src/preferences/drivesetup/main.h From stippi at mail.berlios.de Wed Nov 7 23:16:06 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 7 Nov 2007 23:16:06 +0100 Subject: [Haiku-commits] r22855 - haiku/trunk/src/preferences/drivesetup Message-ID: <200711072216.lA7MG6Bx009139@sheep.berlios.de> Author: stippi Date: 2007-11-07 23:16:06 +0100 (Wed, 07 Nov 2007) New Revision: 22855 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22855&view=rev Modified: haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp haiku/trunk/src/preferences/drivesetup/DriveSetup.h haiku/trunk/src/preferences/drivesetup/MainWindow.cpp haiku/trunk/src/preferences/drivesetup/MainWindow.h Log: * fix saving settings (don't let the window quit by itself) * add partition creation menu items * filter filesystems by their support for "initializing" Modified: haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp 2007-11-07 20:11:56 UTC (rev 22854) +++ haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp 2007-11-07 22:16:06 UTC (rev 22855) @@ -78,15 +78,23 @@ fWindow->Unlock(); } - if (ret < B_OK) + if (ret < B_OK) { + fprintf(stderr, "failed to store settings: %s\n", strerror(ret)); return ret; + } BFile file; ret = _GetSettingsFile(file, true); if (ret < B_OK) return ret; - return fSettings.Flatten(&file); + ret = fSettings.Flatten(&file); + if (ret < B_OK) { + fprintf(stderr, "failed to flatten settings: %s\n", strerror(ret)); + return ret; + } + + return B_OK; } @@ -95,14 +103,23 @@ { BFile file; status_t ret = _GetSettingsFile(file, false); + if (ret < B_OK) + return ret; - if (ret >= B_OK) - ret = fSettings.Unflatten(&file); + ret = fSettings.Unflatten(&file); + if (ret < B_OK) { + fprintf(stderr, "failed to unflatten settings: %s\n", strerror(ret)); + return ret; + } +fSettings.PrintToStream(); - if (ret >= B_OK) - ret = fWindow->RestoreSettings(&fSettings); + ret = fWindow->RestoreSettings(&fSettings); + if (ret < B_OK) { + fprintf(stderr, "failed to restore settings: %s\n", strerror(ret)); + return ret; + } - return ret; + return B_OK; } Modified: haiku/trunk/src/preferences/drivesetup/DriveSetup.h =================================================================== --- haiku/trunk/src/preferences/drivesetup/DriveSetup.h 2007-11-07 20:11:56 UTC (rev 22854) +++ haiku/trunk/src/preferences/drivesetup/DriveSetup.h 2007-11-07 22:16:06 UTC (rev 22855) @@ -2,8 +2,8 @@ * Copyright 2002-2007 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT license. */ -#ifndef MAIN_H -#define MAIN_H +#ifndef DRIVE_SETUP_H +#define DRIVE_SETUP_H #include @@ -34,4 +34,4 @@ }; -#endif // MAIN_H +#endif // DRIVE_SETUP_H Modified: haiku/trunk/src/preferences/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/MainWindow.cpp 2007-11-07 20:11:56 UTC (rev 22854) +++ haiku/trunk/src/preferences/drivesetup/MainWindow.cpp 2007-11-07 22:16:06 UTC (rev 22855) @@ -95,6 +95,9 @@ MSG_MOUNT = 'mnts', MSG_UNMOUNT = 'unmt', MSG_FORMAT = 'frmt', + MSG_CREATE_PRIMARY = 'crpr', + MSG_CREATE_EXTENDED = 'crex', + MSG_CREATE_LOGICAL = 'crlg', MSG_INITIALIZE = 'init', MSG_EJECT = 'ejct', MSG_SURFACE_TEST = 'sfct', @@ -120,8 +123,10 @@ // Parition menu menu = new BMenu("Partition"); - BMenu* initMenu = new BMenu("Initialize"); - menu->AddItem(initMenu); + BMenu* createMenu = new BMenu("Create"); + menu->AddItem(createMenu); + fInitMenu = new BMenu("Initialize"); + menu->AddItem(fInitMenu); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Mount", new BMessage(MSG_MOUNT), 'M')); menu->AddItem(new BMenuItem("Unmount", new BMessage(MSG_UNMOUNT), 'U')); @@ -132,23 +137,20 @@ AddChild(rootMenu); + createMenu->AddItem(new BMenuItem("Primary", + new BMessage(MSG_CREATE_PRIMARY))); + createMenu->AddItem(new BMenuItem("Extended", + new BMessage(MSG_CREATE_EXTENDED))); + createMenu->AddItem(new BMenuItem("Logical", + new BMessage(MSG_CREATE_LOGICAL))); + BRect r(Bounds()); r.top = rootMenu->Frame().bottom + 1; fListView = new PartitionListView(r); AddChild(fListView); // Populate the Initialiaze menu with the available file systems - BDiskSystem diskSystem; - fDDRoster.RewindDiskSystems(); - while(fDDRoster.GetNextDiskSystem(&diskSystem) == B_OK) { - if (diskSystem.IsFileSystem()) { - BMessage* message = new BMessage(MSG_INITIALIZE); - message->AddString("format", diskSystem.Name()); - BString label = diskSystem.PrettyName(); - label << B_UTF8_ELLIPSIS; - initMenu->AddItem(new BMenuItem(label.String(), message)); - } - } + _ScanFileSystems(); // Visit all disks in the system and show their contents _ScanDrives(); @@ -162,31 +164,37 @@ case MSG_MOUNT_ALL: printf("MSG_MOUNT_ALL\n"); break; - case MSG_MOUNT: printf("MSG_MOUNT\n"); break; - case MSG_UNMOUNT: printf("MSG_UNMOUNT\n"); break; - + case MSG_FORMAT: printf("MSG_FORMAT\n"); break; - + + case MSG_CREATE_PRIMARY: + printf("MSG_CREATE_PRIMARY\n"); + break; + case MSG_CREATE_EXTENDED: + printf("MSG_CREATE_EXTENDED\n"); + break; + case MSG_CREATE_LOGICAL: + printf("MSG_CREATE_LOGICAL\n"); + break; + case MSG_INITIALIZE: printf("MSG_INITIALIZE\n"); break; - + case MSG_EJECT: printf("MSG_EJECT\n"); break; - case MSG_SURFACE_TEST: printf("MSG_SURFACE_TEST\n"); break; - case MSG_RESCAN: _ScanDrives(); break; @@ -203,7 +211,8 @@ { // TODO: ask about any unsaved changes be_app->PostMessage(B_QUIT_REQUESTED); - return true; + Hide(); + return false; } @@ -249,6 +258,26 @@ } +void +MainWindow::_ScanFileSystems() +{ + while (BMenuItem* item = fInitMenu->RemoveItem(0L)) + delete item; + + BDiskSystem diskSystem; + fDDRoster.RewindDiskSystems(); + while(fDDRoster.GetNextDiskSystem(&diskSystem) == B_OK) { + if (diskSystem.IsFileSystem() && diskSystem.SupportsInitializing()) { + BMessage* message = new BMessage(MSG_INITIALIZE); + message->AddString("format", diskSystem.Name()); + BString label = diskSystem.PrettyName(); + label << B_UTF8_ELLIPSIS; + fInitMenu->AddItem(new BMenuItem(label.String(), message)); + } + } +} + + // #pragma mark - DriveVisitor Modified: haiku/trunk/src/preferences/drivesetup/MainWindow.h =================================================================== --- haiku/trunk/src/preferences/drivesetup/MainWindow.h 2007-11-07 20:11:56 UTC (rev 22854) +++ haiku/trunk/src/preferences/drivesetup/MainWindow.h 2007-11-07 22:16:06 UTC (rev 22855) @@ -10,9 +10,9 @@ #include -class PosSettings; +class BDiskDevice; class BPartition; -class BDiskDevice; +class BMenu; class PartitionListView; @@ -35,10 +35,13 @@ private: void _ScanDrives(); + void _ScanFileSystems(); BDiskDeviceRoster fDDRoster; PartitionListView* fListView; + + BMenu* fInitMenu; }; From axeld at mail.berlios.de Wed Nov 7 23:26:55 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 7 Nov 2007 23:26:55 +0100 Subject: [Haiku-commits] r22856 - haiku/trunk/src/system/kernel/vm Message-ID: <200711072226.lA7MQt3A009796@sheep.berlios.de> Author: axeld Date: 2007-11-07 23:26:55 +0100 (Wed, 07 Nov 2007) New Revision: 22856 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22856&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: Added the sModifiedTemporaryPages counter to the output of the "page_stats" KDL command. Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-11-07 22:16:06 UTC (rev 22855) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-11-07 22:26:55 UTC (rev 22856) @@ -577,8 +577,8 @@ sFreePageQueue.count); kprintf("clear queue: %p, count = %ld\n", &sClearPageQueue, sClearPageQueue.count); - kprintf("modified queue: %p, count = %ld\n", &sModifiedPageQueue, - sModifiedPageQueue.count); + kprintf("modified queue: %p, count = %ld (%ld temporary)\n", + &sModifiedPageQueue, sModifiedPageQueue.count, sModifiedTemporaryPages); kprintf("active queue: %p, count = %ld\n", &sActivePageQueue, sActivePageQueue.count); kprintf("inactive queue: %p, count = %ld\n", &sInactivePageQueue, From axeld at mail.berlios.de Thu Nov 8 10:30:58 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 Nov 2007 10:30:58 +0100 Subject: [Haiku-commits] r22857 - haiku/trunk/src/system/kernel/cache Message-ID: <200711080930.lA89UwfX022571@sheep.berlios.de> Author: axeld Date: 2007-11-08 10:30:58 +0100 (Thu, 08 Nov 2007) New Revision: 22857 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22857&view=rev Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp Log: The file cache now completely bypasses the cache for writes equal or larger than 64KB. Reads should probably get a similar logic, at least if memory is tight. Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-11-07 22:26:55 UTC (rev 22856) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-11-08 09:30:58 UTC (rev 22857) @@ -78,7 +78,11 @@ bool last_access_was_write; }; +typedef status_t (*cache_func)(file_cache_ref *ref, off_t offset, + size_t numBytes, int32 pageOffset, addr_t buffer, size_t bufferSize, + size_t lastReservedPages, size_t reservePages); + static struct cache_module_info *sCacheModule; @@ -853,10 +857,32 @@ static status_t -satisfy_cache_io(file_cache_ref *ref, off_t offset, addr_t buffer, - int32 &pageOffset, size_t bytesLeft, size_t &reservePages, +write_to_file(file_cache_ref *ref, off_t offset, size_t numBytes, + int32 pageOffset, addr_t buffer, size_t bufferSize, + size_t lastReservedPages, size_t reservePages) +{ + iovec vec; + vec.iov_base = (void *)buffer; + vec.iov_len = bufferSize; + + mutex_unlock(&ref->cache->lock); + vm_page_unreserve_pages(lastReservedPages); + + status_t status = pages_io(ref, offset, &vec, 1, &numBytes, true); + if (status == B_OK) + reserve_pages(ref, reservePages, true); + + mutex_lock(&ref->cache->lock); + + return status; +} + + +static inline status_t +satisfy_cache_io(file_cache_ref *ref, cache_func function, off_t offset, + addr_t buffer, int32 &pageOffset, size_t bytesLeft, size_t &reservePages, off_t &lastOffset, addr_t &lastBuffer, int32 &lastPageOffset, - size_t &lastLeft, size_t &lastReservedPages, bool doWrite) + size_t &lastLeft, size_t &lastReservedPages) { if (lastBuffer == buffer) return B_OK; @@ -865,14 +891,8 @@ reservePages = min_c(MAX_IO_VECS, (lastLeft - requestSize + B_PAGE_SIZE - 1) >> PAGE_SHIFT); - status_t status; - if (doWrite) { - status = write_to_cache(ref, lastOffset, requestSize, lastPageOffset, - lastBuffer, requestSize, lastReservedPages, reservePages); - } else { - status = read_into_cache(ref, lastOffset, requestSize, lastPageOffset, - lastBuffer, requestSize, lastReservedPages, reservePages); - } + status_t status = function(ref, lastOffset, requestSize, lastPageOffset, + lastBuffer, requestSize, lastReservedPages, reservePages); if (status == B_OK) { lastReservedPages = reservePages; lastBuffer = buffer; @@ -917,6 +937,15 @@ if (size == 0) return B_OK; + cache_func function; + if (doWrite) { + if (size >= 65536) + function = write_to_file; + else + function = write_to_cache; + } else + function = read_into_cache; + // "offset" and "lastOffset" are always aligned to B_PAGE_SIZE, // the "last*" variables always point to the end of the last // satisfied request part @@ -941,9 +970,9 @@ // in the near future, we need to satisfy the request of the pages // we didn't get yet (to make sure no one else interferes in the // mean time). - status_t status = satisfy_cache_io(ref, offset, buffer, pageOffset, - bytesLeft, reservePages, lastOffset, lastBuffer, lastPageOffset, - lastLeft, lastReservedPages, doWrite); + status_t status = satisfy_cache_io(ref, function, offset, buffer, + pageOffset, bytesLeft, reservePages, lastOffset, lastBuffer, + lastPageOffset, lastLeft, lastReservedPages); if (status != B_OK) return status; @@ -1009,9 +1038,9 @@ offset += B_PAGE_SIZE; if (buffer - lastBuffer + lastPageOffset >= kMaxChunkSize) { - status_t status = satisfy_cache_io(ref, offset, buffer, pageOffset, - bytesLeft, reservePages, lastOffset, lastBuffer, lastPageOffset, - lastLeft, lastReservedPages, doWrite); + status_t status = satisfy_cache_io(ref, function, offset, buffer, + pageOffset, bytesLeft, reservePages, lastOffset, lastBuffer, + lastPageOffset, lastLeft, lastReservedPages); if (status != B_OK) return status; } @@ -1019,16 +1048,8 @@ // fill the last remaining bytes of the request (either write or read) - status_t status; - if (doWrite) { - status = write_to_cache(ref, lastOffset, lastLeft, lastPageOffset, - lastBuffer, lastLeft, lastReservedPages, 0); - } else { - status = read_into_cache(ref, lastOffset, lastLeft, lastPageOffset, - lastBuffer, lastLeft, lastReservedPages, 0); - } - - return status; + return function(ref, lastOffset, lastLeft, lastPageOffset, + lastBuffer, lastLeft, lastReservedPages, 0); } From ingo_weinhold at gmx.de Thu Nov 8 13:27:40 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 08 Nov 2007 13:27:40 +0100 Subject: [Haiku-commits] r22857 - haiku/trunk/src/system/kernel/cache In-Reply-To: <200711080930.lA89UwfX022571@sheep.berlios.de> References: <200711080930.lA89UwfX022571@sheep.berlios.de> Message-ID: <20071108132740.605.1@graete.1194523090.fake> On 2007-11-08 at 10:30:58 [+0100], axeld at BerliOS wrote: > Author: axeld > Date: 2007-11-08 10:30:58 +0100 (Thu, 08 Nov 2007) > New Revision: 22857 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22857&view=rev > > Modified: > haiku/trunk/src/system/kernel/cache/file_cache.cpp > Log: > The file cache now completely bypasses the cache for writes equal or larger > than 64KB. Reads should probably get a similar logic, at least if memory is > tight. I can see why this makes sense in low memory situations, but it doesn't quite sound like a good general strategy. E.g. on Linux creating and filling the Haiku image seems to happen completely in the cache. On Haiku the initial "dd" would go directly to disk now, copying the files depending on the buffer size of the copy program. CU, Ingo From bga at bug-br.org.br Thu Nov 8 13:44:59 2007 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Thu, 08 Nov 2007 10:44:59 -0200 Subject: [Haiku-commits] r22857 - haiku/trunk/src/system/kernel/cache In-Reply-To: <20071108132740.605.1@graete.1194523090.fake> References: <200711080930.lA89UwfX022571@sheep.berlios.de> <20071108132740.605.1@graete.1194523090.fake> Message-ID: <473304CB.5080909@bug-br.org.br> Ingo Weinhold wrote: > I can see why this makes sense in low memory situations, but it doesn't quite > sound like a good general strategy. E.g. on Linux creating and filling the > Haiku image seems to happen completely in the cache. On Haiku the initial > "dd" would go directly to disk now, copying the files depending on the buffer > size of the copy program. I am pretty sure you know that but, in BeOS, this strategy of not caching any data transfers bigger than 64 Kb was also used. Of course it made more sense in BeOS as huge data transfers would completely fill the cache really quick and then all we had was an extra overhead of copying data to the cache first. Right now we have a better cache implementation and maybe the 64 Kb threshold is too small but I still think it makes sense to have a limit on transfers. It is also very easy to avoid this at all, just make your buffer size be 65535 bytes and it will still use the cache. -Bruno From stefano.ceccherini at gmail.com Thu Nov 8 13:47:25 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 8 Nov 2007 13:47:25 +0100 Subject: [Haiku-commits] r22850 - haiku/trunk/src/kits/interface In-Reply-To: <200711071424.lA7EO9Rx028996@sheep.berlios.de> References: <200711071424.lA7EO9Rx028996@sheep.berlios.de> Message-ID: <894b9700711080447s7f415dc1n3a3049070f224d49@mail.gmail.com> 2007/11/7, axeld at BerliOS : > Author: axeld > Date: 2007-11-07 15:24:09 +0100 (Wed, 07 Nov 2007) > New Revision: 22850 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22850&view=rev > > Modified: > haiku/trunk/src/kits/interface/Menu.cpp > Log: > * Fixed _ComputeColumnLayout() optimization introduced in r22658: it actually > never worked correctly for any case which was very visible in Tracker (and > especially so if you had "sorting apps" turned on). > * Removed superfluous white space at the end of lines. That means bug #532 is fixed now ? From axeld at mail.berlios.de Thu Nov 8 14:45:06 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 Nov 2007 14:45:06 +0100 Subject: [Haiku-commits] r22858 - haiku/trunk/src/system/kernel/cache Message-ID: <200711081345.lA8Dj6wj026680@sheep.berlios.de> Author: axeld Date: 2007-11-08 14:45:04 +0100 (Thu, 08 Nov 2007) New Revision: 22858 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22858&view=rev Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp Log: * read_into_cache() and write_to_cache() both did not compute the number of needed pages correctly, and would also not read/write enough in case the offset didn't start at 0 resulting in undetected short reads/writes. It's amazing how many bugs can be hidden in a few lines of code. * Fixed a bug that might have been the cause for bug #1601: when the last part of the write did not end on a page boundary, the last page had to be read first, but that was done from the wrong offset. Also, if only parts of that page could be read (because the file size didn't span over the whole page) the remaining parts needed to be cleared. * The cache_funcs were always called with the same value for numBytes and bufferSize so I've eliminated the former. * Large reads now also bypass the cache in case of low memory, large writes now also only bypass the cache in that case, following Ingo's suggestion. * Fixed compilation with debugging turned on. Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-11-08 09:30:58 UTC (rev 22857) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-11-08 13:45:04 UTC (rev 22858) @@ -41,6 +41,7 @@ // must be smaller than MAX_FILE_IO_VECS // ToDo: find out how much of these are typically used +#define BYPASS_IO_SIZE 65536 #define LAST_ACCESSES 3 struct file_extent { @@ -79,7 +80,7 @@ }; typedef status_t (*cache_func)(file_cache_ref *ref, off_t offset, - size_t numBytes, int32 pageOffset, addr_t buffer, size_t bufferSize, + int32 pageOffset, addr_t buffer, size_t bufferSize, size_t lastReservedPages, size_t reservePages); @@ -610,13 +611,12 @@ operation it will unlock the cache, though. */ static status_t -read_into_cache(file_cache_ref *ref, off_t offset, size_t numBytes, - int32 pageOffset, addr_t buffer, size_t bufferSize, - size_t lastReservedPages, size_t reservePages) +read_into_cache(file_cache_ref *ref, off_t offset, int32 pageOffset, + addr_t buffer, size_t bufferSize, size_t lastReservedPages, + size_t reservePages) { - TRACE(("read_into_cache(offset = %Ld, size = %lu, pageOffset = %ld, buffer " - "= %#lx, bufferSize = %lu\n", offset, numBytes, pageOffset, buffer, - bufferSize)); + TRACE(("read_into_cache(offset = %Ld, pageOffset = %ld, buffer = %#lx, " + "bufferSize = %lu\n", offset, pageOffset, buffer, bufferSize)); vm_cache *cache = ref->cache; @@ -625,6 +625,7 @@ iovec vecs[MAX_IO_VECS]; int32 vecCount = 0; + size_t numBytes = PAGE_ALIGN(pageOffset + bufferSize); vm_page *pages[MAX_IO_VECS]; ConditionVariable busyConditions[MAX_IO_VECS]; int32 pageIndex = 0; @@ -716,20 +717,43 @@ } +static status_t +read_from_file(file_cache_ref *ref, off_t offset, int32 pageOffset, + addr_t buffer, size_t bufferSize, size_t lastReservedPages, + size_t reservePages) +{ + iovec vec; + vec.iov_base = (void *)buffer; + vec.iov_len = bufferSize; + + mutex_unlock(&ref->cache->lock); + vm_page_unreserve_pages(lastReservedPages); + + status_t status = pages_io(ref, offset, &vec, 1, &bufferSize, false); + if (status == B_OK) + reserve_pages(ref, reservePages, false); + + mutex_lock(&ref->cache->lock); + + return status; +} + + /*! Like read_into_cache() but writes data into the cache. To preserve data consistency, it might also read pages into the cache, though, if only a partial page gets written. The same restrictions apply. */ static status_t -write_to_cache(file_cache_ref *ref, off_t offset, size_t numBytes, - int32 pageOffset, addr_t buffer, size_t bufferSize, - size_t lastReservedPages, size_t reservePages) +write_to_cache(file_cache_ref *ref, off_t offset, int32 pageOffset, + addr_t buffer, size_t bufferSize, size_t lastReservedPages, + size_t reservePages) { // TODO: We're using way too much stack! Rather allocate a sufficiently // large chunk on the heap. iovec vecs[MAX_IO_VECS]; int32 vecCount = 0; + size_t numBytes = PAGE_ALIGN(pageOffset + bufferSize); vm_page *pages[MAX_IO_VECS]; int32 pageIndex = 0; status_t status = B_OK; @@ -786,17 +810,22 @@ // the space in the page after this write action needs to be cleaned memset((void *)(last + lastPageOffset), 0, B_PAGE_SIZE - lastPageOffset); - } else if (vecCount > 1) { + } else { // the end of this write does not happen on a page boundary, so we // need to fetch the last page before we can update it iovec readVec = { (void *)last, B_PAGE_SIZE }; size_t bytesRead = B_PAGE_SIZE; - status = pages_io(ref, offset + numBytes - B_PAGE_SIZE, &readVec, 1, - &bytesRead, false); + status = pages_io(ref, PAGE_ALIGN(offset + pageOffset + bufferSize) + - B_PAGE_SIZE, &readVec, 1, &bytesRead, false); // ToDo: handle errors for real! if (status < B_OK) panic("pages_io() failed: %s!\n", strerror(status)); + + if (bytesRead < B_PAGE_SIZE) { + // the space beyond the file size needs to be cleaned + memset((void *)(last + bytesRead), 0, B_PAGE_SIZE - bytesRead); + } } } @@ -857,9 +886,9 @@ static status_t -write_to_file(file_cache_ref *ref, off_t offset, size_t numBytes, - int32 pageOffset, addr_t buffer, size_t bufferSize, - size_t lastReservedPages, size_t reservePages) +write_to_file(file_cache_ref *ref, off_t offset, int32 pageOffset, + addr_t buffer, size_t bufferSize, size_t lastReservedPages, + size_t reservePages) { iovec vec; vec.iov_base = (void *)buffer; @@ -868,7 +897,7 @@ mutex_unlock(&ref->cache->lock); vm_page_unreserve_pages(lastReservedPages); - status_t status = pages_io(ref, offset, &vec, 1, &numBytes, true); + status_t status = pages_io(ref, offset, &vec, 1, &bufferSize, true); if (status == B_OK) reserve_pages(ref, reservePages, true); @@ -891,8 +920,8 @@ reservePages = min_c(MAX_IO_VECS, (lastLeft - requestSize + B_PAGE_SIZE - 1) >> PAGE_SHIFT); - status_t status = function(ref, lastOffset, requestSize, lastPageOffset, - lastBuffer, requestSize, lastReservedPages, reservePages); + status_t status = function(ref, lastOffset, lastPageOffset, lastBuffer, + requestSize, lastReservedPages, reservePages); if (status == B_OK) { lastReservedPages = reservePages; lastBuffer = buffer; @@ -939,12 +968,18 @@ cache_func function; if (doWrite) { - if (size >= 65536) + // in low memory situations, we bypass the cache beyond a + // certain I/O size + if (size >= BYPASS_IO_SIZE && vm_low_memory_state() != B_NO_LOW_MEMORY) function = write_to_file; else function = write_to_cache; - } else - function = read_into_cache; + } else { + if (size >= BYPASS_IO_SIZE && vm_low_memory_state() != B_NO_LOW_MEMORY) + function = read_from_file; + else + function = read_into_cache; + } // "offset" and "lastOffset" are always aligned to B_PAGE_SIZE, // the "last*" variables always point to the end of the last @@ -1048,8 +1083,8 @@ // fill the last remaining bytes of the request (either write or read) - return function(ref, lastOffset, lastLeft, lastPageOffset, - lastBuffer, lastLeft, lastReservedPages, 0); + return function(ref, lastOffset, lastPageOffset, lastBuffer, lastLeft, + lastReservedPages, 0); } @@ -1340,7 +1375,7 @@ { file_cache_ref *ref = (file_cache_ref *)_cacheRef; - TRACE(("file_cache_set_size(ref = %p, size = %Ld)\n", ref, size)); + TRACE(("file_cache_set_size(ref = %p, size = %Ld)\n", ref, newSize)); if (ref == NULL) return B_OK; From axeld at pinc-software.de Thu Nov 8 14:50:11 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 08 Nov 2007 14:50:11 +0100 CET Subject: [Haiku-commits] r22857 - haiku/trunk/src/system/kernel/cache In-Reply-To: <20071108132740.605.1@graete.1194523090.fake> Message-ID: <17712138763-BeMail@zon> Ingo Weinhold wrote: > On 2007-11-08 at 10:30:58 [+0100], axeld at BerliOS < > axeld at mail.berlios.de> > wrote: > > Log: > > The file cache now completely bypasses the cache for writes equal > > or larger > > than 64KB. Reads should probably get a similar logic, at least if > > memory is > > tight. > I can see why this makes sense in low memory situations, but it > doesn't quite > sound like a good general strategy. E.g. on Linux creating and > filling the > Haiku image seems to happen completely in the cache. On Haiku the > initial > "dd" would go directly to disk now, copying the files depending on > the buffer > size of the copy program. Right, that's a good example. For most other cases I could came up with, you'll rarely need the bytes you've just written. Anyway, I've followed your suggestion and made it depending on the amount of free memory. Also, bypassing reading from the cache now follows the same logic. Bye, Axel. From axeld at mail.berlios.de Thu Nov 8 15:44:14 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 Nov 2007 15:44:14 +0100 Subject: [Haiku-commits] r22859 - haiku/trunk/src/system/kernel/cache Message-ID: <200711081444.lA8EiEqk001159@sheep.berlios.de> Author: axeld Date: 2007-11-08 15:44:13 +0100 (Thu, 08 Nov 2007) New Revision: 22859 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22859&view=rev Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp Log: The reserved pages computation used the same broken logic as read_into_cache() and write_to_cache() before, IOW the cache could reserve too few pages. Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-11-08 13:45:04 UTC (rev 22858) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-11-08 14:44:13 UTC (rev 22859) @@ -917,8 +917,8 @@ return B_OK; size_t requestSize = buffer - lastBuffer; - reservePages = min_c(MAX_IO_VECS, - (lastLeft - requestSize + B_PAGE_SIZE - 1) >> PAGE_SHIFT); + reservePages = min_c(MAX_IO_VECS, (lastLeft - requestSize + + lastPageOffset + B_PAGE_SIZE - 1) >> PAGE_SHIFT); status_t status = function(ref, lastOffset, lastPageOffset, lastBuffer, requestSize, lastReservedPages, reservePages); @@ -990,8 +990,8 @@ int32 lastPageOffset = pageOffset; addr_t lastBuffer = buffer; off_t lastOffset = offset; - size_t lastReservedPages = min_c(MAX_IO_VECS, - (bytesLeft + B_PAGE_SIZE - 1) >> PAGE_SHIFT); + size_t lastReservedPages = min_c(MAX_IO_VECS, (pageOffset + bytesLeft + + B_PAGE_SIZE - 1) >> PAGE_SHIFT); size_t reservePages = 0; reserve_pages(ref, lastReservedPages, doWrite); From axeld at mail.berlios.de Thu Nov 8 16:24:28 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 Nov 2007 16:24:28 +0100 Subject: [Haiku-commits] r22860 - haiku/trunk/src/system/kernel/vm Message-ID: <200711081524.lA8FOSDs004311@sheep.berlios.de> Author: axeld Date: 2007-11-08 16:24:27 +0100 (Thu, 08 Nov 2007) New Revision: 22860 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22860&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_daemons.cpp Log: No wonder the page writer sucked so many cycles: the PageCacheLocker constructor did not propagate the "dontWait" argument, letting the page writer never wait for its pages. Modified: haiku/trunk/src/system/kernel/vm/vm_daemons.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_daemons.cpp 2007-11-08 14:44:13 UTC (rev 22859) +++ haiku/trunk/src/system/kernel/vm/vm_daemons.cpp 2007-11-08 15:24:27 UTC (rev 22860) @@ -31,7 +31,7 @@ : fPage(NULL) { - Lock(page); + Lock(page, dontWait); } From marcusoverhagen at arcor.de Thu Nov 8 14:30:25 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Thu, 8 Nov 2007 14:30:25 +0100 (CET) Subject: [Haiku-commits] r22857 - haiku/trunk/src/system/kernel/cache Message-ID: <19593091.1194528625806.JavaMail.ngmail@webmail12> Ingo Weinhold wrote: > On 2007-11-08 at 10:30:58 [+0100], axeld at BerliOS > > wrote: > > Author: axeld > > Date: 2007-11-08 10:30:58 +0100 (Thu, 08 Nov 2007) > > New Revision: 22857 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22857&view=rev > > > > Modified: > > haiku/trunk/src/system/kernel/cache/file_cache.cpp > > Log: > > The file cache now completely bypasses the cache for writes equal or larger > > than 64KB. Reads should probably get a similar logic, at least if memory is > > tight. > > I can see why this makes sense in low memory situations, but it doesn't quite > sound like a good general strategy. E.g. on Linux creating and filling the > Haiku image seems to happen completely in the cache. On Haiku the initial > "dd" would go directly to disk now, copying the files depending on the buffer > size of the copy program. Hi Ingo, hi Axel, Axel I know BeOS did the same, but I also don't think this strategy is a good idea. I think the cache bypass can severly degrade performance on current systems. For example, my newest machine has 2 GB of ram, with 1,5 GB usually unused. This memory should be used by the file cache, until it is exhausted. At that point, the file cache should discard unused data, or flush it to disk (and it should also flush periodically or when the system is idle). When creating a 256 MB image file, probably with writes as large a 1 MB, and reading it again and copying the data into another file, I would wish it to happen completely in the cache. The build process on Linux of dd'ing the image file when creating the vmdk file seems to benefit much from this. regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From geist at foobox.com Thu Nov 8 20:29:34 2007 From: geist at foobox.com (Travis Geiselbrecht) Date: Thu, 8 Nov 2007 11:29:34 -0800 Subject: [Haiku-commits] r22857 - haiku/trunk/src/system/kernel/cache In-Reply-To: <19593091.1194528625806.JavaMail.ngmail@webmail12> References: <19593091.1194528625806.JavaMail.ngmail@webmail12> Message-ID: On Nov 8, 2007, at 5:30 AM, Marcus Overhagen wrote: > Ingo Weinhold wrote: > >> On 2007-11-08 at 10:30:58 [+0100], axeld at BerliOS >> >> >> wrote: >>> Author: axeld >>> Date: 2007-11-08 10:30:58 +0100 (Thu, 08 Nov 2007) >>> New Revision: 22857 >>> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22857&view=rev >>> >>> Modified: >>> haiku/trunk/src/system/kernel/cache/file_cache.cpp >>> Log: >>> The file cache now completely bypasses the cache for writes equal >>> or larger >>> than 64KB. Reads should probably get a similar logic, at least if >>> memory is >>> tight. >> >> I can see why this makes sense in low memory situations, but it >> doesn't quite >> sound like a good general strategy. E.g. on Linux creating and >> filling the >> Haiku image seems to happen completely in the cache. On Haiku the >> initial >> "dd" would go directly to disk now, copying the files depending on >> the buffer >> size of the copy program. > > Hi Ingo, hi Axel, > > Axel I know BeOS did the same, but I also don't think this strategy > is a good idea. > > I think the cache bypass can severly degrade performance on current > systems. > For example, my newest machine has 2 GB of ram, with 1,5 GB usually > unused. > This memory should be used by the file cache, until it is > exhausted. At that point, > the file cache should discard unused data, or flush it to disk (and > it should also > flush periodically or when the system is idle). > > When creating a 256 MB image file, probably with writes as large a > 1 MB, > and reading it again and copying the data into another file, I > would wish it > to happen completely in the cache. > > The build process on Linux of dd'ing the image file when creating > the vmdk file > seems to benefit much from this. I believe the main point of bypassing the cache was for large reads and especially writes the fastest way with the lowest latency to get the blocks out is to bypass the cache, go directly to disk. It was definitely a dbg thing, and I believe it came from a similar strategy that Irix was using at the time, and as far as I know still does. The idea is that if you're writing large chunks of data, you're probably streaming it as part of a multimedia stream or a high speed log, and caching it doesn't make any real difference, except evicting other things from the cache, and potentially being less efficient with it's write back caching. I believe Irix took it a bit farther and would actually let the IO subsystem dedicate a certain percentage of the disk(s) to any given stream, guaranteeing that it would succeed. I think OSX has something similar to this now as well. In BeOS it was I guess sort of the equivalent of having a dont-cache- me flag on the file. If you wanted it to try to bypass, you use block sizes >=64k, otherwise you're guaranteed to not bypass. Whether or not that behavior is worth bringing forward I dunno. I personally would tend to think that having an explicit ioctl or open flag that specifies that you're streaming and don't need cache would work better. Would be cleaner to me. Travis From axeld at pinc-software.de Thu Nov 8 20:58:10 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 08 Nov 2007 20:58:10 +0100 CET Subject: [Haiku-commits] r22857 - haiku/trunk/src/system/kernel/cache In-Reply-To: Message-ID: <39791472829-BeMail@zon> Travis Geiselbrecht wrote: [...] Thanks for the overview! > In BeOS it was I guess sort of the equivalent of having a dont-cache- > > me flag on the file. If you wanted it to try to bypass, you use block > sizes >=64k, otherwise you're guaranteed to not bypass. Whether or > not that behavior is worth bringing forward I dunno. I personally > would tend to think that having an explicit ioctl or open flag that > specifies that you're streaming and don't need cache would work > better. Would be cleaner to me. That flag even exists already (O_NOCACHE/O_DIRECT), it's just not yet respected :-) Bye, Axel. From korli at mail.berlios.de Thu Nov 8 21:24:09 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 8 Nov 2007 21:24:09 +0100 Subject: [Haiku-commits] r22861 - haiku/trunk/build/jam Message-ID: <200711082024.lA8KO9CM011964@sheep.berlios.de> Author: korli Date: 2007-11-08 21:24:08 +0100 (Thu, 08 Nov 2007) New Revision: 22861 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22861&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: 3com, rtl8139 and via_rhine are only buildable for x86 Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-08 15:24:27 UTC (rev 22860) +++ haiku/trunk/build/jam/HaikuImage 2007-11-08 20:24:08 UTC (rev 22861) @@ -115,8 +115,8 @@ $(X86_ONLY)s3savage $(X86_ONLY)via vesa #$(X86_ONLY)vmware ; BEOS_ADD_ONS_DRIVERS_MIDI = emuxki ; -BEOS_ADD_ONS_DRIVERS_NET = 3com etherpci ipro1000 rtl8139 rtl8169 sis900 - via_rhine wb840 net_stack #vlance +BEOS_ADD_ONS_DRIVERS_NET = $(X86_ONLY)3com etherpci ipro1000 $(X86_ONLY)rtl8139 rtl8169 sis900 + $(X86_ONLY)via_rhine wb840 net_stack #vlance $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; #BEOS_ADD_ONS_DRIVERS_ACPI = $(X86_ONLY)acpi_button ; From axeld at pinc-software.de Thu Nov 8 23:12:43 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 08 Nov 2007 23:12:43 +0100 CET Subject: [Haiku-commits] r22850 - haiku/trunk/src/kits/interface In-Reply-To: <894b9700711080447s7f415dc1n3a3049070f224d49@mail.gmail.com> Message-ID: <47864621903-BeMail@zon> "Stefano Ceccherini" wrote: > 2007/11/7, axeld at BerliOS : > > Log: > > * Fixed _ComputeColumnLayout() optimization introduced in r22658: > > it actually > > never worked correctly for any case which was very visible in > > Tracker (and > > especially so if you had "sorting apps" turned on). > That means bug #532 is fixed now ? I don't see how this could have helped here. It only optimizes the behind-the-scenes layout, it does not optimize the rendering. Before, it layouted incorrectly, leaving to cut off items, and unexpected free space between items (in case you had "sorting apps" turned on). In any case, I can still see more redraws than there have to be, dunno if it's comparable to R5 now (a lot has happened since #532 anyway) :) Bye, Axel. From marcusoverhagen at mail.berlios.de Fri Nov 9 16:49:55 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Fri, 9 Nov 2007 16:49:55 +0100 Subject: [Haiku-commits] r22862 - haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112 Message-ID: <200711091549.lA9FntVP026095@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-09 16:49:55 +0100 (Fri, 09 Nov 2007) New Revision: 22862 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22862&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c Log: added more device IDs Modified: haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c 2007-11-08 20:24:08 UTC (rev 22861) +++ haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c 2007-11-09 15:49:55 UTC (rev 22862) @@ -141,8 +141,13 @@ #define ID(v, d) (((v) << 16) | (d)) switch (ID(vendorID, deviceID)) { + case ID(0x1095, 0x0240): case ID(0x1095, 0x3112): case ID(0x1095, 0x3114): + case ID(0x1095, 0x3512): + case ID(0x1002, 0x436e): // ATI + case ID(0x1002, 0x4379): // ATI + case ID(0x1002, 0x437a): // ATI break; default: return 0.0f; @@ -162,6 +167,7 @@ device_node_handle controller_node; uint32 mmioBase; uint16 deviceID; + uint16 vendorID; uint8 interruptNumber; int asicIndex; int channelIndex; @@ -174,15 +180,21 @@ return B_ERROR; deviceID = pci->read_pci_config(device, PCI_device_id, 2); + vendorID = pci->read_pci_config(device, PCI_vendor_id, 2); interruptNumber = pci->read_pci_config(device, PCI_interrupt_line, 1); mmioBase = pci->read_pci_config(device, PCI_base_registers + 20, 4) & PCI_address_io_mask; - switch (deviceID) { - case 0x3112: + switch (ID(vendorID, deviceID)) { + case ID(0x1095, 0x0240): + case ID(0x1095, 0x3112): + case ID(0x1095, 0x3512): + case ID(0x1002, 0x436e): // ATI + case ID(0x1002, 0x4379): // ATI + case ID(0x1002, 0x437a): // ATI asicIndex = ASIC_SI3112; break; - case 0x3114: + case ID(0x1095, 0x3114): asicIndex = ASIC_SI3114; break; default: From marcusoverhagen at mail.berlios.de Fri Nov 9 17:36:59 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Fri, 9 Nov 2007 17:36:59 +0100 Subject: [Haiku-commits] r22863 - haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112 Message-ID: <200711091636.lA9Gaxo8029522@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-09 17:36:59 +0100 (Fri, 09 Nov 2007) New Revision: 22863 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22863&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c Log: disabled most debug output, this makes the driver useable Modified: haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c 2007-11-09 15:49:55 UTC (rev 22862) +++ haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c 2007-11-09 16:36:59 UTC (rev 22863) @@ -13,8 +13,9 @@ #include #include -#define TRACE(a...) dprintf("si-3112: " a) -#define FLOW(a...) dprintf("si-3112: " a) +#define TRACE(x...) dprintf("si-3112: " x) +//#define FLOW(x...) dprintf("si-3112: " x) +#define FLOW(x...) #define DRIVER_PRETTY_NAME "Silicon Image SATA" @@ -628,7 +629,7 @@ { channel_data *channel = channelCookie; - FLOW("device_control_write %x\n", val); + FLOW("device_control_write 0x%x\n", val); if (channel->lost) return B_ERROR; @@ -803,15 +804,15 @@ if ((status & IDE_BM_STATUS_INTERRUPT) == 0) { if ((status & IDE_BM_STATUS_ACTIVE) != 0) { - FLOW("dma_finish: transfer aborted\n"); + TRACE("dma_finish: transfer aborted\n"); return B_ERROR; } else { - FLOW("dma_finish: buffer underrun\n"); + TRACE("dma_finish: buffer underrun\n"); return B_DEV_DATA_UNDERRUN; } } else { if ((status & IDE_BM_STATUS_ACTIVE) != 0) { - FLOW("dma_finish: buffer too large\n"); + TRACE("dma_finish: buffer too large\n"); return B_DEV_DATA_OVERRUN; } else { FLOW("dma_finish leave\n"); From axeld at mail.berlios.de Fri Nov 9 18:09:54 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 9 Nov 2007 18:09:54 +0100 Subject: [Haiku-commits] r22864 - haiku/trunk/src/system/kernel/cache Message-ID: <200711091709.lA9H9sd5031699@sheep.berlios.de> Author: axeld Date: 2007-11-09 18:09:54 +0100 (Fri, 09 Nov 2007) New Revision: 22864 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22864&view=rev Added: haiku/trunk/src/system/kernel/cache/file_map.cpp Log: Extracted file_map API for later use. Added: haiku/trunk/src/system/kernel/cache/file_map.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_map.cpp 2007-11-09 16:36:59 UTC (rev 22863) +++ haiku/trunk/src/system/kernel/cache/file_map.cpp 2007-11-09 17:09:54 UTC (rev 22864) @@ -0,0 +1,308 @@ +/* + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//#define TRACE_FILE_MAP +#ifdef TRACE_FILE_MAP +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + +#define CACHED_FILE_EXTENTS 2 + // must be smaller than MAX_FILE_IO_VECS + // ToDo: find out how much of these are typically used + +struct file_extent { + off_t offset; + file_io_vec disk; +}; + +struct file_map { + file_map(); + ~file_map(); + + file_extent *operator[](uint32 index); + file_extent *ExtentAt(uint32 index); + status_t Add(file_io_vec *vecs, size_t vecCount, off_t &lastOffset); + void Free(); + + union { + file_extent direct[CACHED_FILE_EXTENTS]; + file_extent *array; + }; + size_t count; + struct vnode *vnode; +}; + + +file_map::file_map() +{ + array = NULL; + count = 0; +} + + +file_map::~file_map() +{ + Free(); +} + + +file_extent * +file_map::operator[](uint32 index) +{ + return ExtentAt(index); +} + + +file_extent * +file_map::ExtentAt(uint32 index) +{ + if (index >= count) + return NULL; + + if (count > CACHED_FILE_EXTENTS) + return &array[index]; + + return &direct[index]; +} + + +status_t +file_map::Add(file_io_vec *vecs, size_t vecCount, off_t &lastOffset) +{ + TRACE(("file_map::Add(vecCount = %ld)\n", vecCount)); + + off_t offset = 0; + + if (vecCount <= CACHED_FILE_EXTENTS && count == 0) { + // just use the reserved area in the file_cache_ref structure + } else { + // TODO: once we can invalidate only parts of the file map, + // we might need to copy the previously cached file extends + // from the direct range + file_extent *newMap = (file_extent *)realloc(array, + (count + vecCount) * sizeof(file_extent)); + if (newMap == NULL) + return B_NO_MEMORY; + + array = newMap; + + if (count != 0) { + file_extent *extent = ExtentAt(count - 1); + offset = extent->offset + extent->disk.length; + } + } + + int32 start = count; + count += vecCount; + + for (uint32 i = 0; i < vecCount; i++) { + file_extent *extent = ExtentAt(start + i); + + extent->offset = offset; + extent->disk = vecs[i]; + + offset += extent->disk.length; + } + +#ifdef TRACE_FILE_CACHE + for (uint32 i = 0; i < count; i++) { + file_extent *extent = ExtentAt(i); + dprintf("[%ld] extend offset %Ld, disk offset %Ld, length %Ld\n", + i, extent->offset, extent->disk.offset, extent->disk.length); + } +#endif + + lastOffset = offset; + return B_OK; +} + + +void +file_map::Free() +{ + if (count > CACHED_FILE_EXTENTS) + free(array); + + array = NULL; + count = 0; +} + + +// #pragma mark - + + +static file_extent * +find_file_extent(file_map &map, off_t offset, uint32 *_index) +{ + // TODO: do binary search + + for (uint32 index = 0; index < map.count; index++) { + file_extent *extent = map[index]; + + if (extent->offset <= offset + && extent->offset + extent->disk.length > offset) { + if (_index) + *_index = index; + return extent; + } + } + + return NULL; +} + + +// #pragma mark - public FS API + + +extern "C" void * +file_map_create(dev_t mountID, ino_t vnodeID) +{ + TRACE(("file_map_create(mountID = %ld, vnodeID = %Ld)\n", mountID, vnodeID)); + + file_map *map = new file_map; + if (map == NULL) + return NULL; + + // Get the vnode for the object + // (note, this does not grab a reference to the node) + if (vfs_lookup_vnode(mountID, vnodeID, &map->vnode) != B_OK) { + delete map; + return NULL; + } + + return map; +} + + +extern "C" void +file_map_delete(void *_map) +{ + file_map *map = (file_map *)_map; + if (map == NULL) + return; + + TRACE(("file_map_delete(map = %p)\n", map)); + delete map; +} + + +extern "C" void +file_map_invalidate(void *_map, off_t offset, off_t size) +{ + // TODO: honour offset/size parameters + file_map *map = (file_map *)_map; + map->Free(); +} + + +extern "C" status_t +file_map_translate(void *_map, off_t offset, size_t size, file_io_vec *vecs, + size_t *_count) +{ + file_map &map = *(file_map *)_map; + size_t maxVecs = *_count; + status_t status = B_OK; + + if (map.count == 0) { + // we don't yet have the map of this file, so let's grab it + // (ordered by offset, so that we can do a binary search on them) + size_t vecCount = maxVecs; + off_t mapOffset = 0; + + while (true) { + status = vfs_get_file_map(map.vnode, mapOffset, ~0UL, vecs, + &vecCount); + if (status < B_OK && status != B_BUFFER_OVERFLOW) + return status; + + status_t addStatus = map.Add(vecs, vecCount, mapOffset); + if (addStatus != B_OK) { + // only clobber the status in case of failure + status = addStatus; + } + + if (status != B_BUFFER_OVERFLOW) + break; + + // when we are here, the map has been stored in the array, and + // the array size was still too small to cover the whole file + vecCount = maxVecs; + } + } + + if (status != B_OK) { + // We must invalidate the (part of the) map we already + // have, as we cannot know if it's complete or not + map.Free(); + return status; + } + + // We now have cached the map of this file, we now need to + // translate it for the requested access. + + uint32 index; + file_extent *fileExtent = find_file_extent(map, offset, &index); + if (fileExtent == NULL) { + // access outside file bounds? But that's not our problem + *_count = 0; + return B_OK; + } + + offset -= fileExtent->offset; + vecs[0].offset = fileExtent->disk.offset + offset; + vecs[0].length = fileExtent->disk.length - offset; + + if (vecs[0].length >= size || index >= map.count - 1) { + *_count = 1; + return B_OK; + } + + // copy the rest of the vecs + + size -= vecs[0].length; + + for (index = 1; index < map.count;) { + fileExtent++; + + vecs[index] = fileExtent->disk; + index++; + + if (size <= fileExtent->disk.length) + break; + + if (index >= maxVecs) { + *_count = index; + return B_BUFFER_OVERFLOW; + } + + size -= fileExtent->disk.length; + } + + *_count = index; + return B_OK; +} + From bonefish at mail.berlios.de Sat Nov 10 00:23:46 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 00:23:46 +0100 Subject: [Haiku-commits] r22865 - in haiku/trunk: headers/posix src/system/libroot/posix/signal Message-ID: <200711092323.lA9NNkbD015206@sheep.berlios.de> Author: bonefish Date: 2007-11-10 00:23:46 +0100 (Sat, 10 Nov 2007) New Revision: 22865 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22865&view=rev Added: haiku/trunk/src/system/libroot/posix/signal/sigrelse.cpp Modified: haiku/trunk/headers/posix/signal.h haiku/trunk/src/system/libroot/posix/signal/Jamfile Log: Patch by Vasilis Kaoutsis: Implemented sigrelse(). Modified: haiku/trunk/headers/posix/signal.h =================================================================== --- haiku/trunk/headers/posix/signal.h 2007-11-09 17:09:54 UTC (rev 22864) +++ haiku/trunk/headers/posix/signal.h 2007-11-09 23:23:46 UTC (rev 22865) @@ -165,6 +165,7 @@ int sigismember(const sigset_t *set, int signo); int sigignore(int signo); int sighold(int signo); +int sigrelse(int signo); const char *strsignal(int sig); Modified: haiku/trunk/src/system/libroot/posix/signal/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/signal/Jamfile 2007-11-09 17:09:54 UTC (rev 22864) +++ haiku/trunk/src/system/libroot/posix/signal/Jamfile 2007-11-09 23:23:46 UTC (rev 22865) @@ -15,6 +15,7 @@ signal.c sigpending.c sigprocmask.c + sigrelse.cpp sigset.c sigsuspend.c strsignal.c Added: haiku/trunk/src/system/libroot/posix/signal/sigrelse.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/signal/sigrelse.cpp 2007-11-09 17:09:54 UTC (rev 22864) +++ haiku/trunk/src/system/libroot/posix/signal/sigrelse.cpp 2007-11-09 23:23:46 UTC (rev 22865) @@ -0,0 +1,22 @@ +/* + * Copyright 2007, Vasilis Kaoutsis, kaoutsis at sch.gr + * Distributed under the terms of the MIT License. + */ + + +#include + + +int +sigrelse(int signal) +{ + // make an empty set + // and add the signal + sigset_t tempSignalSet; + sigemptyset(&tempSignalSet); + if (sigaddset(&tempSignalSet, signal) == -1) + return -1; + + // remove the signal from the calling process' signal mask + return sigprocmask(SIG_UNBLOCK, &tempSignalSet, NULL); +} From bonefish at mail.berlios.de Sat Nov 10 00:27:30 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 00:27:30 +0100 Subject: [Haiku-commits] r22866 - in haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces: . sigrelse Message-ID: <200711092327.lA9NRU4q015460@sheep.berlios.de> Author: bonefish Date: 2007-11-10 00:27:30 +0100 (Sat, 10 Nov 2007) New Revision: 22866 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22866&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/3-core-buildonly.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/Jamfile Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile Log: Patch by Vasilis Kaoutsis: Added posixtestsuite tests for sigrelse(). Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-11-09 23:23:46 UTC (rev 22865) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-11-09 23:27:30 UTC (rev 22866) @@ -10,5 +10,6 @@ SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sighold ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigignore ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigprocmask ; +SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigrelse ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces signal ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigsuspend ; Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/1-1.c 2007-11-09 23:23:46 UTC (rev 22865) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/1-1.c 2007-11-09 23:27:30 UTC (rev 22866) @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Steps: + 1. Set up a handler for signal SIGABRT, such that it is called if +signal is ever raised. + 2. Call sighold on that SIGABRT. + 3. Raise a SIGABRT and verify that the signal handler was not called. +Otherwise, the test exits with unresolved results. + 4. Call sigrelse on SIGABRT. + 5. Verify that the handler gets called this time. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include "posixtest.h" + +int handler_called = 0; + +void handler(int signo) +{ + handler_called = 1; +} + +int main() +{ + struct sigaction act; + + act.sa_handler = handler; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + if (sigaction(SIGABRT, &act, 0) == -1) { + perror("Unexpected error while attempting to setup test " + "pre-conditions"); + return PTS_UNRESOLVED; + } + + sighold(SIGABRT); + + if (raise(SIGABRT) == -1) { + perror("Unexpected error while attempting to setup test " + "pre-conditions"); + return PTS_UNRESOLVED; + } + + if (handler_called) { + printf("UNRESOLVED. possible problem in sigrelse\n"); + return PTS_UNRESOLVED; + } + + if (sigrelse(SIGABRT) == -1) { + printf("UNRESOLVED. possible problem in sigrelse\n"); + return PTS_UNRESOLVED; + } + + sleep(1); + + if (handler_called) { + printf("sigrelse(): Test PASSED: SIGABRT successfully removed from signal mask\n"); + return PTS_PASS; + } + printf("FAIL\n"); + return PTS_FAIL; +} + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/2-1.c 2007-11-09 23:23:46 UTC (rev 22865) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/2-1.c 2007-11-09 23:27:30 UTC (rev 22866) @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Simply, if sigrelse returns a 0 here, test passes. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include "posixtest.h" + +int main() +{ + + if ((int)sigrelse(SIGABRT) != 0) { + perror("sigrelse failed -- returned -- test aborted"); + return PTS_UNRESOLVED; + } + printf("sigrelse(): Test PASSED\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/3-core-buildonly.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/3-core-buildonly.c 2007-11-09 23:23:46 UTC (rev 22865) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/3-core-buildonly.c 2007-11-09 23:27:30 UTC (rev 22866) @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Testing passing an invalid signals to sigrelse(). + After sighold is called on an invalid signal, sigrelse() should +return -1 and set errno to EINVAL + + The invalid signal passed to sigrelse() depends on the argument +passed to this program. + There are currently 4 invalid signals. + */ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include +#include +#include "posixtest.h" + +jmp_buf sig11_recover; +void sig11_handler(int sig); + +int main(int argc, char *argv[]) +{ + int signo, TEST_RETURN; + struct sigaction sa, osa; + + if (argc < 2) { + printf("Usage: %s [1|2|3|4]\n", argv[0]); + return PTS_UNRESOLVED; + } + + /* + Various error conditions + */ + switch (argv[1][0]) { + case '1': + signo=-1; + break; + case '2': + signo=-10000; + break; + case '3': + signo=INT32_MIN+1; + break; + case '4': + signo=INT32_MIN; + break; + default: + printf("Usage: %s [1|2|3|4]\n", argv[0]); + return PTS_UNRESOLVED; + } + + /* special sig11 case */ + sa.sa_handler = &sig11_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + + sigaction(SIGSEGV, NULL, &osa); + sigaction(SIGSEGV, &sa, NULL); + + if (setjmp(sig11_recover)) { + errno = EINVAL; + TEST_RETURN=-2; + } else { + TEST_RETURN=sigrelse(signo); + } + sigaction(SIGSEGV, &osa, NULL); + + if (TEST_RETURN == -1) { + if (EINVAL == errno) { + printf ("errno set to EINVAL\n"); + printf("sigrelse(): Test PASSED\n"); + return PTS_PASS; + } else { + printf ("errno not set to EINVAL\n"); + return PTS_FAIL; + } + } + if (TEST_RETURN == -2) { + printf ("test received SIGSEGV\n"); + return PTS_UNRESOLVED; + } + + printf("sigrelse did not return -1\n"); + return PTS_FAIL; + +} + +/****************************************************************** + * sig11_handler() - our segfault recover hack + ******************************************************************/ +void +sig11_handler(int sig) +{ + longjmp(sig11_recover, 1); +} + + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/Jamfile 2007-11-09 23:23:46 UTC (rev 22865) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/Jamfile 2007-11-09 23:27:30 UTC (rev 22866) @@ -0,0 +1,7 @@ +SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigrelse ; + +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ; + +SimpleTest sigrelse_1-1 : 1-1.c ; +SimpleTest sigrelse_2-1 : 2-1.c ; +SimpleTest sigrelse_3-core-buildonly : 3-core-buildonly.c ; From bonefish at mail.berlios.de Sat Nov 10 00:36:38 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 00:36:38 +0100 Subject: [Haiku-commits] r22867 - haiku/trunk/src/tests/system/libroot/posix/posixtestsuite Message-ID: <200711092336.lA9NacAq001802@sheep.berlios.de> Author: bonefish Date: 2007-11-10 00:36:37 +0100 (Sat, 10 Nov 2007) New Revision: 22867 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22867&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh Log: Patch by Vasilis Kaoutsis: Shell script to run the POSIX conformance tests. Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh 2007-11-09 23:27:30 UTC (rev 22866) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh 2007-11-09 23:36:37 UTC (rev 22867) @@ -0,0 +1,124 @@ +#!/bin/sh + +usage() +{ + cat < References: <200711092323.lA9NNkbD015206@sheep.berlios.de> Message-ID: 2007/11/10, bonefish at BerliOS : > haiku/trunk/src/system/libroot/posix/signal/sigrelse.cpp Why the need for a cpp file (seems every cpp file is from Vasilis in signal/) ? Bye, J?r?me From ingo_weinhold at gmx.de Sat Nov 10 14:23:20 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 10 Nov 2007 14:23:20 +0100 Subject: [Haiku-commits] r22865 - in haiku/trunk: headers/posix src/system/libroot/posix/signal In-Reply-To: References: <200711092323.lA9NNkbD015206@sheep.berlios.de> Message-ID: <20071110142320.520.1@graete.1194699459.fake> On 2007-11-10 at 13:54:13 [+0100], J?r?me Duval wrote: > 2007/11/10, bonefish at BerliOS : > > haiku/trunk/src/system/libroot/posix/signal/sigrelse.cpp > > Why the need for a cpp file (seems every cpp file is from Vasilis in > signal/) ? C++ is simply the better language, and the compiler issues better warnings. CU, Ingo From korli at users.berlios.de Sat Nov 10 15:00:34 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Sat, 10 Nov 2007 15:00:34 +0100 Subject: [Haiku-commits] r22865 - in haiku/trunk: headers/posix src/system/libroot/posix/signal In-Reply-To: <20071110142320.520.1@graete.1194699459.fake> References: <200711092323.lA9NNkbD015206@sheep.berlios.de> <20071110142320.520.1@graete.1194699459.fake> Message-ID: 2007/11/10, Ingo Weinhold : > > On 2007-11-10 at 13:54:13 [+0100], J?r?me Duval > wrote: > > 2007/11/10, bonefish at BerliOS : > > > haiku/trunk/src/system/libroot/posix/signal/sigrelse.cpp > > > > Why the need for a cpp file (seems every cpp file is from Vasilis in > > signal/) ? > > C++ is simply the better language, and the compiler issues better warnings. > Then just move every C file to C++ for consistency ... Bye, J?r?me From marcusoverhagen at mail.berlios.de Sat Nov 10 16:51:41 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 10 Nov 2007 16:51:41 +0100 Subject: [Haiku-commits] r22868 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200711101551.lAAFpfYX009821@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-10 16:51:40 +0100 (Sat, 10 Nov 2007) New Revision: 22868 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22868&view=rev Added: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.h Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/Jamfile haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp Log: New PCI quirk/fixup support. The Jmicron AHCI controller has a mode that combines IDE and AHCI functionality into a single PCI device at function 0. This happens when the controller is set in the BIOS to "basic" or "IDE" mode (but not in "RAID" or "AHCI" mode). To avoid needing two drivers to handle a single PCI device, we switch to the multifunction (split device) AHCI mode. This will set PCI device at function 0 to AHCI, and PCI device at function 1 to IDE controller. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/Jamfile 2007-11-09 23:36:37 UTC (rev 22867) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/Jamfile 2007-11-10 15:51:40 UTC (rev 22868) @@ -5,6 +5,7 @@ KernelAddon pci : pci.cpp + pci_fixup.cpp pci_info.cpp pci_module.c pci_device.c Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2007-11-09 23:36:37 UTC (rev 22867) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2007-11-10 15:51:40 UTC (rev 22868) @@ -13,6 +13,7 @@ #include #include "util/kernel_cpp.h" +#include "pci_fixup.h" #include "pci_priv.h" #include "pci.h" @@ -328,12 +329,8 @@ ppnext = &bus->next; } - bool bus_enumeration = true; - - if (bus_enumeration) { - for (int i = 0; i < fDomainCount; i++) { - EnumerateBus(i, 0); - } + for (int i = 0; i < fDomainCount; i++) { + EnumerateBus(i, 0); } if (fRootBus) { @@ -511,6 +508,8 @@ if (device_id == 0xffff) continue; + pci_fixup_device(this, domain, bus, dev, func); + uint8 base_class = ReadPciConfig(domain, bus, dev, func, PCI_class_base, 1); uint8 sub_class = ReadPciConfig(domain, bus, dev, func, PCI_class_sub, 1); if (base_class != PCI_bridge || sub_class != PCI_pci) Added: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-11-09 23:36:37 UTC (rev 22867) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-11-10 15:51:40 UTC (rev 22868) @@ -0,0 +1,70 @@ +/* + * Copyright 2007, Marcus Overhagen. All rights reserved. + * + * Distributed under the terms of the MIT License. + */ + +#include "pci.h" +#include "pci_fixup.h" + +#include + +/* The Jmicron AHCI controller has a mode that combines IDE and AHCI functionality + * into a single PCI device at function 0. This happens when the controller is set + * in the BIOS to "basic" or "IDE" mode (but not in "RAID" or "AHCI" mode). + * To avoid needing two drivers to handle a single PCI device, we switch to the + * multifunction (split device) AHCI mode. This will set PCI device at function 0 + * to AHCI, and PCI device at function 1 to IDE controller. + */ +static void +jmicron_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, uint16 deviceId) +{ + if (deviceId != 0x2360 && deviceId != 0x2361 && deviceId != 0x2362 && deviceId != 0x2363 && deviceId != 0x2366) + return; + + dprintf("jmicron_fixup_ahci: domain %u, bus %u, device %u, function %u, deviceId 0x%04x\n", + domain, bus, device, function, deviceId); + + if (function == 0) { + dprintf("0x40: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x40, 4)); + dprintf("0xdc: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4)); + uint32 val = pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4); + if (!(val & (1 << 30))) { + dprintf("jmicron_fixup_ahci: enabling split device mode\n"); + val &= ~(1 << 24); + val |= (1 << 25) | (1 << 30); + pci->WritePciConfig(domain, bus, device, function, 0xdc, 4, val); + val = pci->ReadPciConfig(domain, bus, device, function, 0x40, 4); + val &= ~(1 << 16); + val |= (1 << 1) | (1 << 17) | (1 << 22); + pci->WritePciConfig(domain, bus, device, function, 0x40, 4, val); + } + dprintf("0x40: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x40, 4)); + dprintf("0xdc: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4)); + } +} + + +static void +intel_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, uint16 deviceId) +{ +} + + +void +pci_fixup_device(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function) +{ + uint16 vendorId = pci->ReadPciConfig(domain, bus, device, function, PCI_vendor_id, 2); + uint16 deviceId = pci->ReadPciConfig(domain, bus, device, function, PCI_device_id, 2); + + switch (vendorId) { + case 0x197b: + jmicron_fixup_ahci(pci, domain, bus, device, function, deviceId); + break; + + case 0x8086: + intel_fixup_ahci(pci, domain, bus, device, function, deviceId); + break; + } +} + Added: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.h 2007-11-09 23:36:37 UTC (rev 22867) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.h 2007-11-10 15:51:40 UTC (rev 22868) @@ -0,0 +1,14 @@ +/* + * Copyright 2007, Marcus Overhagen. All rights reserved. + * + * Distributed under the terms of the MIT License. + */ +#ifndef _PCI_FIXUP_H +#define _PCI_FIXUP_H + +class PCI; + +void +pci_fixup_device(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function); + +#endif From ingo_weinhold at gmx.de Sat Nov 10 17:11:49 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 10 Nov 2007 17:11:49 +0100 Subject: [Haiku-commits] r22865 - in haiku/trunk: headers/posix src/system/libroot/posix/signal In-Reply-To: References: <200711092323.lA9NNkbD015206@sheep.berlios.de> <20071110142320.520.1@graete.1194699459.fake> Message-ID: <20071110171149.26650.2@graete.1194699459.fake> On 2007-11-10 at 15:00:34 [+0100], J?r?me Duval wrote: > 2007/11/10, Ingo Weinhold : > > > > On 2007-11-10 at 13:54:13 [+0100], J?r?me Duval > > wrote: > > > 2007/11/10, bonefish at BerliOS : > > > > haiku/trunk/src/system/libroot/posix/signal/sigrelse.cpp > > > > > > Why the need for a cpp file (seems every cpp file is from Vasilis in > > > signal/) ? > > > > C++ is simply the better language, and the compiler issues better > > warnings. > > Then just move every C file to C++ for consistency ... If you want to do that, feel free. I see very little benefit for investing time in this endeavor, though. As opposed to migrating the kernel sources to C++, BTW, since that would allow us to clean up the private kernel headers at last. CU, Ingo From marcusoverhagen at mail.berlios.de Sat Nov 10 17:25:50 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 10 Nov 2007 17:25:50 +0100 Subject: [Haiku-commits] r22869 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200711101625.lAAGPoFS011636@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-10 17:25:49 +0100 (Sat, 10 Nov 2007) New Revision: 22869 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22869&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp Log: Enable SATA ports 5 and 6 on Intel ICH8 and ICH9 based systems, and possibly enable ports 7 and 8 in the future. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-11-10 15:51:40 UTC (rev 22868) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-11-10 16:25:49 UTC (rev 22869) @@ -251,9 +251,13 @@ if (fPCIVendorID == PCI_VENDOR_INTEL) { // Intel PCS?Port Control and Status - // In AHCI enabled systems, bits[3:0] must always be set - gPCI->write_pci_config(fPCIDevice, 0x92, 2, - 0xf | gPCI->read_pci_config(fPCIDevice, 0x92, 2)); + // SATA port enable bits must be set + int portCount = 1 + ((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); + if (portCount > 8) + panic("Intel AHCI: too many SATA ports! Please report at http://dev.haiku-os.org"); + uint16 pcs = gPCI->read_pci_config(fPCIDevice, 0x92, 2); + pcs |= (0xff >> (8 - portCount)); + gPCI->write_pci_config(fPCIDevice, 0x92, 2, pcs); } return B_OK; } From marcusoverhagen at mail.berlios.de Sat Nov 10 17:49:40 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 10 Nov 2007 17:49:40 +0100 Subject: [Haiku-commits] r22870 - haiku/trunk/src/add-ons/kernel/bus_managers/scsi Message-ID: <200711101649.lAAGnemg012596@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-10 17:49:39 +0100 (Sat, 10 Nov 2007) New Revision: 22870 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22870&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/devices.c Log: Warn when lun is not 0. Might be needed for SATA PM support. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/devices.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/devices.c 2007-11-10 16:25:49 UTC (rev 22869) +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/devices.c 2007-11-10 16:49:39 UTC (rev 22870) @@ -117,6 +117,9 @@ // ask for restrictions bus->interface->get_restrictions(bus->sim_cookie, target_id, &is_atapi, &manual_autosense, &max_blocks); + if (target_lun != 0) + dprintf("WARNING: SCSI target %d lun %d getting restrictions without lun\n", + target_id, target_lun); // find maximum transfer blocks // set default value to max (need something like ULONG_MAX here) From revol at free.fr Sat Nov 10 18:16:54 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sat, 10 Nov 2007 18:16:54 +0100 CET Subject: [Haiku-commits] r22865 - in haiku/trunk: headers/posix src/system/libroot/posix/signal In-Reply-To: <20071110171149.26650.2@graete.1194699459.fake> Message-ID: <3204752342-BeMail@laptop> > > On 2007-11-10 at 15:00:34 [+0100], J?r?me Duval < > korli at users.berlios.de> > wrote: > > 2007/11/10, Ingo Weinhold : > > > > > > On 2007-11-10 at 13:54:13 [+0100], J?r?me Duval < > > > korli at users.berlios.de> > > > wrote: > > > > 2007/11/10, bonefish at BerliOS : > > > > > haiku/trunk/src/system/libroot/posix/signal/sigrelse.cpp > > > > > > > > Why the need for a cpp file (seems every cpp file is from > > > > Vasilis in > > > > signal/) ? > > > > > > C++ is simply the better language, and the compiler issues better > > > warnings. > > > > Then just move every C file to C++ for consistency ... > > If you want to do that, feel free. I see very little benefit for > investing > time in this endeavor, though. As opposed to migrating the kernel > sources > to C++, BTW, since that would allow us to clean up the private kernel > headers at last. Ugh :p Fran?ois. From bonefish at mail.berlios.de Sat Nov 10 18:33:48 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 18:33:48 +0100 Subject: [Haiku-commits] r22871 - in haiku/trunk/src: add-ons/kernel/file_systems/bfs tools/bfs_shell Message-ID: <200711101733.lAAHXmeY024950@sheep.berlios.de> Author: bonefish Date: 2007-11-10 18:33:47 +0100 (Sat, 10 Nov 2007) New Revision: 22871 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22871&view=rev Added: haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_disk_system.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_disk_system.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Jamfile haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp haiku/trunk/src/tools/bfs_shell/Jamfile Log: * Moved helper function to check initialization parameters to separate source file. Added function to check the volume name. * Removed bfs_validate_initialize(). This functionality is to be implemented in a userland add-on. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Jamfile 2007-11-10 16:49:39 UTC (rev 22870) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Jamfile 2007-11-10 17:33:47 UTC (rev 22871) @@ -28,6 +28,7 @@ UsePrivateHeaders [ FDirName storage ] ; KernelAddon bfs : + bfs_disk_system.cpp BlockAllocator.cpp BPlusTree.cpp kernel_cpp.cpp Added: haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_disk_system.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_disk_system.cpp 2007-11-10 16:49:39 UTC (rev 22870) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_disk_system.cpp 2007-11-10 17:33:47 UTC (rev 22871) @@ -0,0 +1,57 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "bfs_disk_system.h" + +#include "bfs.h" +#include "Volume.h" + + +status_t +parse_initialize_parameters(const char* parameterString, + initialize_parameters& parameters) +{ + parameters.flags = 0; + parameters.verbose = false; + + void *handle = parse_driver_settings_string(parameterString); + if (handle == NULL) + return B_ERROR; + + if (get_driver_boolean_parameter(handle, "noindex", false, true)) + parameters.flags |= VOLUME_NO_INDICES; + if (get_driver_boolean_parameter(handle, "verbose", false, true)) + parameters.verbose = true; + + const char *string = get_driver_parameter(handle, "block_size", + NULL, NULL); + uint32 blockSize = 1024; + if (string != NULL) + blockSize = strtoul(string, NULL, 0); + + delete_driver_settings(handle); + + if (blockSize != 1024 && blockSize != 2048 && blockSize != 4096 + && blockSize != 8192) { + return B_BAD_VALUE; + } + + parameters.blockSize = blockSize; + + return B_OK; +} + + +status_t +check_volume_name(const char* name) +{ + if (name == NULL || strlen(name) >= BFS_DISK_NAME_LENGTH + || strchr(name, '/') != NULL) { + return B_BAD_VALUE; + } + + return B_OK; +} + Added: haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_disk_system.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_disk_system.h 2007-11-10 16:49:39 UTC (rev 22870) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_disk_system.h 2007-11-10 17:33:47 UTC (rev 22871) @@ -0,0 +1,22 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _BFS_DISK_SYSTEM_H +#define _BFS_DISK_SYSTEM_H + +#include "system_dependencies.h" + + +struct initialize_parameters { + uint32 blockSize; + uint32 flags; + bool verbose; +}; + +status_t parse_initialize_parameters(const char* parameterString, + initialize_parameters& parameters); +status_t check_volume_name(const char* name); + + +#endif // _BFS_DISK_SYSTEM_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-11-10 16:49:39 UTC (rev 22870) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-11-10 17:33:47 UTC (rev 22871) @@ -14,6 +14,7 @@ #include "Query.h" #include "Attribute.h" #include "bfs_control.h" +#include "bfs_disk_system.h" #define BFS_IO_SIZE 65536 @@ -2014,49 +2015,6 @@ // #pragma mark - -struct initialize_parameters { - uint32 blockSize; - uint32 flags; - bool verbose; -}; - - -static status_t -parse_initialize_parameters(const char* parameterString, - initialize_parameters& parameters) -{ - parameters.flags = 0; - parameters.verbose = false; - - void *handle = parse_driver_settings_string(parameterString); - if (handle == NULL) - return B_ERROR; - - if (get_driver_boolean_parameter(handle, "noindex", false, true)) - parameters.flags |= VOLUME_NO_INDICES; - if (get_driver_boolean_parameter(handle, "verbose", false, true)) - parameters.verbose = true; - - const char *string = get_driver_parameter(handle, "block_size", - NULL, NULL); - uint32 blockSize = 1024; - if (string != NULL) - blockSize = strtoul(string, NULL, 0); - - delete_driver_settings(handle); - - if (blockSize != 1024 && blockSize != 2048 && blockSize != 4096 - && blockSize != 8192) { - INFORM(("valid block sizes are: 1024, 2048, 4096, and 8192\n")); - return B_BAD_VALUE; - } - - parameters.blockSize = blockSize; - - return B_OK; -} - - static uint32 bfs_get_supported_operations(partition_data* partition, uint32 mask) { @@ -2066,37 +2024,18 @@ } -static bool -bfs_validate_initialize(partition_data *partition, char *name, - const char *parameterString) -{ - if (name == NULL) - return B_BAD_VALUE; - - // truncate the name, if it is too long - size_t nameLen = strlen(name); - if (nameLen >= BFS_DISK_NAME_LENGTH) { - nameLen = BFS_DISK_NAME_LENGTH - 1; - name[nameLen] = '\0'; - } - - // replace '/' by '-' - while ((name = strchr(name, '/')) != NULL) - *name = '-'; - - // parse parameters - initialize_parameters parameters; - return (parse_initialize_parameters(parameterString, parameters) == B_OK); -} - - static status_t bfs_initialize(int fd, partition_id partitionID, const char *name, const char *parameterString, off_t /*partitionSize*/, disk_job_id job) { + // check name + status_t status = check_volume_name(name); + if (status != B_OK) + return status; + // parse parameters initialize_parameters parameters; - status_t status = parse_initialize_parameters(parameterString, parameters); + status = parse_initialize_parameters(parameterString, parameters); if (status != B_OK) return status; @@ -2296,7 +2235,7 @@ NULL, // validate_move NULL, // validate_set_content_name NULL, // validate_set_content_parameters - &bfs_validate_initialize, + NULL, // validate_initialize, /* shadow partition modification */ NULL, // shadow_changed Modified: haiku/trunk/src/tools/bfs_shell/Jamfile =================================================================== --- haiku/trunk/src/tools/bfs_shell/Jamfile 2007-11-10 16:49:39 UTC (rev 22870) +++ haiku/trunk/src/tools/bfs_shell/Jamfile 2007-11-10 17:33:47 UTC (rev 22871) @@ -28,6 +28,7 @@ BuildPlatformMain bfs_shell : + bfs_disk_system.cpp BlockAllocator.cpp BPlusTree.cpp Attribute.cpp From bonefish at mail.berlios.de Sat Nov 10 18:34:47 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 18:34:47 +0100 Subject: [Haiku-commits] r22872 - in haiku/trunk/src/add-ons/disk_systems: . bfs Message-ID: <200711101734.lAAHYlPg027667@sheep.berlios.de> Author: bonefish Date: 2007-11-10 18:34:44 +0100 (Sat, 10 Nov 2007) New Revision: 22872 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22872&view=rev Added: haiku/trunk/src/add-ons/disk_systems/bfs/ haiku/trunk/src/add-ons/disk_systems/bfs/BFSAddOn.cpp haiku/trunk/src/add-ons/disk_systems/bfs/BFSAddOn.h haiku/trunk/src/add-ons/disk_systems/bfs/Jamfile Modified: haiku/trunk/src/add-ons/disk_systems/Jamfile Log: Beginnings of a BFS userland disk system add-on. Modified: haiku/trunk/src/add-ons/disk_systems/Jamfile =================================================================== --- haiku/trunk/src/add-ons/disk_systems/Jamfile 2007-11-10 17:33:47 UTC (rev 22871) +++ haiku/trunk/src/add-ons/disk_systems/Jamfile 2007-11-10 17:34:44 UTC (rev 22872) @@ -1,3 +1,4 @@ SubDir HAIKU_TOP src add-ons disk_systems ; +SubInclude HAIKU_TOP src add-ons disk_systems bfs ; SubInclude HAIKU_TOP src add-ons disk_systems intel ; Added: haiku/trunk/src/add-ons/disk_systems/bfs/BFSAddOn.cpp =================================================================== --- haiku/trunk/src/add-ons/disk_systems/bfs/BFSAddOn.cpp 2007-11-10 17:33:47 UTC (rev 22871) +++ haiku/trunk/src/add-ons/disk_systems/bfs/BFSAddOn.cpp 2007-11-10 17:34:44 UTC (rev 22872) @@ -0,0 +1,207 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "BFSAddOn.h" + +#include + +#include + +#include +#include + +#include + +#include "bfs.h" +#include "bfs_disk_system.h" + + +using std::nothrow; + + +static const uint32 kDiskSystemFlags = + 0 +// | B_DISK_SYSTEM_SUPPORTS_CHECKING +// | B_DISK_SYSTEM_SUPPORTS_REPAIRING +// | B_DISK_SYSTEM_SUPPORTS_RESIZING +// | B_DISK_SYSTEM_SUPPORTS_MOVING +// | B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME +// | B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS + | B_DISK_SYSTEM_SUPPORTS_INITIALIZING + | B_DISK_SYSTEM_SUPPORTS_CONTENT_NAME +// | B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING +// | B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING_WHILE_MOUNTED +// | B_DISK_SYSTEM_SUPPORTS_CHECKING_WHILE_MOUNTED +// | B_DISK_SYSTEM_SUPPORTS_REPAIRING_WHILE_MOUNTED +// | B_DISK_SYSTEM_SUPPORTS_RESIZING_WHILE_MOUNTED +// | B_DISK_SYSTEM_SUPPORTS_MOVING_WHILE_MOUNTED +// | B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME_WHILE_MOUNTED +// | B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS_WHILE_MOUNTED +; + + +// #pragma mark - BFSAddOn + + +// constructor +BFSAddOn::BFSAddOn() + : BDiskSystemAddOn(kPartitionTypeBFS, kDiskSystemFlags) +{ +} + + +// destructor +BFSAddOn::~BFSAddOn() +{ +} + + +// CreatePartitionHandle +status_t +BFSAddOn::CreatePartitionHandle(BMutablePartition* partition, + BPartitionHandle** _handle) +{ + BFSPartitionHandle* handle = new(nothrow) BFSPartitionHandle(partition); + if (!handle) + return B_NO_MEMORY; + + status_t error = handle->Init(); + if (error != B_OK) { + delete handle; + return error; + } + + *_handle = handle; + return B_OK; +} + + +// CanInitialize +bool +BFSAddOn::CanInitialize(const BMutablePartition* partition) +{ + // TODO: Check partition size. + return true; +} + + +// GetInitializationParameterEditor +status_t +BFSAddOn::GetInitializationParameterEditor(const BMutablePartition* partition, + BDiskDeviceParameterEditor** editor) +{ + // TODO: Implement! + *editor = NULL; + return B_OK; +} + + +// ValidateInitialize +status_t +BFSAddOn::ValidateInitialize(const BMutablePartition* partition, BString* name, + const char* parameterString) +{ + if (!CanInitialize(partition) || !name) + return B_BAD_VALUE; + + // validate name + + // truncate, if it is too long + if (name->Length() >= BFS_DISK_NAME_LENGTH) + name->Truncate(BFS_DISK_NAME_LENGTH - 1); + + // replace '/' by '-' + name->ReplaceAll('/', '-'); + + // check parameters + initialize_parameters parameters; + status_t error = parse_initialize_parameters(parameterString, parameters); + if (error != B_OK) + return error; + + return B_OK; +} + + +// Initialize +status_t +BFSAddOn::Initialize(BMutablePartition* partition, const char* name, + const char* parameterString, BPartitionHandle** _handle) +{ + if (!CanInitialize(partition) || check_volume_name(name) != B_OK) + return B_BAD_VALUE; + + initialize_parameters parameters; + status_t error = parse_initialize_parameters(parameterString, parameters); + if (error != B_OK) + return error; + + // create the handle + BFSPartitionHandle* handle = new(nothrow) BFSPartitionHandle(partition); + if (!handle) + return B_NO_MEMORY; + ObjectDeleter handleDeleter(handle); + + // init the partition + error = partition->SetContentType(Name()); + if (error != B_OK) + return error; +// TODO: The content type could as well be set by the caller. + + partition->SetContentName(name); + partition->SetContentParameters(parameterString); + uint32 blockSize = parameters.blockSize; + partition->SetBlockSize(blockSize); + partition->SetContentSize(partition->Size() / blockSize * blockSize); + + *_handle = handleDeleter.Detach(); + + return B_OK; +} + + +// #pragma mark - BFSPartitionHandle + + +// constructor +BFSPartitionHandle::BFSPartitionHandle(BMutablePartition* partition) + : BPartitionHandle(partition) +{ +} + + +// destructor +BFSPartitionHandle::~BFSPartitionHandle() +{ +} + + +// Init +status_t +BFSPartitionHandle::Init() +{ +// TODO: Check parameters. + return B_OK; +} + + +// #pragma mark - + + +// get_disk_system_add_ons +status_t +get_disk_system_add_ons(BList* addOns) +{ + BFSAddOn* addOn = new(nothrow) BFSAddOn; + if (!addOn) + return B_NO_MEMORY; + + if (!addOns->AddItem(addOn)) { + delete addOn; + return B_NO_MEMORY; + } + + return B_OK; +} Added: haiku/trunk/src/add-ons/disk_systems/bfs/BFSAddOn.h =================================================================== --- haiku/trunk/src/add-ons/disk_systems/bfs/BFSAddOn.h 2007-11-10 17:33:47 UTC (rev 22871) +++ haiku/trunk/src/add-ons/disk_systems/bfs/BFSAddOn.h 2007-11-10 17:34:44 UTC (rev 22872) @@ -0,0 +1,44 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _BFS_ADD_ON_H +#define _BFS_ADD_ON_H + +#include + + +class BFSAddOn : public BDiskSystemAddOn { +public: + BFSAddOn(); + virtual ~BFSAddOn(); + + virtual status_t CreatePartitionHandle( + BMutablePartition* partition, + BPartitionHandle** handle); + + virtual bool CanInitialize( + const BMutablePartition* partition); + virtual status_t GetInitializationParameterEditor( + const BMutablePartition* partition, + BDiskDeviceParameterEditor** editor); + virtual status_t ValidateInitialize( + const BMutablePartition* partition, + BString* name, const char* parameters); + virtual status_t Initialize(BMutablePartition* partition, + const char* name, const char* parameters, + BPartitionHandle** handle); +}; + + +class BFSPartitionHandle : public BPartitionHandle { +public: + BFSPartitionHandle( + BMutablePartition* partition); + ~BFSPartitionHandle(); + + status_t Init(); +}; + + +#endif // _BFS_ADD_ON_H Added: haiku/trunk/src/add-ons/disk_systems/bfs/Jamfile =================================================================== --- haiku/trunk/src/add-ons/disk_systems/bfs/Jamfile 2007-11-10 17:33:47 UTC (rev 22871) +++ haiku/trunk/src/add-ons/disk_systems/bfs/Jamfile 2007-11-10 17:34:44 UTC (rev 22872) @@ -0,0 +1,15 @@ +SubDir HAIKU_TOP src add-ons disk_systems bfs ; + +UsePrivateHeaders kernel ; +UsePrivateHeaders shared ; +UsePrivateHeaders storage ; + +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems bfs ] ; + +Addon bfs : + BFSAddOn.cpp + + bfs_disk_system.cpp + + : be +; From axeld at pinc-software.de Sat Nov 10 18:42:38 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sat, 10 Nov 2007 18:42:38 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r22871_-_in_haiku/trunk/src=3A_ad?= =?iso-8859-15?q?d-ons/kernel/file=5Fsystems/bfs__tools/bfs=5Fshell?= In-Reply-To: <200711101733.lAAHXmeY024950@sheep.berlios.de> Message-ID: <29918602879-BeMail@zon> bonefish at BerliOS wrote: > + if (name == NULL || strlen(name) >= BFS_DISK_NAME_LENGTH > + || strchr(name, '/') != NULL) { Nice, but I think that the system should at least check for '/' itself, ie. the file/disk system should not need to do that. Bye, Axel. From sbenedetto at mail.berlios.de Sat Nov 10 18:47:04 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 10 Nov 2007 18:47:04 +0100 Subject: [Haiku-commits] r22873 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711101747.lAAHl4xc017089@sheep.berlios.de> Author: sbenedetto Date: 2007-11-10 18:47:03 +0100 (Sat, 10 Nov 2007) New Revision: 22873 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22873&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h Log: * Placed underscore to private methods like ReadReg and WriteReg * Rewrote _AllocateEndpoint * More work in the constructor Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-10 17:34:44 UTC (rev 22872) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-10 17:47:03 UTC (rev 22873) @@ -67,9 +67,9 @@ fStack(stack), fRegisterArea(-1), fHccaArea(-1), - fDummyControl(0), - fDummyBulk(0), - fDummyIsochronous(0), + fDummyControl(NULL), + fDummyBulk(NULL), + fDummyIsochronous(NULL), fRootHub(NULL), fRootHubAddress(0), fNumPorts(0) @@ -109,7 +109,7 @@ *fOperationalRegisters)); // Check the revision of the controller, which should be 10h - uint32 revision = ReadReg(OHCI_REVISION) & 0xff; + uint32 revision = _ReadReg(OHCI_REVISION) & 0xff; TRACE(("usb_ohci: version %ld.%ld%s\n", OHCI_REVISION_HIGH(revision), OHCI_REVISION_LOW(revision), OHCI_REVISION_LEGACY(revision) ? ", legacy support" : "")); @@ -135,42 +135,67 @@ fDummyControl = _AllocateEndpoint(); if (!fDummyControl) return; + fDummyControl->flags |= OHCI_ENDPOINT_SKIP; + fDummyBulk = _AllocateEndpoint(); - if (!fDummyBulk) + if (!fDummyBulk) { + _FreeEndpoint(fDummyControl); return; + } + fDummyBulk->flags |= OHCI_ENDPOINT_SKIP; + fDummyIsochronous = _AllocateEndpoint(); - if (!fDummyIsochronous) + if (!fDummyIsochronous) { + _FreeEndpoint(fDummyControl); + _FreeEndpoint(fDummyBulk); return; + } + fDummyIsochronous->flags |= OHCI_ENDPOINT_SKIP; // Create the interrupt tree // Algorithm kindly borrowed from NetBSD code - for( uint32 i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) { - fInterruptEndpoints[i] = _AllocateEndpoint(); - if (!fInterruptEndpoints[i]) + // TODO: Check it once again + ohci_endpoint_descriptor *current, *previous; + for( uint32 i = 0; i < OHCI_NUMBER_OF_ENDPOINTS; i++) { + current = _AllocateEndpoint(); + if (!current) { + TRACE_ERROR(("usb_ohci: failed to create interrupts tree\n")); + while (--i >= 0) + _FreeEndpoint(fInterruptEndpoints[i]); + _FreeEndpoint(fDummyBulk); + _FreeEndpoint(fDummyControl); + _FreeEndpoint(fDummyIsochronous); return; + } + fInterruptEndpoints[i] = current; + current->flags |= OHCI_ENDPOINT_SKIP; if (i != 0) - fInterruptEndpoints[i]->SetNext(fInterruptEndpoints[(i-1) / 2]); + previous = fInterruptEndpoints[(i - 1) / 2]; else - fInterruptEndpoints[i]->SetNext(fDummyIsochronous); + previous = fDummyIsochronous; + current->next_logical_endpoint = previous; + current->next_physical_endpoint = previous->this_physical; } + // Fill HCCA interrupt table. The bit reversal is to get + // the tree set up properly to spread the interrupts. for (uint32 i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) fHcca->hcca_interrupt_table[revbits[i]] = - fInterruptEndpoints[OHCI_NO_EDS-OHCI_NUMBER_OF_INTERRUPTS+i]->physical_address; - + fInterruptEndpoints[OHCI_NUMBER_OF_ENDPOINTS - OHCI_NUMBER_OF_INTERRUPTS + i]->physical_address; + // Determine in what context we are running (Kindly copied from FreeBSD) - uint32 control = ReadReg(OHCI_CONTROL); + uint32 control = _ReadReg(OHCI_CONTROL); if (control & OHCI_INTERRUPT_ROUTING) { TRACE(("usb_ohci: SMM is in control of the host controller\n")); - WriteReg(OHCI_COMMAND_STATUS, OHCI_OWNERSHIP_CHANGE_REQUEST); + _WriteReg(OHCI_COMMAND_STATUS, OHCI_OWNERSHIP_CHANGE_REQUEST); for (uint32 i = 0; i < 100 && (control & OHCI_INTERRUPT_ROUTING); i++) { snooze(1000); - control = ReadReg(OHCI_CONTROL); + control = _ReadReg(OHCI_CONTROL); } if (!(control & OHCI_INTERRUPT_ROUTING)) { TRACE(("usb_ohci: SMM does not respond. Resetting...\n")); - WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_RESET); + _WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_RESET); snooze(USB_DELAY_BUS_RESET); } } else if ((control & OHCI_HC_FUNCTIONAL_STATE_MASK) @@ -178,7 +203,7 @@ TRACE(("usb_ohci: BIOS is in control of the host controller\n")); if ((control & OHCI_HC_FUNCTIONAL_STATE_MASK) != OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL) { - WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL); + _WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL); // TOFIX: shorter delay snooze(USB_DELAY_BUS_RESET); } @@ -186,21 +211,21 @@ // This reset should not be necessary according to the OHCI spec, but // without it some controllers do not start. - WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_RESET); + _WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_RESET); snooze(USB_DELAY_BUS_RESET); // We now own the host controller and the bus has been reset - uint32 frameInterval = ReadReg(OHCI_FRAME_INTERVAL); + uint32 frameInterval = _ReadReg(OHCI_FRAME_INTERVAL); uint32 intervalValue = OHCI_GET_INTERVAL_VALUE(frameInterval); - WriteReg(OHCI_COMMAND_STATUS, OHCI_HOST_CONTROLLER_RESET); + _WriteReg(OHCI_COMMAND_STATUS, OHCI_HOST_CONTROLLER_RESET); for (uint32 i = 0; i < 10; i++) { snooze(10); - if (!(ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET)) + if (!(_ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET)) break; } - if (ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET) { + if (_ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET) { TRACE_ERROR(("usb_ohci: Error resetting the host controller (timeout)\n")); return; } @@ -208,47 +233,51 @@ // The controller is now in SUSPEND state, we have 2ms to finish // TODO: maybe add spinlock protection??? // Set up host controller register - WriteReg(OHCI_HCCA, (uint32)hccaPhysicalAddress); - WriteReg(OHCI_CONTROL_HEAD_ED, (uint32)fDummyControl->physical_address); - WriteReg(OHCI_BULK_HEAD_ED, (uint32)fDummyBulk->physical_address); + _WriteReg(OHCI_HCCA, (uint32)hccaPhysicalAddress); + _WriteReg(OHCI_CONTROL_HEAD_ED, (uint32)fDummyControl->physical_address); + _WriteReg(OHCI_BULK_HEAD_ED, (uint32)fDummyBulk->physical_address); // Disable all interrupts and then switch on all desired interrupts - WriteReg(OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTERRUPTS); - WriteReg(OHCI_INTERRUPT_ENABLE, OHCI_NORMAL_INTERRUPTS + _WriteReg(OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTERRUPTS); + _WriteReg(OHCI_INTERRUPT_ENABLE, OHCI_NORMAL_INTERRUPTS | OHCI_MASTER_INTERRUPT_ENABLE); // Switch on desired functional features - control = ReadReg(OHCI_CONTROL); + control = _ReadReg(OHCI_CONTROL); control &= ~(OHCI_CONTROL_BULK_SERVICE_RATIO_MASK | OHCI_ENABLE_LIST | OHCI_HC_FUNCTIONAL_STATE_MASK | OHCI_INTERRUPT_ROUTING); control |= OHCI_ENABLE_LIST | OHCI_CONTROL_BULK_RATIO_1_4 | OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL; // And finally start the controller - WriteReg(OHCI_CONTROL, control); + _WriteReg(OHCI_CONTROL, control); // The controller is now OPERATIONAL. - frameInterval = (ReadReg(OHCI_FRAME_INTERVAL) & OHCI_FRAME_INTERVAL_TOGGLE) + frameInterval = (_ReadReg(OHCI_FRAME_INTERVAL) & OHCI_FRAME_INTERVAL_TOGGLE) ^ OHCI_FRAME_INTERVAL_TOGGLE; frameInterval |= OHCI_FSMPS(intervalValue) | intervalValue; - WriteReg(OHCI_FRAME_INTERVAL, frameInterval); + _WriteReg(OHCI_FRAME_INTERVAL, frameInterval); // 90% periodic uint32 periodic = OHCI_PERIODIC(intervalValue); - WriteReg(OHCI_PERIODIC_START, periodic); + _WriteReg(OHCI_PERIODIC_START, periodic); // Fiddle the No Over Current Protection bit to avoid chip bug - uint32 desca = ReadReg(OHCI_RH_DESCRIPTOR_A); - WriteReg(OHCI_RH_DESCRIPTOR_A, desca | OHCI_RH_NO_OVER_CURRENT_PROTECTION); - WriteReg(OHCI_RH_STATUS, OHCI_RH_LOCAL_POWER_STATUS_CHANGE); + uint32 desca = _ReadReg(OHCI_RH_DESCRIPTOR_A); + _WriteReg(OHCI_RH_DESCRIPTOR_A, desca | OHCI_RH_NO_OVER_CURRENT_PROTECTION); + _WriteReg(OHCI_RH_STATUS, OHCI_RH_LOCAL_POWER_STATUS_CHANGE); snooze(OHCI_ENABLE_POWER_DELAY); - WriteReg(OHCI_RH_DESCRIPTOR_A, desca); + _WriteReg(OHCI_RH_DESCRIPTOR_A, desca); // The AMD756 requires a delay before re-reading the register, // otherwise it will occasionally report 0 ports. uint32 numberOfPorts = 0; for (uint32 i = 0; i < 10 && numberOfPorts == 0; i++) { snooze(OHCI_READ_DESC_DELAY); - uint32 descriptor = ReadReg(OHCI_RH_DESCRIPTOR_A); + uint32 descriptor = _ReadReg(OHCI_RH_DESCRIPTOR_A); numberOfPorts = OHCI_RH_GET_PORT_COUNT(descriptor); } + // TODO: Add Finisher Thread. + + TRACE(("usb_ohci: OHCI Host Controller Driver constructed\n")); + fInitOK = true; } @@ -280,13 +309,13 @@ if (InitCheck()) return B_ERROR; - if (!(ReadReg(OHCI_CONTROL) & OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL)) { + if (!(_ReadReg(OHCI_CONTROL) & OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL)) { TRACE(("usb_ohci::Start(): Controller not started. TODO: find out what happens.\n")); return B_ERROR; } fRootHubAddress = AllocateAddress(); - fNumPorts = OHCI_RH_GET_PORT_COUNT(ReadReg(OHCI_RH_DESCRIPTOR_A)); + fNumPorts = OHCI_RH_GET_PORT_COUNT(_ReadReg(OHCI_RH_DESCRIPTOR_A)); fRootHub = new(std::nothrow) OHCIRootHub(RootObject(), fRootHubAddress); if (!fRootHub) { @@ -420,7 +449,7 @@ return B_BAD_INDEX; status->status = status->change = 0; - uint32 portStatus = ReadReg(OHCI_RH_PORT_STATUS(index)); + uint32 portStatus = _ReadReg(OHCI_RH_PORT_STATUS(index)); TRACE(("usb_ohci: RootHub::GetPortStatus: Port %i Value 0x%lx\n", OHCI_RH_PORT_STATUS(index), portStatus)); @@ -466,11 +495,11 @@ switch (feature) { case PORT_RESET: - WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PRS); + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PRS); return B_OK; case PORT_POWER: - WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PPS); + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PPS); return B_OK; } @@ -487,11 +516,11 @@ switch (feature) { case C_PORT_RESET: - WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_CSC); + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_CSC); return B_OK; case C_PORT_CONNECTION: - WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_CSC); + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_CSC); return B_OK; } @@ -499,34 +528,35 @@ } -Endpoint * +ohci_endpoint_descriptor* OHCI::_AllocateEndpoint() { - TRACE(("OHCI::%s()\n", __FUNCTION__)); + ohci_endpoint_descriptor *endpoint; + void* physicalAddress; + //Allocate memory chunk - Endpoint *endpoint = new(std::nothrow) Endpoint; - void *phy; - if (fStack->AllocateChunk((void **)&endpoint->ed, &phy, sizeof(ohci_endpoint_descriptor)) != B_OK) { - TRACE(("OHCI::AllocateEndpoint(): Error Allocating Endpoint\n")); - return 0; + if (fStack->AllocateChunk((void **)&endpoint, &physicalAddress, + sizeof(ohci_endpoint_descriptor)) < B_OK) { + TRACE_ERROR(("usb_uhci: failed to allocate endpoint descriptor\n")); + return NULL; } - endpoint->physical_address = (addr_t)phy; - - //Initialize the physical part - memset((void *)endpoint->ed, 0, sizeof(ohci_endpoint_descriptor)); - endpoint->ed->flags = OHCI_ENDPOINT_SKIP; - - //Add a NULL list by creating one TransferDescriptor - TransferDescriptor *trans = new(std::nothrow) TransferDescriptor; - endpoint->head = endpoint->tail = trans; - endpoint->ed->head_pointer = endpoint->ed->tail_pointer = trans->physical_address; - + + endpoint->this_physical = (addr_t)physicalAddress; + + // Add an empty list by creating a general descriptor + ohci_general_transfer_descriptor *descriptor = _CreateGeneralDescriptor(); + endpoint->head_physical_descriptor = descriptor->this_physical; + endpoint->tail_physical_descriptor = descriptor->this_physical; + + endpoint->head_logical_descriptor = descriptor; + endpoint->tail_logical_descriptor = descriptor; + return endpoint; } void -OHCI::_FreeEndpoint(Endpoint *end) +OHCI::_FreeEndpoint(ohci_endpoint_descriptor *endpoint) { TRACE(("OHCI::%s(%p)\n", __FUNCTION__, end)); fStack->FreeChunk((void *)end->ed, (void *) end->physical_address, sizeof(ohci_endpoint_descriptor)); @@ -653,14 +683,14 @@ inline void -OHCI::WriteReg(uint32 reg, uint32 value) +OHCI::_WriteReg(uint32 reg, uint32 value) { *(volatile uint32 *)(fOperationalRegisters + reg) = value; } inline uint32 -OHCI::ReadReg(uint32 reg) +OHCI::_ReadReg(uint32 reg) { return *(volatile uint32 *)(fOperationalRegisters + reg); } Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-10 17:34:44 UTC (rev 22872) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-10 17:47:03 UTC (rev 22873) @@ -81,15 +81,15 @@ // Host Controller Communication Area related stuff area_id fHccaArea; struct ohci_hcca *fHcca; - Endpoint *fInterruptEndpoints[OHCI_NUMBER_OF_ENDPOINTS]; + ohci_endpoint_descriptor *fInterruptEndpoints[OHCI_NUMBER_OF_ENDPOINTS]; // Dummy endpoints - Endpoint *fDummyControl; - Endpoint *fDummyBulk; - Endpoint *fDummyIsochronous; + ohci_endpoint_descriptor *fDummyControl; + ohci_endpoint_descriptor *fDummyBulk; + ohci_endpoint_descriptor *fDummyIsochronous; // Endpoint related methods - Endpoint *_AllocateEndpoint(); + ohci_endpoint_descriptor *_AllocateEndpoint(); void _FreeEndpoint(Endpoint *end); TransferDescriptor *_AllocateTransfer(); void _FreeTransfer(TransferDescriptor *trans); From marcusoverhagen at mail.berlios.de Sat Nov 10 18:47:58 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 10 Nov 2007 18:47:58 +0100 Subject: [Haiku-commits] r22874 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200711101747.lAAHlwK9018355@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-10 18:47:57 +0100 (Sat, 10 Nov 2007) New Revision: 22874 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22874&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_sim.cpp Log: Propagate is-ATAPI restriction to the SCSI bus manager. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-11-10 17:47:03 UTC (rev 22873) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-11-10 17:47:57 UTC (rev 22874) @@ -330,3 +330,12 @@ return fPort[targetID]->ScsiResetDevice(); } + +void +AHCIController::GetRestrictions(uchar targetID, bool *isATAPI, bool *noAutoSense, uint32 *maxBlocks) +{ + if (!fPort[targetID]) + return; + + return fPort[targetID]->ScsiGetRestrictions(isATAPI, noAutoSense, maxBlocks); +} Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-11-10 17:47:03 UTC (rev 22873) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-11-10 17:47:57 UTC (rev 22874) @@ -23,6 +23,7 @@ uchar AbortRequest(scsi_ccb *request); uchar TerminateRequest(scsi_ccb *request); uchar ResetDevice(uchar targetID, uchar targetLUN); + void GetRestrictions(uchar targetID, bool *isATAPI, bool *noAutoSense, uint32 *maxBlocks); device_node_handle DeviceNode() { return fNode; } 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 2007-11-10 17:47:03 UTC (rev 22873) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-11-10 17:47:57 UTC (rev 22874) @@ -772,3 +772,14 @@ { return SCSI_REQ_CMP; } + + +void +AHCIPort::ScsiGetRestrictions(bool *isATAPI, bool *noAutoSense, uint32 *maxBlocks) +{ + *isATAPI = !!(fRegs->cmd & PORT_CMD_ATAPI); + *noAutoSense = false; + *maxBlocks = fUse48BitCommands ? 65536 : 256; + TRACE("AHCIPort::ScsiGetRestrictions port %d: isATAPI %d, noAutoSense %d, maxBlocks %lu\n", + fIndex, *isATAPI, *noAutoSense, *maxBlocks); +} Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-11-10 17:47:03 UTC (rev 22873) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-11-10 17:47:57 UTC (rev 22874) @@ -25,6 +25,7 @@ uchar ScsiAbortRequest(scsi_ccb *request); uchar ScsiTerminateRequest(scsi_ccb *request); uchar ScsiResetDevice(); + void ScsiGetRestrictions(bool *isATAPI, bool *noAutoSense, uint32 *maxBlocks); private: void ScsiTestUnitReady(scsi_ccb *request); Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_sim.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_sim.cpp 2007-11-10 17:47:03 UTC (rev 22873) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_sim.cpp 2007-11-10 17:47:57 UTC (rev 22874) @@ -104,9 +104,7 @@ { TRACE("ahci_get_restrictions, cookie %p\n", cookie); - *isATAPI = false; - *noAutoSense = false; - *maxBlocks = 256; + static_cast(cookie)->GetRestrictions(targetID, isATAPI, noAutoSense, maxBlocks); } From ingo_weinhold at gmx.de Sat Nov 10 19:23:24 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 10 Nov 2007 19:23:24 +0100 Subject: [Haiku-commits] r22871 - in haiku/trunk/src: add-ons/kernel/file_systems/bfs tools/bfs_shell In-Reply-To: <29918602879-BeMail@zon> References: <29918602879-BeMail@zon> Message-ID: <20071110192324.90033.4@graete.1194699459.fake> On 2007-11-10 at 18:42:38 [+0100], Axel D?rfler wrote: > bonefish at BerliOS wrote: > > + if (name == NULL || strlen(name) >= BFS_DISK_NAME_LENGTH > > + || strchr(name, '/') != NULL) { > > Nice, but I think that the system should at least check for '/' itself, > ie. the file/disk system should not need to do that. Actually I'm not even sure, if we should do that check at all. AFAIK, the only reason is that volumes are usually mounted at "/". But since we have to deal with volume names that contain slashes anyway, we could as well allow setting such volume names. CU, Ingo From sbenedetto at mail.berlios.de Sat Nov 10 19:36:56 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 10 Nov 2007 19:36:56 +0100 Subject: [Haiku-commits] r22875 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711101836.lAAIaubf002341@sheep.berlios.de> Author: sbenedetto Date: 2007-11-10 19:36:56 +0100 (Sat, 10 Nov 2007) New Revision: 22875 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22875&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp Log: * ups :) Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-10 17:47:57 UTC (rev 22874) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-10 18:36:56 UTC (rev 22875) @@ -537,7 +537,7 @@ //Allocate memory chunk if (fStack->AllocateChunk((void **)&endpoint, &physicalAddress, sizeof(ohci_endpoint_descriptor)) < B_OK) { - TRACE_ERROR(("usb_uhci: failed to allocate endpoint descriptor\n")); + TRACE_ERROR(("usb_ohci: failed to allocate endpoint descriptor\n")); return NULL; } From marcusoverhagen at mail.berlios.de Sat Nov 10 19:41:24 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 10 Nov 2007 19:41:24 +0100 Subject: [Haiku-commits] r22876 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200711101841.lAAIfOR3002618@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-10 19:41:24 +0100 (Sat, 10 Nov 2007) New Revision: 22876 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22876&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp Log: fail gracefully when base address register or irq hasn't been assigned. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-11-10 18:36:56 UTC (rev 22875) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-11-10 18:41:24 UTC (rev 22876) @@ -98,11 +98,21 @@ gPCI->write_pci_config(fPCIDevice, PCI_JMICRON_CONTROLLER_CONTROL_1, 4, ctrl); } + fIRQ = pciInfo.u.h0.interrupt_line; + if (fIRQ == 0 || fIRQ == 0xff) { + TRACE("PCI IRQ not assigned\n"); + return B_ERROR; + } + void *addr = (void *)pciInfo.u.h0.base_registers[5]; size_t size = pciInfo.u.h0.base_register_sizes[5]; TRACE("registers at %p, size %#lx\n", addr, size); - + if (!addr) { + TRACE("PCI base address register 5 not assigned\n"); + return B_ERROR; + } + fRegsArea = map_mem((void **)&fRegs, addr, size, 0, "AHCI HBA regs"); if (fRegsArea < B_OK) { TRACE("mapping registers failed\n"); @@ -123,12 +133,6 @@ goto err; } - fIRQ = gPCI->read_pci_config(fPCIDevice, PCI_interrupt_line, 1); - if (fIRQ == 0 || fIRQ == 0xff) { - TRACE("no IRQ assigned\n"); - goto err; - } - TRACE("cap: Interface Speed Support: generation %lu\n", (fRegs->cap >> CAP_ISS_SHIFT) & CAP_ISS_MASK); TRACE("cap: Number of Command Slots: %d (raw %#lx)\n", fCommandSlotCount, (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); TRACE("cap: Number of Ports: %d (raw %#lx)\n", fPortCountMax, (fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); From axeld at pinc-software.de Sat Nov 10 19:44:27 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sat, 10 Nov 2007 19:44:27 +0100 CET Subject: [Haiku-commits] r22871 - in haiku/trunk/src: add-ons/kernel/file_systems/bfs tools/bfs_shell In-Reply-To: <20071110192324.90033.4@graete.1194699459.fake> Message-ID: <33627444263-BeMail@zon> Ingo Weinhold wrote: > On 2007-11-10 at 18:42:38 [+0100], Axel D?rfler > > wrote: > > bonefish at BerliOS wrote: > > > + if (name == NULL || strlen(name) >= BFS_DISK_NAME_LENGTH > > > + || strchr(name, '/') != NULL) { > > > > Nice, but I think that the system should at least check for '/' > > itself, > > ie. the file/disk system should not need to do that. > Actually I'm not even sure, if we should do that check at all. AFAIK, > the > only reason is that volumes are usually mounted at "/". > But > since we have to deal with volume names that contain slashes anyway, > we > could as well allow setting such volume names. I was actually thinking about the same thing shortly after I wrote the mail. Whoever mounts the volume, should then replace those characters. OTOH it's not as intuitive when the mount name differs from the volume name, but since you don't have to use those characters, anyway... :-) Bye, Axel. From marcusoverhagen at mail.berlios.de Sat Nov 10 19:55:58 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 10 Nov 2007 19:55:58 +0100 Subject: [Haiku-commits] r22877 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200711101855.lAAItwVu003399@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-10 19:55:57 +0100 (Sat, 10 Nov 2007) New Revision: 22877 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22877&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c Log: Removed non-AHCI id. Reverts bugreport #1599 change. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c 2007-11-10 18:41:24 UTC (rev 22876) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c 2007-11-10 18:55:57 UTC (rev 22877) @@ -91,7 +91,6 @@ { 0x8086, 0x2683, "Intel ESB2" }, { 0x8086, 0x27c1, "Intel ICH7R (AHCI mode)" }, { 0x8086, 0x27c3, "Intel ICH7R (RAID mode)" }, - { 0x8086, 0x27c4, "Intel ICH7 (AHCI mode)" }, { 0x8086, 0x27c5, "Intel ICH7-M (AHCI mode)" }, { 0x8086, 0x27c6, "Intel ICH7-M DH (RAID mode)" }, { 0x8086, 0x2821, "Intel ICH8 (AHCI mode)" }, From marcusoverhagen at mail.berlios.de Sat Nov 10 19:59:30 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 10 Nov 2007 19:59:30 +0100 Subject: [Haiku-commits] r22878 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200711101859.lAAIxUfF003542@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-10 19:59:29 +0100 (Sat, 10 Nov 2007) New Revision: 22878 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22878&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp Log: Switch Intel AHCI controller from IDE into AHCI mode. Clears BAR5 on ICH8 and ICH9. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-11-10 18:55:57 UTC (rev 22877) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-11-10 18:59:29 UTC (rev 22878) @@ -19,8 +19,16 @@ static void jmicron_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, uint16 deviceId) { - if (deviceId != 0x2360 && deviceId != 0x2361 && deviceId != 0x2362 && deviceId != 0x2363 && deviceId != 0x2366) - return; + switch (deviceId) { + case 0x2360: + case 0x2361: + case 0x2362: + case 0x2363: + case 0x2366: + break; + default: + return; + } dprintf("jmicron_fixup_ahci: domain %u, bus %u, device %u, function %u, deviceId 0x%04x\n", domain, bus, device, function, deviceId); @@ -48,6 +56,56 @@ static void intel_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, uint16 deviceId) { + switch (deviceId) { + case 0x2825: // ICH8 Desktop when in IDE emulation mode + dprintf("intel_fixup_ahci: WARNING found ICH8 device id 0x2825"); + return; + case 0x2926: // ICH9 Desktop when in IDE emulation mode + dprintf("intel_fixup_ahci: WARNING found ICH9 device id 0x2926"); + return; + + case 0x27c0: // ICH7 Desktop non-AHCI and non-RAID mode + case 0x27c4: // ICH7 Mobile non-AHCI and non-RAID mode + case 0x2820: // ICH8 Desktop non-AHCI and non-RAID mode + case 0x2828: // ICH8 Mobile non-AHCI and non-RAID mode + case 0x2920: // ICH9 Desktop non-AHCI and non-RAID mode (4 ports) + case 0x2921: // ICH9 Desktop non-AHCI and non-RAID mode (2 ports) + break; + default: + return; + } + + dprintf("intel_fixup_ahci: domain %u, bus %u, device %u, function %u, deviceId 0x%04x\n", + domain, bus, device, function, deviceId); + + dprintf("0x24: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + dprintf("0x90: 0x%02lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x90, 1)); + + uint8 map = pci->ReadPciConfig(domain, bus, device, function, 0x90, 1); + uint32 bar5 = pci->ReadPciConfig(domain, bus, device, function, 0x24, 4); + if ((map >> 6) == 0) { + dprintf("intel_fixup_ahci: switching from IDE to AHCI mode\n"); + map &= ~0x03; + map |= 0x40; + pci->WritePciConfig(domain, bus, device, function, 0x90, 1, map); + + uint16 pcicmd = pci->ReadPciConfig(domain, bus, device, function, PCI_command, 2); + pci->WritePciConfig(domain, bus, device, function, PCI_command, 2, + pcicmd & ~(PCI_command_io | PCI_command_memory)); + + pci->WritePciConfig(domain, bus, device, function, 0x24, 4, 0xffffffff); + dprintf("intel_fixup_ahci: bar5 bits-1: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + pci->WritePciConfig(domain, bus, device, function, 0x24, 4, 0); + dprintf("intel_fixup_ahci: bar5 bits-0: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + + if (deviceId == 0x27c0 || deviceId == 0x27c4) // restore on ICH7 + pci->WritePciConfig(domain, bus, device, function, 0x24, 4, bar5); + + pci->WritePciConfig(domain, bus, device, function, PCI_command, 2, pcicmd); + } + + dprintf("0x24: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + dprintf("0x90: 0x%02lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x90, 1)); } From marcusoverhagen at mail.berlios.de Sat Nov 10 20:15:13 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 10 Nov 2007 20:15:13 +0100 Subject: [Haiku-commits] r22879 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200711101915.lAAJFD56004485@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-10 20:15:12 +0100 (Sat, 10 Nov 2007) New Revision: 22879 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22879&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp Log: improved debug output Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-11-10 18:59:29 UTC (rev 22878) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-11-10 19:15:12 UTC (rev 22879) @@ -34,8 +34,8 @@ domain, bus, device, function, deviceId); if (function == 0) { - dprintf("0x40: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x40, 4)); - dprintf("0xdc: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4)); + dprintf("jmicron_fixup_ahci: 0x40: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x40, 4)); + dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4)); uint32 val = pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4); if (!(val & (1 << 30))) { dprintf("jmicron_fixup_ahci: enabling split device mode\n"); @@ -47,8 +47,8 @@ val |= (1 << 1) | (1 << 17) | (1 << 22); pci->WritePciConfig(domain, bus, device, function, 0x40, 4, val); } - dprintf("0x40: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x40, 4)); - dprintf("0xdc: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4)); + dprintf("jmicron_fixup_ahci: 0x40: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x40, 4)); + dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4)); } } @@ -78,34 +78,41 @@ dprintf("intel_fixup_ahci: domain %u, bus %u, device %u, function %u, deviceId 0x%04x\n", domain, bus, device, function, deviceId); - dprintf("0x24: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); - dprintf("0x90: 0x%02lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x90, 1)); + dprintf("intel_fixup_ahci: 0x24: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + dprintf("intel_fixup_ahci: 0x90: 0x%02lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x90, 1)); uint8 map = pci->ReadPciConfig(domain, bus, device, function, 0x90, 1); - uint32 bar5 = pci->ReadPciConfig(domain, bus, device, function, 0x24, 4); if ((map >> 6) == 0) { + uint32 bar5 = pci->ReadPciConfig(domain, bus, device, function, 0x24, 4); + uint16 pcicmd = pci->ReadPciConfig(domain, bus, device, function, PCI_command, 2); + dprintf("intel_fixup_ahci: switching from IDE to AHCI mode\n"); - map &= ~0x03; - map |= 0x40; - pci->WritePciConfig(domain, bus, device, function, 0x90, 1, map); - uint16 pcicmd = pci->ReadPciConfig(domain, bus, device, function, PCI_command, 2); pci->WritePciConfig(domain, bus, device, function, PCI_command, 2, pcicmd & ~(PCI_command_io | PCI_command_memory)); pci->WritePciConfig(domain, bus, device, function, 0x24, 4, 0xffffffff); - dprintf("intel_fixup_ahci: bar5 bits-1: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + dprintf("intel_fixup_ahci: ide-bar5 bits-1: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); pci->WritePciConfig(domain, bus, device, function, 0x24, 4, 0); - dprintf("intel_fixup_ahci: bar5 bits-0: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + dprintf("intel_fixup_ahci: ide-bar5 bits-0: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + map &= ~0x03; + map |= 0x40; + pci->WritePciConfig(domain, bus, device, function, 0x90, 1, map); + + pci->WritePciConfig(domain, bus, device, function, 0x24, 4, 0xffffffff); + dprintf("intel_fixup_ahci: ahci-bar5 bits-1: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + pci->WritePciConfig(domain, bus, device, function, 0x24, 4, 0); + dprintf("intel_fixup_ahci: ahci-bar5 bits-0: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + if (deviceId == 0x27c0 || deviceId == 0x27c4) // restore on ICH7 pci->WritePciConfig(domain, bus, device, function, 0x24, 4, bar5); pci->WritePciConfig(domain, bus, device, function, PCI_command, 2, pcicmd); } - dprintf("0x24: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); - dprintf("0x90: 0x%02lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x90, 1)); + dprintf("intel_fixup_ahci: 0x24: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x24, 4)); + dprintf("intel_fixup_ahci: 0x90: 0x%02lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x90, 1)); } From bonefish at mail.berlios.de Sat Nov 10 21:30:23 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 21:30:23 +0100 Subject: [Haiku-commits] r22880 - in haiku/trunk: headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager Message-ID: <200711102030.lAAKUNIc008551@sheep.berlios.de> Author: bonefish Date: 2007-11-10 21:30:22 +0100 (Sat, 10 Nov 2007) New Revision: 22880 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22880&view=rev Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp Log: * KDiskDeviceManager::{Find,Load}DiskSystem() can also find the disk system by pretty name (not only module name) now. * _user_initialize_partition() loads the disk system by pretty name. Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h 2007-11-10 19:15:12 UTC (rev 22879) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h 2007-11-10 20:30:22 UTC (rev 22880) @@ -81,12 +81,12 @@ // Disk Systems // manager must be locked - KDiskSystem *FindDiskSystem(const char *name); + KDiskSystem *FindDiskSystem(const char *name, bool byPrettyName = false); KDiskSystem *FindDiskSystem(disk_system_id id); int32 CountDiskSystems(); KDiskSystem *NextDiskSystem(int32 *cookie); - KDiskSystem *LoadDiskSystem(const char *name); + KDiskSystem *LoadDiskSystem(const char *name, bool byPrettyName = false); KDiskSystem *LoadDiskSystem(disk_system_id id); KDiskSystem *LoadNextDiskSystem(int32 *cookie); Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-10 19:15:12 UTC (rev 22879) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-10 20:30:22 UTC (rev 22880) @@ -630,12 +630,17 @@ // FindDiskSystem KDiskSystem * -KDiskDeviceManager::FindDiskSystem(const char *name) +KDiskDeviceManager::FindDiskSystem(const char *name, bool byPrettyName) { for (int32 cookie = 0; KDiskSystem *diskSystem = NextDiskSystem(&cookie); ) { - if (!strcmp(name, diskSystem->Name())) - return diskSystem; + if (byPrettyName) { + if (strcmp(name, diskSystem->PrettyName()) == 0) + return diskSystem; + } else { + if (strcmp(name, diskSystem->Name()) == 0) + return diskSystem; + } } return NULL; } @@ -674,11 +679,11 @@ // LoadDiskSystem KDiskSystem * -KDiskDeviceManager::LoadDiskSystem(const char *name) +KDiskDeviceManager::LoadDiskSystem(const char *name, bool byPrettyName) { KDiskSystem *diskSystem = NULL; if (ManagerLocker locker = this) { - diskSystem = FindDiskSystem(name); + diskSystem = FindDiskSystem(name, byPrettyName); if (diskSystem && diskSystem->Load() != B_OK) diskSystem = NULL; } Modified: haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp 2007-11-10 19:15:12 UTC (rev 22879) +++ haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp 2007-11-10 20:30:22 UTC (rev 22880) @@ -1162,7 +1162,8 @@ return B_BAD_VALUE; // load the new disk system - KDiskSystem *diskSystem = manager->LoadDiskSystem(diskSystemName.value); + KDiskSystem *diskSystem = manager->LoadDiskSystem(diskSystemName.value, + true); if (!diskSystem) return B_ENTRY_NOT_FOUND; DiskSystemLoader loader(diskSystem, true); From bonefish at mail.berlios.de Sat Nov 10 21:31:51 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 21:31:51 +0100 Subject: [Haiku-commits] r22881 - haiku/trunk/src/kits/storage/disk_device Message-ID: <200711102031.lAAKVpNG008685@sheep.berlios.de> Author: bonefish Date: 2007-11-10 21:31:50 +0100 (Sat, 10 Nov 2007) New Revision: 22881 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22881&view=rev Modified: haiku/trunk/src/kits/storage/disk_device/DiskSystemAddOnManager.cpp Log: Initialize ref count. Modified: haiku/trunk/src/kits/storage/disk_device/DiskSystemAddOnManager.cpp =================================================================== --- haiku/trunk/src/kits/storage/disk_device/DiskSystemAddOnManager.cpp 2007-11-10 20:30:22 UTC (rev 22880) +++ haiku/trunk/src/kits/storage/disk_device/DiskSystemAddOnManager.cpp 2007-11-10 20:31:50 UTC (rev 22881) @@ -58,7 +58,8 @@ struct DiskSystemAddOnManager::AddOn { AddOn(AddOnImage* image, BDiskSystemAddOn* addOn) : image(image), - addOn(addOn) + addOn(addOn), + refCount(1) { } From bonefish at mail.berlios.de Sat Nov 10 21:33:44 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 21:33:44 +0100 Subject: [Haiku-commits] r22882 - haiku/trunk/src/kits/storage/disk_device Message-ID: <200711102033.lAAKXipJ008846@sheep.berlios.de> Author: bonefish Date: 2007-11-10 21:33:43 +0100 (Sat, 10 Nov 2007) New Revision: 22882 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22882&view=rev Modified: haiku/trunk/src/kits/storage/disk_device/Partition.cpp haiku/trunk/src/kits/storage/disk_device/PartitionDelegate.cpp haiku/trunk/src/kits/storage/disk_device/PartitionDelegate.h Log: Implemented BPartition::_IsModified(), so that BDiskDevice::IsModified() does actually work now. Modified: haiku/trunk/src/kits/storage/disk_device/Partition.cpp =================================================================== --- haiku/trunk/src/kits/storage/disk_device/Partition.cpp 2007-11-10 20:31:50 UTC (rev 22881) +++ haiku/trunk/src/kits/storage/disk_device/Partition.cpp 2007-11-10 20:33:43 UTC (rev 22882) @@ -1598,6 +1598,5 @@ if (!fDelegate) return false; - // TODO: Implement! - return false; + return fDelegate->IsModified(); } Modified: haiku/trunk/src/kits/storage/disk_device/PartitionDelegate.cpp =================================================================== --- haiku/trunk/src/kits/storage/disk_device/PartitionDelegate.cpp 2007-11-10 20:31:50 UTC (rev 22881) +++ haiku/trunk/src/kits/storage/disk_device/PartitionDelegate.cpp 2007-11-10 20:33:43 UTC (rev 22882) @@ -118,6 +118,14 @@ } +// IsModified +bool +BPartition::Delegate::IsModified() const +{ + return fMutablePartition.ChangeFlags() != 0; +} + + // SupportedOperations uint32 BPartition::Delegate::SupportedOperations(uint32 mask) Modified: haiku/trunk/src/kits/storage/disk_device/PartitionDelegate.h =================================================================== --- haiku/trunk/src/kits/storage/disk_device/PartitionDelegate.h 2007-11-10 20:31:50 UTC (rev 22881) +++ haiku/trunk/src/kits/storage/disk_device/PartitionDelegate.h 2007-11-10 20:33:43 UTC (rev 22882) @@ -33,6 +33,8 @@ Delegate* ChildAt(int32 index) const; int32 CountChildren() const; + bool IsModified() const; + uint32 SupportedOperations(uint32 mask); uint32 SupportedChildOperations(Delegate* child, uint32 mask); From bonefish at mail.berlios.de Sat Nov 10 21:36:30 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 21:36:30 +0100 Subject: [Haiku-commits] r22883 - haiku/trunk/src/kits/storage/disk_device Message-ID: <200711102036.lAAKaUYp009109@sheep.berlios.de> Author: bonefish Date: 2007-11-10 21:36:30 +0100 (Sat, 10 Nov 2007) New Revision: 22883 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22883&view=rev Modified: haiku/trunk/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp haiku/trunk/src/kits/storage/disk_device/DiskDeviceJobQueue.cpp Log: * Added some debug output. * Don't generate an uninitialize job, when there's the partition wasn't initialized anyway (the syscall would fail in this case). Modified: haiku/trunk/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp =================================================================== --- haiku/trunk/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp 2007-11-10 20:33:43 UTC (rev 22882) +++ haiku/trunk/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp 2007-11-10 20:36:30 UTC (rev 22883) @@ -30,6 +30,11 @@ #include "UninitializeJob.h" +#undef TRACE +//#define TRACE(x...) +#define TRACE(x...) printf(x) + + using std::nothrow; @@ -133,22 +138,33 @@ // changes, also those that shall be initialized with a disk system. // This simplifies moving and resizing. status_t error = _GenerateCleanupJobs(fDevice); - if (error != B_OK) + if (error != B_OK) { + TRACE("DiskDeviceJobGenerator::GenerateJobs(): _GenerateCleanupJobs() " + "failed\n"); return error; + } // Generate jobs that move and resize the remaining physical partitions // to their final position/size. error = _GeneratePlacementJobs(fDevice); - if (error != B_OK) + if (error != B_OK) { + TRACE("DiskDeviceJobGenerator::GenerateJobs(): " + "_GeneratePlacementJobs() failed\n"); return error; + } // Generate the remaining jobs in one run: initialization, creation of // partitions, and changing of name, content name, type, parameters, and // content parameters. error = _GenerateRemainingJobs(NULL, fDevice); - if (error != B_OK) + if (error != B_OK) { + TRACE("DiskDeviceJobGenerator::GenerateJobs(): " + "_GenerateRemainingJobs() failed\n"); return error; + } + TRACE("DiskDeviceJobGenerator::GenerateJobs(): succeeded\n"); + return B_OK; } @@ -175,7 +191,8 @@ // TODO: Depending on how this shall be handled, we might want to unmount // all descendants of a partition to be uninitialized or removed. if (BMutablePartition* shadow = _GetMutablePartition(partition)) { - if (shadow->ChangeFlags() & B_PARTITION_CHANGED_INITIALIZATION) { + if ((shadow->ChangeFlags() & B_PARTITION_CHANGED_INITIALIZATION) + && partition->fPartitionData->content_type) { // partition changes initialization status_t error = _GenerateUninitializeJob(partition); if (error != B_OK) @@ -368,7 +385,6 @@ return error; } else { // partition already exists: set non-content properties - // name if ((changeFlags & B_PARTITION_CHANGED_NAME) Modified: haiku/trunk/src/kits/storage/disk_device/DiskDeviceJobQueue.cpp =================================================================== --- haiku/trunk/src/kits/storage/disk_device/DiskDeviceJobQueue.cpp 2007-11-10 20:33:43 UTC (rev 22882) +++ haiku/trunk/src/kits/storage/disk_device/DiskDeviceJobQueue.cpp 2007-11-10 20:36:30 UTC (rev 22883) @@ -5,9 +5,16 @@ #include "DiskDeviceJobQueue.h" +#include + #include "DiskDeviceJob.h" +#undef TRACE +//#define TRACE(x...) +#define TRACE(x...) printf(x) + + // constructor DiskDeviceJobQueue::DiskDeviceJobQueue() : fJobs(20, true) @@ -39,9 +46,15 @@ int32 count = fJobs.CountItems(); for (int32 i = 0; i < count; i++) { DiskDeviceJob* job = fJobs.ItemAt(i); + + TRACE("DiskDeviceJobQueue::Execute(): executing job: %s\n", + typeid(*job).name()); + status_t error = job->Do(); - if (error != B_OK) + if (error != B_OK) { + TRACE("DiskDeviceJobQueue::Execute(): executing job failed\n"); return error; + } } return B_OK; From bonefish at mail.berlios.de Sat Nov 10 21:38:39 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 21:38:39 +0100 Subject: [Haiku-commits] r22884 - haiku/trunk/src/tests/apps/partitioner Message-ID: <200711102038.lAAKcdlp009285@sheep.berlios.de> Author: bonefish Date: 2007-11-10 21:38:39 +0100 (Sat, 10 Nov 2007) New Revision: 22884 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22884&view=rev Modified: haiku/trunk/src/tests/apps/partitioner/Partitioner.cpp Log: The API expects the disk systems' to be referred to by pretty name. Initializing a partition with BFS works again. Modified: haiku/trunk/src/tests/apps/partitioner/Partitioner.cpp =================================================================== --- haiku/trunk/src/tests/apps/partitioner/Partitioner.cpp 2007-11-10 20:36:30 UTC (rev 22883) +++ haiku/trunk/src/tests/apps/partitioner/Partitioner.cpp 2007-11-10 20:38:39 UTC (rev 22884) @@ -346,7 +346,7 @@ { BDiskSystem diskSystem; while (roster.GetNextDiskSystem(&diskSystem) == B_OK) { - if (partition->CanInitialize(diskSystem.Name())) + if (partition->CanInitialize(diskSystem.PrettyName())) diskSystems.AddItem(new BDiskSystem(diskSystem)); } } @@ -360,7 +360,7 @@ // print the available disk systems printf("\ndisk systems that can initialize the selected partition:\n"); for (int32 i = 0; BDiskSystem* diskSystem = diskSystems.ItemAt(i); i++) - printf("%2ld %s\n", i, diskSystem->Name()); + printf("%2ld %s\n", i, diskSystem->PrettyName()); printf("\n"); @@ -385,7 +385,7 @@ // validate parameters BString validatedName(name); - if (partition->ValidateInitialize(diskSystem->Name(), + if (partition->ValidateInitialize(diskSystem->PrettyName(), supportsName ? &validatedName : NULL, parameters.String()) != B_OK) { printf("Validation of the given values failed. Sorry, can't " @@ -425,7 +425,7 @@ } // initialize - status_t error = partition->Initialize(diskSystem->Name(), + status_t error = partition->Initialize(diskSystem->PrettyName(), supportsName ? name.String() : NULL, parameters.String()); if (error != B_OK) printf("Initialization failed: %s\n", strerror(error)); From bonefish at mail.berlios.de Sat Nov 10 21:43:00 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 10 Nov 2007 21:43:00 +0100 Subject: [Haiku-commits] r22885 - haiku/trunk/build/jam Message-ID: <200711102043.lAAKh0Es009647@sheep.berlios.de> Author: bonefish Date: 2007-11-10 21:43:00 +0100 (Sat, 10 Nov 2007) New Revision: 22885 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22885&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Added the userland disk system add-ons to the image. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-10 20:38:39 UTC (rev 22884) +++ haiku/trunk/build/jam/HaikuImage 2007-11-10 20:43:00 UTC (rev 22885) @@ -396,6 +396,9 @@ AddFilesToHaikuImage beos system add-ons Screen\ Savers : $(BEOS_ADD_ONS_SCREENSAVERS) ; +AddFilesToHaikuImage beos system add-ons disk_systems + : intel bfs ; + AddDirectoryToHaikuImage home config add-ons Tracker ; AddDirectoryToHaikuImage home config add-ons Screen\ Savers ; AddDirectoryToHaikuImage home config add-ons Translators ; From axeld at mail.berlios.de Sat Nov 10 22:19:57 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 10 Nov 2007 22:19:57 +0100 Subject: [Haiku-commits] r22886 - in haiku/trunk: headers/os/drivers headers/private/fs_shell headers/private/kernel src/add-ons/kernel/file_systems/bfs src/add-ons/kernel/file_systems/cdda src/add-ons/kernel/file_systems/fat src/add-ons/kernel/file_systems/iso9660 src/system/kernel/cache src/system/kernel/fs src/system/kernel/vm src/tools/fs_shell Message-ID: <200711102119.lAALJvHS011598@sheep.berlios.de> Author: axeld Date: 2007-11-10 22:19:52 +0100 (Sat, 10 Nov 2007) New Revision: 22886 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22886&view=rev Added: haiku/trunk/src/tools/fs_shell/file_map.cpp Modified: haiku/trunk/headers/os/drivers/fs_cache.h haiku/trunk/headers/os/drivers/fs_interface.h haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h haiku/trunk/headers/private/kernel/vfs.h haiku/trunk/headers/private/kernel/vm_types.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp haiku/trunk/src/add-ons/kernel/file_systems/fat/dir.c haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.h haiku/trunk/src/add-ons/kernel/file_systems/fat/file.c haiku/trunk/src/add-ons/kernel/file_systems/fat/file.h haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp haiku/trunk/src/system/kernel/cache/Jamfile haiku/trunk/src/system/kernel/cache/file_cache.cpp haiku/trunk/src/system/kernel/cache/file_map.cpp haiku/trunk/src/system/kernel/cache/vnode_store.cpp haiku/trunk/src/system/kernel/fs/devfs.cpp haiku/trunk/src/system/kernel/fs/pipefs.cpp haiku/trunk/src/system/kernel/fs/rootfs.cpp haiku/trunk/src/system/kernel/fs/vfs.cpp haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/kernel/vm/vm_page.cpp haiku/trunk/src/system/kernel/vm/vm_store_anonymous_noswap.cpp haiku/trunk/src/system/kernel/vm/vm_store_device.c haiku/trunk/src/system/kernel/vm/vm_store_null.c haiku/trunk/src/tools/fs_shell/Jamfile haiku/trunk/src/tools/fs_shell/file_cache.cpp haiku/trunk/src/tools/fs_shell/vfs.cpp haiku/trunk/src/tools/fs_shell/vfs.h Log: * Extracted file_map API out of the file cache - it's now an optional service that can be used by file systems. * Changed the way the file cache works: instead of reading/writing to the underlying device directly, it can now be used for any data source, ie. also network file systems. * As a result, the former pages_io() moved to the VFS layer, and can now be called by a file system via {read|write}_file_io_vec_pages() (naming suggestions are always welcomed :-)). It now gets an FD, and uses that to communicate with the device (via its fs_{read|write}_pages() hooks). * The file_cache_{read|write}() functions must now be called without holding an I/O relevant file system lock. That allows the file cache to prepare the pages without colliding with the page writer, IOW the "mayBlock" flag can go into the attic again (yay!). * This also results in a much better performance when the system does I/O and is low on memory, as the page writer can now finally write back some pages, and that even without maxing out the CPU :) * The API changes put slightly more burden on the fs_{read|write}_pages() hooks, but in combination with the file_map it's still pretty straight forward. It just will have to dispatch the call to the underlying device directly, usually it will just call its fs_{read|write}_pages() hooks via the above mentioned calls. * Ported BFS and FAT to the new API, the latter has not been tested, though. * Also ported the API changes to the fs_shell. I also completely removed its file cache level page handling - the downside is that device access is no longer cached (ie. depends on the host OS now), the upside is that the code is greatly simplified. Modified: haiku/trunk/headers/os/drivers/fs_cache.h =================================================================== --- haiku/trunk/headers/os/drivers/fs_cache.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/headers/os/drivers/fs_cache.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -56,23 +56,24 @@ extern void block_cache_put(void *_cache, off_t blockNumber); /* file cache */ -extern void *file_cache_create(dev_t mountID, ino_t vnodeID, off_t size, - int fd); +extern void *file_cache_create(dev_t mountID, ino_t vnodeID, off_t size); extern void file_cache_delete(void *_cacheRef); extern status_t file_cache_set_size(void *_cacheRef, off_t size); extern status_t file_cache_sync(void *_cache); -extern status_t file_cache_invalidate_file_map(void *_cacheRef, off_t offset, - off_t size); -extern status_t file_cache_read_pages(void *_cacheRef, off_t offset, - const iovec *vecs, size_t count, size_t *_numBytes); -extern status_t file_cache_write_pages(void *_cacheRef, off_t offset, - const iovec *vecs, size_t count, size_t *_numBytes); -extern status_t file_cache_read(void *_cacheRef, off_t offset, void *bufferBase, - size_t *_size); -extern status_t file_cache_write(void *_cacheRef, off_t offset, +extern status_t file_cache_read(void *_cacheRef, void *cookie, off_t offset, + void *bufferBase, size_t *_size); +extern status_t file_cache_write(void *_cacheRef, void *cookie, off_t offset, const void *buffer, size_t *_size); +/* file map */ +extern void *file_map_create(dev_t mountID, ino_t vnodeID); +extern void file_map_delete(void *_map); +extern void file_map_set_size(void *_map, off_t size); +extern void file_map_invalidate(void *_map, off_t offset, off_t size); +extern status_t file_map_translate(void *_map, off_t offset, size_t size, + struct file_io_vec *vecs, size_t *_count); + #ifdef __cplusplus } #endif Modified: haiku/trunk/headers/os/drivers/fs_interface.h =================================================================== --- haiku/trunk/headers/os/drivers/fs_interface.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/headers/os/drivers/fs_interface.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -92,10 +92,10 @@ bool (*can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie); status_t (*read_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes, - bool mayBlock, bool reenter); + bool reenter); status_t (*write_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes, - bool mayBlock, bool reenter); + bool reenter); /* cache file access */ status_t (*get_file_map)(fs_volume fs, fs_vnode vnode, off_t offset, @@ -251,6 +251,18 @@ extern status_t unremove_vnode(dev_t mountID, ino_t vnodeID); extern status_t get_vnode_removed(dev_t mountID, ino_t vnodeID, bool* removed); +extern status_t read_pages(int fd, off_t pos, const struct iovec *vecs, + size_t count, size_t *_numBytes, bool fsReenter); +extern status_t write_pages(int fd, off_t pos, const struct iovec *vecs, + size_t count, size_t *_numBytes, bool fsReenter); +extern status_t read_file_io_vec_pages(int fd, + const struct file_io_vec *fileVecs, size_t fileVecCount, + const struct iovec *vecs, size_t vecCount, + uint32 *_vecIndex, size_t *_vecOffset, size_t *_bytes); +extern status_t write_file_io_vec_pages(int fd, + const struct file_io_vec *fileVecs, size_t fileVecCount, + const struct iovec *vecs, size_t vecCount, + uint32 *_vecIndex, size_t *_vecOffset, size_t *_bytes); // Deprecated! Will disappear soon! extern status_t notify_listener(int op, dev_t device, ino_t parentNode, Modified: haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -820,13 +820,16 @@ #define file_cache_delete fssh_file_cache_delete #define file_cache_set_size fssh_file_cache_set_size #define file_cache_sync fssh_file_cache_sync -#define file_cache_invalidate_file_map fssh_file_cache_invalidate_file_map -#define file_cache_read_pages fssh_file_cache_read_pages -#define file_cache_write_pages fssh_file_cache_write_pages #define file_cache_read fssh_file_cache_read #define file_cache_write fssh_file_cache_write +/* file map */ +#define file_map_create fssh_file_map_create +#define file_map_delete fssh_file_map_delete +#define file_map_set_size fssh_file_map_set_size +#define file_map_invalidate fssh_file_map_invalidate +#define file_map_translate fssh_file_map_translate //////////////////////////////////////////////////////////////////////////////// // #pragma mark - fssh_fs_index.h @@ -893,6 +896,10 @@ #define remove_vnode fssh_remove_vnode #define unremove_vnode fssh_unremove_vnode #define get_vnode_removed fssh_get_vnode_removed +#define read_pages fssh_read_pages +#define write_pages fssh_write_pages +#define read_file_io_vec_pages fssh_read_file_io_vec_pages +#define write_file_io_vec_pages fssh_write_file_io_vec_pages #define notify_entry_created fssh_notify_entry_created #define notify_entry_removed fssh_notify_entry_removed Modified: haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -69,26 +69,30 @@ /* file cache */ extern void * fssh_file_cache_create(fssh_mount_id mountID, - fssh_vnode_id vnodeID, fssh_off_t size, int fd); + fssh_vnode_id vnodeID, fssh_off_t size); extern void fssh_file_cache_delete(void *_cacheRef); extern fssh_status_t fssh_file_cache_set_size(void *_cacheRef, fssh_off_t size); extern fssh_status_t fssh_file_cache_sync(void *_cache); -extern fssh_status_t fssh_file_cache_invalidate_file_map(void *_cacheRef, - fssh_off_t offset, fssh_off_t size); -extern fssh_status_t fssh_file_cache_read_pages(void *_cacheRef, - fssh_off_t offset, const fssh_iovec *vecs, - fssh_size_t count, fssh_size_t *_numBytes); -extern fssh_status_t fssh_file_cache_write_pages(void *_cacheRef, - fssh_off_t offset, const fssh_iovec *vecs, - fssh_size_t count, fssh_size_t *_numBytes); -extern fssh_status_t fssh_file_cache_read(void *_cacheRef, fssh_off_t offset, - void *bufferBase, fssh_size_t *_size); -extern fssh_status_t fssh_file_cache_write(void *_cacheRef, +extern fssh_status_t fssh_file_cache_read(void *_cacheRef, void *cookie, + fssh_off_t offset, void *bufferBase, + fssh_size_t *_size); +extern fssh_status_t fssh_file_cache_write(void *_cacheRef, void *cookie, fssh_off_t offset, const void *buffer, fssh_size_t *_size); +/* file map */ +extern void * fssh_file_map_create(fssh_mount_id mountID, + fssh_vnode_id vnodeID); +extern void fssh_file_map_delete(void *_map); +extern void fssh_file_map_set_size(void *_map, fssh_off_t size); +extern void fssh_file_map_invalidate(void *_map, fssh_off_t offset, + fssh_off_t size); +extern fssh_status_t fssh_file_map_translate(void *_map, fssh_off_t offset, + fssh_size_t size, struct fssh_file_io_vec *vecs, + fssh_size_t *_count); + #ifdef __cplusplus } #endif Modified: haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -96,12 +96,10 @@ fssh_fs_cookie cookie); fssh_status_t (*read_pages)(fssh_fs_volume fs, fssh_fs_vnode vnode, fssh_fs_cookie cookie, fssh_off_t pos, const fssh_iovec *vecs, - fssh_size_t count, fssh_size_t *_numBytes, bool mayBlock, - bool reenter); + fssh_size_t count, fssh_size_t *_numBytes, bool reenter); fssh_status_t (*write_pages)(fssh_fs_volume fs, fssh_fs_vnode vnode, fssh_fs_cookie cookie, fssh_off_t pos, const fssh_iovec *vecs, - fssh_size_t count, fssh_size_t *_numBytes, bool mayBlock, - bool reenter); + fssh_size_t count, fssh_size_t *_numBytes, bool reenter); /* cache file access */ fssh_status_t (*get_file_map)(fssh_fs_volume fs, fssh_fs_vnode vnode, @@ -293,6 +291,22 @@ fssh_vnode_id vnodeID); extern fssh_status_t fssh_get_vnode_removed(fssh_mount_id mountID, fssh_vnode_id vnodeID, bool* removed); +extern fssh_status_t fssh_read_pages(int fd, fssh_off_t pos, + const struct fssh_iovec *vecs, fssh_size_t count, + fssh_size_t *_numBytes, bool fsReenter); +extern fssh_status_t fssh_write_pages(int fd, fssh_off_t pos, + const struct fssh_iovec *vecs, fssh_size_t count, + fssh_size_t *_numBytes, bool fsReenter); +extern fssh_status_t fssh_read_file_io_vec_pages(int fd, + const struct fssh_file_io_vec *fileVecs, + fssh_size_t fileVecCount, const struct fssh_iovec *vecs, + fssh_size_t vecCount, uint32_t *_vecIndex, + fssh_size_t *_vecOffset, fssh_size_t *_bytes); +extern fssh_status_t fssh_write_file_io_vec_pages(int fd, + const struct fssh_file_io_vec *fileVecs, + fssh_size_t fileVecCount, const struct fssh_iovec *vecs, + fssh_size_t vecCount, uint32_t *_vecIndex, + fssh_size_t *_vecOffset, fssh_size_t *_bytes); extern fssh_status_t fssh_notify_entry_created(fssh_mount_id device, fssh_vnode_id directory, const char *name, fssh_vnode_id node); Modified: haiku/trunk/headers/private/kernel/vfs.h =================================================================== --- haiku/trunk/headers/private/kernel/vfs.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/headers/private/kernel/vfs.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -94,11 +94,9 @@ status_t vfs_get_cookie_from_fd(int fd, void **_cookie); bool vfs_can_page(struct vnode *vnode, void *cookie); status_t vfs_read_pages(struct vnode *vnode, void *cookie, off_t pos, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, - bool fsReenter); + const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter); status_t vfs_write_pages(struct vnode *vnode, void *cookie, off_t pos, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, - bool fsReenter); + const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter); status_t vfs_get_vnode_cache(struct vnode *vnode, struct vm_cache **_cache, bool allocate); status_t vfs_get_file_map(struct vnode *vnode, off_t offset, size_t size, Modified: haiku/trunk/headers/private/kernel/vm_types.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_types.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/headers/private/kernel/vm_types.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -223,11 +223,9 @@ status_t (*commit)(struct vm_store *backingStore, off_t size); bool (*has_page)(struct vm_store *backingStore, off_t offset); status_t (*read)(struct vm_store *backingStore, off_t offset, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, - bool fsReenter); + const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter); status_t (*write)(struct vm_store *backingStore, off_t offset, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, - bool fsReenter); + const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter); status_t (*fault)(struct vm_store *backingStore, struct vm_address_space *aspace, off_t offset); status_t (*acquire_unreferenced_ref)(struct vm_store *backingStore); Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -47,7 +47,7 @@ // D() // the statements in D() are only included if DEBUG is defined -#ifdef DEBUG +#if 0//DEBUG #define PRINT(x) { __out("bfs: "); __out x; } #define REPORT_ERROR(status) \ __out("bfs: %s:%d: %s\n", __FUNCTION__, __LINE__, strerror(status)); Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2007-11-10 21:19:52 UTC (rev 22886) @@ -171,7 +171,8 @@ fID(id), fTree(NULL), fAttributes(NULL), - fCache(NULL) + fCache(NULL), + fMap(NULL) { PRINT(("Inode::Inode(volume = %p, id = %Ld) @ %p\n", volume, id, this)); @@ -189,8 +190,10 @@ if (IsContainer()) fTree = new BPlusTree(this); - if (IsFile() || IsAttribute()) - SetFileCache(file_cache_create(fVolume->ID(), ID(), Size(), fVolume->Device())); + if (IsFile() || IsAttribute()) { + SetFileCache(file_cache_create(fVolume->ID(), ID(), Size())); + SetMap(file_map_create(volume->ID(), ID())); + } } @@ -201,7 +204,8 @@ fID(id), fTree(NULL), fAttributes(NULL), - fCache(NULL) + fCache(NULL), + fMap(NULL) { PRINT(("Inode::Inode(volume = %p, transaction = %p, id = %Ld) @ %p\n", volume, &transaction, id, this)); @@ -242,6 +246,7 @@ PRINT(("Inode::~Inode() @ %p\n", this)); file_cache_delete(FileCache()); + file_map_delete(Map()); delete fTree; } @@ -384,8 +389,8 @@ // Luckily, this doesn't cause any index updates Inode *attribute; - status_t status = CreateAttribute(transaction, item->Name(), item->Type(), - &attribute); + status_t status = CreateAttribute(transaction, item->Name(), + item->Type(), &attribute); if (status < B_OK) RETURN_ERROR(status); @@ -1233,12 +1238,16 @@ if (pos < 0) return B_BAD_VALUE; + ReadLocked locker(Lock()); + if (pos >= Size() || length == 0) { *_length = 0; return B_NO_ERROR; } - return file_cache_read(FileCache(), pos, buffer, _length); + locker.Unlock(); + + return file_cache_read(FileCache(), NULL, pos, buffer, _length); } @@ -1246,6 +1255,10 @@ Inode::WriteAt(Transaction &transaction, off_t pos, const uint8 *buffer, size_t *_length) { + WriteLocked locker(Lock()); + if (locker.IsLocked() < B_OK) + RETURN_ERROR(B_ERROR); + // update the last modification time in memory, it will be written // back to the inode, and the index when the file is closed // ToDo: should update the internal last modified time only at this point! @@ -1298,7 +1311,9 @@ if (length == 0) return B_OK; - return file_cache_write(FileCache(), pos, buffer, _length); + locker.Unlock(); + + return file_cache_write(FileCache(), NULL, pos, buffer, _length); } @@ -1945,6 +1960,8 @@ return status; file_cache_set_size(FileCache(), size); + file_map_set_size(Map(), size); + return WriteBack(transaction); } @@ -2400,7 +2417,8 @@ if (inode->IsFile() || inode->IsAttribute()) { inode->SetFileCache(file_cache_create(volume->ID(), inode->ID(), - inode->Size(), volume->Device())); + inode->Size())); + inode->SetMap(file_map_create(volume->ID(), inode->ID())); } if (_created) Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -156,6 +156,8 @@ // file cache void *FileCache() const { return fCache; } void SetFileCache(void *cache) { fCache = cache; } + void *Map() const { return fMap; } + void SetMap(void *map) { fMap = map; } private: Inode(const Inode &); @@ -198,6 +200,7 @@ BPlusTree *fTree; Inode *fAttributes; void *fCache; + void *fMap; bfs_inode fNode; off_t fOldSize; Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -440,18 +440,26 @@ { fStatus = lock.Lock(); } - + ~ReadLocked() { if (fStatus == B_OK) fLock.Unlock(); } - - status_t IsLocked() + + status_t + IsLocked() { return fStatus; } + void + Unlock() + { + fLock.Unlock(); + fStatus = B_NO_INIT; + } + private: ReadWriteLock &fLock; status_t fStatus; @@ -480,11 +488,19 @@ fLock->UnlockWrite(); } - status_t IsLocked() + status_t + IsLocked() { return fStatus; } + void + Unlock() + { + fLock->UnlockWrite(); + fStatus = B_NO_INIT; + } + private: ReadWriteLock *fLock; status_t fStatus; Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-11-10 21:19:52 UTC (rev 22886) @@ -331,24 +331,43 @@ static status_t bfs_read_pages(fs_volume _fs, fs_vnode _node, fs_cookie _cookie, off_t pos, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, - bool reenter) + const iovec *vecs, size_t count, size_t *_numBytes, bool reenter) { + Volume *volume = (Volume *)_fs; Inode *inode = (Inode *)_node; if (inode->FileCache() == NULL) RETURN_ERROR(B_BAD_VALUE); - if (!reenter) { - if (mayBlock) - inode->Lock().Lock(); - else if (inode->Lock().TryLock() < B_OK) - return B_WOULD_BLOCK; + if (!reenter) + inode->Lock().Lock(); + + uint32 vecIndex = 0; + size_t vecOffset = 0; + size_t bytesLeft = *_numBytes; + status_t status; + + while (true) { + file_io_vec fileVecs[8]; + uint32 fileVecCount = 8; + + status = file_map_translate(inode->Map(), pos, bytesLeft, fileVecs, + &fileVecCount); + if (status != B_OK && status != B_BUFFER_OVERFLOW) + break; + + bool bufferOverflow = status == B_BUFFER_OVERFLOW; + + size_t bytes; + status = read_file_io_vec_pages(volume->Device(), fileVecs, + fileVecCount, vecs, count, &vecIndex, &vecOffset, &bytes); + if (status != B_OK || !bufferOverflow) + break; + + pos += bytes; + bytesLeft -= bytes; } - status_t status = file_cache_read_pages(inode->FileCache(), pos, vecs, - count, _numBytes); - if (!reenter) inode->Lock().Unlock(); @@ -358,24 +377,43 @@ static status_t bfs_write_pages(fs_volume _fs, fs_vnode _node, fs_cookie _cookie, off_t pos, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, - bool reenter) + const iovec *vecs, size_t count, size_t *_numBytes, bool reenter) { + Volume *volume = (Volume *)_fs; Inode *inode = (Inode *)_node; if (inode->FileCache() == NULL) RETURN_ERROR(B_BAD_VALUE); - if (!reenter) { - if (mayBlock) - inode->Lock().Lock(); - else if (inode->Lock().TryLock() < B_OK) - return B_WOULD_BLOCK; + if (!reenter) + inode->Lock().Lock(); + + uint32 vecIndex = 0; + size_t vecOffset = 0; + size_t bytesLeft = *_numBytes; + status_t status; + + while (true) { + file_io_vec fileVecs[8]; + uint32 fileVecCount = 8; + + status = file_map_translate(inode->Map(), pos, bytesLeft, fileVecs, + &fileVecCount); + if (status != B_OK && status != B_BUFFER_OVERFLOW) + break; + + bool bufferOverflow = status == B_BUFFER_OVERFLOW; + + size_t bytes; + status = write_file_io_vec_pages(volume->Device(), fileVecs, + fileVecCount, vecs, count, &vecIndex, &vecOffset, &bytes); + if (status != B_OK || !bufferOverflow) + break; + + pos += bytes; + bytesLeft -= bytes; } - status_t status = file_cache_write_pages(inode->FileCache(), pos, vecs, - count, _numBytes); - if (!reenter) inode->Lock().Unlock(); @@ -818,8 +856,8 @@ | INODE_LOGGED); // links usually don't have a file cache attached - but we now need one - link->SetFileCache(file_cache_create(volume->ID(), link->ID(), 0, - volume->Device())); + link->SetFileCache(file_cache_create(volume->ID(), link->ID(), 0)); + link->SetMap(file_map_create(volume->ID(), link->ID())); // The following call will have to write the inode back, so // we don't have to do that here... @@ -1067,9 +1105,6 @@ } -/** Opens the file with the specified mode. - */ - static status_t bfs_open(void *_fs, void *_node, int openMode, void **_cookie) { @@ -1133,12 +1168,9 @@ } -/** Read a file specified by node, using information in cookie - * and at offset specified by pos. read len bytes into buffer buf. - */ - static status_t -bfs_read(void *_ns, void *_node, void *_cookie, off_t pos, void *buffer, size_t *_length) +bfs_read(void *_ns, void *_node, void *_cookie, off_t pos, void *buffer, + size_t *_length) { //FUNCTION(); Inode *inode = (Inode *)_node; @@ -1148,19 +1180,15 @@ RETURN_ERROR(B_BAD_VALUE); } - ReadLocked locked(inode->Lock()); return inode->ReadAt(pos, (uint8 *)buffer, _length); } static status_t -bfs_write(void *_ns, void *_node, void *_cookie, off_t pos, const void *buffer, size_t *_length) +bfs_write(void *_ns, void *_node, void *_cookie, off_t pos, const void *buffer, + size_t *_length) { //FUNCTION(); - // uncomment to be more robust against a buggy vnode layer ;-) - //if (_ns == NULL || _node == NULL || _cookie == NULL) - // return B_BAD_VALUE; - Volume *volume = (Volume *)_ns; Inode *inode = (Inode *)_node; @@ -1174,21 +1202,20 @@ if (cookie->open_mode & O_APPEND) pos = inode->Size(); - WriteLocked locked(inode->Lock()); - if (locked.IsLocked() < B_OK) - RETURN_ERROR(B_ERROR); - Transaction transaction; // We are not starting the transaction here, since // it might not be needed at all (the contents of // regular files aren't logged) - status_t status = inode->WriteAt(transaction, pos, (const uint8 *)buffer, _length); + status_t status = inode->WriteAt(transaction, pos, (const uint8 *)buffer, + _length); if (status == B_OK) transaction.Done(); if (status == B_OK) { + ReadLocked locker(inode->Lock()); + // periodically notify if the file size has changed // ToDo: should we better test for a change in the last_modified time only? if (!inode->IsDeleted() && cookie->last_size != inode->Size() Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp 2007-11-10 21:19:52 UTC (rev 22886) @@ -1574,8 +1574,7 @@ static status_t cdda_read_pages(fs_volume _volume, fs_vnode _v, fs_cookie cookie, off_t pos, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, - bool reenter) + const iovec *vecs, size_t count, size_t *_numBytes, bool reenter) { return B_NOT_ALLOWED; } @@ -1583,8 +1582,7 @@ static status_t cdda_write_pages(fs_volume _volume, fs_vnode _v, fs_cookie cookie, off_t pos, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, - bool reenter) + const iovec *vecs, size_t count, size_t *_numBytes, bool reenter) { return B_NOT_ALLOWED; } Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/dir.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/fat/dir.c 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/fat/dir.c 2007-11-10 21:19:52 UTC (rev 22886) @@ -1038,8 +1038,9 @@ entry->filename = malloc(sizeof(filename) + 1); if (entry->filename) strcpy(entry->filename, filename); #endif - entry->cache = file_cache_create(vol->id, vnid, entry->st_size, vol->fd); - if(!(entry->mode & FAT_SUBDIR)) + entry->cache = file_cache_create(vol->id, vnid, entry->st_size); + entry->file_map = file_map_create(vol->id, vnid); + if (!(entry->mode & FAT_SUBDIR)) set_mime_type(entry, filename); *_node = entry; Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -65,12 +65,12 @@ #define VNODE_MAGIC 'treB' -typedef struct vnode -{ +typedef struct vnode { uint32 magic; ino_t vnid; // self id ino_t dir_vnid; // parent vnode id (directory containing entry) - void *cache; // for file cache + void *cache; + void *file_map; uint32 disk_image; // 0 = no, 1 = BEOS, 2 = IMAGE.BE Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/file.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/fat/file.c 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/fat/file.c 2007-11-10 21:19:52 UTC (rev 22886) @@ -141,8 +141,8 @@ if (node->vnid != vol->root_vnode.vnid) { node->magic = ~VNODE_MAGIC; // munge magic number to be safe - if (node->cache != NULL) - file_cache_delete(node->cache); + file_cache_delete(node->cache); + file_map_delete(node->file_map); free(node); } } @@ -245,6 +245,7 @@ node->iteration++; dirty = true; file_cache_set_size(node->cache, node->st_size); + file_map_set_size(node->file_map, node->st_size); } } } @@ -393,7 +394,7 @@ if (pos + *len >= node->st_size) *len = node->st_size - pos; - result = file_cache_read(node->cache, pos, buf, len); + result = file_cache_read(node->cache, cookie, pos, buf, len); #if 0 @@ -595,9 +596,10 @@ DPRINTF(0, ("setting file size to %Lx (%lx clusters)\n", node->st_size, clusters)); node->dirty = true; file_cache_set_size(node->cache, node->st_size); + file_map_set_size(node->file_map, node->st_size); } - result = file_cache_write(node->cache, pos, buf, len); + result = file_cache_write(node->cache, cookie, pos, buf, len); #if 0 if (cluster1 == 0xffffffff) { @@ -1479,11 +1481,13 @@ status_t dosfs_read_pages(fs_volume _fs, fs_vnode _node, fs_cookie _cookie, off_t pos, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, - bool reenter) + const iovec *vecs, size_t count, size_t *_numBytes, bool reenter) { nspace *vol = (nspace *)_fs; vnode *node = (vnode *)_node; + uint32 vecIndex = 0; + size_t vecOffset = 0; + size_t bytesLeft = *_numBytes; status_t status; if (check_nspace_magic(vol, "dosfs_read_pages") @@ -1493,23 +1497,49 @@ if (node->cache == NULL) return(B_BAD_VALUE); - // TODO: respect "mayBlock"! - LOCK_VOL(vol); - status = file_cache_read_pages(node->cache, pos, vecs, count, - _numBytes); - UNLOCK_VOL(vol); + if (!reenter) { + LOCK_VOL(vol); + } - return status; + while (true) { + struct file_io_vec fileVecs[8]; + uint32 fileVecCount = 8; + bool bufferOverflow; + size_t bytes; + + status = file_map_translate(node->file_map, pos, bytesLeft, fileVecs, + &fileVecCount); + if (status != B_OK && status != B_BUFFER_OVERFLOW) + break; + + bufferOverflow = status == B_BUFFER_OVERFLOW; + + status = read_file_io_vec_pages(vol->fd, fileVecs, + fileVecCount, vecs, count, &vecIndex, &vecOffset, &bytes); + if (status != B_OK || !bufferOverflow) + break; + + pos += bytes; + bytesLeft -= bytes; + } + + if (!reenter) { + UNLOCK_VOL(vol); + } + + return B_ERROR; } status_t dosfs_write_pages(fs_volume _fs, fs_vnode _node, fs_cookie _cookie, off_t pos, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, - bool reenter) + const iovec *vecs, size_t count, size_t *_numBytes, bool reenter) { nspace *vol = (nspace *)_fs; vnode *node = (vnode *)_node; + uint32 vecIndex = 0; + size_t vecOffset = 0; + size_t bytesLeft = *_numBytes; status_t status; if (check_nspace_magic(vol, "dosfs_write_pages") @@ -1519,19 +1549,43 @@ if (node->cache == NULL) return B_BAD_VALUE; - // TODO: respect "mayBlock"! - LOCK_VOL(vol); - status = file_cache_write_pages(node->cache, pos, vecs, count, - _numBytes); - UNLOCK_VOL(vol); + if (!reenter) { + LOCK_VOL(vol); + } - return status; + while (true) { + struct file_io_vec fileVecs[8]; + uint32 fileVecCount = 8; + bool bufferOverflow; + size_t bytes; + + status = file_map_translate(node->file_map, pos, bytesLeft, fileVecs, + &fileVecCount); + if (status != B_OK && status != B_BUFFER_OVERFLOW) + break; + + bufferOverflow = status == B_BUFFER_OVERFLOW; + + status = write_file_io_vec_pages(vol->fd, fileVecs, + fileVecCount, vecs, count, &vecIndex, &vecOffset, &bytes); + if (status != B_OK || !bufferOverflow) + break; + + pos += bytes; + bytesLeft -= bytes; + } + + if (!reenter) { + UNLOCK_VOL(vol); + } + + return B_ERROR; } status_t dosfs_get_file_map(void *_fs, void *_node, off_t pos, size_t len, - struct file_io_vec *vecs, size_t *_count) + struct file_io_vec *vecs, size_t *_count) { nspace *vol = (nspace *)_fs; vnode *node = (vnode *)_node; Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/file.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/fat/file.h 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/fat/file.h 2007-11-10 21:19:52 UTC (rev 22886) @@ -31,8 +31,8 @@ struct file_io_vec *vecs, size_t *_count); bool dosfs_can_page(fs_volume _fs, fs_vnode _v, fs_cookie _cookie); status_t dosfs_read_pages(fs_volume _fs, fs_vnode _node, fs_cookie _cookie, off_t pos, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, bool reenter); + const iovec *vecs, size_t count, size_t *_numBytes, bool reenter); status_t dosfs_write_pages(fs_volume _fs, fs_vnode _node, fs_cookie _cookie, off_t pos, - const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock, bool reenter); + const iovec *vecs, size_t count, size_t *_numBytes, bool reenter); #endif Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp 2007-11-10 21:19:52 UTC (rev 22886) @@ -462,7 +462,8 @@ result = ENOMEM; if (result == B_OK && !(newNode->flags & ISO_ISDIR)) { - newNode->cache = file_cache_create(ns->id, vnid, newNode->dataLen[FS_DATA_FORMAT], ns->fdOfSession); + newNode->cache = file_cache_create(ns->id, vnid, + newNode->dataLen[FS_DATA_FORMAT]); } TRACE(("fs_read_vnode - EXIT, result is %s\n", strerror(result))); @@ -567,7 +568,7 @@ // Read in the middle blocks. if (numBlocks > 0) { - for (int32 i=startBlock; i= file length, return length of 0. *len = 0; return B_OK; - } - return file_cache_read(node->cache, pos, buf, len); + } + return file_cache_read(node->cache, NULL, pos, buf, len); #endif } Modified: haiku/trunk/src/system/kernel/cache/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/cache/Jamfile 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/system/kernel/cache/Jamfile 2007-11-10 21:19:52 UTC (rev 22886) @@ -4,6 +4,7 @@ block_allocator.cpp block_cache.cpp file_cache.cpp + file_map.cpp vnode_store.cpp : $(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-11-10 20:43:00 UTC (rev 22885) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-11-10 21:19:52 UTC (rev 22886) @@ -35,42 +35,13 @@ // maximum number of iovecs per request #define MAX_IO_VECS 32 // 128 kB #define MAX_FILE_IO_VECS 32 -#define MAX_TEMP_IO_VECS 8 -#define CACHED_FILE_EXTENTS 2 - // must be smaller than MAX_FILE_IO_VECS - // ToDo: find out how much of these are typically used - #define BYPASS_IO_SIZE 65536 #define LAST_ACCESSES 3 -struct file_extent { - off_t offset; - file_io_vec disk; -}; - -struct file_map { - file_map(); - ~file_map(); - - file_extent *operator[](uint32 index); - file_extent *ExtentAt(uint32 index); - status_t Add(file_io_vec *vecs, size_t vecCount, off_t &lastOffset); - void Free(); - - union { - file_extent direct[CACHED_FILE_EXTENTS]; - file_extent *array; - }; - size_t count; -}; - struct file_cache_ref { vm_cache *cache; struct vnode *vnode; - struct vnode *device; - void *cookie; - file_map map; off_t last_access[LAST_ACCESSES]; // TODO: it would probably be enough to only store the least // significant 31 bits, and make this uint32 (one bit for @@ -79,7 +50,7 @@ bool last_access_was_write; }; -typedef status_t (*cache_func)(file_cache_ref *ref, off_t offset, +typedef status_t (*cache_func)(file_cache_ref *ref, void *cookie, off_t offset, int32 pageOffset, addr_t buffer, size_t bufferSize, size_t lastReservedPages, size_t reservePages); [... truncated: 3950 lines follow ...] From marcusoverhagen at mail.berlios.de Sat Nov 10 22:23:05 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 10 Nov 2007 22:23:05 +0100 Subject: [Haiku-commits] r22887 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200711102123.lAALN5lJ011698@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-10 22:23:04 +0100 (Sat, 10 Nov 2007) New Revision: 22887 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22887&view=rev Modified: haiku/trunk/headers/os/interface/Polygon.h haiku/trunk/src/kits/interface/Polygon.cpp Log: This hopefully stops BPoligon from corrupting memory. Modified: haiku/trunk/headers/os/interface/Polygon.h =================================================================== --- haiku/trunk/headers/os/interface/Polygon.h 2007-11-10 21:19:52 UTC (rev 22886) +++ haiku/trunk/headers/os/interface/Polygon.h 2007-11-10 21:23:04 UTC (rev 22887) @@ -38,7 +38,7 @@ private: BRect fBounds; - int32 fCount; + uint32 fCount; BPoint *fPoints; }; Modified: haiku/trunk/src/kits/interface/Polygon.cpp =================================================================== --- haiku/trunk/src/kits/interface/Polygon.cpp 2007-11-10 21:19:52 UTC (rev 22886) +++ haiku/trunk/src/kits/interface/Polygon.cpp 2007-11-10 21:23:04 UTC (rev 22887) @@ -4,23 +4,30 @@ * * Authors: * Marc Flerackers, mflerackers at androme.be + * Marcus Overhagen */ #include #include +#include #include +// Limit to avoid integer overflow when calculating the size to allocate +#define MAX_POINT_COUNT 10000000 + + BPolygon::BPolygon(const BPoint *ptArray, int32 numPoints) : fBounds(0.0, 0.0, 0.0, 0.0), fCount(numPoints), fPoints(NULL) { - if (fCount > 0) { - fPoints = (BPoint*)malloc(numPoints * sizeof(BPoint)); + if (fCount) { + if (fCount > MAX_POINT_COUNT) + debugger("BPolygon::BPolygon too many points"); // Note the use of memcpy here. The assumption is that an array of BPoints can // be copied bit by bit and not use a copy constructor or an assignment @@ -31,14 +38,24 @@ // Luckily, BPoint is a very simple class which isn't likely to change much. // // Similar use of memcpy appears later in this implementation also. - - memcpy(fPoints, ptArray, numPoints * sizeof(BPoint)); + size_t size = fCount * sizeof(BPoint); + fPoints = (BPoint *)malloc(size); + if (!fPoints) { + fprintf(stderr, "BPolygon::BPolygon out of memory\n"); + fCount = 0; + return; + } + memcpy(fPoints, ptArray, size); _ComputeBounds(); } } BPolygon::BPolygon(const BPolygon *poly) + : + fBounds(0.0, 0.0, 0.0, 0.0), + fCount(0), + fPoints(NULL) { *this = *poly; } @@ -64,11 +81,21 @@ { // Make sure we aren't trying to perform a "self assignment". if (this != &from) { + free(fPoints); fBounds = from.fBounds; fCount = from.fCount; - if (fCount > 0) { - fPoints = (BPoint*)malloc(fCount * sizeof(BPoint)); - memcpy(fPoints, from.fPoints, fCount * sizeof(BPoint)); + if (fCount) { + if (fCount > MAX_POINT_COUNT) + debugger("BPolygon::operator= too many points"); + fPoints = (BPoint *)malloc(fCount * sizeof(BPoint)); + if (!fPoints) { + fprintf(stderr, "BPolygon::operator= out of memory\n"); + fCount = 0; + } else { + memcpy(fPoints, from.fPoints, fCount * sizeof(BPoint)); + } + } else { + fPoints = NULL; } } return *this; @@ -85,11 +112,21 @@ void BPolygon::AddPoints(const BPoint *ptArray, int32 numPoints) { + if (numPoints < 0) + debugger("BPolygon::AddPoints negative points"); + if (numPoints > MAX_POINT_COUNT || (fCount + numPoints) > MAX_POINT_COUNT) + debugger("BPolygon::AddPoints too many points"); + if (numPoints > 0) { - fPoints = (BPoint*)realloc(fPoints, (fCount + numPoints) * sizeof(BPoint)); - memcpy(fPoints + fCount + numPoints, ptArray, numPoints * sizeof(BPoint)); - fCount += numPoints; - _ComputeBounds(); + BPoint *points = (BPoint *)realloc(fPoints, (fCount + numPoints) * sizeof(BPoint)); + if (!points) { + fprintf(stderr, "BPolygon::AddPoints out of memory\n"); + } else { + fPoints = points; + memcpy(fPoints + fCount, ptArray, numPoints * sizeof(BPoint)); + fCount += numPoints; + _ComputeBounds(); + } } } @@ -104,7 +141,7 @@ void BPolygon::MapTo(BRect srcRect, BRect dstRect) { - for (int32 i = 0; i < fCount; i++) + for (uint32 i = 0; i < fCount; i++) _MapPoint(fPoints + i, srcRect, dstRect); _MapRectangle(&fBounds, srcRect, dstRect); } @@ -113,7 +150,7 @@ void BPolygon::PrintToStream () const { - for (int32 i = 0; i < fCount; i++) + for (uint32 i = 0; i < fCount; i++) fPoints[i].PrintToStream(); } @@ -128,7 +165,7 @@ fBounds = BRect(fPoints[0], fPoints[0]); - for (int32 i = 1; i < fCount; i++) { + for (uint32 i = 1; i < fCount; i++) { if (fPoints[i].x < fBounds.left) fBounds.left = fPoints[i].x; if (fPoints[i].y < fBounds.top) From axeld at mail.berlios.de Sat Nov 10 22:46:57 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 10 Nov 2007 22:46:57 +0100 Subject: [Haiku-commits] r22888 - haiku/trunk/src/tools/fs_shell Message-ID: <200711102146.lAALkvmS013294@sheep.berlios.de> Author: axeld Date: 2007-11-10 22:46:57 +0100 (Sat, 10 Nov 2007) New Revision: 22888 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22888&view=rev Modified: haiku/trunk/src/tools/fs_shell/vfs.cpp Log: This might help with the build on Linux. Modified: haiku/trunk/src/tools/fs_shell/vfs.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/vfs.cpp 2007-11-10 21:23:04 UTC (rev 22887) +++ haiku/trunk/src/tools/fs_shell/vfs.cpp 2007-11-10 21:46:57 UTC (rev 22888) @@ -2064,7 +2064,7 @@ if (*_numBytes < toRead) { // We're supposed to read less than specified by the vecs. Since // readv_pos() doesn't support this, we need to clone the vecs. - newVecs = new(nothrow) fssh_iovec[count]; + newVecs = new(std::nothrow) fssh_iovec[count]; if (!newVecs) return FSSH_B_NO_MEMORY; @@ -2105,7 +2105,7 @@ if (*_numBytes < toWrite) { // We're supposed to write less than specified by the vecs. Since // writev_pos() doesn't support this, we need to clone the vecs. - newVecs = new(nothrow) fssh_iovec[count]; + newVecs = new(std::nothrow) fssh_iovec[count]; if (!newVecs) return FSSH_B_NO_MEMORY; From stippi at mail.berlios.de Sun Nov 11 00:48:54 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 11 Nov 2007 00:48:54 +0100 Subject: [Haiku-commits] r22889 - haiku/trunk/src/preferences/drivesetup Message-ID: <200711102348.lAANmslE024615@sheep.berlios.de> Author: stippi Date: 2007-11-11 00:48:53 +0100 (Sun, 11 Nov 2007) New Revision: 22889 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22889&view=rev Added: haiku/trunk/src/preferences/drivesetup/Support.cpp haiku/trunk/src/preferences/drivesetup/Support.h Modified: haiku/trunk/src/preferences/drivesetup/Jamfile haiku/trunk/src/preferences/drivesetup/MainWindow.cpp haiku/trunk/src/preferences/drivesetup/PartitionList.cpp haiku/trunk/src/preferences/drivesetup/PartitionList.h Log: * extract a Support.cpp/h with utility functions * fix the problem with duplicated parent partition entries, we need to recurse into child rows when findig a particular BRow, or else RowAt() or CountRows() will only return the top level list entries * disabled the bitmap column for now, to get a better overview of "level" * display the device path also for partitions, not just devices Modified: haiku/trunk/src/preferences/drivesetup/Jamfile =================================================================== --- haiku/trunk/src/preferences/drivesetup/Jamfile 2007-11-10 21:46:57 UTC (rev 22888) +++ haiku/trunk/src/preferences/drivesetup/Jamfile 2007-11-10 23:48:53 UTC (rev 22889) @@ -10,6 +10,7 @@ DriveSetup.cpp MainWindow.cpp PartitionList.cpp + Support.cpp : be ; Modified: haiku/trunk/src/preferences/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/MainWindow.cpp 2007-11-10 21:46:57 UTC (rev 22888) +++ haiku/trunk/src/preferences/drivesetup/MainWindow.cpp 2007-11-10 23:48:53 UTC (rev 22889) @@ -9,6 +9,7 @@ */ #include "MainWindow.h" #include "PartitionList.h" +#include "Support.h" #include @@ -37,59 +38,7 @@ PartitionListView* fPartitionList; }; -const char* -SizeAsString(off_t size, char *string) -{ - double kb = size / 1024.0; - if (kb < 1.0) { - sprintf(string, "%Ld B", size); - return string; - } - float mb = kb / 1024.0; - if (mb < 1.0) { - sprintf(string, "%3.1f KB", kb); - return string; - } - float gb = mb / 1024.0; - if (gb < 1.0) { - sprintf(string, "%3.1f MB", mb); - return string; - } - float tb = gb / 1024.0; - if (tb < 1.0) { - sprintf(string, "%3.1f GB", gb); - return string; - } - sprintf(string, "%.1f TB", tb); - return string; -} - -static void -dump_partition_info(BPartition* partition) -{ - char size[1024]; - printf("\tOffset(): %Ld\n", partition->Offset()); - printf("\tSize(): %s\n", SizeAsString(partition->Size(),size)); - printf("\tContentSize(): %s\n", SizeAsString(partition->ContentSize(), size)); - printf("\tBlockSize(): %ld\n", partition->BlockSize()); - printf("\tIndex(): %ld\n", partition->Index()); - printf("\tStatus(): %ld\n\n", partition->Status()); - printf("\tContainsFileSystem(): %s\n", partition->ContainsFileSystem() ? "true" : "false"); - printf("\tContainsPartitioningSystem(): %s\n\n", partition->ContainsPartitioningSystem() ? "true" : "false"); - printf("\tIsDevice(): %s\n", partition->IsDevice() ? "true" : "false"); - printf("\tIsReadOnly(): %s\n", partition->IsReadOnly() ? "true" : "false"); - printf("\tIsMounted(): %s\n", partition->IsMounted() ? "true" : "false"); - printf("\tIsBusy(): %s\n\n", partition->IsBusy() ? "true" : "false"); - printf("\tFlags(): %lx\n\n", partition->Flags()); - printf("\tName(): %s\n", partition->Name()); - printf("\tContentName(): %s\n", partition->ContentName()); - printf("\tType(): %s\n", partition->Type()); - printf("\tContentType(): %s\n", partition->ContentType()); - printf("\tID(): %lx\n\n", partition->ID()); -} - - enum { MSG_MOUNT_ALL = 'mnta', MSG_MOUNT = 'mnts', Modified: haiku/trunk/src/preferences/drivesetup/PartitionList.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/PartitionList.cpp 2007-11-10 21:46:57 UTC (rev 22888) +++ haiku/trunk/src/preferences/drivesetup/PartitionList.cpp 2007-11-10 23:48:53 UTC (rev 22889) @@ -6,15 +6,12 @@ * Ithamar R. Adema */ #include "PartitionList.h" +#include "Support.h" #include #include -extern const char* -SizeAsString(off_t size, char* string); //FIXME: from MainWindow.cpp - - PartitionListRow::PartitionListRow(BPartition* partition) : Inherited() , fPartitionID(partition->ID()) @@ -24,12 +21,12 @@ partition->GetPath(&path); - SetField(new BBitmapField(NULL), 0); +// SetField(new BBitmapField(NULL), 0); - if (partition->IsDevice()) // Only show device path for actual devices (so only for /dev/disk/..../raw entries) +// if (partition->IsDevice()) // Only show device path for actual devices (so only for /dev/disk/..../raw entries) SetField(new BStringField(path.Path()), 1); - else - SetField(new BStringField(""), 1); +// else +// SetField(new BStringField("n/a"), 1); // if (partition->ContainsPartitioningSystem()) { // SetField(new BStringField(partition->ContentType()), 2); @@ -51,14 +48,14 @@ SetField(new BStringField(""), 4); } - SetField(new BStringField(SizeAsString(partition->Size(), size)), 5); + SetField(new BStringField(string_for_size(partition->Size(), size)), 5); } PartitionListView::PartitionListView(const BRect& frame) : Inherited(frame, "storagelist", B_FOLLOW_ALL, 0, B_NO_BORDER, true) { - AddColumn(new BBitmapColumn("", 20, 20, 100, B_ALIGN_CENTER), 0); +// AddColumn(new BBitmapColumn("", 20, 20, 100, B_ALIGN_CENTER), 0); AddColumn(new BStringColumn("Device", 100, 50, 500, B_TRUNCATE_MIDDLE), 1); AddColumn(new BStringColumn("Filesystem", 100, 50, 500, B_TRUNCATE_MIDDLE), 2); AddColumn(new BStringColumn("Volume Name", 100, 50, 500, B_TRUNCATE_MIDDLE), 3); @@ -68,12 +65,18 @@ PartitionListRow* -PartitionListView::FindRow(partition_id id) +PartitionListView::FindRow(partition_id id, PartitionListRow* parent) { - for (int32 i = 0; i < CountRows(); i++) { - PartitionListRow* item = dynamic_cast(RowAt(i)); + for (int32 i = 0; i < CountRows(parent); i++) { + PartitionListRow* item = dynamic_cast(RowAt(i, parent)); if (item != NULL && item->ID() == id) return item; + if (CountRows(item) > 0) { + // recurse into child rows + item = FindRow(id, item); + if (item) + return item; + } } return NULL; @@ -83,28 +86,28 @@ PartitionListRow* PartitionListView::AddPartition(BPartition* partition) { - PartitionListRow* parent = NULL; - PartitionListRow* partitionrow = NULL; + PartitionListRow* partitionrow = FindRow(partition->ID()); // Forget about it if this partition is already in the listview - if ((partitionrow = FindRow(partition->ID())) != NULL) + if (partitionrow != NULL) { return partitionrow; + } // Create the row for this partition partitionrow = new PartitionListRow(partition); // If this partition has a parent... if (partition->Parent() != NULL) { -printf("partition has parent\n"); // check if it is in the listview - parent = FindRow(partition->Parent()->ID()); + PartitionListRow* parent = FindRow(partition->Parent()->ID()); // If parent of this partition is not yet in the list - if (parent == NULL) //add it + if (parent == NULL) { + // add it parent = AddPartition(partition->Parent()); + } // Now it is ok to add this partition under its parent AddRow(partitionrow, parent); } else { -printf("partition has NO parent\n"); // If this partition has no parent, add it in the 'root' AddRow(partitionrow); } Modified: haiku/trunk/src/preferences/drivesetup/PartitionList.h =================================================================== --- haiku/trunk/src/preferences/drivesetup/PartitionList.h 2007-11-10 21:46:57 UTC (rev 22888) +++ haiku/trunk/src/preferences/drivesetup/PartitionList.h 2007-11-10 23:48:53 UTC (rev 22889) @@ -22,7 +22,8 @@ public: PartitionListRow(BPartition* partition); - partition_id ID() { return fPartitionID; } + partition_id ID() const + { return fPartitionID; } private: partition_id fPartitionID; }; @@ -33,7 +34,8 @@ public: PartitionListView(const BRect& frame); - PartitionListRow* FindRow(partition_id id); + PartitionListRow* FindRow(partition_id id, + PartitionListRow* parent = NULL); PartitionListRow* AddPartition(BPartition* partition); }; Copied: haiku/trunk/src/preferences/drivesetup/Support.cpp (from rev 22860, haiku/trunk/src/preferences/drivesetup/MainWindow.cpp) =================================================================== --- haiku/trunk/src/preferences/drivesetup/MainWindow.cpp 2007-11-08 15:24:27 UTC (rev 22860) +++ haiku/trunk/src/preferences/drivesetup/Support.cpp 2007-11-10 23:48:53 UTC (rev 22889) @@ -0,0 +1,69 @@ +/* + * Copyright 2002-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. + * + * Authors: + * Erik Jaesler + * Ithamar R. Adema + * Stephan A?mus + */ +#include "Support.h" + +#include + + +const char* +string_for_size(off_t size, char *string) +{ + double kb = size / 1024.0; + if (kb < 1.0) { + sprintf(string, "%Ld B", size); + return string; + } + float mb = kb / 1024.0; + if (mb < 1.0) { + sprintf(string, "%3.1f KB", kb); + return string; + } + float gb = mb / 1024.0; + if (gb < 1.0) { + sprintf(string, "%3.1f MB", mb); + return string; + } + float tb = gb / 1024.0; + if (tb < 1.0) { + sprintf(string, "%3.1f GB", gb); + return string; + } + sprintf(string, "%.1f TB", tb); + return string; +} + + +void +dump_partition_info(const BPartition* partition) +{ + char size[1024]; + printf("\tOffset(): %Ld\n", partition->Offset()); + printf("\tSize(): %s\n", string_for_size(partition->Size(),size)); + printf("\tContentSize(): %s\n", string_for_size(partition->ContentSize(), + size)); + printf("\tBlockSize(): %ld\n", partition->BlockSize()); + printf("\tIndex(): %ld\n", partition->Index()); + printf("\tStatus(): %ld\n\n", partition->Status()); + printf("\tContainsFileSystem(): %s\n", + partition->ContainsFileSystem() ? "true" : "false"); + printf("\tContainsPartitioningSystem(): %s\n\n", + partition->ContainsPartitioningSystem() ? "true" : "false"); + printf("\tIsDevice(): %s\n", partition->IsDevice() ? "true" : "false"); + printf("\tIsReadOnly(): %s\n", partition->IsReadOnly() ? "true" : "false"); + printf("\tIsMounted(): %s\n", partition->IsMounted() ? "true" : "false"); + printf("\tIsBusy(): %s\n\n", partition->IsBusy() ? "true" : "false"); + printf("\tFlags(): %lx\n\n", partition->Flags()); + printf("\tName(): %s\n", partition->Name()); + printf("\tContentName(): %s\n", partition->ContentName()); + printf("\tType(): %s\n", partition->Type()); + printf("\tContentType(): %s\n", partition->ContentType()); + printf("\tID(): %lx\n\n", partition->ID()); +} + Added: haiku/trunk/src/preferences/drivesetup/Support.h =================================================================== --- haiku/trunk/src/preferences/drivesetup/Support.h 2007-11-10 21:46:57 UTC (rev 22888) +++ haiku/trunk/src/preferences/drivesetup/Support.h 2007-11-10 23:48:53 UTC (rev 22889) @@ -0,0 +1,20 @@ +/* + * Copyright 2002-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. + */ +#ifndef SUPPORT_H +#define SUPPORT_H + + +#include + + +class BPartition; + + +const char* string_for_size(off_t size, char *string); + +void dump_partition_info(const BPartition* partition); + + +#endif // SUPPORT_H From leavengood at mail.berlios.de Sun Nov 11 04:23:18 2007 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Sun, 11 Nov 2007 04:23:18 +0100 Subject: [Haiku-commits] r22890 - haiku/trunk/src/system/libroot/posix/glibc/arch/x86 Message-ID: <200711110323.lAB3NIQN023209@sheep.berlios.de> Author: leavengood Date: 2007-11-11 04:23:17 +0100 (Sun, 11 Nov 2007) New Revision: 22890 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22890&view=rev Modified: haiku/trunk/src/system/libroot/posix/glibc/arch/x86/Jamfile Log: I needed nextafterf support in WebKit, so I added it here. It was already defined in the headers. If this is not the correct way to do this, let me know, but it seems to work (well it compiled at least.) Modified: haiku/trunk/src/system/libroot/posix/glibc/arch/x86/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/glibc/arch/x86/Jamfile 2007-11-10 23:48:53 UTC (rev 22889) +++ haiku/trunk/src/system/libroot/posix/glibc/arch/x86/Jamfile 2007-11-11 03:23:17 UTC (rev 22890) @@ -151,6 +151,7 @@ s_log1p.S s_log1pf.S s_log1pl.S s_logb.S s_logbf.S s_logbl.c s_lrint.S s_lrintf.S s_lrintl.S + s_nextafterf.c s_rint.S s_rintf.S s_rintl.c s_scalbn.S s_scalbnf.S s_scalbnl.S s_significand.S s_significandf.S From stippi at mail.berlios.de Sun Nov 11 11:19:28 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 11 Nov 2007 11:19:28 +0100 Subject: [Haiku-commits] r22891 - haiku/trunk/src/add-ons/translators/stxt Message-ID: <200711111019.lABAJS2D024289@sheep.berlios.de> Author: stippi Date: 2007-11-11 11:19:27 +0100 (Sun, 11 Nov 2007) New Revision: 22891 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22891&view=rev Modified: haiku/trunk/src/add-ons/translators/stxt/Jamfile Log: * removed the Styled Edit Text translator from the "CVS" package for BeOS, since it doesn't build for BeOS Modified: haiku/trunk/src/add-ons/translators/stxt/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/stxt/Jamfile 2007-11-11 03:23:17 UTC (rev 22890) +++ haiku/trunk/src/add-ons/translators/stxt/Jamfile 2007-11-11 10:19:27 UTC (rev 22891) @@ -24,7 +24,7 @@ : true ; -Package haiku-translationkit-cvs : - STXTTranslator : - boot home config add-ons Translators ; +#Package haiku-translationkit-cvs : +# STXTTranslator : +# boot home config add-ons Translators ; From stippi at mail.berlios.de Sun Nov 11 11:21:29 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 11 Nov 2007 11:21:29 +0100 Subject: [Haiku-commits] r22892 - haiku/trunk/src/add-ons/translators/stxt Message-ID: <200711111021.lABALTU0024391@sheep.berlios.de> Author: stippi Date: 2007-11-11 11:21:29 +0100 (Sun, 11 Nov 2007) New Revision: 22892 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22892&view=rev Modified: haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp Log: * fixed a bug researched by Varadi Zsolt Gyula, if the buffer is one byte long or empty, assume text anyways, fixes Styled Edit opening empty files (#1610) Modified: haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp 2007-11-11 10:19:27 UTC (rev 22891) +++ haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp 2007-11-11 10:21:29 UTC (rev 22892) @@ -218,10 +218,15 @@ code = "ASCII"; encoding = NULL; //"us-ascii"; type = "text"; - } else if (looks_utf8(buf, nbytes, ubuf, &ulen)) { + } else if (nbytes == 0 || looks_utf8(buf, nbytes, ubuf, &ulen)) { code = "UTF-8 Unicode"; encoding = NULL; // "UTF-8"; type = "text"; + if (nbytes == 0) { + // this is also the Haiku default encoding + // in case we have an empty buffer + rv = 1; + } } else if ((i = looks_unicode(buf, nbytes, ubuf, &ulen)) != 0) { if (i == 1) { code = "Little-endian UTF-16 Unicode"; @@ -258,7 +263,6 @@ } if (nbytes <= 1) { - rv = 0; goto done; } From stippi at mail.berlios.de Sun Nov 11 11:29:07 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 11 Nov 2007 11:29:07 +0100 Subject: [Haiku-commits] r22893 - haiku/trunk/src/add-ons/translators/stxt Message-ID: <200711111029.lABAT7oB024669@sheep.berlios.de> Author: stippi Date: 2007-11-11 11:29:07 +0100 (Sun, 11 Nov 2007) New Revision: 22893 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22893&view=rev Modified: haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp Log: * this should cover the case where the buffer is one byte long but is _not_ a text file Modified: haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp 2007-11-11 10:21:29 UTC (rev 22892) +++ haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp 2007-11-11 10:29:07 UTC (rev 22893) @@ -218,6 +218,8 @@ code = "ASCII"; encoding = NULL; //"us-ascii"; type = "text"; + if (nbytes == 1) + rv = 1; } else if (nbytes == 0 || looks_utf8(buf, nbytes, ubuf, &ulen)) { code = "UTF-8 Unicode"; encoding = NULL; // "UTF-8"; @@ -263,6 +265,8 @@ } if (nbytes <= 1) { + if (rv == -1) + rv = 0; goto done; } From axeld at mail.berlios.de Sun Nov 11 13:55:23 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 11 Nov 2007 13:55:23 +0100 Subject: [Haiku-commits] r22894 - haiku/trunk/src/add-ons/kernel/network/stack Message-ID: <200711111255.lABCtNYq020530@sheep.berlios.de> Author: axeld Date: 2007-11-11 13:55:22 +0100 (Sun, 11 Nov 2007) New Revision: 22894 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22894&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/stack/interfaces.cpp Log: There is absolutely no need that the interface packet consumer runs at a priority that high. Modified: haiku/trunk/src/add-ons/kernel/network/stack/interfaces.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/interfaces.cpp 2007-11-11 10:29:07 UTC (rev 22893) +++ haiku/trunk/src/add-ons/kernel/network/stack/interfaces.cpp 2007-11-11 12:55:22 UTC (rev 22894) @@ -137,7 +137,7 @@ interface->reader_thread = -1; interface->consumer_thread = spawn_kernel_thread(device_consumer_thread, - name, B_REAL_TIME_DISPLAY_PRIORITY - 10, interface); + name, B_DISPLAY_PRIORITY, interface); if (interface->consumer_thread < B_OK) goto error_3; resume_thread(interface->consumer_thread); From stippi at mail.berlios.de Sun Nov 11 13:56:46 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 11 Nov 2007 13:56:46 +0100 Subject: [Haiku-commits] r22895 - haiku/trunk/src/add-ons/translators/stxt Message-ID: <200711111256.lABCukic020760@sheep.berlios.de> Author: stippi Date: 2007-11-11 13:56:46 +0100 (Sun, 11 Nov 2007) New Revision: 22895 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22895&view=rev Modified: haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp Log: * patch by vzsolt which really fixes the problem with zero byte buffers Modified: haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp 2007-11-11 12:55:22 UTC (rev 22894) +++ haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp 2007-11-11 12:56:46 UTC (rev 22895) @@ -214,21 +214,23 @@ * the text converted into one-my_unichar-per-character Unicode in * ubuf, and the number of characters converted in ulen. */ - if (looks_ascii(buf, nbytes, ubuf, &ulen)) { + if (nbytes == 0) { + code = "UTF-8 Unicode"; + encoding = NULL; // "UTF-8"; + type = "text"; + rv = 1; + } else if (looks_ascii(buf, nbytes, ubuf, &ulen)) { code = "ASCII"; encoding = NULL; //"us-ascii"; type = "text"; - if (nbytes == 1) + if (nbytes == 1) { + // no further tests rv = 1; - } else if (nbytes == 0 || looks_utf8(buf, nbytes, ubuf, &ulen)) { + } + } else if (looks_utf8(buf, nbytes, ubuf, &ulen)) { code = "UTF-8 Unicode"; encoding = NULL; // "UTF-8"; type = "text"; - if (nbytes == 0) { - // this is also the Haiku default encoding - // in case we have an empty buffer - rv = 1; - } } else if ((i = looks_unicode(buf, nbytes, ubuf, &ulen)) != 0) { if (i == 1) { code = "Little-endian UTF-16 Unicode"; From axeld at mail.berlios.de Sun Nov 11 14:00:59 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 11 Nov 2007 14:00:59 +0100 Subject: [Haiku-commits] r22896 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200711111300.lABD0xTA021660@sheep.berlios.de> Author: axeld Date: 2007-11-11 14:00:59 +0100 (Sun, 11 Nov 2007) New Revision: 22896 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22896&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h Log: Minor cleanup. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp 2007-11-11 12:56:46 UTC (rev 22895) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp 2007-11-11 13:00:59 UTC (rev 22896) @@ -1,10 +1,11 @@ -/* Journal - transaction and logging - * - * Copyright 2001-2005, Axel D?rfler, axeld at pinc-software.de. +/* + * Copyright 2001-2007, Axel D?rfler, axeld at pinc-software.de. * This file may be used under the terms of the MIT License. */ +//! Transaction and logging + #include "Journal.h" #include "Inode.h" #include "Debug.h" @@ -74,10 +75,11 @@ static void -add_to_iovec(iovec *vecs, int32 &index, int32 max, const void *address, size_t size) +add_to_iovec(iovec *vecs, int32 &index, int32 max, const void *address, + size_t size) { - if (index > 0 - && (addr_t)vecs[index - 1].iov_base + vecs[index - 1].iov_len == (addr_t)address) { + if (index > 0 && (addr_t)vecs[index - 1].iov_base + + vecs[index - 1].iov_len == (addr_t)address) { // the iovec can be combined with the previous one vecs[index - 1].iov_len += size; return; @@ -143,7 +145,8 @@ continue; if (run.Start() >= arrayRun.Start() - && run.Start() + run.Length() <= arrayRun.Start() + arrayRun.Length()) + && run.Start() + run.Length() + <= arrayRun.Start() + arrayRun.Length()) return true; } } @@ -152,11 +155,10 @@ } -/** Adds the specified block_run into the array. - * Note: it doesn't support overlapping - it must only be used - * with block_runs of length 1! - */ - +/*! Adds the specified block_run into the array. + Note: it doesn't support overlapping - it must only be used + with block_runs of length 1! +*/ bool RunArrays::_AddRun(block_run &run) { @@ -279,7 +281,8 @@ int32 blockSize = fJournal->GetVolume()->BlockSize(); for (int32 i = 0; i < CountArrays(); i++) { - ArrayAt(i)->max_runs = HOST_ENDIAN_TO_BFS_INT32(run_array::MaxRuns(blockSize)); + ArrayAt(i)->max_runs = HOST_ENDIAN_TO_BFS_INT32( + run_array::MaxRuns(blockSize)); } } @@ -348,11 +351,10 @@ } -/** Replays an entry in the log. - * \a _start points to the entry in the log, and will be bumped to the next - * one if replaying succeeded. - */ - +/*! Replays an entry in the log. + \a _start points to the entry in the log, and will be bumped to the next + one if replaying succeeded. +*/ status_t Journal::_ReplayRunArray(int32 *_start) { @@ -365,7 +367,8 @@ CachedBlock cachedArray(fVolume); - const run_array *array = (const run_array *)cachedArray.SetTo(logOffset + blockNumber); + const run_array *array = (const run_array *)cachedArray.SetTo(logOffset + + blockNumber); if (array == NULL) return B_IO_ERROR; @@ -377,8 +380,8 @@ CachedBlock cached(fVolume); for (int32 index = 0; index < array->CountRuns(); index++) { const block_run &run = array->RunAt(index); - PRINT(("replay block run %lu:%u:%u in log at %Ld!\n", run.AllocationGroup(), - run.Start(), run.Length(), blockNumber)); + PRINT(("replay block run %lu:%u:%u in log at %Ld!\n", + run.AllocationGroup(), run.Start(), run.Length(), blockNumber)); off_t offset = fVolume->ToOffset(run); for (int32 i = 0; i < run.Length(); i++) { @@ -401,13 +404,12 @@ } -/** Replays all log entries - this will put the disk into a - * consistent and clean state, if it was not correctly unmounted - * before. - * This method is called by Journal::InitCheck() if the log start - * and end pointer don't match. - */ - +/*! Replays all log entries - this will put the disk into a + consistent and clean state, if it was not correctly unmounted + before. + This method is called by Journal::InitCheck() if the log start + and end pointer don't match. +*/ status_t Journal::ReplayLog() { @@ -443,12 +445,11 @@ } -/** This is a callback function that is called by the cache, whenever - * a block is flushed to disk that was updated as part of a transaction. - * This is necessary to keep track of completed transactions, to be - * able to update the log start pointer. - */ - +/*! This is a callback function that is called by the cache, whenever + a block is flushed to disk that was updated as part of a transaction. + This is necessary to keep track of completed transactions, to be + able to update the log start pointer. +*/ void Journal::_blockNotify(int32 transactionID, void *arg) { @@ -470,7 +471,8 @@ int32 length = next->Start() - logEntry->Start(); // log entries inbetween could have been already released, so // we can't just use LogEntry::Length() here - superBlock.log_start = (superBlock.log_start + length) % journal->fLogSize; + superBlock.log_start = (superBlock.log_start + length) + % journal->fLogSize; } else superBlock.log_start = journal->fVolume->LogEnd(); @@ -521,8 +523,8 @@ uint32 cookie = 0; off_t blockNumber; - while (cache_next_block_in_transaction(fVolume->BlockCache(), fTransactionID, - &cookie, &blockNumber, NULL, NULL) == B_OK) { + while (cache_next_block_in_transaction(fVolume->BlockCache(), + fTransactionID, &cookie, &blockNumber, NULL, NULL) == B_OK) { status = runArrays.Insert(blockNumber); if (status < B_OK) { FATAL(("filling log entry failed!")); @@ -592,10 +594,12 @@ // make blocks available in the cache const void *data; if (j == 0) { - data = block_cache_get_etc(fVolume->BlockCache(), blockNumber, - blockNumber, run.Length()); - } else - data = block_cache_get(fVolume->BlockCache(), blockNumber + j); + data = block_cache_get_etc(fVolume->BlockCache(), + blockNumber, blockNumber, run.Length()); + } else { + data = block_cache_get(fVolume->BlockCache(), + blockNumber + j); + } if (data == NULL) return B_IO_ERROR; @@ -608,8 +612,8 @@ // write back log entry if (count > 0) { logPosition = logStart + count; - if (writev_pos(fVolume->Device(), logOffset + (logStart << blockShift), - vecs, index) < 0) + if (writev_pos(fVolume->Device(), logOffset + + (logStart << blockShift), vecs, index) < 0) FATAL(("could not write log area: %s!\n", strerror(errno))); } @@ -624,7 +628,8 @@ } } - LogEntry *logEntry = new LogEntry(this, fVolume->LogEnd(), runArrays.Length()); + LogEntry *logEntry = new LogEntry(this, fVolume->LogEnd(), + runArrays.Length()); if (logEntry == NULL) { FATAL(("no memory to allocate log entries!")); return B_NO_MEMORY; @@ -651,7 +656,8 @@ fUsed += logEntry->Length(); fEntriesLock.Unlock(); - cache_end_transaction(fVolume->BlockCache(), fTransactionID, _blockNotify, logEntry); + cache_end_transaction(fVolume->BlockCache(), fTransactionID, _blockNotify, + logEntry); // If the log goes to the next round (the log is written as a // circular buffer), all blocks will be flushed out which is @@ -754,7 +760,8 @@ uint32 Journal::_TransactionSize() const { - int32 count = cache_blocks_in_transaction(fVolume->BlockCache(), fTransactionID); + int32 count = cache_blocks_in_transaction(fVolume->BlockCache(), + fTransactionID); if (count < 0) return 0; Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h 2007-11-11 12:56:46 UTC (rev 22895) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h 2007-11-11 13:00:59 UTC (rev 22896) @@ -1,6 +1,5 @@ -/* Journal - transaction and logging - * - * Copyright 2001-2005, Axel D?rfler, axeld at pinc-software.de. +/* + * Copyright 2001-2007, Axel D?rfler, axeld at pinc-software.de. * This file may be used under the terms of the MIT License. */ #ifndef JOURNAL_H @@ -119,14 +118,16 @@ status_t Start(Volume *volume, off_t refBlock); bool IsStarted() const { return fJournal != NULL; } - void Done() + void + Done() { if (fJournal != NULL) fJournal->Unlock(this, true); fJournal = NULL; } - bool HasParent() + bool + HasParent() { if (fJournal != NULL) return fJournal->CurrentTransaction() == this; @@ -134,7 +135,8 @@ return false; } - status_t WriteBlocks(off_t blockNumber, const uint8 *buffer, size_t numBlocks = 1) + status_t + WriteBlocks(off_t blockNumber, const uint8 *buffer, size_t numBlocks = 1) { if (fJournal == NULL) return B_NO_INIT; @@ -148,8 +150,10 @@ return B_ERROR; } - Volume *GetVolume() { return fJournal != NULL ? fJournal->GetVolume() : NULL; } - int32 ID() const { return fJournal->TransactionID(); } + Volume *GetVolume() + { return fJournal != NULL ? fJournal->GetVolume() : NULL; } + int32 ID() const + { return fJournal->TransactionID(); } private: Transaction(const Transaction &); From axeld at mail.berlios.de Sun Nov 11 14:07:56 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 11 Nov 2007 14:07:56 +0100 Subject: [Haiku-commits] r22897 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200711111307.lABD7uSD022289@sheep.berlios.de> Author: axeld Date: 2007-11-11 14:07:56 +0100 (Sun, 11 Nov 2007) New Revision: 22897 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22897&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp Log: * The previous locking order "inode write" -> "journal" was not only not honoured (in the Inode attribute code), it also couldn't be honoured there. Therefore, the locking order is now reversed, that is "journal" comes first, then the Inode write lock. This should also help with the lock ups that appeared after r22886. * Got rid of INODE_NO_TRANSACTION; it doesn't make any sense to use. * When Inode::WriteAttribute() changed the type, the type field was actually never written back within the current transaction. * If the attribute data fit into the inode again, the attribute's write lock was never released. * Since r22886, Inode::ReadAt() does its own locking, so we must no longer lock the inode before calling it. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2007-11-11 13:00:59 UTC (rev 22896) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2007-11-11 13:07:56 UTC (rev 22897) @@ -55,11 +55,13 @@ status_t -InodeAllocator::New(block_run *parentRun, mode_t mode, block_run &run, Inode **_inode) +InodeAllocator::New(block_run *parentRun, mode_t mode, block_run &run, + Inode **_inode) { Volume *volume = fTransaction->GetVolume(); - status_t status = volume->AllocateForInode(*fTransaction, parentRun, mode, fRun); + status_t status = volume->AllocateForInode(*fTransaction, parentRun, mode, + fRun); if (status < B_OK) { // don't free the space in the destructor, because // the allocation failed @@ -101,7 +103,8 @@ if (fInode->IsRegularNode()) { if (tree->Insert(*fTransaction, ".", fInode->ID()) < B_OK - || tree->Insert(*fTransaction, "..", volume->ToVnode(fInode->Parent())) < B_OK) + || tree->Insert(*fTransaction, "..", + volume->ToVnode(fInode->Parent())) < B_OK) return B_ERROR; } return B_OK; @@ -833,11 +836,7 @@ Inode *attribute; status_t status = GetAttribute(name, &attribute); if (status == B_OK) { - if (attribute->Lock().Lock() == B_OK) { - status = attribute->ReadAt(pos, (uint8 *)buffer, _length); - attribute->Lock().Unlock(); - } else - status = B_ERROR; + status = attribute->ReadAt(pos, (uint8 *)buffer, _length); ReleaseAttribute(attribute); } @@ -862,6 +861,8 @@ // TODO: we actually depend on that the contents of "buffer" are constant. // If they get changed during the write (hey, user programs), we may mess // up our index trees! + // TODO: for attribute files, we need to log the first BPLUSTREE_MAX_KEY_LENGTH + // bytes of the data stream, or the same as above might happen. Index index(fVolume); index.SetTo(name); @@ -916,19 +917,24 @@ // check if the data fits into the small_data section again NodeGetter node(fVolume, transaction, this); - status = _AddSmallData(transaction, node, name, type, buffer, *_length); + status = _AddSmallData(transaction, node, name, type, buffer, + *_length); + if (status == B_OK) { // it does - remove its file + attribute->Lock().UnlockWrite(); status = _RemoveAttribute(transaction, name, false, NULL); } else { - status = attribute->WriteAt(transaction, pos, buffer, _length); + // The attribute type might have been changed - we need to + // adopt the new one + attribute->Node().type = HOST_ENDIAN_TO_BFS_INT32(type); + status = attribute->WriteBack(transaction); + attribute->Lock().UnlockWrite(); + if (status == B_OK) { - // The attribute type might have been changed - we need to adopt - // the new one - the attribute's inode will be written back on close - attribute->Node().type = HOST_ENDIAN_TO_BFS_INT32(type); + status = attribute->WriteAt(transaction, pos, buffer, + _length); } - - attribute->Lock().UnlockWrite(); } } else status = B_ERROR; @@ -976,8 +982,8 @@ uint32 length = smallData->DataSize(); if (length > BPLUSTREE_MAX_KEY_LENGTH) length = BPLUSTREE_MAX_KEY_LENGTH; - index.Update(transaction, name, smallData->Type(), smallData->Data(), - length, NULL, 0, this); + index.Update(transaction, name, smallData->Type(), + smallData->Data(), length, NULL, 0, this); } fSmallDataLock.Unlock(); } @@ -1224,14 +1230,6 @@ status_t Inode::ReadAt(off_t pos, uint8 *buffer, size_t *_length) { -#if 0 - // call the right ReadAt() method, depending on the inode flags - - if (Flags() & INODE_LOGGED) - return ((Stream *)this)->ReadAt(pos, buffer, _length); - - return ((Stream *)this)->ReadAt(pos, buffer, _length); -#endif size_t length = *_length; // set/check boundaries for pos/length @@ -1266,27 +1264,28 @@ << INODE_TIME_SHIFT); // TODO: support INODE_LOGGED! -#if 0 - if (Flags() & INODE_LOGGED) - return ((Stream *)this)->WriteAt(transaction, pos, buffer, _length); - return ((Stream *)this)->WriteAt(transaction, pos, buffer, _length); -#endif size_t length = *_length; + bool changeSize = false; // set/check boundaries for pos/length if (pos < 0) return B_BAD_VALUE; + if (pos + length > Size()) + changeSize = true; + + locker.Unlock(); + + // the transaction doesn't have to be started already + if (changeSize && !transaction.IsStarted()) + transaction.Start(fVolume, BlockNumber()); + + locker.Lock(); + if (pos + length > Size()) { off_t oldSize = Size(); - // the transaction doesn't have to be started already - // ToDo: what's that INODE_NO_TRANSACTION flag good for again? - if ((Flags() & INODE_NO_TRANSACTION) == 0 - && !transaction.IsStarted()) - transaction.Start(fVolume, BlockNumber()); - // let's grow the data stream to the size needed status_t status = SetFileSize(transaction, pos + length); if (status < B_OK) { Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h 2007-11-11 13:00:59 UTC (rev 22896) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h 2007-11-11 13:07:56 UTC (rev 22897) @@ -479,7 +479,7 @@ : fLock(lock) { - fStatus = lock != NULL ? lock->LockWrite() : B_ERROR; + fStatus = lock != NULL ? lock->LockWrite() : B_NO_INIT; } ~WriteLocked() @@ -489,6 +489,14 @@ } status_t + Lock() + { + if (fStatus == B_OK) + return B_ERROR; + return fStatus = fLock->LockWrite(); + } + + status_t IsLocked() { return fStatus; @@ -497,8 +505,9 @@ void Unlock() { - fLock->UnlockWrite(); - fStatus = B_NO_INIT; + if (fStatus == B_OK) + fLock->UnlockWrite(); + fStatus = B_ERROR; } private: Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h 2007-11-11 13:00:59 UTC (rev 22896) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h 2007-11-11 13:07:56 UTC (rev 22897) @@ -217,7 +217,6 @@ INODE_PERMANENT_FLAGS = 0x0000ffff, INODE_WAS_WRITTEN = 0x00020000, - INODE_NO_TRANSACTION = 0x00040000, INODE_DONT_FREE_SPACE = 0x00080000, // only used by the "chkbfs" functionality INODE_CHKBFS_RUNNING = 0x00200000, }; Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-11-11 13:00:59 UTC (rev 22896) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-11-11 13:07:56 UTC (rev 22897) @@ -694,20 +694,19 @@ Volume *volume = (Volume *)_ns; Inode *inode = (Inode *)_node; - // that may be incorrect here - I don't think we need write access to - // change most of the stat... - // we should definitely check a bit more if the new stats are correct and valid... + // TODO: we should definitely check a bit more if the new stats are + // valid - or even better, the VFS should check this before calling us status_t status = inode->CheckPermissions(W_OK); if (status < B_OK) RETURN_ERROR(status); + Transaction transaction(volume, inode->BlockNumber()); + WriteLocked locked(inode->Lock()); if (locked.IsLocked() < B_OK) RETURN_ERROR(B_ERROR); - Transaction transaction(volume, inode->BlockNumber()); - bfs_inode &node = inode->Node(); if (mask & B_STAT_SIZE) { @@ -737,7 +736,8 @@ if (mask & B_STAT_MODE) { PRINT(("original mode = %ld, stat->st_mode = %d\n", node.Mode(), stat->st_mode)); - node.mode = HOST_ENDIAN_TO_BFS_INT32(node.Mode() & ~S_IUMSK | stat->st_mode & S_IUMSK); + node.mode = HOST_ENDIAN_TO_BFS_INT32(node.Mode() & ~S_IUMSK + | stat->st_mode & S_IUMSK); } if (mask & B_STAT_UID) @@ -762,7 +762,8 @@ (bigtime_t)stat->st_crtime << INODE_TIME_SHIFT); } - if ((status = inode->WriteBack(transaction)) == B_OK) + status = inode->WriteBack(transaction); + if (status == B_OK) transaction.Done(); notify_stat_changed(volume->ID(), inode->ID(), mask); @@ -772,8 +773,8 @@ status_t -bfs_create(void *_ns, void *_directory, const char *name, int openMode, int mode, - void **_cookie, ino_t *_vnodeID) +bfs_create(void *_ns, void *_directory, const char *name, int openMode, + int mode, void **_cookie, ino_t *_vnodeID) { FUNCTION_START(("name = \"%s\", perms = %d, openMode = %d\n", name, mode, openMode)); @@ -1147,8 +1148,8 @@ // Should we truncate the file? if (openMode & O_TRUNC) { + Transaction transaction(volume, inode->BlockNumber()); WriteLocked locked(inode->Lock()); - Transaction transaction(volume, inode->BlockNumber()); status_t status = inode->SetFileSize(transaction, 0); if (status >= B_OK) @@ -1255,25 +1256,32 @@ return B_BAD_VALUE; file_cookie *cookie = (file_cookie *)_cookie; - Volume *volume = (Volume *)_ns; Inode *inode = (Inode *)_node; - WriteLocked locked(inode->Lock()); + Transaction transaction; + bool needsTrimming; - bool needsTrimming = inode->NeedsTrimming(); + { + ReadLocked locker(inode->Lock()); + needsTrimming = inode->NeedsTrimming(); - if ((cookie->open_mode & O_RWMASK) != 0 - && !inode->IsDeleted() - && (needsTrimming - || inode->OldLastModified() != inode->LastModified() - || inode->OldSize() != inode->Size())) { + if ((cookie->open_mode & O_RWMASK) != 0 + && !inode->IsDeleted() + && (needsTrimming + || inode->OldLastModified() != inode->LastModified() + || inode->OldSize() != inode->Size())) { + locker.Unlock(); + transaction.Start(volume, inode->BlockNumber()); + } + } + WriteLocked locker(inode->Lock()); + status_t status = B_ERROR; + + if (transaction.IsStarted()) { // trim the preallocated blocks and update the size, // and last_modified indices if needed - - Transaction transaction(volume, inode->BlockNumber()); - status_t status = B_OK; bool changedSize = false, changedTime = false; Index index(volume); @@ -1299,14 +1307,14 @@ inode->WriteBack(transaction); } - if (status == B_OK) - transaction.Done(); - if (changedSize || changedTime) { notify_stat_changed(volume->ID(), inode->ID(), - (changedTime ? B_STAT_MODIFICATION_TIME : 0) | (changedSize ? B_STAT_SIZE : 0)); + (changedTime ? B_STAT_MODIFICATION_TIME : 0) + | (changedSize ? B_STAT_SIZE : 0)); } } + if (status == B_OK) + transaction.Done(); if (inode->Flags() & INODE_CHKBFS_RUNNING) { // "chkbfs" exited abnormally, so we have to stop it here... From axeld at pinc-software.de Sun Nov 11 14:37:03 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 11 Nov 2007 14:37:03 +0100 CET Subject: [Haiku-commits] r22895 - haiku/trunk/src/add-ons/translators/stxt In-Reply-To: <200711111256.lABCukic020760@sheep.berlios.de> Message-ID: <17410825021-BeMail@zon> stippi at BerliOS wrote: > + } else if (looks_ascii(buf, nbytes, ubuf, &ulen)) { BTW there is an superfluous tab in that line :-) Bye, Axel. From stippi at mail.berlios.de Sun Nov 11 15:45:04 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 11 Nov 2007 15:45:04 +0100 Subject: [Haiku-commits] r22898 - haiku/trunk/src/add-ons/translators/stxt Message-ID: <200711111445.lABEj4hH029421@sheep.berlios.de> Author: stippi Date: 2007-11-11 15:45:04 +0100 (Sun, 11 Nov 2007) New Revision: 22898 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22898&view=rev Modified: haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp Log: * remove superfluous tab Modified: haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp 2007-11-11 13:07:56 UTC (rev 22897) +++ haiku/trunk/src/add-ons/translators/stxt/STXTTranslator.cpp 2007-11-11 14:45:04 UTC (rev 22898) @@ -219,7 +219,7 @@ encoding = NULL; // "UTF-8"; type = "text"; rv = 1; - } else if (looks_ascii(buf, nbytes, ubuf, &ulen)) { + } else if (looks_ascii(buf, nbytes, ubuf, &ulen)) { code = "ASCII"; encoding = NULL; //"us-ascii"; type = "text"; From mmu_man at mail.berlios.de Sun Nov 11 15:56:24 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 11 Nov 2007 15:56:24 +0100 Subject: [Haiku-commits] r22899 - in haiku/trunk/src/apps: . 3dmov Message-ID: <200711111456.lABEuOv0030109@sheep.berlios.de> Author: mmu_man Date: 2007-11-11 15:56:22 +0100 (Sun, 11 Nov 2007) New Revision: 22899 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22899&view=rev Added: haiku/trunk/src/apps/3dmov/ haiku/trunk/src/apps/3dmov/3dmov.rdef haiku/trunk/src/apps/3dmov/CubeView.cpp haiku/trunk/src/apps/3dmov/CubeView.h haiku/trunk/src/apps/3dmov/GLMovApp.cpp haiku/trunk/src/apps/3dmov/GLMovApp.h haiku/trunk/src/apps/3dmov/GLMovMessages.h haiku/trunk/src/apps/3dmov/GLMovStrings.h haiku/trunk/src/apps/3dmov/GLMovView.cpp haiku/trunk/src/apps/3dmov/GLMovView.h haiku/trunk/src/apps/3dmov/GLMovWindow.cpp haiku/trunk/src/apps/3dmov/GLMovWindow.h haiku/trunk/src/apps/3dmov/Jamfile haiku/trunk/src/apps/3dmov/makefile Log: A canvas for a reimplementation of the memorable 3DMov demo, this time using OpenGL and the Media Kit. Stippi, an HVIF icon please ;) Added: haiku/trunk/src/apps/3dmov/3dmov.rdef =================================================================== --- haiku/trunk/src/apps/3dmov/3dmov.rdef 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/3dmov.rdef 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,93 @@ +/* +** /Data/haiku/trunk/src/apps/3dmov/3dmov.rdef +** +** Automatically generated by BResourceParser on +** Tuesday, May 08, 2007 at 16:24:02. +** +*/ + +resource(1, "BEOS:APP_FLAGS") (#'APPF') $"00000000"; + +resource(1, "BEOS:APP_VERSION") #'APPV' array { + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"000000000000000000000000000000000000000080031200FC105760EC111000" + $"EC088BC800000000FC1057808003220080052980800294408000600380032200" + $"8005298000000002FC1057C0FC105A7C000000018003E7800000000280032200" + $"800529808002944080006003EC02ECB88005298000000000FC1057D0EC111000" + $"EC01BE200000000200000000FC105A7C000000018003E7800000000280006003" + $"000000028001DEE88001DEF8EC02ECB88004B38000000000FC1058108003E780" + $"EC01BE20EC02ECB8FC105810EC111000EC01BE7C00000001FC10582000000000" + $"EC02ECBCFFFFFFFFEC05B434FC1058B88005298080029440FC10585080019244" + $"FC1059B8EC02ECB8FC105850EC111000EC01BE7C8002A680FC105870EC111000" + $"80052980FFFFFFFFEC05B434FC10593800000004000201DC800060038003E780" + $"8005298000000000FC105890420C0000EC019C080000010043300000EC111000" + $"8004B38000000000" +}; + +resource(101, "BEOS:L:STD_ICON") #'ICON' array { + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF005D00FFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF005D5D00FFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF005D5D5D00FFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF003F5D5D5D5D00FFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF003F5D5D5D5D00FFFFFFFFFFFFFF" + $"FFFFFFFF000000FFFFFFFFFFFFFFFFFFFF00FA3F5D5D5D5D5D00FFFFFFFFFFFF" + $"FFFFFF005E5E5E0000FFFFFFFFFFFFFFFF00FA3F5D5D5D5D5D00FFFFFFFFFFFF" + $"FFFF005E5E5E5E5E5E0000FFFFFFFFFF00FAFA3F5D5D5D5D5D00FFFFFFFFFFFF" + $"FF005E5E5E5E5E5E5E5E5E00FFFFFFFF00FAFAFA3F5D5D5D5D5D00FFFFFFFFFF" + $"005E5E5E5E5E5E5E5E5EB200FFFFFF00FAFAFAFA3F5D5D5D5D5D00FFFFFFFFFF" + $"00B2B25E5E5E5E5E5EB22100FFFF00FAFAFAFAFA3F5D5D5D5D5D5D00FFFFFFFF" + $"002121B2B25E5E5EB2212400FFFF00FAFAFAFAFAFA3F5D5D5D5D5D00FFFFFFFF" + $"0021212021B2B2B221242500FF00FAFAFAFAFAFAFA3F5D5D5D5D5D5D00FFFFFF" + $"002121202121BE2124252500FF00FAFAFAFAFAFAFAFA3F5D5D5D5D5D00FFFFFF" + $"002121202121BE212425250000FAFAFAFAFAFAFAFAFA3F5D5D5D5D5D00FFFFFF" + $"002121202121BE212425250000FAFAFAFAFAFAFAFAFA3F5D5D5D5D5D5D00FFFF" + $"002121202121BE2124252500FF0000FAFAFA00000000003F5D5D5D5D5D0011FF" + $"002121202121BE2124252500FFFFFF0000002FEB2F302F00005D5D5D5D001111" + $"002121202121BE2124252500FFFFFF002F2B2B2B2D2D2F302F005D5D00111111" + $"002121202121BE2124252500FFFF002F2B2A2B2A2C2C2BEB2F2F0000111111FF" + $"002121202121BE2124252500FFFF002B2B2B2A2B2B2B2D2D2F2F00111111FFFF" + $"002121202121BE2124252500FF002F2B2B2A5A2B2B2B2C2D2DEB3000FFFFFFFF" + $"002121202121BE212425250011002F2B2B5A3F5A2B2C2C2D2D2F2F00FFFFFFFF" + $"002121202121BE212425250011002F2C2C2A5A2C2B2C2C2DEB2F2F00FFFFFFFF" + $"002121202121BE21242500111100302E2B2C2B2B2C2C2D2CEB2F2F0011FFFFFF" + $"FF0000212120BE2124001111FF002F2F2D2C2C2C2C2D2D2E2EEB30001111FFFF" + $"FFFFFF000021BE21001111FFFFFF00302D2D2D2C2D2DEBEB2F2F00111111FFFF" + $"FFFFFFFFFF0000001111FFFFFFFF00302EEBEBEBEBEBEB2FEB3000111111FFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00302F2FEB2FEB2F2F2F0011111111FFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000302F2F302F000011111111FFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000011111111FFFFFFFFFF" +}; + +resource(101, "BEOS:M:STD_ICON") #'MICN' array { + $"FFFFFFFFFFFFFFFFFFFFFF0000FFFFFF" + $"FFFFFFFFFFFFFFFFFFFF005D5D00FFFF" + $"FFFF000000FFFFFFFF005D5D5D00FFFF" + $"FF005E5E5E00FFFF00FA5D5D5D00FFFF" + $"005E5E5E5E5E00FF00FAFA5D5D5D00FF" + $"00215E5E5E250000FAFAFA5D5D5D00FF" + $"0021212025250000FAFAFA5D5D5D5D00" + $"00202121242500FAFAFAFAFA5D5D5D00" + $"00212021252400FAFA000000005D5D00" + $"00212120252500FA002B2D2F30000000" + $"00202121242500002B2B2B2D2D2F0011" + $"00212021252400002B5A2C2C2D2F00FF" + $"00212120250000002D2B2B2D2D2F0011" + $"00002120001111002F2E2C2E2E2F0011" + $"FFFF00001111FFFF0030EB2F2F001111" + $"FFFFFFFFFFFFFFFFFF00000000111111" +}; + +resource(1, "BEOS:APP_SIG") (#'MIMS') "application/x-vnd.Haiku-3DMov"; + +resource(1, "BEOS:FILE_TYPES") message { }; + Added: haiku/trunk/src/apps/3dmov/CubeView.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/CubeView.cpp 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/CubeView.cpp 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,35 @@ +/* + ----------------------------------------------------------------------------- + + File: CubeView.cpp + + Date: 10/20/2004 + + Description: 3DMov reloaded... + + Author: Fran?ois Revol. + + + Copyright 2004, yellowTAB GmbH, All rights reserved. + + + ----------------------------------------------------------------------------- +*/ + +#include +#include +#include "CubeView.h" + +CubeView::CubeView(BRect frame) + : GLMovView(frame) +{ +} + +CubeView::~CubeView() +{ +} + +void CubeView::AttachedToWindow() +{ + +} Added: haiku/trunk/src/apps/3dmov/CubeView.h =================================================================== --- haiku/trunk/src/apps/3dmov/CubeView.h 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/CubeView.h 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,32 @@ +/* + ----------------------------------------------------------------------------- + + File: CubeView.h + + Date: 10/20/2004 + + Description: 3DMov reloaded... + + Author: Fran?ois Revol. + + + Copyright 2004, yellowTAB GmbH, All rights reserved. + + + ----------------------------------------------------------------------------- +*/ +#ifndef _CUBEVIEW_H +#define _CUBEVIEW_H + +#include "GLMovView.h" + +class CubeView: public GLMovView +{ + public: + CubeView(BRect frame); + ~CubeView(); + virtual void AttachedToWindow(); + +}; + +#endif /* _CUBEVIEW_H */ Added: haiku/trunk/src/apps/3dmov/GLMovApp.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovApp.cpp 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/GLMovApp.cpp 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,54 @@ +/* + ----------------------------------------------------------------------------- + + File: GLMovApp.cpp + + Date: 10/20/2004 + + Description: 3DMov reloaded... + + Author: Fran?ois Revol. + + + Copyright 2004, yellowTAB GmbH, All rights reserved. + + + ----------------------------------------------------------------------------- +*/ + +#include +#include "GLMovApp.h" +#include "GLMovStrings.h" +#include "GLMovWindow.h" + +GLMovApp::GLMovApp() + : BApplication("application/x-vnd.Be-3DM2") +{ +} + +GLMovApp::~GLMovApp() +{ +} + +void GLMovApp::ReadyToRun() +{ + GLMovWindow *win = GLMovWindow::MakeWindow(OBJ_CUBE); +} + +void GLMovApp::AboutRequested() +{ + BAlert *alert; + alert = new BAlert("about", STR_ABOUT_TEXT, STR_OK); + alert->Go(NULL); +} + +void GLMovApp::MessageReceived(BMessage *message) +{ +} + +int main(int argc, char **argv) +{ + GLMovApp app; + app.Run(); + return 0; +} Added: haiku/trunk/src/apps/3dmov/GLMovApp.h =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovApp.h 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/GLMovApp.h 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,34 @@ +/* + ----------------------------------------------------------------------------- + + File: GLMovApp.h + + Date: 10/20/2004 + + Description: 3DMov reloaded... + + Author: Fran?ois Revol. + + + Copyright 2004, yellowTAB GmbH, All rights reserved. + + + ----------------------------------------------------------------------------- +*/ +#ifndef _GLMOVAPP_H +#define _GLMOVAPP_H + +#include + +class GLMovApp: public BApplication +{ + public: + GLMovApp(); + ~GLMovApp(); + virtual void ReadyToRun(); + virtual void AboutRequested(); + virtual void MessageReceived(BMessage *message); + +}; + +#endif /* _GLMOVAPP_H */ Added: haiku/trunk/src/apps/3dmov/GLMovMessages.h =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovMessages.h 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/GLMovMessages.h 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,27 @@ +/* + ----------------------------------------------------------------------------- + + File: GLMovStrings.h + + Date: 10/20/2004 + + Description: 3DMov reloaded... + + Author: Fran?ois Revol. + + + Copyright 2004, yellowTAB GmbH, All rights reserved. + + + ----------------------------------------------------------------------------- +*/ +#ifndef _GLMOVMESSAGES_H +#define _GLMOVMESSAGES_H + +#define MSG_OBJ1 'Obj1' +#define MSG_OBJ2 'Obj2' +#define MSG_OBJ3 'Obj3' +#define MSG_OBJ4 'Obj4' +#define MSG_PAUSE 'Paus' + +#endif /* _GLMOVMESSAGES_H */ Added: haiku/trunk/src/apps/3dmov/GLMovStrings.h =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovStrings.h 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/GLMovStrings.h 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,36 @@ +/* + ----------------------------------------------------------------------------- + + File: GLMovStrings.h + + Date: 10/20/2004 + + Description: 3DMov reloaded... + + Author: Fran?ois Revol. + + + Copyright 2004, yellowTAB GmbH, All rights reserved. + + + ----------------------------------------------------------------------------- +*/ +#ifndef _GLMOVSTRINGS_H +#define _GLMOVSTRINGS_H + +#define STR_ABOUT_TEXT "3DMov reloaded.\n\n Demonstrates OpenGL and the Media Kit." +#define STR_OK "Ok" + +#define STR_MENU "File" //not really related.... "Object" ? + +#define STR_CUBE "Cube" +#define STR_SPHERE "Sphere" +#define STR_PULSE "Pulse" +#define STR_BOOK "Book" + +#define STR_PAUSE "Pause" +#define STR_CLOSE "Close" +#define STR_ABOUT "About 3dMov" +#define STR_QUIT "Quit" + +#endif /* _GLMOVSTRINGS_H */ Added: haiku/trunk/src/apps/3dmov/GLMovView.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovView.cpp 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/GLMovView.cpp 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,35 @@ +/* + ----------------------------------------------------------------------------- + + File: GLMovView.cpp + + Date: 10/20/2004 + + Description: 3DMov reloaded... + + Author: Fran?ois Revol. + + + Copyright 2004, yellowTAB GmbH, All rights reserved. + + + ----------------------------------------------------------------------------- +*/ + +#include +#include +#include "GLMovView.h" + +GLMovView::GLMovView(BRect frame) + : BGLView(frame, "glview", B_FOLLOW_ALL, B_WILL_DRAW, BGL_RGB|BGL_DOUBLE) +{ +} + +GLMovView::~GLMovView() +{ +} + +void GLMovView::AttachedToWindow() +{ + +} Added: haiku/trunk/src/apps/3dmov/GLMovView.h =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovView.h 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/GLMovView.h 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,40 @@ +/* + ----------------------------------------------------------------------------- + + File: GLMovView.h + + Date: 10/20/2004 + + Description: 3DMov reloaded... + + Author: Fran?ois Revol. + + + Copyright 2004, yellowTAB GmbH, All rights reserved. + + + ----------------------------------------------------------------------------- +*/ +#ifndef _GLMOVVIEW_H +#define _GLMOVVIEW_H + +#include +#include + +class GLMovView: public BGLView +{ + public: + GLMovView(BRect frame); + ~GLMovView(); + virtual void AttachedToWindow(); + + // for mouse control + virtual void MouseDown(BPoint where); + virtual void MouseUp(BPoint where); + virtual void MouseMoved(BPoint where, uint32 code, const BMessage *a_message); + + // + virtual void FileDropped(BPoint where, BMediaFile *file); +}; + +#endif /* _GLMOVVIEW_H */ Added: haiku/trunk/src/apps/3dmov/GLMovWindow.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovWindow.cpp 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/GLMovWindow.cpp 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,126 @@ +/* + ----------------------------------------------------------------------------- + + File: GLMovWindow.cpp + + Date: 10/20/2004 + + Description: 3DMov reloaded... + + Author: Fran?ois Revol. + + + Copyright 2004, yellowTAB GmbH, All rights reserved. + + + ----------------------------------------------------------------------------- +*/ + +#include +#include +#include +#include "GLMovStrings.h" +#include "GLMovMessages.h" +#include "GLMovWindow.h" +#include "GLMovView.h" +#include "CubeView.h" + +#include + +GLMovWindow::GLMovWindow(GLMovView *view, BRect frame, const char *title) + : BDirectWindow(frame, title, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 0) +{ + fGLView = view; +} + +GLMovWindow::~GLMovWindow() +{ +} + +bool GLMovWindow::QuitRequested() +{ + be_app->Lock(); + if (be_app->CountWindows() < 2) + be_app_messenger.SendMessage(B_QUIT_REQUESTED); + be_app->Unlock(); + return true; +} + +void GLMovWindow::MessageReceived(BMessage *message) +{ + switch (message->what) { + case MSG_OBJ1: + case MSG_OBJ2: + case MSG_OBJ3: + case MSG_OBJ4: + MakeWindow((object_type)(OBJ_CUBE + message->what - MSG_OBJ1)); + break; + case 'Paus': + break; + default: + BDirectWindow::MessageReceived(message); + } +} + +void GLMovWindow::DirectConnected(direct_buffer_info *info) +{ + fGLView->DirectConnected(info); +} + + +GLMovWindow *GLMovWindow::MakeWindow(object_type obj) +{ + GLMovWindow *win; + GLMovView *view; + BMenuBar *bar; + BMenu *menu; + BMenuItem *menuItem; + BRect frame(0, 0, 400-1, 400-1); + const char *title = "3dMov"; + + bar = new BMenuBar(frame, "menu", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_ITEMS_IN_ROW, true); + menu = new BMenu(STR_MENU); + menu->AddItem(new BMenuItem(STR_CUBE, new BMessage(MSG_OBJ1), '1')); + menu->AddItem(new BMenuItem(STR_SPHERE, new BMessage(MSG_OBJ2), '2')); + menu->AddItem(new BMenuItem(STR_PULSE, new BMessage(MSG_OBJ3), '3')); + menu->AddItem(new BMenuItem(STR_BOOK, new BMessage(MSG_OBJ4), '4')); + menu->AddItem(new BSeparatorItem); + menu->AddItem((menuItem = new BMenuItem(STR_PAUSE, new BMessage(MSG_PAUSE), 'P'))); + menuItem->SetTarget(be_app_messenger); + menu->AddItem(new BMenuItem(STR_CLOSE, new BMessage(B_QUIT_REQUESTED), 'W')); + menu->AddItem(new BSeparatorItem); + menu->AddItem((menuItem = new BMenuItem(STR_ABOUT, new BMessage(B_ABOUT_REQUESTED)))); + menuItem->SetTarget(be_app_messenger); + menu->AddItem((menuItem = new BMenuItem(STR_QUIT, new BMessage(B_QUIT_REQUESTED), 'Q'))); + menuItem->SetTarget(be_app_messenger); + bar->AddItem(new BMenuItem(menu)); + bar->ResizeToPreferred(); + switch (obj) { + case OBJ_CUBE: + default: + view = new CubeView(frame.OffsetByCopy(0, bar->Bounds().Height()+1)); + title = STR_CUBE; + break; + case OBJ_SPHERE: + view = new GLMovView(frame.OffsetByCopy(0, bar->Bounds().Height()+1)); + title = STR_SPHERE; + break; + case OBJ_PULSE: + view = new GLMovView(frame.OffsetByCopy(0, bar->Bounds().Height()+1)); + title = STR_PULSE; + break; + case OBJ_BOOK: + frame = BRect(0, 0, 600-1, 400-1); + view = new GLMovView(frame.OffsetByCopy(0, bar->Bounds().Height()+1)); + title = STR_BOOK; + break; + } + view->SetViewColor(0,0,0); + frame.bottom += bar->Bounds().Height()+1; + frame.OffsetBySelf(50,50); + win = new GLMovWindow(view, frame, title); + win->AddChild(bar); + win->AddChild(view); + win->Show(); + return win; +} Added: haiku/trunk/src/apps/3dmov/GLMovWindow.h =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovWindow.h 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/GLMovWindow.h 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,46 @@ +/* + ----------------------------------------------------------------------------- + + File: GLMovWindow.h + + Date: 10/20/2004 + + Description: 3DMov reloaded... + + Author: Fran?ois Revol. + + + Copyright 2004, yellowTAB GmbH, All rights reserved. + + + ----------------------------------------------------------------------------- +*/ +#ifndef _GLMOVWINDOW_H +#define _GLMOVWINDOW_H + +#include + +class GLMovView; + +enum object_type { + OBJ_CUBE, + OBJ_SPHERE, + OBJ_PULSE, + OBJ_BOOK, +}; + +class GLMovWindow: public BDirectWindow +{ + public: + GLMovWindow(GLMovView *view, BRect frame, const char *title); + ~GLMovWindow(); + virtual bool QuitRequested(); + virtual void MessageReceived(BMessage *message); + virtual void DirectConnected(direct_buffer_info *info); + static GLMovWindow *MakeWindow(object_type obj); + + private: + GLMovView *fGLView; +}; + +#endif /* _GLMOVWINDOW_H */ Added: haiku/trunk/src/apps/3dmov/Jamfile =================================================================== --- haiku/trunk/src/apps/3dmov/Jamfile 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/Jamfile 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,12 @@ +SubDir HAIKU_TOP src apps 3dmov ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +Application 3DMov : + CubeView.cpp + GLMovApp.cpp + GLMovView.cpp + GLMovWindow.cpp + : be GL game + : 3dmov.rdef +; Added: haiku/trunk/src/apps/3dmov/makefile =================================================================== --- haiku/trunk/src/apps/3dmov/makefile 2007-11-11 14:45:04 UTC (rev 22898) +++ haiku/trunk/src/apps/3dmov/makefile 2007-11-11 14:56:22 UTC (rev 22899) @@ -0,0 +1,120 @@ +## BeOS Generic Makefile v2.2 ## + +## Fill in this file to specify the project being created, and the referenced +## makefile-engine will do all of the hard work for you. This handles both +## Intel and PowerPC builds of the BeOS. + +## Application Specific Settings --------------------------------------------- + +# specify the name of the binary +NAME= 3DMov2 + +# specify the type of binary +# APP: Application +# SHARED: Shared library or add-on +# STATIC: Static library archive +# DRIVER: Kernel Driver +TYPE= APP + +# add support for new Pe and Eddie features +# to fill in generic makefile + +#%{ +# @src->@ + +# specify the source files to use +# full paths or paths relative to the makefile can be included +# all files, regardless of directory, will have their object +# files created in the common object directory. +# Note that this means this makefile will not work correctly +# if two source files with the same name (source.c or source.cpp) +# are included from different directories. Also note that spaces +# in folder names do not work well with this makefile. +SRCS= $(wildcard *.cpp) + +# specify the resource files to use +# full path or a relative path to the resource file can be used. +RSRCS= 3dmov.rsrc + +# @<-src@ +#%} + +# end support for Pe and Eddie + +# specify additional libraries to link against +# there are two acceptable forms of library specifications +# - if your library follows the naming pattern of: +# libXXX.so or libXXX.a you can simply specify XXX +# library: libbe.so entry: be +# +# - if your library does not follow the standard library +# naming scheme you need to specify the path to the library +# and it's name +# library: my_lib.a entry: my_lib.a or path/my_lib.a +LIBS= be game GL + +# specify additional paths to directories following the standard +# libXXX.so or libXXX.a naming scheme. You can specify full paths +# or paths relative to the makefile. The paths included may not +# be recursive, so include all of the paths where libraries can +# be found. Directories where source files are found are +# automatically included. +LIBPATHS= + +# additional paths to look for system headers +# thes use the form: #include
+# source file directories are NOT auto-included here +SYSTEM_INCLUDE_PATHS = + +# additional paths to look for local headers +# thes use the form: #include "header" +# source file directories are automatically included +LOCAL_INCLUDE_PATHS = + +# specify the level of optimization that you desire +# NONE, SOME, FULL +OPTIMIZE= + +# specify any preprocessor symbols to be defined. The symbols will not +# have their values set automatically; you must supply the value (if any) +# to use. For example, setting DEFINES to "DEBUG=1" will cause the +# compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" +# would pass "-DDEBUG" on the compiler's command line. +DEFINES= + +# specify special warning levels +# if unspecified default warnings will be used +# NONE = supress all warnings +# ALL = enable all warnings +WARNINGS = + +# specify whether image symbols will be created +# so that stack crawls in the debugger are meaningful +# if TRUE symbols will be created +SYMBOLS = + +# specify debug settings +# if TRUE will allow application to be run from a source-level +# debugger. Note that this will disable all optimzation. +DEBUGGER = + +# specify additional compiler flags for all files +COMPILER_FLAGS = + +# specify additional linker flags +LINKER_FLAGS = + +# specify the version of this particular item +# (for example, -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL") +# This may also be specified in a resource. +APP_VERSION = + +# (for TYPE == DRIVER only) Specify desired location of driver in the /dev +# hierarchy. Used by the driverinstall rule. E.g., DRIVER_PATH = video/usb will +# instruct the driverinstall rule to place a symlink to your driver's binary in +# ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will appear at +# /dev/video/usb when loaded. Default is "misc". +DRIVER_PATH = + +## include the makefile-engine +include $(BUILDHOME)/etc/makefile-engine From axeld at pinc-software.de Sun Nov 11 16:12:44 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 11 Nov 2007 16:12:44 +0100 CET Subject: [Haiku-commits] r22899 - in haiku/trunk/src/apps: . 3dmov In-Reply-To: <200711111456.lABEuOv0030109@sheep.berlios.de> Message-ID: <23151159359-BeMail@zon> mmu_man at BerliOS wrote: > + Copyright 2004, yellowTAB GmbH, All rights reserved. If you have written this, and own this, why is there a copyright from yellowTab on it? If you don't own this, we can't add it anyway. Also, please, we still have a coding style - it isn't too hard to at least use indent or something similar to correct the most obvious violations. Bye, Axel. From korli at mail.berlios.de Sun Nov 11 16:50:11 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 11 Nov 2007 16:50:11 +0100 Subject: [Haiku-commits] r22900 - haiku/trunk/src/add-ons/media/plugins/raw_decoder Message-ID: <200711111550.lABFoBB6001076@sheep.berlios.de> Author: korli Date: 2007-11-11 16:50:11 +0100 (Sun, 11 Nov 2007) New Revision: 22900 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22900&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/raw_decoder/AudioConversion.cpp Log: fix int24 to float conversion : the formula was correct, but the sign bit of int32 doesn't help, and my ears confirmed. Modified: haiku/trunk/src/add-ons/media/plugins/raw_decoder/AudioConversion.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/raw_decoder/AudioConversion.cpp 2007-11-11 14:56:22 UTC (rev 22899) +++ haiku/trunk/src/add-ons/media/plugins/raw_decoder/AudioConversion.cpp 2007-11-11 15:50:11 UTC (rev 22900) @@ -76,17 +76,13 @@ inline operator int8() const { return (int8)data[2]; } inline operator int16() const { return (int16)((uint32)data[2] << 8 | (uint32)data[1]); } inline operator int32() const { return (int32)((uint32)data[2] << 24 | (uint32)data[1] << 16 | (uint32)data[0] << 8); } - inline operator float() const { return (int32)((uint32)data[2] << 16 | (uint32)data[1] << 8 | (uint32)data[0]) * (1.0f / (2147483647.0f / 256)); } -// XXX is the line above correct? long version: -// inline operator float() const { return (int32)((uint32)data[2] << 24 | (uint32)data[1] << 16 | (uint32)data[0] << 8) * (1.0f / 2147483647.0f); } + inline operator float() const { return (int32)((uint32)data[2] << 24 | (uint32)data[1] << 16 | (uint32)data[0] << 8) * (1.0f / 2147483647.0f); } #else inline operator uint8() const { return (int32)data[0] + 128; } inline operator int8() const { return (int8)data[0]; } inline operator int16() const { return (int16)((uint32)data[0] << 8 | (uint32)data[1]); } inline operator int32() const { return (int32)((uint32)data[0] << 24 | (uint32)data[1] << 16 | (uint32)data[2] << 8); } - inline operator float() const { return (int32)((uint32)data[0] << 16 | (uint32)data[1] << 8 | (uint32)data[2]) * (1.0f / (2147483647.0f / 256)); } -// XXX is the line above correct? long version: -// inline operator float() const { return (int32)((uint32)data[0] << 24 | (uint32)data[1] << 16 | (uint32)data[2] << 8) * (1.0f / 2147483647.0f); } + inline operator float() const { return (int32)((uint32)data[0] << 24 | (uint32)data[1] << 16 | (uint32)data[2] << 8) * (1.0f / 2147483647.0f); } #endif private: uint8 data[3]; From axeld at mail.berlios.de Sun Nov 11 17:28:57 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 11 Nov 2007 17:28:57 +0100 Subject: [Haiku-commits] r22901 - in haiku/trunk/src/add-ons/kernel/file_systems: bfs fat Message-ID: <200711111628.lABGSv64003137@sheep.berlios.de> Author: axeld Date: 2007-11-11 17:28:56 +0100 (Sun, 11 Nov 2007) New Revision: 22901 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22901&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp haiku/trunk/src/add-ons/kernel/file_systems/fat/file.c Log: * The "bytes" as passed to {read|write}_file_io_vec_pages() was never initialized, causing those functions to read|write a random amount. * This fixes bug #1614 - amazing how well the system worked with those randomly sized requests... Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-11-11 15:50:11 UTC (rev 22900) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-11-11 16:28:56 UTC (rev 22901) @@ -358,7 +358,7 @@ bool bufferOverflow = status == B_BUFFER_OVERFLOW; - size_t bytes; + size_t bytes = bytesLeft; status = read_file_io_vec_pages(volume->Device(), fileVecs, fileVecCount, vecs, count, &vecIndex, &vecOffset, &bytes); if (status != B_OK || !bufferOverflow) @@ -404,7 +404,7 @@ bool bufferOverflow = status == B_BUFFER_OVERFLOW; - size_t bytes; + size_t bytes = bytesLeft; status = write_file_io_vec_pages(volume->Device(), fileVecs, fileVecCount, vecs, count, &vecIndex, &vecOffset, &bytes); if (status != B_OK || !bufferOverflow) Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/file.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/fat/file.c 2007-11-11 15:50:11 UTC (rev 22900) +++ haiku/trunk/src/add-ons/kernel/file_systems/fat/file.c 2007-11-11 16:28:56 UTC (rev 22901) @@ -1505,7 +1505,7 @@ struct file_io_vec fileVecs[8]; uint32 fileVecCount = 8; bool bufferOverflow; - size_t bytes; + size_t bytes = bytesLeft; status = file_map_translate(node->file_map, pos, bytesLeft, fileVecs, &fileVecCount); @@ -1557,7 +1557,7 @@ struct file_io_vec fileVecs[8]; uint32 fileVecCount = 8; bool bufferOverflow; - size_t bytes; + size_t bytes = bytesLeft; status = file_map_translate(node->file_map, pos, bytesLeft, fileVecs, &fileVecCount); From axeld at mail.berlios.de Sun Nov 11 17:33:28 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 11 Nov 2007 17:33:28 +0100 Subject: [Haiku-commits] r22902 - haiku/trunk/src/system/kernel/cache Message-ID: <200711111633.lABGXSnU003354@sheep.berlios.de> Author: axeld Date: 2007-11-11 17:33:28 +0100 (Sun, 11 Nov 2007) New Revision: 22902 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22902&view=rev Modified: haiku/trunk/src/system/kernel/cache/file_map.cpp Log: A tiny bit more debug output when tracing is enabled. Modified: haiku/trunk/src/system/kernel/cache/file_map.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_map.cpp 2007-11-11 16:28:56 UTC (rev 22901) +++ haiku/trunk/src/system/kernel/cache/file_map.cpp 2007-11-11 16:33:28 UTC (rev 22902) @@ -241,6 +241,9 @@ if (_map == NULL) return B_BAD_VALUE; + TRACE(("file_map_translate(map %p, offset %Ld, size %ld)\n", + _map, offset, size)); + file_map &map = *(file_map *)_map; size_t maxVecs = *_count; status_t status = B_OK; From mmu_man at mail.berlios.de Sun Nov 11 19:26:37 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 11 Nov 2007 19:26:37 +0100 Subject: [Haiku-commits] r22903 - haiku/trunk/src/apps/3dmov Message-ID: <200711111826.lABIQb9p027334@sheep.berlios.de> Author: mmu_man Date: 2007-11-11 19:26:37 +0100 (Sun, 11 Nov 2007) New Revision: 22903 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22903&view=rev Modified: haiku/trunk/src/apps/3dmov/3dmov.rdef haiku/trunk/src/apps/3dmov/CubeView.cpp haiku/trunk/src/apps/3dmov/CubeView.h haiku/trunk/src/apps/3dmov/GLMovApp.cpp haiku/trunk/src/apps/3dmov/GLMovApp.h haiku/trunk/src/apps/3dmov/GLMovMessages.h haiku/trunk/src/apps/3dmov/GLMovStrings.h haiku/trunk/src/apps/3dmov/GLMovView.cpp haiku/trunk/src/apps/3dmov/GLMovView.h haiku/trunk/src/apps/3dmov/GLMovWindow.cpp haiku/trunk/src/apps/3dmov/GLMovWindow.h Log: Fix wrong copyright. Modified: haiku/trunk/src/apps/3dmov/3dmov.rdef =================================================================== --- haiku/trunk/src/apps/3dmov/3dmov.rdef 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/3dmov.rdef 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,10 +1,12 @@ -/* -** /Data/haiku/trunk/src/apps/3dmov/3dmov.rdef -** -** Automatically generated by BResourceParser on -** Tuesday, May 08, 2007 at 16:24:02. -** -*/ +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + * + * Copyright Be, Inc. (for the icon) + */ resource(1, "BEOS:APP_FLAGS") (#'APPF') $"00000000"; Modified: haiku/trunk/src/apps/3dmov/CubeView.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/CubeView.cpp 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/CubeView.cpp 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,21 +1,11 @@ -/* - ----------------------------------------------------------------------------- +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ - File: CubeView.cpp - - Date: 10/20/2004 - - Description: 3DMov reloaded... - - Author: Fran?ois Revol. - - - Copyright 2004, yellowTAB GmbH, All rights reserved. - - - ----------------------------------------------------------------------------- -*/ - #include #include #include "CubeView.h" Modified: haiku/trunk/src/apps/3dmov/CubeView.h =================================================================== --- haiku/trunk/src/apps/3dmov/CubeView.h 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/CubeView.h 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,20 +1,10 @@ -/* - ----------------------------------------------------------------------------- - - File: CubeView.h - - Date: 10/20/2004 - - Description: 3DMov reloaded... - - Author: Fran?ois Revol. - - - Copyright 2004, yellowTAB GmbH, All rights reserved. - - - ----------------------------------------------------------------------------- -*/ +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ #ifndef _CUBEVIEW_H #define _CUBEVIEW_H Modified: haiku/trunk/src/apps/3dmov/GLMovApp.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovApp.cpp 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/GLMovApp.cpp 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,21 +1,11 @@ -/* - ----------------------------------------------------------------------------- +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ - File: GLMovApp.cpp - - Date: 10/20/2004 - - Description: 3DMov reloaded... - - Author: Fran?ois Revol. - - - Copyright 2004, yellowTAB GmbH, All rights reserved. - - - ----------------------------------------------------------------------------- -*/ - #include #include "GLMovApp.h" #include "GLMovStrings.h" Modified: haiku/trunk/src/apps/3dmov/GLMovApp.h =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovApp.h 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/GLMovApp.h 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,20 +1,11 @@ -/* - ----------------------------------------------------------------------------- +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ - File: GLMovApp.h - - Date: 10/20/2004 - - Description: 3DMov reloaded... - - Author: Fran?ois Revol. - - - Copyright 2004, yellowTAB GmbH, All rights reserved. - - - ----------------------------------------------------------------------------- -*/ #ifndef _GLMOVAPP_H #define _GLMOVAPP_H Modified: haiku/trunk/src/apps/3dmov/GLMovMessages.h =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovMessages.h 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/GLMovMessages.h 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,20 +1,11 @@ -/* - ----------------------------------------------------------------------------- +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ - File: GLMovStrings.h - - Date: 10/20/2004 - - Description: 3DMov reloaded... - - Author: Fran?ois Revol. - - - Copyright 2004, yellowTAB GmbH, All rights reserved. - - - ----------------------------------------------------------------------------- -*/ #ifndef _GLMOVMESSAGES_H #define _GLMOVMESSAGES_H Modified: haiku/trunk/src/apps/3dmov/GLMovStrings.h =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovStrings.h 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/GLMovStrings.h 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,20 +1,11 @@ -/* - ----------------------------------------------------------------------------- +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ - File: GLMovStrings.h - - Date: 10/20/2004 - - Description: 3DMov reloaded... - - Author: Fran?ois Revol. - - - Copyright 2004, yellowTAB GmbH, All rights reserved. - - - ----------------------------------------------------------------------------- -*/ #ifndef _GLMOVSTRINGS_H #define _GLMOVSTRINGS_H Modified: haiku/trunk/src/apps/3dmov/GLMovView.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovView.cpp 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/GLMovView.cpp 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,21 +1,11 @@ -/* - ----------------------------------------------------------------------------- +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ - File: GLMovView.cpp - - Date: 10/20/2004 - - Description: 3DMov reloaded... - - Author: Fran?ois Revol. - - - Copyright 2004, yellowTAB GmbH, All rights reserved. - - - ----------------------------------------------------------------------------- -*/ - #include #include #include "GLMovView.h" Modified: haiku/trunk/src/apps/3dmov/GLMovView.h =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovView.h 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/GLMovView.h 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,20 +1,11 @@ -/* - ----------------------------------------------------------------------------- +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ - File: GLMovView.h - - Date: 10/20/2004 - - Description: 3DMov reloaded... - - Author: Fran?ois Revol. - - - Copyright 2004, yellowTAB GmbH, All rights reserved. - - - ----------------------------------------------------------------------------- -*/ #ifndef _GLMOVVIEW_H #define _GLMOVVIEW_H Modified: haiku/trunk/src/apps/3dmov/GLMovWindow.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovWindow.cpp 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/GLMovWindow.cpp 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,21 +1,11 @@ -/* - ----------------------------------------------------------------------------- +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ - File: GLMovWindow.cpp - - Date: 10/20/2004 - - Description: 3DMov reloaded... - - Author: Fran?ois Revol. - - - Copyright 2004, yellowTAB GmbH, All rights reserved. - - - ----------------------------------------------------------------------------- -*/ - #include #include #include Modified: haiku/trunk/src/apps/3dmov/GLMovWindow.h =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovWindow.h 2007-11-11 16:33:28 UTC (rev 22902) +++ haiku/trunk/src/apps/3dmov/GLMovWindow.h 2007-11-11 18:26:37 UTC (rev 22903) @@ -1,20 +1,10 @@ -/* - ----------------------------------------------------------------------------- - - File: GLMovWindow.h - - Date: 10/20/2004 - - Description: 3DMov reloaded... - - Author: Fran?ois Revol. - - - Copyright 2004, yellowTAB GmbH, All rights reserved. - - - ----------------------------------------------------------------------------- -*/ +/* + * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol + */ #ifndef _GLMOVWINDOW_H #define _GLMOVWINDOW_H From revol at free.fr Sun Nov 11 20:09:34 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 Nov 2007 20:09:34 +0100 CET Subject: [Haiku-commits] r22899 - in haiku/trunk/src/apps: . 3dmov In-Reply-To: <23151159359-BeMail@zon> Message-ID: <594195232-BeMail@laptop> > mmu_man at BerliOS wrote: > > + Copyright 2004, yellowTAB GmbH, All rights reserved. > > If you have written this, and own this, why is there a copyright from > yellowTab on it? If you don't own this, we can't add it anyway. Because I started it when I worked there, so I used the standard template we had, but I was never asked to write it, so it's mine. See I sometimes do follow coding style :) > Also, please, we still have a coding style - it isn't too hard to at > least use indent or something similar to correct the most obvious > violations. Yes I'm currently fixing my xemacs settings to do the indent correctly. Fran?ois. From mmu_man at mail.berlios.de Sun Nov 11 21:12:01 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 11 Nov 2007 21:12:01 +0100 Subject: [Haiku-commits] r22904 - haiku/trunk/src/apps/3dmov Message-ID: <200711112012.lABKC1CT009283@sheep.berlios.de> Author: mmu_man Date: 2007-11-11 21:12:01 +0100 (Sun, 11 Nov 2007) New Revision: 22904 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22904&view=rev Modified: haiku/trunk/src/apps/3dmov/GLMovApp.cpp Log: Fix signature. References for GL stuff to do: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=23 http://www.3dbuzz.com/vbforum/showthread.php?t=118279 Modified: haiku/trunk/src/apps/3dmov/GLMovApp.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovApp.cpp 2007-11-11 18:26:37 UTC (rev 22903) +++ haiku/trunk/src/apps/3dmov/GLMovApp.cpp 2007-11-11 20:12:01 UTC (rev 22904) @@ -12,7 +12,7 @@ #include "GLMovWindow.h" GLMovApp::GLMovApp() - : BApplication("application/x-vnd.Be-3DM2") + : BApplication("application/x-vnd.Haiku-3DMov") { } From mmu_man at mail.berlios.de Sun Nov 11 21:37:11 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 11 Nov 2007 21:37:11 +0100 Subject: [Haiku-commits] r22905 - haiku/trunk/src/apps/3dmov Message-ID: <200711112037.lABKbB2S010704@sheep.berlios.de> Author: mmu_man Date: 2007-11-11 21:37:10 +0100 (Sun, 11 Nov 2007) New Revision: 22905 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22905&view=rev Modified: haiku/trunk/src/apps/3dmov/CubeView.cpp haiku/trunk/src/apps/3dmov/GLMovApp.cpp haiku/trunk/src/apps/3dmov/GLMovView.cpp haiku/trunk/src/apps/3dmov/GLMovWindow.cpp Log: Put return types for funcs on their own line. Modified: haiku/trunk/src/apps/3dmov/CubeView.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/CubeView.cpp 2007-11-11 20:12:01 UTC (rev 22904) +++ haiku/trunk/src/apps/3dmov/CubeView.cpp 2007-11-11 20:37:10 UTC (rev 22905) @@ -19,7 +19,8 @@ { } -void CubeView::AttachedToWindow() +void +CubeView::AttachedToWindow() { } Modified: haiku/trunk/src/apps/3dmov/GLMovApp.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovApp.cpp 2007-11-11 20:12:01 UTC (rev 22904) +++ haiku/trunk/src/apps/3dmov/GLMovApp.cpp 2007-11-11 20:37:10 UTC (rev 22905) @@ -20,7 +20,8 @@ { } -void GLMovApp::ReadyToRun() +void +GLMovApp::ReadyToRun() { GLMovWindow *win = GLMovWindow::MakeWindow(OBJ_CUBE); } @@ -36,7 +37,8 @@ { } -int main(int argc, char **argv) +int +main(int argc, char **argv) { GLMovApp app; app.Run(); Modified: haiku/trunk/src/apps/3dmov/GLMovView.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovView.cpp 2007-11-11 20:12:01 UTC (rev 22904) +++ haiku/trunk/src/apps/3dmov/GLMovView.cpp 2007-11-11 20:37:10 UTC (rev 22905) @@ -19,7 +19,8 @@ { } -void GLMovView::AttachedToWindow() +void +GLMovView::AttachedToWindow() { } Modified: haiku/trunk/src/apps/3dmov/GLMovWindow.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovWindow.cpp 2007-11-11 20:12:01 UTC (rev 22904) +++ haiku/trunk/src/apps/3dmov/GLMovWindow.cpp 2007-11-11 20:37:10 UTC (rev 22905) @@ -27,7 +27,8 @@ { } -bool GLMovWindow::QuitRequested() +bool +GLMovWindow::QuitRequested() { be_app->Lock(); if (be_app->CountWindows() < 2) @@ -36,7 +37,8 @@ return true; } -void GLMovWindow::MessageReceived(BMessage *message) +void +GLMovWindow::MessageReceived(BMessage *message) { switch (message->what) { case MSG_OBJ1: @@ -52,13 +54,15 @@ } } -void GLMovWindow::DirectConnected(direct_buffer_info *info) +void +GLMovWindow::DirectConnected(direct_buffer_info *info) { fGLView->DirectConnected(info); } -GLMovWindow *GLMovWindow::MakeWindow(object_type obj) +GLMovWindow * +GLMovWindow::MakeWindow(object_type obj) { GLMovWindow *win; GLMovView *view; From axeld at pinc-software.de Sun Nov 11 22:44:31 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 11 Nov 2007 22:44:31 +0100 CET Subject: [Haiku-commits] r22899 - in haiku/trunk/src/apps: . 3dmov In-Reply-To: <594195232-BeMail@laptop> Message-ID: <46658657372-BeMail@zon> "Fran?ois Revol" wrote: > > mmu_man at BerliOS wrote: > > > + Copyright 2004, yellowTAB GmbH, All rights reserved. > > If you have written this, and own this, why is there a copyright > > from > > yellowTab on it? If you don't own this, we can't add it anyway. > Because I started it when I worked there, so I used the standard > template we had, but I was never asked to write it, so it's mine. > See I sometimes do follow coding style :) Hehe, so we need to promise to pay you to get you to follow our style guide? ;-)) > > Also, please, we still have a coding style - it isn't too hard to > > at > > least use indent or something similar to correct the most obvious > > violations. > Yes I'm currently fixing my xemacs settings to do the indent > correctly. It's only one setting for every project you're working on, that can't be too hard :)) Bye, Axel. From stippi at mail.berlios.de Mon Nov 12 00:00:12 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 12 Nov 2007 00:00:12 +0100 Subject: [Haiku-commits] r22906 - in haiku/trunk/src: apps/icon-o-matic/gui libs/icon libs/icon/style Message-ID: <200711112300.lABN0Cqs026564@sheep.berlios.de> Author: stippi Date: 2007-11-12 00:00:11 +0100 (Mon, 12 Nov 2007) New Revision: 22906 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22906&view=rev Modified: haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp haiku/trunk/src/libs/icon/IconRenderer.cpp haiku/trunk/src/libs/icon/style/Gradient.cpp haiku/trunk/src/libs/icon/style/Gradient.h Log: * fix spelling mistake diamont -> diamond (fixes #1618) Modified: haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp 2007-11-11 20:37:10 UTC (rev 22905) +++ haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp 2007-11-11 23:00:11 UTC (rev 22906) @@ -101,8 +101,8 @@ message->AddInt32("type", GRADIENT_CIRCULAR); menu->AddItem(new BMenuItem("Radial", message)); message = new BMessage(MSG_SET_GRADIENT_TYPE); - message->AddInt32("type", GRADIENT_DIAMONT); - menu->AddItem(new BMenuItem("Diamont", message)); + message->AddInt32("type", GRADIENT_DIAMOND); + menu->AddItem(new BMenuItem("Diamond", message)); message = new BMessage(MSG_SET_GRADIENT_TYPE); message->AddInt32("type", GRADIENT_CONIC); menu->AddItem(new BMenuItem("Conic", message)); Modified: haiku/trunk/src/libs/icon/IconRenderer.cpp =================================================================== --- haiku/trunk/src/libs/icon/IconRenderer.cpp 2007-11-11 20:37:10 UTC (rev 22905) +++ haiku/trunk/src/libs/icon/IconRenderer.cpp 2007-11-11 23:00:11 UTC (rev 22906) @@ -142,7 +142,7 @@ styleItem->transformation); break; } - case GRADIENT_DIAMONT: { + case GRADIENT_DIAMOND: { agg::gradient_diamond function; _GenerateGradient(span, x, y, len, function, 0, 64, colors, styleItem->transformation); Modified: haiku/trunk/src/libs/icon/style/Gradient.cpp =================================================================== --- haiku/trunk/src/libs/icon/style/Gradient.cpp 2007-11-11 20:37:10 UTC (rev 22905) +++ haiku/trunk/src/libs/icon/style/Gradient.cpp 2007-11-11 23:00:11 UTC (rev 22906) @@ -582,8 +582,8 @@ return "GRADIENT_LINEAR"; case GRADIENT_CIRCULAR: return "GRADIENT_CIRCULAR"; - case GRADIENT_DIAMONT: - return "GRADIENT_DIAMONT"; + case GRADIENT_DIAMOND: + return "GRADIENT_DIAMOND"; case GRADIENT_CONIC: return "GRADIENT_CONIC"; case GRADIENT_XY: @@ -615,7 +615,7 @@ switch (fType) { case GRADIENT_LINEAR: case GRADIENT_CIRCULAR: - case GRADIENT_DIAMONT: + case GRADIENT_DIAMOND: case GRADIENT_CONIC: case GRADIENT_XY: case GRADIENT_SQRT_XY: Modified: haiku/trunk/src/libs/icon/style/Gradient.h =================================================================== --- haiku/trunk/src/libs/icon/style/Gradient.h 2007-11-11 20:37:10 UTC (rev 22905) +++ haiku/trunk/src/libs/icon/style/Gradient.h 2007-11-11 23:00:11 UTC (rev 22906) @@ -29,7 +29,7 @@ enum gradient_type { GRADIENT_LINEAR = 0, GRADIENT_CIRCULAR, - GRADIENT_DIAMONT, + GRADIENT_DIAMOND, GRADIENT_CONIC, GRADIENT_XY, GRADIENT_SQRT_XY, From bonefish at mail.berlios.de Mon Nov 12 01:08:08 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 12 Nov 2007 01:08:08 +0100 Subject: [Haiku-commits] r22907 - in haiku/trunk: build/jam src/tests/system/libroot/posix/posixtestsuite Message-ID: <200711120008.lAC0884V013719@sheep.berlios.de> Author: bonefish Date: 2007-11-12 01:08:06 +0100 (Mon, 12 Nov 2007) New Revision: 22907 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22907&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/UserBuildConfig.sample haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/Jamfile haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh Log: Patch by Vasilis Kaoutsis (slightly edited): * The POSIX test suite is copied to the image when the jam variable HAIKU_ADD_POSIX_TEST_SUITE_TO_IMAGE is defined (cf. UserBuildConfig.sample). * Added difftime and fork tests to the test suite run script. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-11 23:00:11 UTC (rev 22906) +++ haiku/trunk/build/jam/HaikuImage 2007-11-12 00:08:06 UTC (rev 22907) @@ -415,6 +415,36 @@ : home-config-settings-printers-save-as-pdf.rdef ; +#pragma mark - Tests + +# PosixTestSuite +if $(HAIKU_ADD_POSIX_TEST_SUITE_TO_IMAGE) { + # add run script + AddFilesToHaikuImage home posixtestsuite : run_posix_tests ; + + # add standard posix tests + AddFilesToHaikuImage home posixtestsuite conformance interfaces difftime + : difftime_1-1 ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces fork + : fork_3-1 fork_4-1 fork_6-1 fork_8-1 fork_9-1 fork_12-1 ; + + # add signal posix tests + AddFilesToHaikuImage home posixtestsuite conformance interfaces kill + : kill_2-1 ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces sighold + : sighold_1-1 sighold_2-1 sighold_3-core-buildonly ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces sigignore + : sigignore_1-1 sigignore_4-1 sigignore_5-core-buildonly + sigignore_6-1 sigignore_6-2 ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces sigprocmask + : sigprocmask_8-1 sigprocmask_8-2 sigprocmask_8-3 sigprocmask_12-1 ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces sigrelse + : sigrelse_1-1 sigrelse_2-1 sigrelse_3-core-buildonly ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces signal + : signal_1-1 signal_2-1 signal_3-1 signal_5-1 signal_6-1 signal_7-1 ; +} + + #pragma mark - Optional Packages Modified: haiku/trunk/build/jam/UserBuildConfig.sample =================================================================== --- haiku/trunk/build/jam/UserBuildConfig.sample 2007-11-11 23:00:11 UTC (rev 22906) +++ haiku/trunk/build/jam/UserBuildConfig.sample 2007-11-12 00:08:06 UTC (rev 22907) @@ -1,132 +1,136 @@ -# UserBuildConfig can be used to customize the build according to your needs. -# If existent it is included by the build system, but it is ignored by svn. -# This file documents a few examples, what can be done. - -# Adjusting Build Variables - -# Turn off warnings in directory src/system/kernel. As fourth (scope) parameter -# "local" is specified, which means, that this setting applies only to the -# given directory, but not any of its subdirectories. -SetConfigVar WARNINGS : HAIKU_TOP src system kernel : 0 : local ; - -# Add "RUN_WITHOUT_REGISTRAR" to the DEFINES for the directory src/kits and -# all its subdirectories (scope is "global"). -AppendToConfigVar DEFINES : HAIKU_TOP src kits : RUN_WITHOUT_REGISTRAR - : global ; - -# Set the debug level for file src/bin/gdb/gdb/haiku-nat.c (note, that -# the object file must be specified) to 1. It is worth mentioning, that the -# executable the object file is linked into (gdb), will still be placed in -# generated/objects/.../release/... Only when setting DEBUG for the executable, -# too, it will be placed in .../debug_1/... -DEBUG on haiku-nat.o = 1 ; - - -# Haiku Image Related Modifications - -# Create a 100 MB image at /tmp/walter.image. -HAIKU_IMAGE_NAME = walter.image ; -HAIKU_IMAGE_DIR = /tmp ; -HAIKU_IMAGE_SIZE = 100 ; - -# Name the VMWare image walter.vmdk (in directory $(HAIKU_IMAGE_DIR)). -HAIKU_VMWARE_IMAGE_NAME = walter.vmdk ; - -# Install Haiku in directory /Haiku. -HAIKU_INSTALL_DIR = /Haiku ; - -# If the image does already exist it won't be zeroed out. It will nevertheless -# freshly be initialized with BFS. Useful when installing Haiku on a partition. -HAIKU_DONT_CLEAR_IMAGE = 1 ; - - -# Affects the haiku-image, haiku-vmware-image, and install-haiku targets. Only -# targets on which the HAIKU_INCLUDE_IN_IMAGE variable has been set will be -# updated in the image file/installation directory. -# The update-image, update-vmware-image, and update-install targets always invoke -# this rule, so one likely doesn't ever need to do it manually. -SetUpdateHaikuImageOnly 1 ; - -# libbe.so and the kernel will be updated on image updates. Note that this -# generally doesn't work for pseudo targets (it does where special support -# has been added, like for "kernel"). -HAIKU_INCLUDE_IN_IMAGE on libbe.so kernel = 1 ; - -# Add "crashing_app" to the beos/bin directory of the Haiku image/installation. -# Note, that this also makes the image depend on the target, i.e. it is -# automatically updated when the image is built. -AddFilesToHaikuImage beos bin : crashing_app ; - -# Make a symlink to home/config/bin/crash. -AddSymlinkToHaikuImage home config bin : /beos/bin/crashing_app : crash ; - -# Adds the source directories src/kits/storage and src/tests/servers/debug -# (recursively) to the image (as /boot/home/HaikuSources/src/kits/storage -# and /boot/home/HaikuSources/src/tests/servers/debug respectively). -# Note that the second directory will also be copied, if the image will only -# be updated; the first one won't in that case. -AddSourceDirectoryToHaikuImage src/kits/storage ; -AddSourceDirectoryToHaikuImage src/tests/servers/debug : 1 ; - -# Unzips the given zip archive onto the image under /boot/develop/tools. -UnzipArchiveToHaikuImage develop tools - : /home/bonefish/develop/haiku/misc/gcc-2.95.3-beos-070218/gcc-2.95.3_binutils-2.17_rel-070218.zip ; - -# Adds the optional package WonderBrush to the image. The package is downloaded -# via wget (i.e. wget must be installed). -AddOptionalHaikuImagePackages WonderBrush ; - -# Adds the optional package Vision to the image. See above. -AddOptionalHaikuImagePackages Vision ; - -# Add all available optional packages. -HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ; - -# Specify scripts that shall be run when populating the image/installation -# directory. The "early" script is run before anything has been copied onto -# the image/into the installation directory. The "late" script is run after -# everything has been copied, but before the MIME database is installed. -HAIKU_IMAGE_EARLY_USER_SCRIPTS = $(HAIKU_TOP)/../early-image-script.sh ; -HAIKU_IMAGE_LATE_USER_SCRIPTS = $(HAIKU_TOP)/../late-image-script.sh ; - - -# Creating Sourceable Shell Scripts - -# If you use shell scripts (e.g. for testing) that need to access targets or -# build system properties, you can tell the build system to generate a -# variables defining shell script you can source from your shell script. - -# General setup for the shell script to generate. Name is test.inc, located -# in the output directory. -MakeLocate test.inc : $(HAIKU_OUTPUT_DIR) ; -Always test.inc ; - -# Define variable "outputDir" in the shell script, with the value of -# HAIKU_OUTPUT_DIR. -AddVariableToScript test.inc : outputDir : $(HAIKU_OUTPUT_DIR) ; - -# Define variables "bfsShell" and "fsShellCommand" referring to the -# generated bfs_shell and fs_shell_command respectively. -AddTargetVariableToScript test.inc : bfs_shell : bfsShell ; -AddTargetVariableToScript test.inc : fs_shell_command : fsShellCommand ; - -# If no variable name is given, the name (without grist) of the target is -# used, i.e. a variable "rc" referring to the rc command built for the host -# platform is defined in the script. -AddTargetVariableToScript test.inc : rc ; - - -# Optimizing Jamfile Parsing Times - -# Setting this variable will prevent the root Jamfile to include the Jamfile -# in the src directory. Instead only the directories required for building the -# build tools are included. Only useful in combination with DeferredSubInclude. -HAIKU_DONT_INCLUDE_SRC = 1 ; - -# Schedule the given subdirectory for inclusion at the end of the root -# Jamfile (directly using SubInclude here is not possible). Using this -# feature together with HAIKU_DONT_INCLUDE_SRC allows developers working -# only on a subproject to reduce Jamfile parsing times considerably. -DeferredSubInclude HAIKU_TOP src tests add-ons kernel file_systems - userlandfs ; - +# UserBuildConfig can be used to customize the build according to your needs. +# If existent it is included by the build system, but it is ignored by svn. +# This file documents a few examples, what can be done. + +# Adjusting Build Variables + +# Turn off warnings in directory src/system/kernel. As fourth (scope) parameter +# "local" is specified, which means, that this setting applies only to the +# given directory, but not any of its subdirectories. +SetConfigVar WARNINGS : HAIKU_TOP src system kernel : 0 : local ; + +# Add "RUN_WITHOUT_REGISTRAR" to the DEFINES for the directory src/kits and +# all its subdirectories (scope is "global"). +AppendToConfigVar DEFINES : HAIKU_TOP src kits : RUN_WITHOUT_REGISTRAR + : global ; + +# Set the debug level for file src/bin/gdb/gdb/haiku-nat.c (note, that +# the object file must be specified) to 1. It is worth mentioning, that the +# executable the object file is linked into (gdb), will still be placed in +# generated/objects/.../release/... Only when setting DEBUG for the executable, +# too, it will be placed in .../debug_1/... +DEBUG on haiku-nat.o = 1 ; + + +# Haiku Image Related Modifications + +# Create a 100 MB image at /tmp/walter.image. +HAIKU_IMAGE_NAME = walter.image ; +HAIKU_IMAGE_DIR = /tmp ; +HAIKU_IMAGE_SIZE = 100 ; + +# Name the VMWare image walter.vmdk (in directory $(HAIKU_IMAGE_DIR)). +HAIKU_VMWARE_IMAGE_NAME = walter.vmdk ; + +# Install Haiku in directory /Haiku. +HAIKU_INSTALL_DIR = /Haiku ; + +# If the image does already exist it won't be zeroed out. It will nevertheless +# freshly be initialized with BFS. Useful when installing Haiku on a partition. +HAIKU_DONT_CLEAR_IMAGE = 1 ; + + +# Affects the haiku-image, haiku-vmware-image, and install-haiku targets. Only +# targets on which the HAIKU_INCLUDE_IN_IMAGE variable has been set will be +# updated in the image file/installation directory. +# The update-image, update-vmware-image, and update-install targets always invoke +# this rule, so one likely doesn't ever need to do it manually. +SetUpdateHaikuImageOnly 1 ; + +# libbe.so and the kernel will be updated on image updates. Note that this +# generally doesn't work for pseudo targets (it does where special support +# has been added, like for "kernel"). +HAIKU_INCLUDE_IN_IMAGE on libbe.so kernel = 1 ; + +# Add "crashing_app" to the beos/bin directory of the Haiku image/installation. +# Note, that this also makes the image depend on the target, i.e. it is +# automatically updated when the image is built. +AddFilesToHaikuImage beos bin : crashing_app ; + +# Make a symlink to home/config/bin/crash. +AddSymlinkToHaikuImage home config bin : /beos/bin/crashing_app : crash ; + +# Adds the source directories src/kits/storage and src/tests/servers/debug +# (recursively) to the image (as /boot/home/HaikuSources/src/kits/storage +# and /boot/home/HaikuSources/src/tests/servers/debug respectively). +# Note that the second directory will also be copied, if the image will only +# be updated; the first one won't in that case. +AddSourceDirectoryToHaikuImage src/kits/storage ; +AddSourceDirectoryToHaikuImage src/tests/servers/debug : 1 ; + +# Unzips the given zip archive onto the image under /boot/develop/tools. +UnzipArchiveToHaikuImage develop tools + : /home/bonefish/develop/haiku/misc/gcc-2.95.3-beos-070218/gcc-2.95.3_binutils-2.17_rel-070218.zip ; + +# Adds the optional package WonderBrush to the image. The package is downloaded +# via wget (i.e. wget must be installed). +AddOptionalHaikuImagePackages WonderBrush ; + +# Adds the optional package Vision to the image. See above. +AddOptionalHaikuImagePackages Vision ; + +# Add all available optional packages. +HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ; + +# Specify scripts that shall be run when populating the image/installation +# directory. The "early" script is run before anything has been copied onto +# the image/into the installation directory. The "late" script is run after +# everything has been copied, but before the MIME database is installed. +HAIKU_IMAGE_EARLY_USER_SCRIPTS = $(HAIKU_TOP)/../early-image-script.sh ; +HAIKU_IMAGE_LATE_USER_SCRIPTS = $(HAIKU_TOP)/../late-image-script.sh ; + + +# Creating Sourceable Shell Scripts + +# If you use shell scripts (e.g. for testing) that need to access targets or +# build system properties, you can tell the build system to generate a +# variables defining shell script you can source from your shell script. + +# General setup for the shell script to generate. Name is test.inc, located +# in the output directory. +MakeLocate test.inc : $(HAIKU_OUTPUT_DIR) ; +Always test.inc ; + +# Define variable "outputDir" in the shell script, with the value of +# HAIKU_OUTPUT_DIR. +AddVariableToScript test.inc : outputDir : $(HAIKU_OUTPUT_DIR) ; + +# Define variables "bfsShell" and "fsShellCommand" referring to the +# generated bfs_shell and fs_shell_command respectively. +AddTargetVariableToScript test.inc : bfs_shell : bfsShell ; +AddTargetVariableToScript test.inc : fs_shell_command : fsShellCommand ; + +# If no variable name is given, the name (without grist) of the target is +# used, i.e. a variable "rc" referring to the rc command built for the host +# platform is defined in the script. +AddTargetVariableToScript test.inc : rc ; + + +# Optimizing Jamfile Parsing Times + +# Setting this variable will prevent the root Jamfile to include the Jamfile +# in the src directory. Instead only the directories required for building the +# build tools are included. Only useful in combination with DeferredSubInclude. +HAIKU_DONT_INCLUDE_SRC = 1 ; + +# Schedule the given subdirectory for inclusion at the end of the root +# Jamfile (directly using SubInclude here is not possible). Using this +# feature together with HAIKU_DONT_INCLUDE_SRC allows developers working +# only on a subproject to reduce Jamfile parsing times considerably. +DeferredSubInclude HAIKU_TOP src tests add-ons kernel file_systems + userlandfs ; + + +# Copy the posix test suite onto the image (or on the installation) into +# "home/posixtestsuite" directory, including the run script. +HAIKU_ADD_POSIX_TEST_SUITE_TO_IMAGE = 1 ; Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/Jamfile 2007-11-11 23:00:11 UTC (rev 22906) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/Jamfile 2007-11-12 00:08:06 UTC (rev 22907) @@ -1,3 +1,6 @@ SubDir HAIKU_TOP src tests system libroot posix posixtestsuite ; +MakeLocatePlatform run_posix_tests ; +Shell run_posix_tests : run_posix_tests.sh ; + SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance ; Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh 2007-11-11 23:00:11 UTC (rev 22906) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh 2007-11-12 00:08:06 UTC (rev 22907) @@ -3,14 +3,17 @@ usage() { cat < Message-ID: <411900576-BeMail@laptop> > "Fran?ois Revol" wrote: > > > mmu_man at BerliOS wrote: > > > > + Copyright 2004, yellowTAB GmbH, All rights reserved. > > > If you have written this, and own this, why is there a copyright > > > from > > > yellowTab on it? If you don't own this, we can't add it anyway. > > Because I started it when I worked there, so I used the standard > > template we had, but I was never asked to write it, so it's mine. > > See I sometimes do follow coding style :) > > Hehe, so we need to promise to pay you to get you to follow our style > guide? ;-)) Lol! > > > Also, please, we still have a coding style - it isn't too hard to > > > at > > > least use indent or something similar to correct the most obvious > > > violations. > > Yes I'm currently fixing my xemacs settings to do the indent > > correctly. > > It's only one setting for every project you're working on, that can't > be too hard :)) > Except it has many features... and some oddities of our style I'm not yet sure how to tell it. it should be possible to have it automatically put return types on their own line, but I don't know how to do. It would allow to reformat existing code very easily with M-x indent-region. It already can compact things like if(foo) {bar} else {plop} Into if (foo) { bar } else { plop } With correct indentation, putting braces on correct lines and fixing spaces. Fran?ois. From axeld at mail.berlios.de Mon Nov 12 12:44:57 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 12 Nov 2007 12:44:57 +0100 Subject: [Haiku-commits] r22908 - haiku/trunk/src/servers/app/drawing Message-ID: <200711121144.lACBivnR015476@sheep.berlios.de> Author: axeld Date: 2007-11-12 12:44:55 +0100 (Mon, 12 Nov 2007) New Revision: 22908 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22908&view=rev Modified: haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.h Log: * _FindBestMode() can now also take the aspect ratio into account. * Reduced rating of the color space - after all, the resolution is more important. * The EDID detailed modes are now scanned for the best mode available, this could be done in various ways, so please report any problems you have with it. * Ignore resolutions below 640x350 - this should also fix bug #1615. Modified: haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp 2007-11-12 00:08:06 UTC (rev 22907) +++ haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp 2007-11-12 11:44:55 UTC (rev 22908) @@ -403,20 +403,26 @@ */ status_t AccelerantHWInterface::_FindBestMode(const display_mode& compareMode, - display_mode& modeFound) const + float compareAspectRatio, display_mode& modeFound, int32 *_diff) const { int32 bestDiff = 0; int32 bestIndex = -1; for (int32 i = 0; i < fModeCount; i++) { display_mode& mode = fModeList[i]; + float aspectRatio = 0; + if (compareAspectRatio != 0 && mode.timing.v_display != 0) + aspectRatio = mode.timing.h_display / mode.timing.v_display; + // compute some random equality score + // TODO: check if these scores make sense int32 diff = 1000 * abs(mode.timing.h_display - compareMode.timing.h_display) + 1000 * abs(mode.timing.v_display - compareMode.timing.v_display) + abs(mode.timing.h_total * mode.timing.v_total - compareMode.timing.h_total * compareMode.timing.v_total) / 100 + abs(mode.timing.pixel_clock - compareMode.timing.pixel_clock) / 100 - + 100000 * abs(mode.space - compareMode.space); + + (int32)(500 * fabs(aspectRatio - compareAspectRatio)) + + 100 * abs(mode.space - compareMode.space); if (bestIndex == -1 || diff < bestDiff) { bestDiff = diff; @@ -428,6 +434,9 @@ return B_ERROR; modeFound = fModeList[bestIndex]; + if (_diff != 0) + *_diff = bestDiff; + return B_OK; } @@ -446,7 +455,7 @@ // At first, we search the closest display mode from the list of // supported modes - if that fails, we just take one - if (_FindBestMode(newMode, newMode) == B_OK + if (_FindBestMode(newMode, 0, newMode) == B_OK && fAccSetDisplayMode(&newMode) == B_OK) return B_OK; @@ -765,6 +774,8 @@ _UpdateModeList(); status = B_NOT_SUPPORTED; + display_mode bestMode; + int32 bestDiff = INT_MAX; // find preferred mode from EDID info for (uint32 i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i) { @@ -773,6 +784,14 @@ // construct basic mode and find it in the mode list const edid1_detailed_timing& timing = info.detailed_monitor[i].data.detailed_timing; + if (timing.h_active < 640 || timing.v_active < 350) + continue; + + float aspectRatio = 0.0f; + if (timing.h_size > 0 && timing.v_size > 0) + aspectRatio = 1.0f * timing.h_size / timing.v_size; + + display_mode modeFound; display_mode mode; mode.timing.pixel_clock = timing.pixel_clock * 10; mode.timing.h_display = timing.h_active; @@ -787,8 +806,20 @@ mode.virtual_width = timing.h_active; mode.virtual_height = timing.v_active; - status = _FindBestMode(mode, *preferredMode); + // TODO: eventually ignore detailed modes for the preferred one + // if there are more than one usable? + int32 diff; + status = _FindBestMode(mode, aspectRatio, modeFound, &diff); + if (status == B_OK) { + if (diff < bestDiff) { + bestMode = modeFound; + bestDiff = diff; + } + } } + + if (status == B_OK) + *preferredMode = bestMode; } return status; Modified: haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.h =================================================================== --- haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.h 2007-11-12 00:08:06 UTC (rev 22907) +++ haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.h 2007-11-12 11:44:55 UTC (rev 22908) @@ -107,7 +107,9 @@ uint32* count) const; uint32 _NativeColor(const rgb_color& color) const; status_t _FindBestMode(const display_mode& compareMode, - display_mode& modeFound) const; + float compareAspectRatio, + display_mode& modeFound, + int32 *_diff = NULL) const; status_t _SetFallbackMode(display_mode& mode) const; void _SetSystemPalette(); void _SetGrayscalePalette(); From bonefish at mail.berlios.de Mon Nov 12 19:41:37 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 12 Nov 2007 19:41:37 +0100 Subject: [Haiku-commits] r22909 - in haiku/trunk: headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager Message-ID: <200711121841.lACIfbup017877@sheep.berlios.de> Author: bonefish Date: 2007-11-12 19:41:36 +0100 (Mon, 12 Nov 2007) New Revision: 22909 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22909&view=rev Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp haiku/trunk/src/system/kernel/disk_device_manager/KFileDiskDevice.cpp haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp Log: axeld + bonefish: * Unmount when uninitializing a partition. * Finished the media checker implementation, i.e. we rescan when a media was inserted and uninitialize when ejected. * Turned the disk device media checker from a kernel daemon into a thread. Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h 2007-11-12 11:44:55 UTC (rev 22908) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h 2007-11-12 18:41:36 UTC (rev 22909) @@ -99,8 +99,8 @@ status_t RescanDiskSystems(); private: - static void _CheckMediaStatusDaemon(void* self, int iteration); - void _CheckMediaStatus(); + static status_t _CheckMediaStatusDaemon(void* self); + status_t _CheckMediaStatus(); status_t _RescanDiskSystems(bool fileSystems); @@ -127,6 +127,8 @@ PartitionMap *fPartitions; DiskSystemMap *fDiskSystems; PartitionSet *fObsoletePartitions; + thread_id fMediaChecker; + volatile bool fTerminating; static KDiskDeviceManager *sDefaultManager; }; Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-11-12 11:44:55 UTC (rev 22908) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-11-12 18:41:36 UTC (rev 22909) @@ -54,6 +54,7 @@ bool IsBusy() const; bool IsBusy(bool includeDescendants); bool CheckAndMarkBusy(bool includeDescendants); + void MarkBusy(bool includeDescendants); void UnmarkBusy(bool includeDescendants); void SetOffset(off_t offset); Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-12 11:44:55 UTC (rev 22908) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-12 18:41:36 UTC (rev 22909) @@ -103,15 +103,19 @@ fDevices(new(nothrow) DeviceMap), fPartitions(new(nothrow) PartitionMap), fDiskSystems(new(nothrow) DiskSystemMap), - fObsoletePartitions(new(nothrow) PartitionSet) + fObsoletePartitions(new(nothrow) PartitionSet), + fMediaChecker(-1), + fTerminating(false) { if (InitCheck() != B_OK) return; RescanDiskSystems(); - register_kernel_daemon(&_CheckMediaStatusDaemon, this, 10); - // once every second + fMediaChecker = spawn_kernel_thread(_CheckMediaStatusDaemon, + "media checker", B_NORMAL_PRIORITY, this); + if (fMediaChecker >= 0) + resume_thread(fMediaChecker); DBG(OUT("number of disk systems: %ld\n", CountDiskSystems())); // TODO: Watch the disk systems and the relevant directories. @@ -120,9 +124,11 @@ KDiskDeviceManager::~KDiskDeviceManager() { - unregister_kernel_daemon(&_CheckMediaStatusDaemon, this); + fTerminating = true; - // TODO: terminate and remove all jobs + status_t result; + wait_for_thread(fMediaChecker, &result); + // remove all devices for (int32 cookie = 0; KDiskDevice *device = NextDevice(&cookie);) { PartitionRegistrar _(device); @@ -1127,35 +1133,45 @@ } -void +status_t KDiskDeviceManager::_CheckMediaStatus() { - if (fLock.LockWithTimeout(0) != B_OK) - return; - - int32 cookie = 0; while (true) { - KDiskDevice* device = NextDevice(&cookie); - if (device == NULL) - break; + int32 cookie = 0; + while (KDiskDevice* device = RegisterNextDevice(&cookie)) { + DeviceWriteLocker locker(device); - bool hadMedia = device->HasMedia(); - device->UpdateMediaStatusIfNeeded(); + if (device->IsBusy(true)) + continue; - // TODO: propagate changes! - if (device->MediaChanged()) { + bool hadMedia = device->HasMedia(); + device->UpdateMediaStatusIfNeeded(); + + if (!device->MediaChanged() && (device->HasMedia() || !hadMedia)) + continue; + + device->MarkBusy(true); + device->UninitializeContents(true); + + if (device->MediaChanged()) { dprintf("Media changed from %s\n", device->Path()); - } else if (!device->HasMedia() && hadMedia) { - dprintf("Media removed from %s\n", device->Path()); + _ScanPartition(device, false); + } else if (!device->HasMedia() && hadMedia) { + dprintf("Media removed from %s\n", device->Path()); + } + + device->UnmarkBusy(true); } + + snooze(1000000); } - fLock.Unlock(); + return 0; } -void -KDiskDeviceManager::_CheckMediaStatusDaemon(void* self, int iteration) +status_t +KDiskDeviceManager::_CheckMediaStatusDaemon(void* self) { - ((KDiskDeviceManager*)self)->_CheckMediaStatus(); + return ((KDiskDeviceManager*)self)->_CheckMediaStatus(); } Modified: haiku/trunk/src/system/kernel/disk_device_manager/KFileDiskDevice.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KFileDiskDevice.cpp 2007-11-12 11:44:55 UTC (rev 22908) +++ haiku/trunk/src/system/kernel/disk_device_manager/KFileDiskDevice.cpp 2007-11-12 18:41:36 UTC (rev 22909) @@ -13,7 +13,6 @@ #include #include -#include "virtualdrive.h" // debugging //#define DBG(x) @@ -166,7 +165,6 @@ geometry->write_once = false; return B_OK; - } // _RegisterDevice @@ -175,48 +173,6 @@ { return devfs_publish_file_device(device + 5, file); // we need to remove the "/dev/" part from the path - - // TODO: For now we use the virtualdrive driver to register a file - // as a device and then simply symlink the assigned device to the - // desired device location. Replace that with the - // respective kernel magic for the OBOS kernel! - // -> Well, we could simply symlink the file there. Doesn't work for R5, - // but we should be able to deal with it properly. -// -// // open the virtualdrive control device -// int fd = open(VIRTUAL_DRIVE_CONTROL_DEVICE, O_RDONLY); -// if (fd < 0) { -// DBG(OUT("Failed to open virtualdrive control device: %s\n", -// strerror(errno))); -// return errno; -// } -// // set up the info -// virtual_drive_info info; -// strcpy(info.file_name, file); -// info.use_geometry = false; -// status_t error = B_OK; -// if (ioctl(fd, VIRTUAL_DRIVE_REGISTER_FILE, &info) != 0) { -// error = errno; -// DBG(OUT("Failed to install file device: %s\n", strerror(error))); -// } -// // close the control device -// close(fd); -// // create a symlink -// if (error == B_OK) { -// if (symlink(info.device_name, device) != 0) { -// DBG(OUT("Failed to create file device symlink: %s\n", -// strerror(error))); -// error = errno; -// // unregister the file device -// // open the device -// int deviceFD = open(info.device_name, O_RDONLY); -// if (deviceFD >= 0) { -// ioctl(deviceFD, VIRTUAL_DRIVE_UNREGISTER_FILE); -// close(deviceFD); -// } -// } -// } -// return error; } // _UnregisterDevice @@ -225,29 +181,6 @@ { return devfs_unpublish_file_device(_device + 5); // we need to remove the "/dev/" part from the path - -// // read the symlink to get the path of the virtualdrive device -// char device[B_PATH_NAME_LENGTH]; -// ssize_t bytesRead = readlink(_device, device, sizeof(device) - 1); -// if (bytesRead < 0) -// return errno; -// device[bytesRead] = '\0'; -// // open the device -// int fd = open(device, O_RDONLY); -// if (fd < 0) -// return errno; -// // issue the ioctl -// status_t error = B_OK; -// if (ioctl(fd, VIRTUAL_DRIVE_UNREGISTER_FILE) != 0) -// error = errno; -// // close the control device -// close(fd); -// // remove the symlink -// if (error == B_OK) { -// if (remove(_device) < 0) -// error = errno; -// } -// return error; } // _GetDirectoryPath Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2007-11-12 11:44:55 UTC (rev 22908) +++ haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2007-11-12 18:41:36 UTC (rev 22909) @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -22,6 +23,7 @@ #include #include #include +#include #include "UserDataWriter.h" @@ -272,6 +274,16 @@ if (IsBusy(includeDescendants)) return false; + MarkBusy(includeDescendants); + + return true; +} + + +// MarkBusy +void +KPartition::MarkBusy(bool includeDescendants) +{ if (includeDescendants) { struct MarkBusyVisitor : KPartitionVisitor { virtual bool VisitPre(KPartition* partition) @@ -284,8 +296,6 @@ VisitEachDescendant(&markVisitor); } else SetBusy(true); - - return true; } @@ -1039,7 +1049,13 @@ // volume if (VolumeID() >= 0) { -// TODO: Unmount? + status_t error = vfs_unmount(VolumeID(), + B_FORCE_UNMOUNT | B_UNMOUNT_BUSY_PARTITION); + if (error != B_OK) { + dprintf("KPartition::UninitializeContents(): Failed to unmount " + "device %ld: %s\n", VolumeID(), strerror(error)); + } + SetVolumeID(-1); flags |= B_PARTITION_CHANGED_VOLUME; } Modified: haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp 2007-11-12 11:44:55 UTC (rev 22908) +++ haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp 2007-11-12 18:41:36 UTC (rev 22909) @@ -1225,7 +1225,7 @@ return B_BAD_VALUE; // check busy - if (partition->IsBusy(true)) + if (!partition->CheckAndMarkBusy(true)) return B_BUSY; // TODO: We should also check, if any partition is mounted! From bonefish at mail.berlios.de Mon Nov 12 21:54:18 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 12 Nov 2007 21:54:18 +0100 Subject: [Haiku-commits] r22910 - in haiku/trunk: headers/private/kernel src/system/kernel/fs Message-ID: <200711122054.lACKsI7N029221@sheep.berlios.de> Author: bonefish Date: 2007-11-12 21:54:17 +0100 (Mon, 12 Nov 2007) New Revision: 22910 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22910&view=rev Modified: haiku/trunk/headers/private/kernel/vfs.h haiku/trunk/src/system/kernel/fs/vfs.cpp Log: axeld + bonefish: Missed those changes in the previous commit: * Added vfs_unmount(), which allows unmounting by dev_t (used by the DDM). Modified: haiku/trunk/headers/private/kernel/vfs.h =================================================================== --- haiku/trunk/headers/private/kernel/vfs.h 2007-11-12 18:41:36 UTC (rev 22909) +++ haiku/trunk/headers/private/kernel/vfs.h 2007-11-12 20:54:17 UTC (rev 22910) @@ -26,6 +26,8 @@ #define DEFAULT_NODE_MONITORS 4096 #define MAX_NODE_MONITORS 65536 +#define B_UNMOUNT_BUSY_PARTITION 0x80000000 + struct kernel_args; struct vm_cache; struct file_descriptor; @@ -107,6 +109,7 @@ status_t vfs_get_vnode_name(struct vnode *vnode, char *name, size_t nameSize); status_t vfs_get_cwd(dev_t *_mountID, ino_t *_vnodeID); void vfs_unlock_vnode_if_locked(struct file_descriptor *descriptor); +status_t vfs_unmount(dev_t mountID, uint32 flags); status_t vfs_disconnect_vnode(dev_t mountID, ino_t vnodeID); void vfs_free_unused_vnodes(int32 level); Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-11-12 18:41:36 UTC (rev 22909) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-11-12 20:54:17 UTC (rev 22910) @@ -244,7 +244,10 @@ static void inc_vnode_ref_count(struct vnode *vnode); static status_t dec_vnode_ref_count(struct vnode *vnode, bool reenter); static inline void put_vnode(struct vnode *vnode); +static status_t fs_unmount(char *path, dev_t mountID, uint32 flags, + bool kernel); + static struct fd_ops sFileOps = { file_read, file_write, @@ -3338,6 +3341,13 @@ } +status_t +vfs_unmount(dev_t mountID, uint32 flags) +{ + return fs_unmount(NULL, mountID, flags, true); +} + + extern "C" status_t vfs_disconnect_vnode(dev_t mountID, ino_t vnodeID) { @@ -5800,7 +5810,7 @@ static status_t -fs_unmount(char *path, uint32 flags, bool kernel) +fs_unmount(char *path, dev_t mountID, uint32 flags, bool kernel) { struct fs_mount *mount; struct vnode *vnode; @@ -5808,9 +5818,11 @@ FUNCTION(("vfs_unmount: entry. path = '%s', kernel %d\n", path, kernel)); - err = path_to_vnode(path, true, &vnode, NULL, kernel); - if (err < 0) - return B_ENTRY_NOT_FOUND; + if (path != NULL) { + err = path_to_vnode(path, true, &vnode, NULL, kernel); + if (err != B_OK) + return B_ENTRY_NOT_FOUND; + } RecursiveLocker mountOpLocker(sMountOpLock); @@ -5818,10 +5830,13 @@ if (!mount) panic("vfs_unmount: find_mount() failed on root vnode @%p of mount\n", vnode); - if (mount->root_vnode != vnode) { - // not mountpoint + if (path != NULL) { put_vnode(vnode); - return B_BAD_VALUE; + + if (mount->root_vnode != vnode) { + // not mountpoint + return B_BAD_VALUE; + } } // if the volume is associated with a partition, lock the device of the @@ -5840,7 +5855,7 @@ // make sure, that the partition is not busy if (partition) { - if (partition->IsBusy()) { + if ((flags & B_UNMOUNT_BUSY_PARTITION) == 0 && partition->IsBusy()) { TRACE(("fs_unmount(): Partition is busy.\n")); return B_BUSY; } @@ -5859,11 +5874,11 @@ // make sure all of them are not busy or have refs on them vnode = NULL; while ((vnode = (struct vnode *)list_get_next_item(&mount->vnodes, vnode)) != NULL) { - // The root vnode ref_count needs to be 2 here: one for the file - // system, one from the path_to_vnode() call above + // The root vnode ref_count needs to be 1 here (the mount has a + // reference). if (vnode->busy || ((vnode->ref_count != 0 && mount->root_vnode != vnode) - || (vnode->ref_count != 2 && mount->root_vnode == vnode))) { + || (vnode->ref_count != 1 && mount->root_vnode == vnode))) { // there are still vnodes in use on this mount, so we cannot // unmount yet busy = true; @@ -5919,8 +5934,8 @@ } } - // The ref_count of the root node is 2 at this point, see above why this is - mount->root_vnode->ref_count -= 2; + // The ref_count of the root node is 1 at this point, see above why this is + mount->root_vnode->ref_count--; mutex_unlock(&sVnodeMutex); @@ -6197,7 +6212,7 @@ if (pathBuffer.InitCheck() != B_OK) return B_NO_MEMORY; - return fs_unmount(pathBuffer.LockBuffer(), flags, true); + return fs_unmount(pathBuffer.LockBuffer(), -1, flags, true); } @@ -6908,7 +6923,7 @@ if (user_strlcpy(path, userPath, B_PATH_NAME_LENGTH) < B_OK) return B_BAD_ADDRESS; - return fs_unmount(path, flags, false); + return fs_unmount(path, -1, flags & ~B_UNMOUNT_BUSY_PARTITION, false); } From axeld at mail.berlios.de Mon Nov 12 23:38:39 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 12 Nov 2007 23:38:39 +0100 Subject: [Haiku-commits] r22911 - haiku/trunk/src/add-ons/kernel/partitioning_systems/session Message-ID: <200711122238.lACMcdRT009128@sheep.berlios.de> Author: axeld Date: 2007-11-12 23:38:39 +0100 (Mon, 12 Nov 2007) New Revision: 22911 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22911&view=rev Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp Log: * The session module deleted its cookie twice, after identifying, and when the partition cookie was deleted - when removing a CD it would crash. * Since the partition cookies are not needed at all, we don't use it anymore. * scan_partition() deleted the identify cookie on error, but that's not its job - free_identify_cookie() is always called, no matter what scan partition does. * Minor cleanup. Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp 2007-11-12 20:54:17 UTC (rev 22910) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp 2007-11-12 22:38:39 UTC (rev 22911) @@ -1,36 +1,27 @@ -//---------------------------------------------------------------------- -// This software is part of the Haiku distribution and is covered -// by the MIT license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -//--------------------------------------------------------------------- +/* + * Copyright 2003 Tyler Akidau, haiku at akidau.net + * Distributed under the terms of the MIT License. + */ + /*! \file session.cpp \brief Disk device manager partition module for CD/DVD sessions. */ +#include + #include #include #include -#include #include "Debug.h" #include "Disc.h" + #define SESSION_PARTITION_MODULE_NAME "partitioning_systems/session/v1" #define SESSION_PARTITION_NAME "Multisession Storage Device" -static status_t standard_operations(int32 op, ...); -static float identify_partition(int fd, partition_data *partition, - void **cookie); -static status_t scan_partition(int fd, partition_data *partition, - void *cookie); -static void free_identify_partition_cookie(partition_data *partition, - void *cookie); -static void free_partition_cookie(partition_data *partition); -static void free_partition_content_cookie(partition_data *partition); - static status_t standard_operations(int32 op, ...) { @@ -48,16 +39,16 @@ identify_partition(int fd, partition_data *partition, void **cookie) { DEBUG_INIT_ETC(NULL, ("fd: %d, id: %ld, offset: %Ld, " - "size: %Ld, block_size: %ld, flags: 0x%lx", fd, - partition->id, partition->offset, partition->size, - partition->block_size, partition->flags)); + "size: %Ld, block_size: %ld, flags: 0x%lx", fd, + partition->id, partition->offset, partition->size, + partition->block_size, partition->flags)); + device_geometry geometry; float result = -1; if (partition->flags & B_PARTITION_IS_DEVICE - && partition->block_size == 2048 - && ioctl(fd, B_GET_GEOMETRY, &geometry) == 0 - && geometry.device_type == B_CD) - { + && partition->block_size == 2048 + && ioctl(fd, B_GET_GEOMETRY, &geometry) == 0 + && geometry.device_type == B_CD) { Disc *disc = new Disc(fd); if (disc && disc->InitCheck() == B_OK) { *cookie = static_cast(disc); @@ -73,51 +64,36 @@ scan_partition(int fd, partition_data *partition, void *cookie) { DEBUG_INIT_ETC(NULL, ("fd: %d, id: %ld, offset: %Ld, size: %Ld, " - "block_size: %ld, cookie: %p", fd, partition->id, partition->offset, - partition->size, partition->block_size, cookie)); + "block_size: %ld, cookie: %p", fd, partition->id, partition->offset, + partition->size, partition->block_size, cookie)); - status_t error = fd >= 0 && partition && cookie ? B_OK : B_BAD_VALUE; - if (!error) { - Disc *disc = static_cast(cookie); - partition->status = B_PARTITION_VALID; - partition->flags |= B_PARTITION_PARTITIONING_SYSTEM - | B_PARTITION_READ_ONLY; - partition->content_size = partition->size; - partition->content_cookie = disc; - - Session *session = NULL; - for (int i = 0; (session = disc->GetSession(i)); i++) { - partition_data *child = create_child_partition(partition->id, - i, -1); - if (!child) { - PRINT(("Unable to create child at index %d.\n", i)); - // something went wrong - error = B_ERROR; - break; - } - child->offset = partition->offset + session->Offset(); - child->size = session->Size(); - child->block_size = session->BlockSize(); - child->flags |= session->Flags(); - child->type = strdup(session->Type()); - if (!child->type) { - error = B_NO_MEMORY; - break; - } - child->parameters = NULL; - child->cookie = session; + Disc *disc = static_cast(cookie); + partition->status = B_PARTITION_VALID; + partition->flags |= B_PARTITION_PARTITIONING_SYSTEM + | B_PARTITION_READ_ONLY; + partition->content_size = partition->size; + + Session *session = NULL; + status_t error = B_OK; + for (int i = 0; (session = disc->GetSession(i)); i++) { + partition_data *child = create_child_partition(partition->id, + i, -1); + if (!child) { + PRINT(("Unable to create child at index %d.\n", i)); + // something went wrong + error = B_ERROR; + break; } - } - // cleanup on error - if (error) { - delete static_cast(cookie); - partition->content_cookie = NULL; - for (int32 i = 0; i < partition->child_count; i++) { - if (partition_data *child = get_child_partition(partition->id, i)) { - delete static_cast(child->cookie); - child->cookie = NULL; - } + child->offset = partition->offset + session->Offset(); + child->size = session->Size(); + child->block_size = session->BlockSize(); + child->flags |= session->Flags(); + child->type = strdup(session->Type()); + if (!child->type) { + error = B_NO_MEMORY; + break; } + child->parameters = NULL; } PRINT(("error: 0x%lx, `%s'\n", error, strerror(error))); RETURN(error); @@ -127,35 +103,11 @@ static void free_identify_partition_cookie(partition_data */*partition*/, void *cookie) { - if (cookie) { - DEBUG_INIT_ETC(NULL, ("cookie: %p", cookie)); - delete static_cast(cookie); - } + DEBUG_INIT_ETC(NULL, ("cookie: %p", cookie)); + delete static_cast(cookie); } -static void -free_partition_cookie(partition_data *partition) -{ - if (partition && partition->cookie) { - DEBUG_INIT_ETC(NULL, ("partition->cookie: %p", partition->cookie)); - delete static_cast(partition->cookie); - partition->cookie = NULL; - } -} - - -static void -free_partition_content_cookie(partition_data *partition) -{ - if (partition && partition->content_cookie) { - DEBUG_INIT_ETC(NULL, ("partition->content_cookie: %p", partition->content_cookie)); - delete static_cast(partition->content_cookie); - partition->content_cookie = NULL; - } -} - - static partition_module_info sSessionModule = { { SESSION_PARTITION_MODULE_NAME, @@ -169,8 +121,8 @@ identify_partition, // identify_partition scan_partition, // scan_partition free_identify_partition_cookie, // free_identify_partition_cookie - free_partition_cookie, // free_partition_cookie - free_partition_content_cookie, // free_partition_content_cookie + NULL, // free_partition_cookie + NULL, // free_partition_content_cookie }; partition_module_info *modules[] = { From axeld at mail.berlios.de Tue Nov 13 00:20:34 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 13 Nov 2007 00:20:34 +0100 Subject: [Haiku-commits] r22912 - in haiku/trunk: headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager Message-ID: <200711122320.lACNKY7S011429@sheep.berlios.de> Author: axeld Date: 2007-11-13 00:20:33 +0100 (Tue, 13 Nov 2007) New Revision: 22912 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22912&view=rev Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp Log: * Added an UninitializeMedia() method to KDiskDevice that also resets the device geometry. * If SetTo() reports no media, and GetGeometry() fails, the device geometry is now reset as well. * KDiskDeviceManager::_ScanPartition() no longer unmarks the partition busy; this is now done by the caller, and done independently from the outcome of _ScanPartition(). This also fixes the problem that devices with no media were never marked unbusy (and thus were ignored subsequently). Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h 2007-11-12 22:38:39 UTC (rev 22911) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h 2007-11-12 23:20:33 UTC (rev 22912) @@ -55,6 +55,7 @@ bool MediaChanged() const; void UpdateMediaStatusIfNeeded(); + void UninitializeMedia(); status_t SetPath(const char *path); // TODO: Remove this method or make it private. Once initialized the @@ -82,6 +83,7 @@ virtual status_t GetGeometry(device_geometry *geometry); private: + void _ResetGeometry(); void _InitPartitionData(); disk_device_data fDeviceData; Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp 2007-11-12 22:38:39 UTC (rev 22911) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp 2007-11-12 23:20:33 UTC (rev 22912) @@ -71,7 +71,8 @@ } else { // no media: try to get the device geometry, but don't fail, if // we can't get it - GetGeometry(&fDeviceData.geometry); + if (GetGeometry(&fDeviceData.geometry) != B_OK) + _ResetGeometry(); } // set device flags if (fDeviceData.geometry.removable) @@ -102,14 +103,7 @@ free(fDeviceData.path); fDeviceData.path = NULL; } - fDeviceData.geometry.bytes_per_sector = 0; - fDeviceData.geometry.sectors_per_track = 0; - fDeviceData.geometry.cylinder_count = 0; - fDeviceData.geometry.head_count = 0; - fDeviceData.geometry.device_type = B_DISK; - fDeviceData.geometry.removable = true; - fDeviceData.geometry.read_only = true; - fDeviceData.geometry.write_once = false; + _ResetGeometry(); } // InitCheck @@ -248,6 +242,14 @@ } +void +KDiskDevice::UninitializeMedia() +{ + UninitializeContents(); + _ResetGeometry(); +} + + // SetPath status_t KDiskDevice::SetPath(const char *path) @@ -383,3 +385,17 @@ fPartitionData.flags |= B_PARTITION_IS_DEVICE; } + +void +KDiskDevice::_ResetGeometry() +{ + fDeviceData.geometry.bytes_per_sector = 0; + fDeviceData.geometry.sectors_per_track = 0; + fDeviceData.geometry.cylinder_count = 0; + fDeviceData.geometry.head_count = 0; + fDeviceData.geometry.device_type = B_DISK; + fDeviceData.geometry.removable = true; + fDeviceData.geometry.read_only = true; + fDeviceData.geometry.write_once = false; +} + Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-12 22:38:39 UTC (rev 22911) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-12 23:20:33 UTC (rev 22912) @@ -531,6 +531,7 @@ // scan device if (error == B_OK) { _ScanPartition(device, false); + device->UnmarkBusy(true); if (newlyCreated) *newlyCreated = true; @@ -746,6 +747,7 @@ if (DeviceWriteLocker deviceLocker = device) { if (ManagerLocker locker = this) { error = _ScanPartition(device, false); + device->UnmarkBusy(true); if (error != B_OK) break; } else @@ -1034,18 +1036,7 @@ // scan synchronously - if (!partition->Device()->HasMedia()) - return B_OK; - - status_t error = _ScanPartition(partition); - - // mark all partitions un-busy -// TODO: This is not quite correct here. Partitions are created marked "busy", -// hence the one creating it should be responsible for clearing the flag, not -// us. - partition->UnmarkBusy(true); - - return error; + return _ScanPartition(partition); } @@ -1055,6 +1046,8 @@ // the partition's device must be write-locked if (!partition) return B_BAD_VALUE; + if (!partition->Device()->HasMedia()) + return B_OK; if (partition->DiskSystem() != NULL) { // TODO: this is more or less a hack to allow rescanning a partition for (int32 i = 0; KPartition *child = partition->ChildAt(i); i++) @@ -1151,7 +1144,7 @@ continue; device->MarkBusy(true); - device->UninitializeContents(true); + device->UninitializeMedia(); if (device->MediaChanged()) { dprintf("Media changed from %s\n", device->Path()); From philippe.houdoin at free.fr Tue Nov 13 10:17:32 2007 From: philippe.houdoin at free.fr (Philippe Houdoin) Date: Tue, 13 Nov 2007 10:17:32 +0100 Subject: [Haiku-commits] r22909 - in haiku/trunk: headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager Message-ID: <1194945452.47396bac48efd@imp.free.fr> > + volatile bool fTerminating; Did I miss something or this variable is not really used actually? I guess checking its value in _CheckMediaStatus() was intended at first but didn't append yet... - Phil, poorly reduced to an occasional commits lurker these days... From axeld at mail.berlios.de Tue Nov 13 11:34:49 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 13 Nov 2007 11:34:49 +0100 Subject: [Haiku-commits] r22913 - in haiku/trunk: headers/os/drivers headers/private/fs_shell src/add-ons/kernel/file_systems/bfs src/add-ons/kernel/file_systems/fat src/system/kernel/cache src/tools/fs_shell Message-ID: <200711131034.lADAYnCY005359@sheep.berlios.de> Author: axeld Date: 2007-11-13 11:34:48 +0100 (Tue, 13 Nov 2007) New Revision: 22913 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22913&view=rev Modified: haiku/trunk/headers/os/drivers/fs_cache.h haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp haiku/trunk/src/add-ons/kernel/file_systems/fat/dir.c haiku/trunk/src/system/kernel/cache/file_map.cpp haiku/trunk/src/tools/fs_shell/file_map.cpp Log: * The file map needs to know the actual file size to be able to know if it has the complete extent info or not. * file_map_translate() now cuts down the request to the file bounds. * Adjusted BFS and FAT to the API changes. Modified: haiku/trunk/headers/os/drivers/fs_cache.h =================================================================== --- haiku/trunk/headers/os/drivers/fs_cache.h 2007-11-12 23:20:33 UTC (rev 22912) +++ haiku/trunk/headers/os/drivers/fs_cache.h 2007-11-13 10:34:48 UTC (rev 22913) @@ -67,7 +67,7 @@ const void *buffer, size_t *_size); /* file map */ -extern void *file_map_create(dev_t mountID, ino_t vnodeID); +extern void *file_map_create(dev_t mountID, ino_t vnodeID, off_t size); extern void file_map_delete(void *_map); extern void file_map_set_size(void *_map, off_t size); extern void file_map_invalidate(void *_map, off_t offset, off_t size); Modified: haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h 2007-11-12 23:20:33 UTC (rev 22912) +++ haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h 2007-11-13 10:34:48 UTC (rev 22913) @@ -84,7 +84,7 @@ /* file map */ extern void * fssh_file_map_create(fssh_mount_id mountID, - fssh_vnode_id vnodeID); + fssh_vnode_id vnodeID, fssh_off_t size); extern void fssh_file_map_delete(void *_map); extern void fssh_file_map_set_size(void *_map, fssh_off_t size); extern void fssh_file_map_invalidate(void *_map, fssh_off_t offset, Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2007-11-12 23:20:33 UTC (rev 22912) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2007-11-13 10:34:48 UTC (rev 22913) @@ -195,7 +195,7 @@ fTree = new BPlusTree(this); if (IsFile() || IsAttribute()) { SetFileCache(file_cache_create(fVolume->ID(), ID(), Size())); - SetMap(file_map_create(volume->ID(), ID())); + SetMap(file_map_create(volume->ID(), ID(), Size())); } } @@ -2417,7 +2417,8 @@ if (inode->IsFile() || inode->IsAttribute()) { inode->SetFileCache(file_cache_create(volume->ID(), inode->ID(), inode->Size())); - inode->SetMap(file_map_create(volume->ID(), inode->ID())); + inode->SetMap(file_map_create(volume->ID(), inode->ID(), + inode->Size())); } if (_created) Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-11-12 23:20:33 UTC (rev 22912) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-11-13 10:34:48 UTC (rev 22913) @@ -858,7 +858,7 @@ // links usually don't have a file cache attached - but we now need one link->SetFileCache(file_cache_create(volume->ID(), link->ID(), 0)); - link->SetMap(file_map_create(volume->ID(), link->ID())); + link->SetMap(file_map_create(volume->ID(), link->ID(), 0)); // The following call will have to write the inode back, so // we don't have to do that here... Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/dir.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/fat/dir.c 2007-11-12 23:20:33 UTC (rev 22912) +++ haiku/trunk/src/add-ons/kernel/file_systems/fat/dir.c 2007-11-13 10:34:48 UTC (rev 22913) @@ -1039,7 +1039,7 @@ if (entry->filename) strcpy(entry->filename, filename); #endif entry->cache = file_cache_create(vol->id, vnid, entry->st_size); - entry->file_map = file_map_create(vol->id, vnid); + entry->file_map = file_map_create(vol->id, vnid, entry->st_size); if (!(entry->mode & FAT_SUBDIR)) set_mime_type(entry, filename); Modified: haiku/trunk/src/system/kernel/cache/file_map.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_map.cpp 2007-11-12 23:20:33 UTC (rev 22912) +++ haiku/trunk/src/system/kernel/cache/file_map.cpp 2007-11-13 10:34:48 UTC (rev 22913) @@ -40,7 +40,7 @@ }; struct file_map { - file_map(); + file_map(off_t size); ~file_map(); file_extent *operator[](uint32 index); @@ -54,13 +54,15 @@ }; size_t count; struct vnode *vnode; + off_t size; }; -file_map::file_map() +file_map::file_map(off_t _size) { array = NULL; count = 0; + size = _size; } @@ -179,11 +181,12 @@ extern "C" void * -file_map_create(dev_t mountID, ino_t vnodeID) +file_map_create(dev_t mountID, ino_t vnodeID, off_t size) { - TRACE(("file_map_create(mountID = %ld, vnodeID = %Ld)\n", mountID, vnodeID)); + TRACE(("file_map_create(mountID = %ld, vnodeID = %Ld, size = %Ld)\n", + mountID, vnodeID, size)); - file_map *map = new file_map; + file_map *map = new file_map(size); if (map == NULL) return NULL; @@ -218,7 +221,9 @@ // TODO: honour offset/size parameters file_map *map = (file_map *)_map; - map->Free(); + if (size < map->size) + map->Free(); + map->size = size; } @@ -248,6 +253,13 @@ size_t maxVecs = *_count; status_t status = B_OK; + if (offset > map.size) { + *_count = 0; + return B_OK; + } + if (offset + size > map.size) + size = map.size - offset; + if (map.count == 0) { // we don't yet have the map of this file, so let's grab it // (ordered by offset, so that we can do a binary search on them) Modified: haiku/trunk/src/tools/fs_shell/file_map.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/file_map.cpp 2007-11-12 23:20:33 UTC (rev 22912) +++ haiku/trunk/src/tools/fs_shell/file_map.cpp 2007-11-13 10:34:48 UTC (rev 22913) @@ -34,7 +34,7 @@ }; struct file_map { - file_map(); + file_map(fssh_off_t size); ~file_map(); file_extent *operator[](uint32_t index); @@ -49,13 +49,15 @@ }; fssh_size_t count; void *vnode; + fssh_off_t size; }; -file_map::file_map() +file_map::file_map(fssh_off_t _size) { array = NULL; count = 0; + size = size; } @@ -178,11 +180,12 @@ extern "C" void * -fssh_file_map_create(fssh_mount_id mountID, fssh_vnode_id vnodeID) +fssh_file_map_create(fssh_mount_id mountID, fssh_vnode_id vnodeID, + fssh_off_t size) { TRACE(("file_map_create(mountID = %ld, vnodeID = %Ld)\n", mountID, vnodeID)); - file_map *map = new file_map; + file_map *map = new file_map(size); if (map == NULL) return NULL; @@ -217,7 +220,9 @@ // TODO: honour offset/size parameters file_map *map = (file_map *)_map; - map->Free(); + if (size < map->size) + map->Free(); + map->size = size; } @@ -244,6 +249,13 @@ fssh_size_t maxVecs = *_count; fssh_status_t status = FSSH_B_OK; + if (offset > map.size) { + *_count = 0; + return FSSH_B_OK; + } + if (offset + size > map.size) + size = map.size - offset; + if (map.count == 0) { // we don't yet have the map of this file, so let's grab it // (ordered by offset, so that we can do a binary search on them) From stippi at mail.berlios.de Tue Nov 13 11:43:41 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 13 Nov 2007 11:43:41 +0100 Subject: [Haiku-commits] r22914 - in haiku/trunk/src/add-ons/screen_savers: . spider Message-ID: <200711131043.lADAhfqI006225@sheep.berlios.de> Author: stippi Date: 2007-11-13 11:43:41 +0100 (Tue, 13 Nov 2007) New Revision: 22914 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22914&view=rev Added: haiku/trunk/src/add-ons/screen_savers/spider/ haiku/trunk/src/add-ons/screen_savers/spider/Jamfile haiku/trunk/src/add-ons/screen_savers/spider/Polygon.cpp haiku/trunk/src/add-ons/screen_savers/spider/Polygon.h haiku/trunk/src/add-ons/screen_savers/spider/PolygonQueue.cpp haiku/trunk/src/add-ons/screen_savers/spider/PolygonQueue.h haiku/trunk/src/add-ons/screen_savers/spider/SpiderSaver.cpp haiku/trunk/src/add-ons/screen_savers/spider/SpiderSaver.h Modified: haiku/trunk/src/add-ons/screen_savers/Jamfile Log: * contributed my "Spider" screen saver to Haiku Modified: haiku/trunk/src/add-ons/screen_savers/Jamfile =================================================================== --- haiku/trunk/src/add-ons/screen_savers/Jamfile 2007-11-13 10:34:48 UTC (rev 22913) +++ haiku/trunk/src/add-ons/screen_savers/Jamfile 2007-11-13 10:43:41 UTC (rev 22914) @@ -5,3 +5,4 @@ SubInclude HAIKU_TOP src add-ons screen_savers ifs ; SubInclude HAIKU_TOP src add-ons screen_savers message ; SubInclude HAIKU_TOP src add-ons screen_savers slideshowsaver ; +SubInclude HAIKU_TOP src add-ons screen_savers spider ; Added: haiku/trunk/src/add-ons/screen_savers/spider/Jamfile =================================================================== --- haiku/trunk/src/add-ons/screen_savers/spider/Jamfile 2007-11-13 10:34:48 UTC (rev 22913) +++ haiku/trunk/src/add-ons/screen_savers/spider/Jamfile 2007-11-13 10:43:41 UTC (rev 22914) @@ -0,0 +1,12 @@ +SubDir HAIKU_TOP src add-ons screen_savers spider ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +ScreenSaver Spider : + Polygon.cpp + PolygonQueue.cpp + SpiderSaver.cpp + + : be libscreensaver.so +; + Added: haiku/trunk/src/add-ons/screen_savers/spider/Polygon.cpp =================================================================== --- haiku/trunk/src/add-ons/screen_savers/spider/Polygon.cpp 2007-11-13 10:34:48 UTC (rev 22913) +++ haiku/trunk/src/add-ons/screen_savers/spider/Polygon.cpp 2007-11-13 10:43:41 UTC (rev 22914) @@ -0,0 +1,83 @@ +/* + * Copyright 2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan A?mus + */ +#include "Polygon.h" + +#include +#include +#include + +// constructor +Polygon::Polygon(BRect bounds, int32 vertices) + : fPoints(vertices), + fBounds(bounds) +{ + float min = bounds.Width() / 64000.0; + float max = bounds.Width() / 320.0; + for (int32 i = 0; i < vertices; i++) { + point_vector* pv = new point_vector; + pv->point.x = bounds.left + fmod(lrand48(), bounds.Width()); + pv->point.y = bounds.top + fmod(lrand48(), bounds.Height()); + pv->vector.x = min + fmod(lrand48(), max - min); + pv->vector.y = min + fmod(lrand48(), max - min); + fPoints.AddItem((void*)pv); + } +} + +// constructor +Polygon::Polygon(BRect bounds, BList points) + : fPoints(points.CountItems()), + fBounds(bounds) +{ + fPoints = points; +} + +// destructor +Polygon::~Polygon() +{ + while (point_vector* pv = (point_vector*)fPoints.RemoveItem(0L)) + delete pv; +} + +// Step +Polygon* +Polygon::Step() const +{ + BList points(CountPoints()); + for (int32 i = 0; point_vector *pv = (point_vector*)fPoints.ItemAt(i); i++) { + point_vector* npv = new point_vector; + BPoint p = pv->point + pv->vector; + if (p.x < fBounds.left || p.x > fBounds.right) + npv->vector.x = -pv->vector.x; + else + npv->vector.x = pv->vector.x; + if (p.y < fBounds.top || p.y > fBounds.bottom) + npv->vector.y = -pv->vector.y; + else + npv->vector.y = pv->vector.y; + npv->point = pv->point + npv->vector; + points.AddItem((void*)npv); + } + return new Polygon(fBounds, points); +} + +// CountPoints +uint32 +Polygon::CountPoints() const +{ + return fPoints.CountItems(); +} + +// PointAt +BPoint +Polygon::PointAt(int32 index) const +{ + BPoint p; + if (point_vector* pv = (point_vector*)fPoints.ItemAt(index)) + p = pv->point; + return p; +} Added: haiku/trunk/src/add-ons/screen_savers/spider/Polygon.h =================================================================== --- haiku/trunk/src/add-ons/screen_savers/spider/Polygon.h 2007-11-13 10:34:48 UTC (rev 22913) +++ haiku/trunk/src/add-ons/screen_savers/spider/Polygon.h 2007-11-13 10:43:41 UTC (rev 22914) @@ -0,0 +1,36 @@ +/* + * Copyright 2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan A?mus + */ +#ifndef POLYGON_H +#define POLYGON_H + +#include +#include +#include + +struct point_vector { + BPoint point; + BPoint vector; +}; + +class Polygon { + public: + Polygon(BRect bounds, BList points); + Polygon(BRect bounds, int32 vertices); + virtual ~Polygon(); + + Polygon* Step() const; + + uint32 CountPoints() const; + BPoint PointAt(int32 index) const; + + private: + BList fPoints; + BRect fBounds; +}; + +#endif // ABOUT_VPOLYGON_HIEW_H Added: haiku/trunk/src/add-ons/screen_savers/spider/PolygonQueue.cpp =================================================================== --- haiku/trunk/src/add-ons/screen_savers/spider/PolygonQueue.cpp 2007-11-13 10:34:48 UTC (rev 22913) +++ haiku/trunk/src/add-ons/screen_savers/spider/PolygonQueue.cpp 2007-11-13 10:43:41 UTC (rev 22914) @@ -0,0 +1,61 @@ +/* + * Copyright 2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan A?mus + */ +#include "PolygonQueue.h" + +#include +#include + +#include "Polygon.h" + +// constructor +PolygonQueue::PolygonQueue(Polygon* start, int32 depth) + : fPolygons(new Polygon*[depth]), + fDepth(depth) +{ + for (int32 i = 0; i < fDepth; i++) + fPolygons[i] = NULL; + fPolygons[fDepth - 1] = start; +} + +// destructor +PolygonQueue::~PolygonQueue() +{ + for (int32 i = 0; i < fDepth; i++) + delete fPolygons[i]; + delete[] fPolygons; +} + +// Head +Polygon* +PolygonQueue::Head() const +{ + return fPolygons[fDepth - 1]; +} + +// Tail +Polygon* +PolygonQueue::Tail() const +{ + return fPolygons[0]; +} + +// Step +void +PolygonQueue::Step() +{ + if (Polygon* p = Head()) { + Polygon *np = p->Step(); + // drop tail + delete Tail(); + // shift + for (int32 i = 0; i < fDepth - 1; i++) + fPolygons[i] = fPolygons[i + 1]; + // and put new head at top + fPolygons[fDepth - 1] = np; + } +} Added: haiku/trunk/src/add-ons/screen_savers/spider/PolygonQueue.h =================================================================== --- haiku/trunk/src/add-ons/screen_savers/spider/PolygonQueue.h 2007-11-13 10:34:48 UTC (rev 22913) +++ haiku/trunk/src/add-ons/screen_savers/spider/PolygonQueue.h 2007-11-13 10:43:41 UTC (rev 22914) @@ -0,0 +1,30 @@ +/* + * Copyright 2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan A?mus + */ +#ifndef POLYGON_QUEUE_H +#define POLYGON_QUEUE_H + +#include + +class Polygon; + +class PolygonQueue { + public: + PolygonQueue(Polygon* start, int32 depth); + virtual ~PolygonQueue(); + + Polygon* Head() const; + Polygon* Tail() const; + + void Step(); + + private: + Polygon** fPolygons; + int32 fDepth; +}; + +#endif // POLYGON_QUEUE_H Added: haiku/trunk/src/add-ons/screen_savers/spider/SpiderSaver.cpp =================================================================== --- haiku/trunk/src/add-ons/screen_savers/spider/SpiderSaver.cpp 2007-11-13 10:34:48 UTC (rev 22913) +++ haiku/trunk/src/add-ons/screen_savers/spider/SpiderSaver.cpp 2007-11-13 10:43:41 UTC (rev 22914) @@ -0,0 +1,473 @@ +/* + * Copyright 2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan A?mus + */ +#include "SpiderSaver.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "Polygon.h" +#include "PolygonQueue.h" + +enum { + MSG_QUEUE_NUMBER = 'qunm', + MSG_POLY_NUMBER = 'plnm', + MSG_QUEUE_DEPTH = 'qudp', + MSG_COLOR = 'colr', +}; + +#define MIN_POLY_POINTS 3 +#define MAX_POLY_POINTS 10 +#define MIN_QUEUE_DEPTH 40 +#define MAX_QUEUE_DEPTH 160 +#define MAX_QUEUE_NUMBER 40 + +enum { + RED = 1, + GREEN = 2, + BLUE = 3, + YELLOW = 4, + PURPLE = 5, + CYAN = 6, + GRAY = 7, +}; + +// MAIN INSTANTIATION FUNCTION +extern "C" _EXPORT BScreenSaver* +instantiate_screen_saver(BMessage *message, image_id image) +{ + return new SpiderSaver(message, image); +} + +// constructor +SpiderSaver::SpiderSaver(BMessage *message, image_id id) + : BScreenSaver(message, id), + fBackBitmap(NULL), + fBackView(NULL), + fQueues(new PolygonQueue*[MAX_QUEUE_NUMBER]), + fQueueNumber(20), + fMaxPolyPoints(MAX_POLY_POINTS), + fMaxQueueDepth(MAX_QUEUE_DEPTH), + fColor(RED) +{ + for (int32 i = 0; i < MAX_QUEUE_NUMBER; i++) + fQueues[i] = NULL; + if (message) { + int32 value; + if (message->FindInt32("queue number", &value) == B_OK) + fQueueNumber = value; + if (message->FindInt32("poly points", &value) == B_OK) + fMaxPolyPoints = value; + if (message->FindInt32("queue depth", &value) == B_OK) + fMaxQueueDepth = value; + if (message->FindInt32("color", &value) == B_OK) + fColor = value; + } + srand48((long int)system_time()); +} + +// destructor +SpiderSaver::~SpiderSaver() +{ + _Cleanup(); + delete[] fQueues; +} + +// StartConfig +void +SpiderSaver::StartConfig(BView *view) +{ + SpiderView* configView = new SpiderView(view->Bounds(), this, + fQueueNumber, fMaxPolyPoints, + fMaxQueueDepth, fColor); + view->AddChild(configView); +} + +// StartSaver +status_t +SpiderSaver::StartSaver(BView *v, bool preview) +{ + SetTickSize(50000); + + fPreview = preview; + fBounds = v->Bounds(); + _Init(fBounds); + + return B_OK; +} + +// StopSaver +void +SpiderSaver::StopSaver() +{ + _Cleanup(); +} + +// Draw +void +SpiderSaver::Draw(BView *view, int32 frame) +{ + fLocker.Lock(); + for (uint32 i = 0; i < fQueueNumber; i++) { + if (fQueues[i]) + fQueues[i]->Step(); + } + if (fBackView) { + if (fBackBitmap->Lock()) { + _DrawInto(fBackView); + fBackView->Sync(); + fBackBitmap->Unlock(); + } + view->DrawBitmap(fBackBitmap, BPoint(0.0, 0.0)); + } + fLocker.Unlock(); +} + +// SaveState +status_t +SpiderSaver::SaveState(BMessage* into) const +{ + if (into) { + into->AddInt32("queue number", (int32)fQueueNumber); + into->AddInt32("poly points", (int32)fMaxPolyPoints); + into->AddInt32("queue depth", (int32)fMaxQueueDepth); + into->AddInt32("color", (int32)fColor); + return B_OK; + } + return B_BAD_VALUE; +} + +// SetQueueNumber +void +SpiderSaver::SetQueueNumber(uint32 number) +{ + fLocker.Lock(); + _Cleanup(); + fQueueNumber = number; + _Init(fBounds); + fLocker.Unlock(); +} + +// SetQueueDepth +void +SpiderSaver::SetQueueDepth(uint32 maxDepth) +{ + fLocker.Lock(); + _Cleanup(); + fMaxQueueDepth = maxDepth; + _Init(fBounds); + fLocker.Unlock(); +} + +// SetPolyPoints +void +SpiderSaver::SetPolyPoints(uint32 maxPoints) +{ + fLocker.Lock(); + _Cleanup(); + fMaxPolyPoints = maxPoints; + _Init(fBounds); + fLocker.Unlock(); +} + +// SetColor +void +SpiderSaver::SetColor(uint32 color) +{ + fLocker.Lock(); + _Cleanup(); + fColor = color; + _Init(fBounds); + fLocker.Unlock(); +} + +// _Init +void +SpiderSaver::_Init(BRect bounds) +{ + _AllocBackBitmap(bounds.Width(), bounds.Height()); + uint32 minPoints = fMaxPolyPoints / 2; + uint32 maxPoints = fMaxPolyPoints; + uint32 minQueueDepth = fMaxQueueDepth / 2; + uint32 maxQueueDepth = fMaxQueueDepth; + if (fPreview) { + minQueueDepth /= 4; + maxQueueDepth /= 4; + } + for (uint32 i = 0; i < fQueueNumber; i++) + fQueues[i] = new PolygonQueue(new Polygon(bounds, minPoints + + lrand48() + % (maxPoints + - minPoints)), + minQueueDepth + lrand48() % (maxQueueDepth + - minQueueDepth)); +} + +// _Cleanup +void +SpiderSaver::_Cleanup() +{ + _FreeBackBitmap(); + for (int32 i = 0; i < MAX_QUEUE_NUMBER; i++) { + delete fQueues[i]; + fQueues[i] = NULL; + } +} + +// _AllocBackBitmap +void +SpiderSaver::_AllocBackBitmap(float width, float height) +{ + // sanity check + if (width <= 0.0 || height <= 0.0) + return; + + BRect b(0.0, 0.0, width, height); + fBackBitmap = new BBitmap(b, B_RGB32, true); + if (!fBackBitmap) + return; + if (fBackBitmap->IsValid()) { + fBackView = new BView(b, 0, B_FOLLOW_NONE, B_WILL_DRAW); + fBackBitmap->AddChild(fBackView); + memset(fBackBitmap->Bits(), 0, fBackBitmap->BitsLength()); + } else { + _FreeBackBitmap(); + fprintf(stderr, "SpiderSaver::_AllocBackBitmap(): bitmap invalid\n"); + } +} + +// _FreeBackBitmap +void +SpiderSaver::_FreeBackBitmap() +{ + if (fBackBitmap) { + delete fBackBitmap; + fBackBitmap = NULL; + fBackView = NULL; + } +} + +// _DrawInto +void +SpiderSaver::_DrawInto(BView *view) +{ + for (uint32 i = 0; i < fQueueNumber; i++) { + switch (fColor) { + case GREEN: + view->SetHighColor(1, 2, 1, 255); + break; + case BLUE: + view->SetHighColor(1, 1, 2, 255); + break; + case YELLOW: + view->SetHighColor(2, 2, 1, 255); + break; + case PURPLE: + view->SetHighColor(2, 1, 2, 255); + break; + case CYAN: + view->SetHighColor(1, 2, 2, 255); + break; + case GRAY: + view->SetHighColor(2, 2, 2, 255); + break; + case RED: + default: + view->SetHighColor(2, 1, 1, 255); + break; + } + if (Polygon* p = fQueues[i]->Head()) { + view->SetDrawingMode(B_OP_ADD); + _DrawPolygon(p, view); + } + if (Polygon* p = fQueues[i]->Tail()) { + view->SetDrawingMode(B_OP_SUBTRACT); + _DrawPolygon(p, view); + } + } +} + +// _DrawPolygon +void +SpiderSaver::_DrawPolygon(Polygon* polygon, BView *view) +{ + int32 pointCount = polygon->CountPoints(); + if (pointCount > 1) { + BPoint p = polygon->PointAt(0); + view->MovePenTo(p); + for (int32 i = 1; i < pointCount; i++) + view->StrokeLine(polygon->PointAt(i)); + view->StrokeLine(p); + } +} + +// constructor +SpiderView::SpiderView(BRect frame, SpiderSaver* saver, + uint32 queueNumber, uint32 maxPolyPoints, + uint32 maxQueueDepth, uint32 color) + : BView(frame, "spider view", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED), + fSaver(saver) +{ + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + + frame.OffsetTo(0.0, 0.0); + frame.InsetBy(10.0, 5.0); + + float viewHeight = floorf(frame.Height() / 5.0); + + // title stuff + font_height fh; + be_bold_font->GetHeight(&fh); + float fontHeight = fh.ascent + fh.descent + 5.0; + frame.bottom = frame.top + fontHeight; + BStringView* title = new BStringView(frame, B_EMPTY_STRING, "Spider by stippi"); + title->SetFont(be_bold_font); + AddChild(title); + + be_plain_font->GetHeight(&fh); + fontHeight = fh.ascent + fh.descent + 5.0; + frame.top = frame.bottom; + frame.bottom = frame.top + fontHeight; + title = new BStringView(frame, B_EMPTY_STRING, "for bonefish"); + BFont font(be_plain_font); + font.SetShear(110.0); + title->SetFont(&font); + title->SetAlignment(B_ALIGN_CENTER); + AddChild(title); + + // controls + frame.top = 10.0; + frame.bottom = frame.top + viewHeight; + frame.OffsetBy(0.0, viewHeight); + fQueueNumberS = new BSlider(frame, "queue number", "Max Polygon Count", + new BMessage(MSG_QUEUE_NUMBER), + 1, MAX_QUEUE_NUMBER); + fQueueNumberS->SetHashMarks(B_HASH_MARKS_BOTTOM); + fQueueNumberS->SetHashMarkCount((MAX_QUEUE_NUMBER - 1) / 2 + 1); + fQueueNumberS->SetValue(queueNumber); + AddChild(fQueueNumberS); + frame.OffsetBy(0.0, viewHeight); + fPolyNumberS = new BSlider(frame, "poly points", "Max Points per Polygon", + new BMessage(MSG_POLY_NUMBER), + MIN_POLY_POINTS, MAX_POLY_POINTS); + fPolyNumberS->SetHashMarks(B_HASH_MARKS_BOTTOM); + fPolyNumberS->SetHashMarkCount(MAX_POLY_POINTS - MIN_POLY_POINTS + 1); + fPolyNumberS->SetValue(maxPolyPoints); + AddChild(fPolyNumberS); + frame.OffsetBy(0.0, viewHeight); + fQueueDepthS = new BSlider(frame, "queue depth", "Trail Depth", + new BMessage(MSG_QUEUE_DEPTH), + MIN_QUEUE_DEPTH, MAX_QUEUE_DEPTH); + fQueueDepthS->SetHashMarks(B_HASH_MARKS_BOTTOM); + fQueueDepthS->SetHashMarkCount((MAX_QUEUE_DEPTH - MIN_QUEUE_DEPTH) / 4 + 1); + fQueueDepthS->SetValue(maxQueueDepth); + AddChild(fQueueDepthS); + + BMenu* menu = new BMenu("Color"); + BMessage* message = new BMessage(MSG_COLOR); + message->AddInt32("color", RED); + BMenuItem* item = new BMenuItem("Red", message); + if (color == RED) + item->SetMarked(true); + menu->AddItem(item); + message = new BMessage(MSG_COLOR); + message->AddInt32("color", GREEN); + item = new BMenuItem("Green", message); + if (color == GREEN) + item->SetMarked(true); + menu->AddItem(item); + message = new BMessage(MSG_COLOR); + message->AddInt32("color", BLUE); + item = new BMenuItem("Blue", message); + if (color == BLUE) + item->SetMarked(true); + menu->AddItem(item); + message = new BMessage(MSG_COLOR); + message->AddInt32("color", YELLOW); + item = new BMenuItem("Yellow", message); + if (color == YELLOW) + item->SetMarked(true); + menu->AddItem(item); + message = new BMessage(MSG_COLOR); + message->AddInt32("color", PURPLE); + item = new BMenuItem("Purple", message); + if (color == PURPLE) + item->SetMarked(true); + menu->AddItem(item); + message = new BMessage(MSG_COLOR); + message->AddInt32("color", CYAN); + item = new BMenuItem("Cyan", message); + if (color == CYAN) + item->SetMarked(true); + menu->AddItem(item); + message = new BMessage(MSG_COLOR); + message->AddInt32("color", GRAY); + item = new BMenuItem("Gray", message); + if (color == GRAY) + item->SetMarked(true); + menu->AddItem(item); + + menu->SetLabelFromMarked(true); + menu->SetRadioMode(true); + + frame.OffsetBy(0.0, viewHeight); + fColorMF = new BMenuField(frame, "color", "Color", menu); + fColorMF->SetDivider(fColorMF->StringWidth("Color") + 5.0); + AddChild(fColorMF); +} + +// destructor +SpiderView::~SpiderView() +{ +} + +// AttachedToWindow +void +SpiderView::AttachedToWindow() +{ + fQueueNumberS->SetTarget(this); + fPolyNumberS->SetTarget(this); + fQueueDepthS->SetTarget(this); + fColorMF->Menu()->SetTargetForItems(this); +} + +// MessageReceived +void +SpiderView::MessageReceived(BMessage* message) +{ + switch (message->what) { + case MSG_QUEUE_NUMBER: + fSaver->SetQueueNumber(fQueueNumberS->Value()); + break; + case MSG_POLY_NUMBER: + fSaver->SetPolyPoints(fPolyNumberS->Value()); + break; + case MSG_QUEUE_DEPTH: + fSaver->SetQueueDepth(fQueueDepthS->Value()); + break; + case MSG_COLOR: { + uint32 color; + if (message->FindInt32("color", (int32*)&color) == B_OK) + fSaver->SetColor(color); + break; + } + default: + BView::MessageReceived(message); + break; + } +} + Added: haiku/trunk/src/add-ons/screen_savers/spider/SpiderSaver.h =================================================================== --- haiku/trunk/src/add-ons/screen_savers/spider/SpiderSaver.h 2007-11-13 10:34:48 UTC (rev 22913) +++ haiku/trunk/src/add-ons/screen_savers/spider/SpiderSaver.h 2007-11-13 10:43:41 UTC (rev 22914) @@ -0,0 +1,86 @@ +/* + * Copyright 2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan A?mus + */ +#ifndef SPIDER_SAVER_H +#define SPIDER_SAVER_H + +#include +#include +#include + +class BSlider; +class BMenuField; +class Polygon; +class PolygonQueue; +class SpiderView; + +class SpiderSaver : public BScreenSaver { + public: + SpiderSaver(BMessage *message, + image_id image); + virtual ~SpiderSaver(); + + // BScreenSaver + virtual void StartConfig(BView *view); + virtual status_t StartSaver(BView *view, bool preview); + virtual void StopSaver(); + virtual void Draw(BView* view, int32 frame); + virtual status_t SaveState(BMessage* into) const; + + // SpiderSaver + void SetQueueNumber(uint32 number); + void SetQueueDepth(uint32 maxDepth); + void SetPolyPoints(uint32 maxPoints); + void SetColor(uint32 color); + + private: + void _Init(BRect bounds); + void _Cleanup(); + void _AllocBackBitmap(float width, float height); + void _FreeBackBitmap(); + void _DrawInto(BView *view); + void _DrawPolygon(Polygon* polygon, BView *view); + + BBitmap* fBackBitmap; + BView* fBackView; + + PolygonQueue** fQueues; + uint32 fQueueNumber; + uint32 fMaxPolyPoints; + uint32 fMaxQueueDepth; + uint32 fColor; + + bool fPreview; + BRect fBounds; + + BLocker fLocker; +}; + +class SpiderView : public BView { + public: + SpiderView(BRect frame, + SpiderSaver* saver, + uint32 queueNumber, + uint32 maxPolyPoints, + uint32 maxQueueDepth, + uint32 color); + virtual ~SpiderView(); + + // BView + virtual void AttachedToWindow(); + virtual void MessageReceived(BMessage* message); + + private: + SpiderSaver* fSaver; + + BSlider* fQueueNumberS; + BSlider* fPolyNumberS; + BSlider* fQueueDepthS; + BMenuField* fColorMF; +}; + +#endif // SPIDER_SAVER_H From stippi at mail.berlios.de Tue Nov 13 11:46:52 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 13 Nov 2007 11:46:52 +0100 Subject: [Haiku-commits] r22915 - haiku/trunk/build/jam Message-ID: <200711131046.lADAkqba006608@sheep.berlios.de> Author: stippi Date: 2007-11-13 11:46:51 +0100 (Tue, 13 Nov 2007) New Revision: 22915 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22915&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: * added Message and Spider screen savers to the image Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-13 10:43:41 UTC (rev 22914) +++ haiku/trunk/build/jam/HaikuImage 2007-11-13 10:46:51 UTC (rev 22915) @@ -51,9 +51,9 @@ NetworkStatus PackageInstaller People PowerStatus ProcessController ShowImage SoundRecorder StyledEdit Terminal TV Workspaces ; -BEOS_PREFERENCES = Appearance Backgrounds DataTranslations E-mail FileTypes - Fonts Keyboard Keymap Media Menu Mouse Network Printers Screen ScreenSaver - Sounds Time VirtualMemory +BEOS_PREFERENCES = Appearance Backgrounds DataTranslations E-mail + FileTypes Fonts Keyboard Keymap Media Menu Mouse Network Printers Screen + ScreenSaver Sounds Time VirtualMemory ; BEOS_DEMOS = BitmapDrawing Chart Clock $(X86_ONLY)Cortex FontDemo $(X86_ONLY)GLDirectMode $(X86_ONLY)GLTeapot Mandelbrot PictureTest @@ -108,7 +108,7 @@ BEOS_ADD_ONS_PRINT_TRANSPORT = HP\ JetDirect IPP LPR Parallel\ Port Print\ To\ File Serial\ Port USB\ Port ; -BEOS_ADD_ONS_SCREENSAVERS = Haiku IFS ; +BEOS_ADD_ONS_SCREENSAVERS = Haiku IFS Message Spider ; BEOS_ADD_ONS_DRIVERS_AUDIO = auich auvia emuxki hda ; BEOS_ADD_ONS_DRIVERS_GRAPHICS = $(X86_ONLY)radeon $(X86_ONLY)nvidia $(X86_ONLY)neomagic $(X86_ONLY)matrox $(X86_ONLY)intel_extreme From axeld at mail.berlios.de Tue Nov 13 12:20:18 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 13 Nov 2007 12:20:18 +0100 Subject: [Haiku-commits] r22916 - in haiku/trunk/src: system/kernel/cache tools/fs_shell Message-ID: <200711131120.lADBKIrT009733@sheep.berlios.de> Author: axeld Date: 2007-11-13 12:20:17 +0100 (Tue, 13 Nov 2007) New Revision: 22916 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22916&view=rev Modified: haiku/trunk/src/system/kernel/cache/file_map.cpp haiku/trunk/src/tools/fs_shell/file_map.cpp Log: The file map code isn't that smart yet... Modified: haiku/trunk/src/system/kernel/cache/file_map.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_map.cpp 2007-11-13 10:46:51 UTC (rev 22915) +++ haiku/trunk/src/system/kernel/cache/file_map.cpp 2007-11-13 11:20:17 UTC (rev 22916) @@ -221,7 +221,7 @@ // TODO: honour offset/size parameters file_map *map = (file_map *)_map; - if (size < map->size) +// if (size < map->size) map->Free(); map->size = size; } Modified: haiku/trunk/src/tools/fs_shell/file_map.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/file_map.cpp 2007-11-13 10:46:51 UTC (rev 22915) +++ haiku/trunk/src/tools/fs_shell/file_map.cpp 2007-11-13 11:20:17 UTC (rev 22916) @@ -220,7 +220,7 @@ // TODO: honour offset/size parameters file_map *map = (file_map *)_map; - if (size < map->size) + //if (size < map->size) map->Free(); map->size = size; } From stippi at mail.berlios.de Tue Nov 13 12:48:36 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 13 Nov 2007 12:48:36 +0100 Subject: [Haiku-commits] r22917 - haiku/trunk/build/jam Message-ID: <200711131148.lADBmaCX015309@sheep.berlios.de> Author: stippi Date: 2007-11-13 12:48:35 +0100 (Tue, 13 Nov 2007) New Revision: 22917 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22917&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: * Ups, I didn't realize Message does not work on Haiku yet... need to investigate Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-13 11:20:17 UTC (rev 22916) +++ haiku/trunk/build/jam/HaikuImage 2007-11-13 11:48:35 UTC (rev 22917) @@ -108,7 +108,7 @@ BEOS_ADD_ONS_PRINT_TRANSPORT = HP\ JetDirect IPP LPR Parallel\ Port Print\ To\ File Serial\ Port USB\ Port ; -BEOS_ADD_ONS_SCREENSAVERS = Haiku IFS Message Spider ; +BEOS_ADD_ONS_SCREENSAVERS = Haiku IFS Spider ; BEOS_ADD_ONS_DRIVERS_AUDIO = auich auvia emuxki hda ; BEOS_ADD_ONS_DRIVERS_GRAPHICS = $(X86_ONLY)radeon $(X86_ONLY)nvidia $(X86_ONLY)neomagic $(X86_ONLY)matrox $(X86_ONLY)intel_extreme From axeld at mail.berlios.de Tue Nov 13 13:18:08 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 13 Nov 2007 13:18:08 +0100 Subject: [Haiku-commits] r22918 - in haiku/trunk: headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager Message-ID: <200711131218.lADCI8JS027695@sheep.berlios.de> Author: axeld Date: 2007-11-13 13:18:06 +0100 (Tue, 13 Nov 2007) New Revision: 22918 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22918&view=rev Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp Log: On a media change, the KDiskDevice must do a bit more than it did: * it now updates the partition data, * the flags, * and the disk geometry - and that now allows the session add-on to actually detect a newly inserted CD. Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h 2007-11-13 11:48:35 UTC (rev 22917) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDevice.h 2007-11-13 12:18:06 UTC (rev 22918) @@ -57,6 +57,8 @@ void UpdateMediaStatusIfNeeded(); void UninitializeMedia(); + void UpdateGeometry(); + status_t SetPath(const char *path); // TODO: Remove this method or make it private. Once initialized the // path must not be changed. @@ -85,6 +87,7 @@ private: void _ResetGeometry(); void _InitPartitionData(); + void _UpdateDeviceFlags(); disk_device_data fDeviceData; RWLocker fLocker; Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp 2007-11-13 11:48:35 UTC (rev 22917) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp 2007-11-13 12:18:06 UTC (rev 22918) @@ -74,15 +74,9 @@ if (GetGeometry(&fDeviceData.geometry) != B_OK) _ResetGeometry(); } + // set device flags - if (fDeviceData.geometry.removable) - SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_REMOVABLE); - if (fMediaStatus == B_OK) - SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_HAS_MEDIA); - if (fDeviceData.geometry.read_only) - SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_READ_ONLY); - if (fDeviceData.geometry.write_once) - SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_WRITE_ONCE); + _UpdateDeviceFlags(); // update partition data _InitPartitionData(); return B_OK; @@ -247,9 +241,22 @@ { UninitializeContents(); _ResetGeometry(); + _UpdateDeviceFlags(); + _InitPartitionData(); } +void +KDiskDevice::UpdateGeometry() +{ + if (GetGeometry(&fDeviceData.geometry) != B_OK) + return; + + _UpdateDeviceFlags(); + _InitPartitionData(); +} + + // SetPath status_t KDiskDevice::SetPath(const char *path) @@ -399,3 +406,20 @@ fDeviceData.geometry.write_once = false; } + +void +KDiskDevice::_UpdateDeviceFlags() +{ + if (fDeviceData.geometry.removable) + SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_REMOVABLE); + if (HasMedia()) + SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_HAS_MEDIA); + else + SetDeviceFlags(DeviceFlags() & ~B_DISK_DEVICE_HAS_MEDIA); + + if (fDeviceData.geometry.read_only) + SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_READ_ONLY); + if (fDeviceData.geometry.write_once) + SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_WRITE_ONCE); +} + Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-13 11:48:35 UTC (rev 22917) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-13 12:18:06 UTC (rev 22918) @@ -1148,6 +1148,7 @@ if (device->MediaChanged()) { dprintf("Media changed from %s\n", device->Path()); + device->UpdateGeometry(); _ScanPartition(device, false); } else if (!device->HasMedia() && hadMedia) { dprintf("Media removed from %s\n", device->Path()); From axeld at mail.berlios.de Tue Nov 13 13:20:39 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 13 Nov 2007 13:20:39 +0100 Subject: [Haiku-commits] r22919 - haiku/trunk/src/system/kernel/disk_device_manager Message-ID: <200711131220.lADCKdci031838@sheep.berlios.de> Author: axeld Date: 2007-11-13 13:20:39 +0100 (Tue, 13 Nov 2007) New Revision: 22919 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22919&view=rev Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp Log: Philippe was right, of course, the media checker thread did not bother to check the fTerminating flag, so it would never quit (too bad no one ever quits it anyway :-)). Thanks for proofreading! Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-13 12:18:06 UTC (rev 22918) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-11-13 12:20:39 UTC (rev 22919) @@ -1129,7 +1129,7 @@ status_t KDiskDeviceManager::_CheckMediaStatus() { - while (true) { + while (!fTerminating) { int32 cookie = 0; while (KDiskDevice* device = RegisterNextDevice(&cookie)) { DeviceWriteLocker locker(device); From axeld at mail.berlios.de Tue Nov 13 15:55:13 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 13 Nov 2007 15:55:13 +0100 Subject: [Haiku-commits] r22920 - haiku/trunk/src/add-ons/kernel/file_systems/iso9660 Message-ID: <200711131455.lADEtDx5010247@sheep.berlios.de> Author: axeld Date: 2007-11-13 15:55:11 +0100 (Tue, 13 Nov 2007) New Revision: 22920 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22920&view=rev Added: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.c haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660_identify.cpp haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660_identify.h haiku/trunk/src/add-ons/kernel/file_systems/iso9660/rock_ridge.h Removed: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso.c haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.h haiku/trunk/src/add-ons/kernel/file_systems/iso9660/rock.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/Jamfile haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp Log: * Fixed a crashing bug in the identification code: it copied a C++ object on the stack to an allocated one - on destruction of the latter, the resources were already freed. * Made the identify code more negligent against bad CDs - ie. it will identify even broken CDs if they can be mounted. * Made identification endian aware (it should now also work on big endian systems). * Renamed many structures, methods, and fields to be less verbose, and follow our style guide. * Renamed iso9660.cpp|h to iso9660_identify.cpp|h. * Renamed iso.c to iso9660.c, rock.h to rock_ridge.h. * Removed unnecessary cruft from the Jamfile. Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/iso9660/Jamfile 2007-11-13 12:20:39 UTC (rev 22919) +++ haiku/trunk/src/add-ons/kernel/file_systems/iso9660/Jamfile 2007-11-13 14:55:11 UTC (rev 22920) @@ -1,27 +1,13 @@ SubDir HAIKU_TOP src add-ons kernel file_systems iso9660 ; -# save original optimization level -oldOPTIM = $(OPTIM) ; +UsePrivateHeaders kernel ; # set some additional defines -{ - SubDirCcFlags -Wall -Wno-multichar ; - SubDirC++Flags -Wall -Wno-multichar -fno-rtti ; -} +SubDirCcFlags -Wall -Wno-multichar ; +SubDirC++Flags -Wall -Wno-multichar -fno-rtti ; -UsePrivateHeaders kernel ; - KernelAddon iso9660 : - iso.c - iso9660.cpp + iso9660.c + iso9660_identify.cpp kernel_interface.cpp - kernel_cpp.cpp ; - -SEARCH on [ FGristFiles - kernel_cpp.cpp - ] = [ FDirName $(HAIKU_TOP) src system kernel util ] ; - -# restore original optimization level -OPTIM = $(oldOPTIM) ; - Deleted: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso.c Copied: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.c (from rev 22908, haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso.c) =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso.c 2007-11-12 11:44:55 UTC (rev 22908) +++ haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.c 2007-11-13 14:55:11 UTC (rev 22920) @@ -0,0 +1,957 @@ +/* + * Copyright 1999, Be Incorporated. All Rights Reserved. + * This file may be used under the terms of the Be Sample Code License. + * + * Copyright 2001, pinc Software. All Rights Reserved. + */ + + +#include "iso.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "rock_ridge.h" + +//#define TRACE_ISO9660 1 +#if TRACE_ISO9660 +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + +// Just needed here +static status_t unicode_to_utf8(const char *src, int32 *srcLen, char *dst, int32 *dstLen); + + +// ISO9660 should start with this string +const char *kISO9660IDString = "CD001"; + +#if 0 +static int GetLogicalBlockSize(int fd); +static off_t GetNumDeviceBlocks(int fd, int block_size); +#endif +static int GetDeviceBlockSize(int fd); + +static int InitVolDate(ISOVolDate *date, char *buf); +static int InitRecDate(ISORecDate *date, char *buf); +static int InitVolDesc(nspace *vol, char *buf); + +#if 0 // currently unused +static int +GetLogicalBlockSize(int fd) +{ + partition_info p_info; + + if (ioctl(fd, B_GET_PARTITION_INFO, &p_info) == B_NO_ERROR) { + TRACE(("GetLogicalBlockSize: ioctl suceed\n")); + return p_info.logical_block_size; + } + TRACE(("GetLogicalBlockSize = ioctl returned error\n")); + + return 0; +} + + +static off_t +GetNumDeviceBlocks(int fd, int block_size) +{ + struct stat st; + device_geometry dg; + + if (ioctl(fd, B_GET_GEOMETRY, &dg) >= 0) { + return (off_t)dg.cylinder_count * + (off_t)dg.sectors_per_track * + (off_t)dg.head_count; + } + + /* if the ioctl fails, try just stat'ing in case it's a regular file */ + if (fstat(fd, &st) < 0) + return 0; + + return st.st_size / block_size; +} +#endif + +static int +GetDeviceBlockSize(int fd) +{ + struct stat st; + device_geometry dg; + + if (ioctl(fd, B_GET_GEOMETRY, &dg) < 0) { + if (fstat(fd, &st) < 0 || S_ISDIR(st.st_mode)) + return 0; + + return 512; /* just assume it's a plain old file or something */ + } + + return dg.bytes_per_sector; +} + + +// From EncodingComversions.cpp + +// Pierre's (modified) Uber Macro + +// NOTE: iso9660 seems to store the unicode text in big-endian form +#define u_to_utf8(str, uni_str)\ +{\ + if ((B_BENDIAN_TO_HOST_INT16(uni_str[0])&0xff80) == 0)\ + *str++ = B_BENDIAN_TO_HOST_INT16(*uni_str++);\ + else if ((B_BENDIAN_TO_HOST_INT16(uni_str[0])&0xf800) == 0) {\ + str[0] = 0xc0|(B_BENDIAN_TO_HOST_INT16(uni_str[0])>>6);\ + str[1] = 0x80|(B_BENDIAN_TO_HOST_INT16(*uni_str++)&0x3f);\ + str += 2;\ + } else if ((B_BENDIAN_TO_HOST_INT16(uni_str[0])&0xfc00) != 0xd800) {\ + str[0] = 0xe0|(B_BENDIAN_TO_HOST_INT16(uni_str[0])>>12);\ + str[1] = 0x80|((B_BENDIAN_TO_HOST_INT16(uni_str[0])>>6)&0x3f);\ + str[2] = 0x80|(B_BENDIAN_TO_HOST_INT16(*uni_str++)&0x3f);\ + str += 3;\ + } else {\ + int val;\ + val = ((B_BENDIAN_TO_HOST_INT16(uni_str[0])-0xd7c0)<<10) | (B_BENDIAN_TO_HOST_INT16(uni_str[1])&0x3ff);\ + str[0] = 0xf0 | (val>>18);\ + str[1] = 0x80 | ((val>>12)&0x3f);\ + str[2] = 0x80 | ((val>>6)&0x3f);\ + str[3] = 0x80 | (val&0x3f);\ + uni_str += 2; str += 4;\ + }\ +} + + +static status_t +unicode_to_utf8(const char *src, int32 *srcLen, char *dst, int32 *dstLen) +{ + int32 srcLimit = *srcLen; + int32 dstLimit = *dstLen; + int32 srcCount = 0; + int32 dstCount = 0; + + for (srcCount = 0; srcCount < srcLimit; srcCount += 2) { + uint16 *UNICODE = (uint16 *)&src[srcCount]; + uchar utf8[4]; + uchar *UTF8 = utf8; + int32 utf8Len; + int32 j; + + u_to_utf8(UTF8, UNICODE); + + utf8Len = UTF8 - utf8; + if ((dstCount + utf8Len) > dstLimit) + break; + + for (j = 0; j < utf8Len; j++) + dst[dstCount + j] = utf8[j]; + dstCount += utf8Len; + } + + *srcLen = srcCount; + *dstLen = dstCount; + + return dstCount > 0 ? B_NO_ERROR : B_ERROR; +} + + +// #pragma mark - +// Functions specific to iso driver. + + +int +ISOMount(const char *path, const int flags, nspace **newVol, bool allow_joliet) +{ + // path: path to device (eg, /dev/disk/scsi/030/raw) + // partition: partition number on device ???? + // flags: currently unused + + // determine if it is an ISO volume. + char buffer[ISO_PVD_SIZE]; + bool done = false; + bool is_iso = false; + off_t offset = 0x8000; + ssize_t retval; + partition_info partitionInfo; + int deviceBlockSize, multiplier; + nspace *vol; + int result = B_NO_ERROR; + + (void)flags; + + TRACE(("ISOMount - ENTER\n")); + + vol = (nspace *)calloc(sizeof(nspace), 1); + if (vol == NULL) { + TRACE(("ISOMount - mem error \n")); + return ENOMEM; + } + + memset(&partitionInfo, 0, sizeof(partition_info)); + + /* open and lock the device */ + vol->fdOfSession = open(path, O_RDONLY); + + /* try to open the raw device to get access to the other sessions as well */ + if (vol->fdOfSession >= 0) { + if (ioctl(vol->fdOfSession, B_GET_PARTITION_INFO, &partitionInfo) < B_NO_ERROR) { + TRACE(("B_GET_PARTITION_INFO: ioctl returned error\n")); + strcpy(partitionInfo.device, path); + } + TRACE(("ISOMount: open device/file \"%s\"\n", partitionInfo.device)); + + vol->fd = open(partitionInfo.device, O_RDONLY); + } + + if (vol->fdOfSession < 0 || vol->fd < 0) { + close(vol->fd); + close(vol->fdOfSession); + + TRACE(("ISO9660 ERROR - Unable to open <%s>\n", path)); + free(vol); + return EINVAL; + } + + deviceBlockSize = GetDeviceBlockSize(vol->fdOfSession); + if (deviceBlockSize < 0) { + TRACE(("ISO9660 ERROR - device block size is 0\n")); + close(vol->fd); + close(vol->fdOfSession); + + free(vol); + return EINVAL; + } + + vol->joliet_level = 0; + while ((!done) && (offset < 0x10000)) { + retval = read_pos (vol->fdOfSession, offset, (void *)buffer, ISO_PVD_SIZE); + if (retval < ISO_PVD_SIZE) { + is_iso = false; + break; + } + + if (strncmp(buffer + 1, kISO9660IDString, 5) == 0) { + if ((*buffer == 0x01) && (!is_iso)) { + // ISO_VD_PRIMARY + + off_t maxBlocks; + + TRACE(("ISOMount: Is an ISO9660 volume, initting rec\n")); + + InitVolDesc(vol, buffer); + strncpy(vol->devicePath,path,127); + vol->id = ISO_ROOTNODE_ID; + TRACE(("ISO9660: vol->blockSize = %d\n", vol->logicalBlkSize[FS_DATA_FORMAT])); + + multiplier = deviceBlockSize / vol->logicalBlkSize[FS_DATA_FORMAT]; + TRACE(("ISOMount: block size multiplier is %d\n", multiplier)); + + // if the session is on a real device, size != 0 + if (partitionInfo.size != 0) + maxBlocks = (partitionInfo.size+partitionInfo.offset) / vol->logicalBlkSize[FS_DATA_FORMAT]; + else + maxBlocks = vol->volSpaceSize[FS_DATA_FORMAT]; + + /* Initialize access to the cache so that we can do cached i/o */ + TRACE(("ISO9660: cache init: dev %d, max blocks %Ld\n", vol->fd, maxBlocks)); + vol->fBlockCache = block_cache_create(vol->fd, maxBlocks, + vol->logicalBlkSize[FS_DATA_FORMAT], true); + is_iso = true; + } else if ((*buffer == 0x02) && is_iso && allow_joliet) { + // ISO_VD_SUPPLEMENTARY + + // JOLIET extension + // test escape sequence for level of UCS-2 characterset + if (buffer[88] == 0x25 && buffer[89] == 0x2f) { + switch (buffer[90]) { + case 0x40: vol->joliet_level = 1; break; + case 0x43: vol->joliet_level = 2; break; + case 0x45: vol->joliet_level = 3; break; + } + + TRACE(("ISO9660 Extensions: Microsoft Joliet Level %d\n", vol->joliet_level)); + + // Because Joliet-stuff starts at other sector, + // update root directory record. + if (vol->joliet_level > 0) + InitNode(&(vol->rootDirRec), &buffer[156], NULL, 0); + } + } else if (*(unsigned char *)buffer == 0xff) { + // ISO_VD_END + done = true; + } else + TRACE(("found header %d\n",*buffer)); + } + offset += 0x800; + } + + if (!is_iso) { + // It isn't an ISO disk. + if (vol->fdOfSession >= 0) + close(vol->fdOfSession); + if (vol->fd >= 0) + close(vol->fd); + + free(vol); + vol = NULL; + result = EINVAL; + TRACE(("ISOMount: Not an ISO9660 volume!\n")); + } + + TRACE(("ISOMount - EXIT, result %s, returning %p\n", strerror(result), vol)); + *newVol = vol; + return result; +} + + +/** Reads in a single directory entry and fills in the values in the + * dirent struct. Uses the cookie to keep track of the current block + * and position within the block. Also uses the cookie to determine when + * it has reached the end of the directory file. + * + * NOTE: If your file sytem seems to work ok from the command line, but + * the tracker doesn't seem to like it, check what you do here closely; + * in particular, if the d_ino in the stat struct isn't correct, the tracker + * will not display the entry. + */ + +int +ISOReadDirEnt(nspace *ns, dircookie *cookie, struct dirent *dirent, size_t bufsize) +{ + off_t totalRead = cookie->pos + ((cookie->block - cookie->startBlock) * + ns->logicalBlkSize[FS_DATA_FORMAT]); + off_t cacheBlock; + char *blockData; + int result = B_NO_ERROR; + int bytesRead = 0; + bool block_out = false; + + TRACE(("ISOReadDirEnt - ENTER\n")); + + // If we're at the end of the data in a block, move to the next block. + while (1) { + blockData = (char *)block_cache_get_etc(ns->fBlockCache, cookie->block, 0, + ns->logicalBlkSize[FS_DATA_FORMAT]); + block_out = true; + + if (blockData != NULL && *(blockData + cookie->pos) == 0) { + //NULL data, move to next block. + block_cache_put(ns->fBlockCache, cookie->block); + block_out = false; + totalRead += ns->logicalBlkSize[FS_DATA_FORMAT] - cookie->pos; + cookie->pos = 0; + cookie->block++; + } + else + break; + + if (totalRead >= cookie->totalSize) + break; + } + + cacheBlock = cookie->block; + if (blockData != NULL && totalRead < cookie->totalSize) { + vnode node; + + if ((result = InitNode(&node, blockData + cookie->pos, &bytesRead, ns->joliet_level)) == + B_NO_ERROR) + { + int nameBufSize = (bufsize - (2 * sizeof(dev_t) + 2* sizeof(ino_t) + + sizeof(unsigned short))); + + dirent->d_ino = (cookie->block << 30) + (cookie->pos & 0xFFFFFFFF); + dirent->d_reclen = node.fileIDLen; + + if (node.fileIDLen <= nameBufSize) { + // need to do some size checking here. + strncpy(dirent->d_name, node.fileIDString, node.fileIDLen +1); + TRACE(("ISOReadDirEnt - success, name is %s\n", dirent->d_name)); + } else { + TRACE(("ISOReadDirEnt - ERROR, name %s does not fit in buffer of size %d\n", node.fileIDString, nameBufSize)); + result = EINVAL; + } + cookie->pos += bytesRead; + } + } else { + if (totalRead >= cookie->totalSize) + result = ENOENT; + else + result = ENOMEM; + } + + if (block_out) + block_cache_put(ns->fBlockCache, cacheBlock); + + TRACE(("ISOReadDirEnt - EXIT, result is %s, vnid is %Lu\n", strerror(result), dirent->d_ino)); + return result; +} + + +int +InitVolDesc(nspace *vol, char *buffer) +{ + TRACE(("InitVolDesc - ENTER\n")); + + vol->volDescType = *(uint8 *)buffer++; + + vol->stdIDString[5] = '\0'; + strncpy(vol->stdIDString, buffer, 5); + buffer += 5; + + vol->volDescVersion = *(uint8 *)buffer; + buffer += 2; // 8th byte unused + + vol->systemIDString[32] = '\0'; + strncpy(vol->systemIDString, buffer, 32); + buffer += 32; + TRACE(("InitVolDesc - system id string is %s\n", vol->systemIDString)); + + vol->volIDString[32] = '\0'; + strncpy(vol->volIDString, buffer, 32); + buffer += (32 + 80-73 + 1); // bytes 80-73 unused + TRACE(("InitVolDesc - volume id string is %s\n", vol->volIDString)); + + vol->volSpaceSize[LSB_DATA] = *(uint32 *)buffer; + buffer += 4; + vol->volSpaceSize[MSB_DATA] = *(uint32 *)buffer; + buffer+= (4 + 120-89 + 1); // bytes 120-89 unused + + vol->volSetSize[LSB_DATA] = *(uint16*)buffer; + buffer += 2; + vol->volSetSize[MSB_DATA] = *(uint16*)buffer; + buffer += 2; + + vol->volSeqNum[LSB_DATA] = *(uint16*)buffer; + buffer += 2; + vol->volSeqNum[MSB_DATA] = *(uint16*)buffer; + buffer += 2; + + vol->logicalBlkSize[LSB_DATA] = *(uint16*)buffer; + buffer += 2; + vol->logicalBlkSize[MSB_DATA] = *(uint16*)buffer; + buffer += 2; + + vol->pathTblSize[LSB_DATA] = *(uint32*)buffer; + buffer += 4; + vol->pathTblSize[MSB_DATA] = *(uint32*)buffer; + buffer += 4; + + vol->lPathTblLoc[LSB_DATA] = *(uint16*)buffer; + buffer += 2; + vol->lPathTblLoc[MSB_DATA] = *(uint16*)buffer; + buffer += 2; + + vol->optLPathTblLoc[LSB_DATA] = *(uint16*)buffer; + buffer += 2; + vol->optLPathTblLoc[MSB_DATA] = *(uint16*)buffer; + buffer += 2; + + vol->mPathTblLoc[LSB_DATA] = *(uint16*)buffer; + buffer += 2; + vol->mPathTblLoc[MSB_DATA] = *(uint16*)buffer; + buffer += 2; + + vol->optMPathTblLoc[LSB_DATA] = *(uint16*)buffer; + buffer += 2; + vol->optMPathTblLoc[MSB_DATA] = *(uint16*)buffer; + buffer += 2; + + // Fill in directory record. + InitNode(&(vol->rootDirRec), buffer, NULL, 0); + + vol->rootDirRec.id = ISO_ROOTNODE_ID; + buffer += 34; + + vol->volSetIDString[128] = '\0'; + strncpy(vol->volSetIDString, buffer, 128); + buffer += 128; + TRACE(("InitVolDesc - volume set id string is %s\n", vol->volSetIDString)); + + vol->pubIDString[128] = '\0'; + strncpy(vol->pubIDString, buffer, 128); + buffer += 128; + TRACE(("InitVolDesc - volume pub id string is %s\n", vol->pubIDString)); + + vol->dataPreparer[128] = '\0'; + strncpy(vol->dataPreparer, buffer, 128); + buffer += 128; + TRACE(("InitVolDesc - volume dataPreparer string is %s\n", vol->dataPreparer)); + + vol->appIDString[128] = '\0'; + strncpy(vol->appIDString, buffer, 128); + buffer += 128; + TRACE(("InitVolDesc - volume app id string is %s\n", vol->appIDString)); + + vol->copyright[38] = '\0'; + strncpy(vol->copyright, buffer, 38); + buffer += 38; + TRACE(("InitVolDesc - copyright is %s\n", vol->copyright)); + + vol->abstractFName[38] = '\0'; + strncpy(vol->abstractFName, buffer, 38); + buffer += 38; + + vol->biblioFName[38] = '\0'; + strncpy(vol->biblioFName, buffer, 38); + buffer += 38; + + InitVolDate(&(vol->createDate), buffer); + buffer += 17; + + InitVolDate(&(vol->modDate), buffer); + buffer += 17; + + InitVolDate(&(vol->expireDate), buffer); + buffer += 17; + + InitVolDate(&(vol->effectiveDate), buffer); + buffer += 17; + + vol->fileStructVers = *(uint8 *)buffer; + return 0; +} + + +int +InitNode(vnode *rec, char *buffer, int *_bytesRead, uint8 joliet_level) +{ + int result = B_NO_ERROR; + uint8 recLen = *(uint8 *)buffer++; + bool no_rock_ridge_stat_struct = TRUE; + + if (_bytesRead != NULL) + *_bytesRead = recLen; + + TRACE(("InitNode - ENTER, bufstart is %p, record length is %d bytes\n", buffer, recLen)); + + rec->cache = NULL; + + if (recLen > 0) { + rec->extAttrRecLen = *(uint8 *)buffer++; + + rec->startLBN[LSB_DATA] = *(uint32 *)buffer; + buffer += 4; + rec->startLBN[MSB_DATA] = *(uint32 *)buffer; + buffer += 4; + TRACE(("InitNode - data start LBN is %ld\n", rec->startLBN[FS_DATA_FORMAT])); + + rec->dataLen[LSB_DATA] = *(uint32 *)buffer; + buffer += 4; + rec->dataLen[MSB_DATA] = *(uint32 *)buffer; + buffer += 4; + TRACE(("InitNode - data length is %ld\n", rec->dataLen[FS_DATA_FORMAT])); + + InitRecDate(&(rec->recordDate), buffer); + buffer += 7; + + rec->flags = *(uint8 *)buffer; + buffer++; + TRACE(("InitNode - flags are %d\n", rec->flags)); + + rec->fileUnitSize = *(uint8 *)buffer; + buffer++; + TRACE(("InitNode - fileUnitSize is %d\n", rec->fileUnitSize)); + + rec->interleaveGapSize = *(uint8 *)buffer; + buffer++; + TRACE(("InitNode - interleave gap size = %d\n", rec->interleaveGapSize)); + + rec->volSeqNum = *(uint32 *)buffer; + buffer += 4; + TRACE(("InitNode - volume seq num is %ld\n", rec->volSeqNum)); + + rec->fileIDLen = *(uint8*)buffer; + buffer++; + TRACE(("InitNode - file id length is %d\n", rec->fileIDLen)); + + if (rec->fileIDLen > 0) { + // JOLIET extension: + // on joliet discs, buffer[0] can be 0 for Unicoded filenames, + // so I've added a check here to test explicitely for + // directories (which have length 1) + if (rec->fileIDLen == 1) { + // Take care of "." and "..", the first two dirents are + // these in iso. + if (buffer[0] == 0) { + rec->fileIDString = strdup("."); + rec->fileIDLen = 1; + } else if (buffer[0] == 1) { + rec->fileIDString = strdup(".."); + rec->fileIDLen = 2; + } + } else { + // JOLIET extension: + // convert Unicode16 string to UTF8 + if (joliet_level > 0) { + // Assume that the unicode->utf8 conversion produces 4 byte + // utf8 characters, and allocate that much space + rec->fileIDString = (char *)malloc(rec->fileIDLen * 2 + 1); + if (rec->fileIDString != NULL) { + status_t err; + int32 srcLen = rec->fileIDLen; + int32 dstLen = rec->fileIDLen * 2; + + err = unicode_to_utf8(buffer, &srcLen, rec->fileIDString, &dstLen); + if (err < B_NO_ERROR) { + dprintf("iso9660: error converting unicode->utf8\n"); + result = err; + } else { + rec->fileIDString[dstLen] = '\0'; + rec->fileIDLen = dstLen; + } + } else { + // Error + result = ENOMEM; + TRACE(("InitNode - unable to allocate memory!\n")); + } + } else { + rec->fileIDString = (char *)malloc((rec->fileIDLen) + 1); + + if (rec->fileIDString != NULL) { + strncpy(rec->fileIDString, buffer, rec->fileIDLen); + rec->fileIDString[rec->fileIDLen] = '\0'; + } else { + // Error + result = ENOMEM; + TRACE(("InitNode - unable to allocate memory!\n")); + } + } + } + + // Get rid of semicolons, which are used to delineate file versions.q + { + char *semi = NULL; + while ((semi = strchr(rec->fileIDString, ';')) != NULL) + semi[0] = '\0'; + } + TRACE(("DirRec ID String is: %s\n", rec->fileIDString)); + + if (result == B_NO_ERROR) { + buffer += rec->fileIDLen; + if (!(rec->fileIDLen % 2)) + buffer++; + + // Now we're at the start of the rock ridge stuff + { + char *altName = NULL; + char *slName = NULL; + uint16 altNameSize = 0; + uint16 slNameSize = 0; + uint8 slFlags = 0; + uint8 length = 0; + bool done = FALSE; + + TRACE(("RR: Start of extensions, but at %p\n", buffer)); + + memset(&(rec->attr.stat), 0, 2 * sizeof(struct stat)); + + // Set defaults, in case there is no RR stuff. + rec->attr.stat[FS_DATA_FORMAT].st_mode = (S_IRUSR | S_IRGRP | S_IROTH); + + while (!done) + { + buffer += length; + length = *(uint8 *)(buffer + 2); + switch (0x100 * buffer[0] + buffer[1]) + { + // Stat structure stuff + case 'PX': + { + uint8 bytePos = 3; + TRACE(("RR: found PX, length %u\n", length)); + rec->attr.pxVer = *(uint8*)(buffer + bytePos++); + no_rock_ridge_stat_struct = FALSE; + + // st_mode + rec->attr.stat[LSB_DATA].st_mode = *(mode_t*)(buffer + bytePos); + bytePos += 4; + rec->attr.stat[MSB_DATA].st_mode = *(mode_t*)(buffer + bytePos); + bytePos += 4; + + // st_nlink + rec->attr.stat[LSB_DATA].st_nlink = *(nlink_t*)(buffer+bytePos); + bytePos += 4; + rec->attr.stat[MSB_DATA].st_nlink = *(nlink_t*)(buffer + bytePos); + bytePos += 4; + + // st_uid + rec->attr.stat[LSB_DATA].st_uid = *(uid_t*)(buffer+bytePos); + bytePos += 4; + rec->attr.stat[MSB_DATA].st_uid = *(uid_t*)(buffer+bytePos); + bytePos += 4; + + // st_gid + rec->attr.stat[LSB_DATA].st_gid = *(gid_t*)(buffer+bytePos); + bytePos += 4; + rec->attr.stat[MSB_DATA].st_gid = *(gid_t*)(buffer+bytePos); + bytePos += 4; + break; + } + + case 'PN': + TRACE(("RR: found PN, length %u\n", length)); + break; + + // Symbolic link info + case 'SL': + { + uint8 bytePos = 3; + uint8 lastCompFlag = 0; + uint8 addPos = 0; + bool slDone = FALSE; + bool useSeparator = TRUE; + + TRACE(("RR: found SL, length %u\n", length)); + TRACE(("Buffer is at %p\n", buffer)); + TRACE(("Current length is %u\n", slNameSize)); + //kernel_debugger(""); + rec->attr.slVer = *(uint8*)(buffer + bytePos++); + slFlags = *(uint8*)(buffer + bytePos++); + + TRACE(("sl flags are %u\n", slFlags)); + while (!slDone && bytePos < length) + { + uint8 compFlag = *(uint8*)(buffer + bytePos++); + uint8 compLen = *(uint8*)(buffer + bytePos++); + + if (slName == NULL) useSeparator = FALSE; + + addPos = slNameSize; + + TRACE(("sl comp flags are %u, length is %u\n", compFlag, compLen)); + TRACE(("Current name size is %u\n", slNameSize)); + switch (compFlag) + { + case SLCP_CONTINUE: + useSeparator = FALSE; + default: + // Add the component to the total path. + slNameSize += compLen; + if ( useSeparator ) slNameSize++; + if (slName == NULL) + slName = (char*)malloc(slNameSize + 1); + else + slName = (char*)realloc(slName, slNameSize + 1); + + if (useSeparator) + { + TRACE(("Adding separator\n")); + slName[addPos++] = '/'; + } + + TRACE(("doing memcopy of %u bytes at offset %d\n", compLen, addPos)); + memcpy((slName + addPos), (buffer + bytePos), compLen); + + addPos += compLen; + useSeparator = TRUE; + break; + + case SLCP_CURRENT: + TRACE(("InitNode - found link to current directory\n")); + slNameSize += 2; + if (slName == NULL) + slName = (char*)malloc(slNameSize + 1); + else + slName = (char*)realloc(slName, slNameSize + 1); + memcpy(slName + addPos, "./", 2); + useSeparator = FALSE; + break; + + case SLCP_PARENT: + slNameSize += 3; + if (slName == NULL) + slName = (char*)malloc(slNameSize + 1); + else + slName = (char*)realloc(slName, slNameSize + 1); + memcpy(slName + addPos, "../", 3); + useSeparator = FALSE; + break; + + case SLCP_ROOT: + TRACE(("InitNode - found link to root directory\n")); + slNameSize += 1; + if (slName == NULL) + slName = (char*)malloc(slNameSize + 1); + else + slName = (char*)realloc(slName, slNameSize + 1); + memcpy(slName + addPos, "/", 1); + useSeparator = FALSE; + break; + + case SLCP_VOLROOT: + slDone = TRUE; + break; + + case SLCP_HOST: + slDone = TRUE; + break; + } + slName[slNameSize] = '\0'; + lastCompFlag = compFlag; + bytePos += compLen; + TRACE(("Current sl name is \'%s\'\n", slName)); + } + rec->attr.slName = slName; + TRACE(("InitNode = symlink name is \'%s\'\n", slName)); + break; + } + + // Altername name + case 'NM': + { + uint8 bytePos = 3; + uint8 flags = 0; + uint16 oldEnd = altNameSize; + + altNameSize += length - 5; + if (altName == NULL) + altName = (char *)malloc(altNameSize + 1); + else + altName = (char *)realloc(altName, altNameSize + 1); + + TRACE(("RR: found NM, length %u\n", length)); + // Read flag and version. + rec->attr.nmVer = *(uint8 *)(buffer + bytePos++); + flags = *(uint8 *)(buffer + bytePos++); + + TRACE(("RR: nm buffer is %s, start at %p\n", (buffer + bytePos), buffer + bytePos)); + + // Build the file name. + memcpy(altName + oldEnd, buffer + bytePos, length - 5); + altName[altNameSize] = '\0'; + TRACE(("RR: alt name is %s\n", altName)); + + // If the name is not continued in another record, update + // the record name. + if (!(flags & NM_CONTINUE)) + { + // Get rid of the ISO name, replace with RR name. + if (rec->fileIDString != NULL) + free(rec->fileIDString); + rec->fileIDString = altName; + rec->fileIDLen = altNameSize; + } + break; + } + + // Deep directory record masquerading as a file. + case 'CL': + TRACE(("RR: found CL, length %u\n", length)); + rec->flags |= ISO_ISDIR; + rec->startLBN[LSB_DATA] = *(uint32*)(buffer+4); + rec->startLBN[MSB_DATA] = *(uint32*)(buffer+8); + break; + + case 'PL': + TRACE(("RR: found PL, length %u\n", length)); + break; + + // Relocated directory, we should skip. + case 'RE': + result = EINVAL; + TRACE(("RR: found RE, length %u\n", length)); + break; + + case 'TF': + TRACE(("RR: found TF, length %u\n", length)); + break; + + case 'RR': + TRACE(("RR: found RR, length %u\n", length)); + break; + + default: + TRACE(("RR: %c%c (%d, %d)\n",buffer[0],buffer[1],buffer[0],buffer[1])); + TRACE(("RR: End of extensions.\n")); + done = TRUE; + break; + } + } + } + } + } else { + TRACE(("InitNode - File ID String is 0 length\n")); + result = ENOENT; + } + } else + result = ENOENT; + + TRACE(("InitNode - EXIT, result is %s name is \'%s\'\n", strerror(result), rec->fileIDString)); + + if (no_rock_ridge_stat_struct) { + if (rec->flags & ISO_ISDIR) + rec->attr.stat[FS_DATA_FORMAT].st_mode |= (S_IFDIR|S_IXUSR|S_IXGRP|S_IXOTH); + else + rec->attr.stat[FS_DATA_FORMAT].st_mode |= (S_IFREG); + } + + return result; +} + + +static int +InitVolDate(ISOVolDate *date, char *buffer) +{ + memcpy(date, buffer, 17); + return 0; +} + + +static int +InitRecDate(ISORecDate *date, char *buffer) +{ + memcpy(date, buffer, 7); + return 0; +} + + +int +ConvertRecDate(ISORecDate* inDate, time_t* outDate) +{ + time_t time; + int days, i, year, tz; + + year = inDate->year -70; + tz = inDate->offsetGMT; + + if (year < 0) { + time = 0; + } else { + const int monlen[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + days = (year * 365); + + if (year > 2) + days += (year + 1)/ 4; + + for (i = 1; (i < inDate->month) && (i < 12); i++) { + days += monlen[i-1]; + } + + if (((year + 2) % 4) == 0 && inDate->month > 2) + days++; + + days += inDate->date - 1; + time = ((((days*24) + inDate->hour) * 60 + inDate->minute) * 60) + + inDate->second; + if (tz & 0x80) + tz |= (-1 << 8); + + if (-48 <= tz && tz <= 52) + time += tz *15 * 60; + } + *outDate = time; + return 0; [... truncated: 785 lines follow ...] From axeld at mail.berlios.de Tue Nov 13 15:57:12 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 13 Nov 2007 15:57:12 +0100 Subject: [Haiku-commits] r22921 - haiku/trunk/src/add-ons/kernel/file_systems/iso9660 Message-ID: <200711131457.lADEvCBL010392@sheep.berlios.de> Author: axeld Date: 2007-11-13 15:57:11 +0100 (Tue, 13 Nov 2007) New Revision: 22921 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22921&view=rev Added: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.h Removed: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.c haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp Log: Renamed iso.h to iso9660.h. Deleted: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.c 2007-11-13 14:55:11 UTC (rev 22920) +++ haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.c 2007-11-13 14:57:11 UTC (rev 22921) @@ -6,7 +6,7 @@ */ -#include "iso.h" +#include "iso9660.h" #include #include Copied: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.h (from rev 22908, haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso.h) =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso.h 2007-11-12 11:44:55 UTC (rev 22908) +++ haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660.h 2007-11-13 14:57:11 UTC (rev 22921) @@ -0,0 +1,238 @@ +/* + * Copyright 1999, Be Incorporated. All Rights Reserved. + * This file may be used under the terms of the Be Sample Code License. + * + * Copyright 2001, pinc Software. All Rights Reserved. + */ +#ifndef ISO_9660_H +#define ISO_9660_H + + +#include "lock.h" + +#include +#include + +#include +#include +#include +#include + + +// Size of primary volume descriptor for ISO9660 +#define ISO_PVD_SIZE 882 + +// ISO structure has both msb and lsb first data. These let you do a +// compile-time switch for different platforms. + +enum { + LSB_DATA = 0, + MSB_DATA +}; + +// This defines the data format for the platform we are compiling +// for. +#if BYTE_ORDER == __LITTLE_ENDIAN +# define FS_DATA_FORMAT LSB_DATA +#else +# define FS_DATA_FORMAT MSB_DATA +#endif + +// ISO pdf file spec I read appears to be WRONG about the date format. See +// www.alumni.caltech.edu/~pje/iso9660.html, definition there seems +// to match. +typedef struct ISOVolDate { + char year[5]; + char month[3]; + char day[3]; + char hour[3]; + char minute[3]; + char second[3]; + char hunSec[3]; + int8 offsetGMT; +} ISOVolDate; + +typedef struct ISORecDate { + uint8 year; // Year - 1900 + uint8 month; + uint8 date; + uint8 hour; + uint8 minute; + uint8 second; + int8 offsetGMT; +} ISORecDate; + +/* This next section is data structure to hold the data found in the rock ridge extensions. */ +typedef struct RRAttr { + char* slName; + struct stat stat[2]; + uint8 nmVer; + uint8 pxVer; + uint8 slVer; +} RRAttr; + +/* For each item on the disk (directory, file, etc), your filesystem should allocate a vnode struct and + pass it back to the kernel when fs_read_vnode is called. This struct is then passed back in to + your file system by functions that reference an item on the disk. You'll need to be able to + create a vnode from a vnode id, either by hashing the id number or encoding the information needed + to create the vnode in the vnode id itself. Vnode ids are assigned by your file system when the + filesystem walk function is called. For this driver, the block number is encoded in the upper bits + of the vnode id, and the offset within the block in the lower, allowing me to just read the info + to fill in the vnode struct from the disk. When the kernel is done with a vnode, it will call + fs_write_vnode (somewhat of a misnomer) where you should deallocate the struct. +*/ + +typedef struct vnode { + /* Most drivers will probably want the first things defined here. */ + ino_t id; + ino_t parID; // parent vnode ID. + void *cache; // for file cache + + // End of members other drivers will definitely want. + + /* The rest of this struct is very ISO-specific. You should replace the rest of this + definition with the stuff your file system needs. + */ + uint8 extAttrRecLen; // Length of extended attribute record. + uint32 startLBN[2]; // Logical block # of start of file/directory data + uint32 dataLen[2]; // Length of file section in bytes + ISORecDate recordDate; // Date file was recorded. + + // BIT MEANING + // --- ----------------------------- + uint8 flags; // 0 - is hidden + // 1 - is directory + // 2 - is "Associated File" + // 3 - Info is structed according to extended attr record + // 4 - Owner, group, ppermisssions are specified in the + // extended attr record + // 5 - Reserved + // 6 - Reserved + // 7 - File has more that one directory record + + uint8 fileUnitSize; // Interleave only + uint8 interleaveGapSize; // Interleave only + uint32 volSeqNum; // Volume sequence number of volume + uint8 fileIDLen; // Length of volume "ID" (name) + char* fileIDString; // Volume "ID" (name) + + // The rest is Rock Ridge extensions. I suggest www.leo.org for spec info. + RRAttr attr; +} vnode; + +// These go with the flags member of the nspace struct. +enum { + ISO_ISHIDDEN = 0, + ISO_ISDIR = 2, + ISO_ISASSOCFILE = 4, + ISO_EXTATTR = 8, + ISO_EXTPERM = 16, + ISO_MOREDIRS = 128 +}; + + +// Arbitrarily - selected root vnode id +#define ISO_ROOTNODE_ID 1 + +/* Structure used for directory "cookie". When you are asked + to open a directory, you are asked to create a cookie for it + and pass it back. The cookie should contain the information you + need to determine where you are at in reading the directory + entries, incremented every time readdir is called, until finally + the end is reached, when readdir returns NULL. */ +typedef struct dircookie { + off_t startBlock; + off_t block; // Current block + off_t pos; // Position within block. + off_t totalSize; // Size of directory file + off_t id; +} dircookie; + +/* You may also need to define a cookie for files, which again is + allocated every time a file is opened and freed when the free + cookie function is called. For ISO, we didn't need one. +*/ + +typedef struct attrfilemap { + char *name; + off_t offset; +} attrfilemap; + +/* This is the global volume nspace struct. When mount is called , this struct should + be allocated. It is passed back into the functions so that you can get at any + global information you need. You'll need to change this struct to suit your purposes. +*/ + +typedef struct nspace { + // Start of members other drivers will definitely want. + dev_t id; // ID passed in to fs_mount + int fd; // File descriptor + int fdOfSession; // File descriptor of the (mounted) session + //unsigned int blockSize; // usually need this, but it's part of ISO + void *fBlockCache; + + char devicePath[127]; + //off_t numBlocks; // May need this, but it's part of ISO + + // End of members other drivers will definitely want. + + // attribute extensions + int32 readAttributes; + attrfilemap *attrFileMap; + ino_t attributesID; + + // JOLIET extension: joliet_level for this volume + uint8 joliet_level; + + // All this stuff comes straight from ISO primary volume + // descriptor structure. + uint8 volDescType; // Volume Descriptor type byte1 + char stdIDString[6]; // Standard ID, 1 extra for null byte2-6 + uint8 volDescVersion; // Volume Descriptor version byte7 + // 8th byte unused + char systemIDString[33]; // System ID, 1 extra for null byte9-40 + char volIDString[33]; // Volume ID, 1 extra for null byte41-72 + // bytes 73-80 unused + uint32 volSpaceSize[2]; // #logical blocks, lsb and msb byte81-88 + // bytes 89-120 unused + uint16 volSetSize[2]; // Assigned Volume Set Size of Vol byte121-124 + uint16 volSeqNum[2]; // Ordinal number of volume in Set byte125-128 + uint16 logicalBlkSize[2]; // Logical blocksize, usually 2048 byte129-132 + uint32 pathTblSize[2]; // Path table size byte133-149 + uint16 lPathTblLoc[2]; // Loc (Logical block #) of "Type L" path table byte141-144 + uint16 optLPathTblLoc[2]; // Loc (Logical block #) of optional Type L path tbl byte145-148 + uint16 mPathTblLoc[2]; // Loc (Logical block #) of "Type M" path table byte149-152 + uint16 optMPathTblLoc[2]; // Loc (Logical block #) of optional Type M path tbl byte153-156 + vnode rootDirRec; // Directory record for root directory byte157-190 + char volSetIDString[29]; // Name of multi-volume set where vol is member byte191-318 + char pubIDString[129]; // Name of publisher byte319-446 + char dataPreparer[129]; // Name of data preparer byte447-574 + char appIDString[129]; // Identifies data fomrat byte575-702 + char copyright[38]; // Copyright string byte703-739 + char abstractFName[38]; // Name of file in root that has abstract byte740-776 + char biblioFName[38]; // Name of file in root that has biblio byte777-813 + + ISOVolDate createDate; // Creation date byte + ISOVolDate modDate; // Modification date + ISOVolDate expireDate; // Data expiration date + ISOVolDate effectiveDate; // Data effective data + + uint8 fileStructVers; // File structure version byte882 +} nspace; + +#ifdef __cplusplus +extern "C" { +#endif + +int ISOMount(const char *path, const int flags, nspace** newVolume, + bool allowJoliet); +int ISOReadDirEnt(nspace* ns, dircookie* cookie, struct dirent* buffer, + size_t bufferSize); +int InitNode(vnode* rec, char* buf, int* bytesRead, uint8 jolietLevel); +int ConvertRecDate(ISORecDate* inDate, time_t* outDate); + +#ifdef __cplusplus +} +#endif + +#endif /* ISO_9660_H */ Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp 2007-11-13 14:55:11 UTC (rev 22920) +++ haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp 2007-11-13 14:57:11 UTC (rev 22921) @@ -32,7 +32,7 @@ #include -#include "iso.h" +#include "iso9660.h" #include "iso9660_identify.h" From axeld at mail.berlios.de Tue Nov 13 16:19:22 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 13 Nov 2007 16:19:22 +0100 Subject: [Haiku-commits] r22922 - haiku/trunk/src/system/kernel/fs Message-ID: <200711131519.lADFJMID011970@sheep.berlios.de> Author: axeld Date: 2007-11-13 16:19:21 +0100 (Tue, 13 Nov 2007) New Revision: 22922 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22922&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: * vfs_unmount() can now safely be called from the kernel (fs_unmount() still tried to access the uninitialized vnode in that case). * That means that it's now safe to remove a mounted CD from the drive, it will then be unmounted automatically. * Added a check for partition::Device() - even though Ingo tells me it's impossible, it was NULL once. * Minor cleanup. Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-11-13 14:57:11 UTC (rev 22921) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-11-13 15:19:21 UTC (rev 22922) @@ -5812,11 +5812,12 @@ static status_t fs_unmount(char *path, dev_t mountID, uint32 flags, bool kernel) { + struct vnode *vnode = NULL; struct fs_mount *mount; - struct vnode *vnode; status_t err; - FUNCTION(("vfs_unmount: entry. path = '%s', kernel %d\n", path, kernel)); + FUNCTION(("fs_unmount(path '%s', dev %ld, kernel %d\n", path, mountID, + kernel)); if (path != NULL) { err = path_to_vnode(path, true, &vnode, NULL, kernel); @@ -5826,9 +5827,11 @@ RecursiveLocker mountOpLocker(sMountOpLock); - mount = find_mount(vnode->device); - if (!mount) - panic("vfs_unmount: find_mount() failed on root vnode @%p of mount\n", vnode); + mount = find_mount(path != NULL ? vnode->device : mountID); + if (mount == NULL) { + panic("fs_unmount: find_mount() failed on root vnode @%p of mount\n", + vnode); + } if (path != NULL) { put_vnode(vnode); @@ -5845,6 +5848,10 @@ KPartition *partition = mount->partition; KDiskDevice *diskDevice = NULL; if (partition) { + if (partition->Device() == NULL) { + dprintf("fs_unmount(): There is no device!\n"); + return B_ERROR; + } diskDevice = ddm->WriteLockDevice(partition->Device()->ID()); if (!diskDevice) { TRACE(("fs_unmount(): Failed to lock disk device!\n")); @@ -5873,7 +5880,8 @@ // cycle through the list of vnodes associated with this mount and // make sure all of them are not busy or have refs on them vnode = NULL; - while ((vnode = (struct vnode *)list_get_next_item(&mount->vnodes, vnode)) != NULL) { + while ((vnode = (struct vnode *)list_get_next_item(&mount->vnodes, + vnode)) != NULL) { // The root vnode ref_count needs to be 1 here (the mount has a // reference). if (vnode->busy @@ -5947,7 +5955,8 @@ // Free all vnodes associated with this mount. // They will be removed from the mount list by free_vnode(), so // we don't have to do this. - while ((vnode = (struct vnode *)list_get_first_item(&mount->vnodes)) != NULL) { + while ((vnode = (struct vnode *)list_get_first_item(&mount->vnodes)) + != NULL) { free_vnode(vnode, false); } From axeld at mail.berlios.de Tue Nov 13 16:20:51 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 13 Nov 2007 16:20:51 +0100 Subject: [Haiku-commits] r22923 - haiku/trunk/src/add-ons/kernel/network/stack Message-ID: <200711131520.lADFKphs012102@sheep.berlios.de> Author: axeld Date: 2007-11-13 16:20:51 +0100 (Tue, 13 Nov 2007) New Revision: 22923 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22923&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp Log: Added a "net_timer" KDL command that dumps all network timers. Modified: haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp 2007-11-13 15:19:21 UTC (rev 22922) +++ haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp 2007-11-13 15:20:51 UTC (rev 22923) @@ -505,6 +505,25 @@ } +static int +dump_timer(int argc, char **argv) +{ + kprintf("timer hook data due in\n"); + + struct net_timer *timer = NULL; + while (true) { + timer = (net_timer *)list_get_next_item(&sTimers, timer); + if (timer == NULL) + break; + + kprintf("%p %p %p %Ld\n", timer, timer->hook, timer->data, + timer->due > 0 ? timer->due - system_time() : -1); + } + + return 0; +} + + status_t init_timers(void) { @@ -528,6 +547,9 @@ goto err2; } + add_debugger_command("net_timer", dump_timer, + "Lists all active network timer"); + return resume_thread(sTimerThread); err1: From leavengood at gmail.com Tue Nov 13 18:49:01 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Tue, 13 Nov 2007 12:49:01 -0500 Subject: [Haiku-commits] r22915 - haiku/trunk/build/jam In-Reply-To: <200711131046.lADAkqba006608@sheep.berlios.de> References: <200711131046.lADAkqba006608@sheep.berlios.de> Message-ID: On Nov 13, 2007 5:46 AM, stippi at BerliOS wrote: > > Modified: > haiku/trunk/build/jam/HaikuImage > Log: > * added Message and Spider screen savers to the image Thanks for this, but Message still doesn't work right in Haiku. It doesn't render in the Screensaver pref app and when you try to preview it the screen goes black and doesn't come back. I am not sure if this is a bug in Message or Haiku. It works fine in BeOS though, so... If you have any hints on what might be wrong, let me know. Or see if you can find the app_server bug if that is the problem :) Ryan From anevilyak at gmail.com Tue Nov 13 20:58:00 2007 From: anevilyak at gmail.com (Rene Gollent) Date: Tue, 13 Nov 2007 13:58:00 -0600 Subject: [Haiku-commits] Haiku-commits Digest, Vol 17, Issue 43 In-Reply-To: References: Message-ID: > 5. r22920 - haiku/trunk/src/add-ons/kernel/file_systems/iso9660 > (axeld at BerliOS) Change 22920 has broken the build. iso9660_identify.cpp is still including "iso.h" rather than the renamed "iso9660.h" Regards, Rene From axeld at mail.berlios.de Tue Nov 13 21:31:31 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 13 Nov 2007 21:31:31 +0100 Subject: [Haiku-commits] r22924 - haiku/trunk/src/add-ons/kernel/file_systems/iso9660 Message-ID: <200711132031.lADKVVSi017699@sheep.berlios.de> Author: axeld Date: 2007-11-13 21:31:31 +0100 (Tue, 13 Nov 2007) New Revision: 22924 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22924&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660_identify.cpp Log: Build fix: iso9660_identify.cpp still included the old header. Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660_identify.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660_identify.cpp 2007-11-13 15:20:51 UTC (rev 22923) +++ haiku/trunk/src/add-ons/kernel/file_systems/iso9660/iso9660_identify.cpp 2007-11-13 20:31:31 UTC (rev 22924) @@ -48,7 +48,7 @@ #include #include -#include "iso.h" +#include "iso9660.h" //#define TRACE(x) ; #define TRACE(x) dprintf x From axeld at pinc-software.de Tue Nov 13 21:32:01 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 13 Nov 2007 21:32:01 +0100 Subject: [Haiku-commits] Haiku-commits Digest, Vol 17, Issue 43 In-Reply-To: Message-ID: <2970451570-BeMail@ibm> "Rene Gollent" wrote: > > 5. r22920 - haiku/trunk/src/add-ons/kernel/file_systems/iso9660 > > (axeld at BerliOS) > Change 22920 has broken the build. iso9660_identify.cpp is still > including "iso.h" rather than the renamed "iso9660.h" Thanks, it's fixed now! Bye, Axel. From axeld at mail.berlios.de Wed Nov 14 02:22:44 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 14 Nov 2007 02:22:44 +0100 Subject: [Haiku-commits] r22925 - haiku/trunk/src/kits/app Message-ID: <200711140122.lAE1MinY023788@sheep.berlios.de> Author: axeld Date: 2007-11-14 02:22:43 +0100 (Wed, 14 Nov 2007) New Revision: 22925 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22925&view=rev Modified: haiku/trunk/src/kits/app/Message.cpp Log: Forwarding did not work anymore for direct targets, since the header::flags field was not initialized properly, and the reply target was taken from the wrong header in this case. Modified: haiku/trunk/src/kits/app/Message.cpp =================================================================== --- haiku/trunk/src/kits/app/Message.cpp 2007-11-13 20:31:31 UTC (rev 22924) +++ haiku/trunk/src/kits/app/Message.cpp 2007-11-14 01:22:43 UTC (rev 22925) @@ -1856,6 +1856,7 @@ copy = new BMessage(*this); if (copy != NULL) { header = copy->fHeader; + header->flags = fHeader->flags; result = B_OK; } else { direct->Release(); @@ -1889,8 +1890,8 @@ return result; if (!replyTo.IsValid()) { - BMessenger::Private(replyTo).SetTo(header->reply_team, - header->reply_port, header->reply_target); + BMessenger::Private(replyTo).SetTo(fHeader->reply_team, + fHeader->reply_port, fHeader->reply_target); if (!replyTo.IsValid()) replyTo = be_app_messenger; From axeld at mail.berlios.de Wed Nov 14 02:28:55 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 14 Nov 2007 02:28:55 +0100 Subject: [Haiku-commits] r22926 - in haiku/trunk: headers/private/app src/servers/debug src/servers/registrar Message-ID: <200711140128.lAE1StLb024309@sheep.berlios.de> Author: axeld Date: 2007-11-14 02:28:47 +0100 (Wed, 14 Nov 2007) New Revision: 22926 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22926&view=rev Modified: haiku/trunk/headers/private/app/RegistrarDefs.h haiku/trunk/src/servers/debug/DebugServer.cpp haiku/trunk/src/servers/registrar/Registrar.cpp haiku/trunk/src/servers/registrar/ShutdownProcess.cpp haiku/trunk/src/servers/registrar/ShutdownProcess.h Log: bonefish+axeld: * The debug_server now sends the registrar messages whenever the debug alert is shown, and also, if the user wants to debug the team. * In the latter case, the registrar will now cancel a shutdown process. * Also, it will now wait with the shutdown process until the user has acknowledged the debugger alert. Modified: haiku/trunk/headers/private/app/RegistrarDefs.h =================================================================== --- haiku/trunk/headers/private/app/RegistrarDefs.h 2007-11-14 01:22:43 UTC (rev 22925) +++ haiku/trunk/headers/private/app/RegistrarDefs.h 2007-11-14 01:28:47 UTC (rev 22926) @@ -104,6 +104,9 @@ B_REG_UPDATE_DISK_DEVICE = 'rgud', B_REG_DEVICE_START_WATCHING = 'rgwd', B_REG_DEVICE_STOP_WATCHING = 'rgsd', + + // debug_server notifications + B_REG_TEAM_DEBUGGER_ALERT = 'rtda', }; // B_REG_MIME_SET_PARAM "which" constants Modified: haiku/trunk/src/servers/debug/DebugServer.cpp =================================================================== --- haiku/trunk/src/servers/debug/DebugServer.cpp 2007-11-14 01:22:43 UTC (rev 22925) +++ haiku/trunk/src/servers/debug/DebugServer.cpp 2007-11-14 01:28:47 UTC (rev 22926) @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -115,6 +116,7 @@ const void *address, char *buffer, int32 bufferSize); void _PrintStackTrace(thread_id thread); void _NotifyAppServer(team_id team); + void _NotifyRegistrar(team_id team, bool openAlert, bool stopShutdown); status_t _InitGUI(); @@ -258,8 +260,7 @@ // DebugServer -class DebugServer : public BServer -{ +class DebugServer : public BServer { public: DebugServer(status_t &error); @@ -558,16 +559,20 @@ } else if (USE_GUI && _AreGUIServersAlive() && _InitGUI() == B_OK) { // normal app -- tell the user _NotifyAppServer(fTeam); + _NotifyRegistrar(fTeam, true, false); char buffer[1024]; snprintf(buffer, sizeof(buffer), "The application:\n\n %s\n\n" "has encountered an error which prevents it from continuing. Haiku " "will terminate the application and clean up.", fTeamInfo.args); + // TODO: It would be nice if the alert would go away automatically + // if someone else kills our teams. BAlert *alert = new BAlert(NULL, buffer, "Debug", "OK", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); int32 result = alert->Go(); kill = (result == 1); + _NotifyRegistrar(fTeam, false, !kill); } return kill; @@ -688,6 +693,22 @@ roster.ApplicationCrashed(team); } + +void +TeamDebugHandler::_NotifyRegistrar(team_id team, bool openAlert, + bool stopShutdown) +{ + BMessage notify(BPrivate::B_REG_TEAM_DEBUGGER_ALERT); + notify.AddInt32("team", team); + notify.AddBool("open", openAlert); + notify.AddBool("stop shutdown", stopShutdown); + + BRoster::Private roster; + BMessage reply; + roster.SendTo(¬ify, &reply, false); +} + + // _InitGUI status_t TeamDebugHandler::_InitGUI() @@ -895,7 +916,7 @@ return B_OK; } -// QuitRequested + bool DebugServer::QuitRequested() { Modified: haiku/trunk/src/servers/registrar/Registrar.cpp =================================================================== --- haiku/trunk/src/servers/registrar/Registrar.cpp 2007-11-14 01:22:43 UTC (rev 22925) +++ haiku/trunk/src/servers/registrar/Registrar.cpp 2007-11-14 01:28:47 UTC (rev 22926) @@ -222,6 +222,7 @@ break; } + // shutdown process case B_REG_SHUT_DOWN: { PRINT(("B_REG_SHUT_DOWN\n")); @@ -229,6 +230,12 @@ _HandleShutDown(message); break; } + case B_REG_TEAM_DEBUGGER_ALERT: + { + if (fShutdownProcess != NULL) + fShutdownProcess->PostMessage(message); + break; + } // roster requests case B_REG_ADD_APP: Modified: haiku/trunk/src/servers/registrar/ShutdownProcess.cpp =================================================================== --- haiku/trunk/src/servers/registrar/ShutdownProcess.cpp 2007-11-14 01:22:43 UTC (rev 22925) +++ haiku/trunk/src/servers/registrar/ShutdownProcess.cpp 2007-11-14 01:28:47 UTC (rev 22926) @@ -62,13 +62,13 @@ static const bigtime_t kDisplayAbortingAppTimeout = 3000000; // 3 s -// message what fields +// message what fields (must not clobber the registrar's message namespace) enum { MSG_PHASE_TIMED_OUT = 'phto', MSG_DONE = 'done', MSG_KILL_APPLICATION = 'kill', MSG_CANCEL_SHUTDOWN = 'cncl', - MSG_REBOOT_SYSTEM = 'rbot', + MSG_REBOOT_SYSTEM = 'lbot', }; // internal events @@ -79,6 +79,7 @@ APP_QUIT_EVENT, KILL_APP_EVENT, REBOOT_SYSTEM_EVENT, + DEBUG_EVENT }; // phases @@ -790,21 +791,15 @@ if (message->FindInt32("team", &team) != B_OK) break; - BAutolock _(fWorkerLock); - // post the event _PushEvent(KILL_APP_EVENT, team, fCurrentPhase); - break; } case MSG_CANCEL_SHUTDOWN: { - BAutolock _(fWorkerLock); - // post the event _PushEvent(ABORT_EVENT, -1, fCurrentPhase); - break; } @@ -812,7 +807,6 @@ { // post the event _PushEvent(REBOOT_SYSTEM_EVENT, -1, INVALID_PHASE); - break; } @@ -820,7 +814,34 @@ { // notify the registrar that we're done be_app->PostMessage(B_REG_SHUTDOWN_FINISHED, be_app); + break; + } + case B_REG_TEAM_DEBUGGER_ALERT: + { + bool stopShutdown; + if (message->FindBool("stop shutdown", &stopShutdown) == B_OK + && stopShutdown) { + // post abort event to the worker + _PushEvent(ABORT_EVENT, -1, fCurrentPhase); + break; + } + + bool open; + team_id team; + if (message->FindInt32("team", &team) != B_OK + || message->FindBool("open", &open) != B_OK) + break; + + BAutolock _(fWorkerLock); + if (open) { + PRINT(("B_REG_TEAM_DEBUGGER_ALERT: insert %ld\n", team)); + fDebuggedTeams.insert(team); + } else { + PRINT(("B_REG_TEAM_DEBUGGER_ALERT: remove %ld\n", team)); + fDebuggedTeams.erase(team); + _PushEvent(DEBUG_EVENT, -1, fCurrentPhase); + } break; } @@ -1145,10 +1166,9 @@ do { error = acquire_sem(fInternalEventSemaphore); } while (error == B_INTERRUPTED); - + if (error != B_OK) return error; - } else { status_t error = acquire_sem_etc(fInternalEventSemaphore, 1, B_RELATIVE_TIMEOUT, 0); @@ -1157,10 +1177,10 @@ return B_OK; } } - + // get the event BAutolock _(fWorkerLock); - + InternalEvent *event = fInternalEvents->Head(); fInternalEvents->Remove(event); @@ -1259,14 +1279,17 @@ // phase 1: terminate the user apps _SetPhase(USER_APP_TERMINATION_PHASE); _QuitApps(fUserApps, false); + _WaitForDebuggedTeams(); // phase 2: terminate the system apps _SetPhase(SYSTEM_APP_TERMINATION_PHASE); _QuitApps(fSystemApps, true); + _WaitForDebuggedTeams(); // phase 3: terminate the background apps _SetPhase(BACKGROUND_APP_TERMINATION_PHASE); _QuitBackgroundApps(); + _WaitForDebuggedTeams(); // phase 4: terminate the other processes _SetPhase(OTHER_PROCESSES_TERMINATION_PHASE); @@ -1274,6 +1297,7 @@ _ScheduleTimeoutEvent(kBackgroundAppQuitTimeout, -1); _WaitForBackgroundApps(); _KillBackgroundApps(); + _WaitForDebuggedTeams(); // we're through: do the shutdown _SetPhase(DONE_PHASE); @@ -1311,7 +1335,49 @@ #endif } -// _QuitApps + +bool +ShutdownProcess::_WaitForApp(team_id team, AppInfoList *list, bool systemApps) +{ + uint32 event; + do { + team_id eventTeam; + int32 phase; + status_t error = _GetNextEvent(event, eventTeam, phase, true); + if (error != B_OK) + throw_error(error); + + if (event == APP_QUIT_EVENT && eventTeam == team) + return true; + + if (event == TIMEOUT_EVENT && eventTeam == team) + return false; + + if (event == ABORT_EVENT) { + if (systemApps) { + // If the app requests aborting the shutdown, we don't need + // to wait any longer. It has processed the request and + // won't quit by itself. We ignore this for system apps. + if (eventTeam == team) + return false; + } else { + PRINT(("ShutdownProcess::_QuitApps(): shutdown cancelled " + "by team %ld (-1 => user)\n", eventTeam)); + + _DisplayAbortingApp(team); + throw_error(B_SHUTDOWN_CANCELLED); + } + } + + BAutolock _(fWorkerLock); + if (list != NULL && !list->InfoFor(team)) + return true; + } while (event != NO_EVENT); + + return false; +} + + void ShutdownProcess::_QuitApps(AppInfoList &list, bool systemApps) { @@ -1401,44 +1467,7 @@ _ScheduleTimeoutEvent(kAppQuitTimeout, team); // wait for the app to die or for the timeout to occur - bool appGone = false; - do { - team_id eventTeam; - int32 phase; - status_t error = _GetNextEvent(event, eventTeam, phase, true); - if (error != B_OK) - throw_error(error); - - if ((event == APP_QUIT_EVENT) - && eventTeam == team) { - appGone = true; - } - - if (event == TIMEOUT_EVENT && eventTeam == team) - break; - - if (event == ABORT_EVENT) { - if (systemApps) { - // If the app requests aborting the shutdown, we don't need - // to wait any longer. It has processed the request and - // won't quit by itself. We ignore this for system apps. - if (eventTeam == team) - break; - } else { - PRINT(("ShutdownProcess::_QuitApps(): shutdown cancelled " - "by team %ld (-1 => user)\n", eventTeam)); - - _DisplayAbortingApp(team); - throw_error(B_SHUTDOWN_CANCELLED); - } - } - - BAutolock _(fWorkerLock); - if (!list.InfoFor(team)) - break; - - } while (event != NO_EVENT); - + bool appGone = _WaitForApp(team, &list, systemApps); if (appGone) { // fine: the app finished in an orderly manner } else { @@ -1623,7 +1652,17 @@ ShutdownProcess::_QuitBlockingApp(AppInfoList &list, team_id team, const char *appName, bool cancelAllowed) { - if (BPrivate::is_app_showing_modal_window(team)) { + bool debugged = false; + bool modal = false; + { + BAutolock _(fWorkerLock); + if (fDebuggedTeams.find(team) != fDebuggedTeams.end()) + debugged = true; + } + if (!debugged) + modal = BPrivate::is_app_showing_modal_window(team); + + if (modal) { // app blocks on a modal window char buffer[1024]; snprintf(buffer, sizeof(buffer), "The application \"%s\" might be " @@ -1631,7 +1670,9 @@ _SetShutdownWindowText(buffer); _SetShutdownWindowCurrentApp(team); _SetShutdownWindowKillButtonEnabled(true); + } + if (modal || debugged) { // wait for something to happen bool appGone = false; while (true) { @@ -1651,7 +1692,7 @@ break; if (event == ABORT_EVENT) { - if (cancelAllowed) { + if (cancelAllowed || debugged) { PRINT(("ShutdownProcess::_QuitBlockingApp(): shutdown " "cancelled by team %ld (-1 => user)\n", eventTeam)); @@ -1758,3 +1799,39 @@ } } + +/*! Waits until the debugged team list is empty, ie. when there is no one + left to debug. +*/ +void +ShutdownProcess::_WaitForDebuggedTeams() +{ + PRINT(("ShutdownProcess::_WaitForDebuggedTeams()\n")); + { + BAutolock _(fWorkerLock); + if (fDebuggedTeams.empty()) + return; + } + + PRINT((" not empty!\n")); + + // wait for something to happen + while (true) { + uint32 event; + team_id eventTeam; + int32 phase; + status_t error = _GetNextEvent(event, eventTeam, phase, true); + if (error != B_OK) + throw_error(error); + + if (event == ABORT_EVENT) + throw_error(B_SHUTDOWN_CANCELLED); + + BAutolock _(fWorkerLock); + if (fDebuggedTeams.empty()) { + PRINT((" out empty")); + return; + } + } +} + Modified: haiku/trunk/src/servers/registrar/ShutdownProcess.h =================================================================== --- haiku/trunk/src/servers/registrar/ShutdownProcess.h 2007-11-14 01:22:43 UTC (rev 22925) +++ haiku/trunk/src/servers/registrar/ShutdownProcess.h 2007-11-14 01:28:47 UTC (rev 22926) @@ -70,6 +70,7 @@ status_t _Worker(); void _WorkerDoShutdown(); + bool _WaitForApp(team_id team, AppInfoList *list, bool systemApps); void _QuitApps(AppInfoList &list, bool systemApps); void _QuitBackgroundApps(); void _WaitForBackgroundApps(); @@ -78,6 +79,7 @@ void _QuitBlockingApp(AppInfoList &list, team_id team, const char *appName, bool cancelAllowed); void _DisplayAbortingApp(team_id team); + void _WaitForDebuggedTeams(); private: class TimeoutEvent; @@ -97,6 +99,7 @@ AppInfoList fSystemApps; AppInfoList fUserApps; AppInfoList fBackgroundApps; + hash_set fDebuggedTeams; TimeoutEvent *fTimeoutEvent; InternalEventList *fInternalEvents; sem_id fInternalEventSemaphore; From sbenedetto at mail.berlios.de Wed Nov 14 14:37:41 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Wed, 14 Nov 2007 14:37:41 +0100 Subject: [Haiku-commits] r22927 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711141337.lAEDbfnW013967@sheep.berlios.de> Author: sbenedetto Date: 2007-11-14 14:37:41 +0100 (Wed, 14 Nov 2007) New Revision: 22927 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22927&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h Log: * Renamed some variables * Reworking the interrupts endpoints tree parts * Added spin_locker, semaphore, finisher thread and interrupt handler (not implemented) * Made fInterruptEndpoints allocation dynamic instead of static * Fixed Start method (it should be correct now) Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-14 01:28:47 UTC (rev 22926) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-14 13:37:41 UTC (rev 22927) @@ -66,13 +66,18 @@ fPCIInfo(info), fStack(stack), fRegisterArea(-1), + fSpinLock(0), fHccaArea(-1), fDummyControl(NULL), fDummyBulk(NULL), fDummyIsochronous(NULL), + fFirstTransfer(NULL), + fFinishTransfer(NULL), + fFinishThread(-1), + fStopFinishThread(false), fRootHub(NULL), fRootHubAddress(0), - fNumPorts(0) + fPortCount(0) { if (!fInitOK) { TRACE_ERROR(("usb_ohci: bus manager failed to init\n")); @@ -119,12 +124,13 @@ } // Set up the Host Controller Communications Area + // which is 256 bytes (2048 bits) and must be aligned void *hccaPhysicalAddress; fHccaArea = fStack->AllocateArea((void **)&fHcca, &hccaPhysicalAddress, 2048, "USB OHCI Host Controller Communication Area"); if (fHccaArea < B_OK) { - TRACE(("usb_ohci: unable to create the HCCA block area\n")); + TRACE_ERROR(("usb_ohci: unable to create the HCCA block area\n")); return; } @@ -153,9 +159,35 @@ fDummyIsochronous->flags |= OHCI_ENDPOINT_SKIP; // Create the interrupt tree - // Algorithm kindly borrowed from NetBSD code - // TODO: Check it once again - ohci_endpoint_descriptor *current, *previous; + fInterruptEndpoints = new(std::nothrow) + ohci_endpoint_descriptor *[OHCI_NUMBER_OF_INTERRUPTS]; + if (!fInterruptEndpoints) { + TRACE_ERROR(("ohci_usb: cannot allocate memory for" + " fInterruptEndpoints array\n")); + _FreeEndpoint(fDummyControl); + _FreeEndpoint(fDummyBulk); + _FreeEndpoint(fDummyIsochronous); + return; + } + + // Static endpoints that get linked in the HCCA + for (uint32 i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) { + fInterruptEndpoints[i] = _AllocateEndpoint(); + if (!fInterruptEndpoints[i]) { + while (--i >= 0) + _FreeEndpoint(fInterruptEndpoints[i]); + _FreeEndpoint(fDummyBulk); + _FreeEndpoint(fDummyControl); + _FreeEndpoint(fDummyIsochronous); + return; + } + fInterruptEndpoints[i]->flags |= OHCI_ENDPOINT_SKIP; + fInterruptEndpoints[i]->next_physical_endpoint + = fDummyIsochronous->physical_address; + } + +#if 0 + ohci_endpoint_descriptor *current; for( uint32 i = 0; i < OHCI_NUMBER_OF_ENDPOINTS; i++) { current = _AllocateEndpoint(); if (!current) { @@ -174,13 +206,14 @@ else previous = fDummyIsochronous; current->next_logical_endpoint = previous; - current->next_physical_endpoint = previous->this_physical; + current->next_physical_endpoint = previous->physical_address; } +#endif // Fill HCCA interrupt table. The bit reversal is to get // the tree set up properly to spread the interrupts. for (uint32 i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) - fHcca->hcca_interrupt_table[revbits[i]] = + fHcca->interrupt_table[revbits[i]] = fInterruptEndpoints[OHCI_NUMBER_OF_ENDPOINTS - OHCI_NUMBER_OF_INTERRUPTS + i]->physical_address; @@ -230,8 +263,12 @@ return; } - // The controller is now in SUSPEND state, we have 2ms to finish - // TODO: maybe add spinlock protection??? + // The controller is now in SUSPEND state, we have 2ms to go OPERATIONAL. + // In order to do so we need a spinlock + + cpu_status former = disable_interrupts(); + acquire_spinlock(&fSpinLock); + // Set up host controller register _WriteReg(OHCI_HCCA, (uint32)hccaPhysicalAddress); _WriteReg(OHCI_CONTROL_HEAD_ED, (uint32)fDummyControl->physical_address); @@ -248,7 +285,10 @@ | OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL; // And finally start the controller _WriteReg(OHCI_CONTROL, control); - + + release_spinlock(&fSpinLock); + restore_interrupts(former); + // The controller is now OPERATIONAL. frameInterval = (_ReadReg(OHCI_FRAME_INTERVAL) & OHCI_FRAME_INTERVAL_TOGGLE) ^ OHCI_FRAME_INTERVAL_TOGGLE; @@ -273,11 +313,28 @@ uint32 descriptor = _ReadReg(OHCI_RH_DESCRIPTOR_A); numberOfPorts = OHCI_RH_GET_PORT_COUNT(descriptor); } + fPortCount = numberOfPorts; - // TODO: Add Finisher Thread. + // Create semaphore the finisher thread will wait for + fFinishTransfersSem = create_sem(0, "OHCI Finish Transfers"); + if (fFinishTransfersSem < B_OK) { + TRACE_ERROR(("usb_ohci: failed to create semaphore\n")); + return; + } + // Create the finisher service thread + fFinishThread = spawn_kernel_thread(_FinishThread, "ohci finish thread", + B_URGENT_DISPLAY_PRIORITY, (void *)this); + resume_thread(fFinishThread); + + // Install the interrupt handler + TRACE(("usb_ohci: installing interrupt handler\n")); + install_io_interrupt_handler(fPCIInfo->u.h0.interrupt_line, + _InterruptHandler, (void *)this, 0); + + // TODO: Enable interrupts. Maybe disable first somewhere before :) + TRACE(("usb_ohci: OHCI Host Controller Driver constructed\n")); - fInitOK = true; } @@ -296,41 +353,73 @@ _FreeEndpoint(fDummyIsochronous); if (fRootHub) delete fRootHub; - for (int i = 0; i < OHCI_NO_EDS; i++) + for (int i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) if (fInterruptEndpoints[i]) _FreeEndpoint(fInterruptEndpoints[i]); + delete [] fInterruptEndpoints; } +int32 +OHCI::_InterruptHandler(void *data) +{ + return ((OHCI *)data)->_Interrupt(); +} + + +int32 +OHCI::_Interrupt() +{ + static spinlock lock = 0; + acquire_spinlock(&lock); + + int32 result = B_UNHANDLED_INTERRUPT; + + release_spinlock(&lock); + + return result; +} + + +int32 +OHCI::_FinishThread(void *data) +{ + ((OHCI *)data)->_FinishTransfer(); + return B_OK; +} + + +void +OHCI::_FinishTransfer() +{ + // TODO: block on the semaphore +} + status_t OHCI::Start() { - TRACE(("usb_ohci::%s()\n", __FUNCTION__)); - if (InitCheck()) - return B_ERROR; - + TRACE(("usb_ohci: starting OHCI Host Controller\n")); + if (!(_ReadReg(OHCI_CONTROL) & OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL)) { - TRACE(("usb_ohci::Start(): Controller not started. TODO: find out what happens.\n")); + TRACE_ERROR(("usb_ohci: Controller not started!\n")); return B_ERROR; } - + fRootHubAddress = AllocateAddress(); - fNumPorts = OHCI_RH_GET_PORT_COUNT(_ReadReg(OHCI_RH_DESCRIPTOR_A)); - fRootHub = new(std::nothrow) OHCIRootHub(RootObject(), fRootHubAddress); if (!fRootHub) { - TRACE_ERROR(("usb_ohci::Start(): no memory to allocate root hub\n")); + TRACE_ERROR(("usb_ohci: no memory to allocate root hub\n")); return B_NO_MEMORY; } if (fRootHub->InitCheck() < B_OK) { - TRACE_ERROR(("usb_ohci::Start(): root hub failed init check\n")); + TRACE_ERROR(("usb_ohci: root hub failed init check\n")); return B_ERROR; } SetRootHub(fRootHub); - TRACE(("usb_ohci::Start(): Succesful start\n")); - return B_OK; + TRACE(("usb_ohci: Host Controller started\n")); + return BusManager::Start(); } @@ -445,7 +534,7 @@ OHCI::GetPortStatus(uint8 index, usb_port_status *status) { TRACE(("usb_ohci::%s(%ud, )\n", __FUNCTION__, index)); - if (index >= fNumPorts) + if (index >= fPortCount) return B_BAD_INDEX; status->status = status->change = 0; @@ -490,7 +579,7 @@ OHCI::SetPortFeature(uint8 index, uint16 feature) { TRACE(("OHCI::%s(%ud, %ud)\n", __FUNCTION__, index, feature)); - if (index > fNumPorts) + if (index > fPortCount) return B_BAD_INDEX; switch (feature) { @@ -511,7 +600,7 @@ OHCI::ClearPortFeature(uint8 index, uint16 feature) { TRACE(("OHCI::%s(%ud, %ud)\n", __FUNCTION__, index, feature)); - if (index > fNumPorts) + if (index > fPortCount) return B_BAD_INDEX; switch (feature) { @@ -534,22 +623,20 @@ ohci_endpoint_descriptor *endpoint; void* physicalAddress; - //Allocate memory chunk + // Allocate memory chunk if (fStack->AllocateChunk((void **)&endpoint, &physicalAddress, sizeof(ohci_endpoint_descriptor)) < B_OK) { TRACE_ERROR(("usb_ohci: failed to allocate endpoint descriptor\n")); return NULL; } - endpoint->this_physical = (addr_t)physicalAddress; + endpoint->physical_address = (addr_t)physicalAddress; - // Add an empty list by creating a general descriptor - ohci_general_transfer_descriptor *descriptor = _CreateGeneralDescriptor(); - endpoint->head_physical_descriptor = descriptor->this_physical; - endpoint->tail_physical_descriptor = descriptor->this_physical; + endpoint->head_physical_descriptor = NULL; + endpoint->tail_physical_descriptor = NULL; - endpoint->head_logical_descriptor = descriptor; - endpoint->tail_logical_descriptor = descriptor; + endpoint->head_logical_descriptor = NULL; + endpoint->tail_logical_descriptor = NULL; return endpoint; } @@ -558,46 +645,53 @@ void OHCI::_FreeEndpoint(ohci_endpoint_descriptor *endpoint) { - TRACE(("OHCI::%s(%p)\n", __FUNCTION__, end)); - fStack->FreeChunk((void *)end->ed, (void *) end->physical_address, sizeof(ohci_endpoint_descriptor)); - delete end; + fStack->FreeChunk((void *)endpoint, (void *)endpoint->physical_address, + sizeof(ohci_endpoint_descriptor)); } -TransferDescriptor * -OHCI::_AllocateTransfer() +ohci_general_descriptor* +OHCI::_CreateGeneralDescriptor() { - TRACE(("OHCI::%s()\n", __FUNCTION__)); - TransferDescriptor *transfer = new TransferDescriptor; - void *phy; - if (fStack->AllocateChunk((void **)&transfer->td, &phy, sizeof(ohci_general_transfer_descriptor)) != B_OK) { - TRACE(("OHCI::AllocateTransfer(): Error Allocating Transfer\n")); - return 0; + ohci_general_descriptor *descriptor; + void *physicalAddress; + + if (fStack->AllocateChunk((void **)&descriptor, &physicalAddress, + sizeof(ohci_general_descriptor)) != B_OK) { + TRACE_ERROR(("usb_ohci: failed to allocate general descriptor\n")); + return NULL; } - transfer->physical_address = (addr_t)phy; - memset((void *)transfer->td, 0, sizeof(ohci_general_transfer_descriptor)); - return transfer; + + // TODO: Finish methods + memset((void *)descriptor, 0, sizeof(ohci_general_descriptor)); + descriptor->physical_address = (addr_t)physicalAddress; + + return descriptor; } void -OHCI::_FreeTransfer(TransferDescriptor *trans) +OHCI::_FreeGeneralDescriptor(ohci_general_descriptor *descriptor) { - TRACE(("OHCI::%s(%p)\n", __FUNCTION__, trans)); - fStack->FreeChunk((void *)trans->td, (void *) trans->physical_address, sizeof(ohci_general_transfer_descriptor)); - delete trans; + if (!descriptor) + return; + + fStack->FreeChunk((void *)descriptor, (void *)descriptor->physical_address, + sizeof(ohci_general_descriptor)); } status_t OHCI::_InsertEndpointForPipe(Pipe *p) { +#if 0 TRACE(("OHCI: Inserting Endpoint for device %u function %u\n", p->DeviceAddress(), p->EndpointAddress())); if (InitCheck()) return B_ERROR; - Endpoint *endpoint = _AllocateEndpoint(); + //Endpoint *endpoint = _AllocateEndpoint(); + ohci_endpoint_descriptor *endpoint = _AllocateEndpoint(); if (!endpoint) return B_NO_MEMORY; @@ -677,7 +771,7 @@ tail = tail->next; tail->SetNext(endpoint); } - +#endif return B_OK; } Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-14 01:28:47 UTC (rev 22926) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-14 13:37:41 UTC (rev 22927) @@ -18,13 +18,20 @@ struct pci_module_info; class OHCIRootHub; +typedef struct transfer_data_s { + Transfer *transfer; + bool incoming; + bool canceled; + transfer_data_s *link; +} transfer_data; + // -------------------------------------- // OHCI:: Software isonchronous // transfer descriptor // -------------------------------------- typedef struct hcd_soft_itransfer { - ohci_isochronous_transfer_descriptor itd; + ohci_isochronous_descriptor itd; struct hcd_soft_itransfer *nextitd; // mirrors nexttd in ITD struct hcd_soft_itransfer *dnext; // next in done list addr_t physaddr; // physical address to the host controller isonchronous transfer @@ -51,6 +58,7 @@ status_t Start(); virtual status_t SubmitTransfer(Transfer *transfer); virtual status_t CancelQueuedTransfers(Pipe *pipe); + status_t SubmitRequest(Transfer *transfer); virtual status_t NotifyPipeChange(Pipe *pipe, usb_change change); @@ -58,48 +66,73 @@ static status_t AddTo(Stack *stack); // Port operations + uint8 PortCount() { return fPortCount; }; status_t GetPortStatus(uint8 index, usb_port_status *status); status_t SetPortFeature(uint8 index, uint16 feature); status_t ClearPortFeature(uint8 index, uint16 feature); - uint8 PortCount() { return fNumPorts; }; + status_t ResetPort(uint8 index); + private: + // Interrupt functions +static int32 _InterruptHandler(void *data); + int32 _Interrupt(); + +static int32 _FinishThread(void *data); + void _FinishTransfer(); + + // Endpoint related methods + status_t _CreateEndpoint(Pipe *pipe, bool isIsochronous); + ohci_endpoint_descriptor *_AllocateEndpoint(); + void _FreeEndpoint( + ohci_endpoint_descriptor *endpoint); + status_t _InsertEndpointForPipe(Pipe *pipe); + + // Transfer descriptor related methods + ohci_general_descriptor *_CreateGeneralDescriptor(); + void _FreeGeneralDescriptor( + ohci_general_descriptor *descriptor); + ohci_isochronous_descriptor *_CreateIsochronousDescriptor(); + void _FreeIsochronousDescriptor( + ohci_isochronous_descriptor *descriptor); + // Register functions inline void _WriteReg(uint32 reg, uint32 value); inline uint32 _ReadReg(uint32 reg); - // Global static pci_module_info *sPCIModule; - - uint32 *fOperationalRegisters; pci_info *fPCIInfo; Stack *fStack; + uint32 *fOperationalRegisters; area_id fRegisterArea; + spinlock fSpinLock; + // Host Controller Communication Area related stuff area_id fHccaArea; - struct ohci_hcca *fHcca; - ohci_endpoint_descriptor *fInterruptEndpoints[OHCI_NUMBER_OF_ENDPOINTS]; + ohci_hcca *fHcca; + ohci_endpoint_descriptor **fInterruptEndpoints; // Dummy endpoints ohci_endpoint_descriptor *fDummyControl; ohci_endpoint_descriptor *fDummyBulk; ohci_endpoint_descriptor *fDummyIsochronous; - // Endpoint related methods - ohci_endpoint_descriptor *_AllocateEndpoint(); - void _FreeEndpoint(Endpoint *end); - TransferDescriptor *_AllocateTransfer(); - void _FreeTransfer(TransferDescriptor *trans); - status_t _InsertEndpointForPipe(Pipe *p); - void _SetNext(ohci_endpoint_descriptor *endpoint); + // Maintain a linked list of transfer + transfer_data *fFirstTransfer; + transfer_data *fFinishTransfer; + sem_id fFinishTransfersSem; + thread_id fFinishThread; + bool fStopFinishThread; // Root Hub OHCIRootHub *fRootHub; uint8 fRootHubAddress; - uint8 fNumPorts; + + // Port management + uint8 fPortCount; }; Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h 2007-11-14 01:28:47 UTC (rev 22926) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h 2007-11-14 13:37:41 UTC (rev 22927) @@ -265,26 +265,23 @@ #define OHCI_PERIODIC(i) ((i) * 9 / 10) // -------------------------------- -// OHCI physical address -// -------------------------------- - -typedef uint32 ohci_physaddr_t; - -// -------------------------------- // HCCA structure (section 4.4) +// 256 bytes aligned // -------------------------------- #define OHCI_NUMBER_OF_INTERRUPTS 32 typedef struct ohci_hcca { - uint32 hcca_interrupt_table[OHCI_NUMBER_OF_INTERRUPTS]; - uint16 hcca_frame_number; - uint32 hcca_done_head; - uint8 hcca_reserved_for_hc[116]; + uint32 interrupt_table[OHCI_NUMBER_OF_INTERRUPTS]; + uint32 current_frame_number; + uint32 done_head; + // The following is 120 instead of 116 because the spec + // only specifies 252 bytes + uint8 reserved_for_hc[120]; }; -#define OHCI_DONE_INTRS 1 +#define OHCI_DONE_INTERRUPTS 1 #define OHCI_HCCA_SIZE 256 #define OHCI_HCCA_ALIGN 256 #define OHCI_PAGE_SIZE 0x1000 @@ -303,7 +300,8 @@ uint32 head_physical_descriptor; // Queue head physical pointer uint32 next_physical_endpoint; // Physical pointer to the next endpoint // Software part - addr_t this_physical; // Physical pointer to this address + // TODO: What about type, state and interval (only interrupts) ? + addr_t physical_address; // Physical pointer to this address void *tail_logical_descriptor; // Queue tail logical pointer void *head_logical_descriptor; // Queue head logical pointer void *next_logical_endpoint; // Logical pointer to the next endpoint @@ -334,7 +332,7 @@ // General transfer descriptor structure (section 4.3.1) // -------------------------------- -typedef struct ohci_general_transfer_descriptor +typedef struct ohci_general_descriptor { // Hardware part uint32 flags; // Flags field @@ -342,7 +340,7 @@ uint32 next_physical_descriptor; // Physical pointer next descriptor uint32 last_physical_byte_address; // Physical pointer to buffer end // Software part - addr_t this_physical; // Physical pointer to this address + addr_t physical_address; // Physical pointer to this address void *buffer_logical; // Logical pointer to the buffer void *next_logical_descriptor; // Logical pointer next descriptor void *last_logical_byte_address; // Logical pointer buffer end @@ -372,7 +370,7 @@ // -------------------------------- #define OHCI_ITD_NOFFSET 8 -typedef struct ohci_isochronous_transfer_descriptor +typedef struct ohci_isochronous_descriptor { uint32 flags; uint32 buffer_page_byte_0; // Physical page number of byte 0 From marcusoverhagen at arcor.de Wed Nov 14 15:20:47 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Wed, 14 Nov 2007 15:20:47 +0100 (CET) Subject: [Haiku-commits] r22927 - haiku/trunk/src/add-ons/kernel/busses/usb In-Reply-To: <200711141337.lAEDbfnW013967@sheep.berlios.de> References: <200711141337.lAEDbfnW013967@sheep.berlios.de> Message-ID: <15400465.1195050047948.JavaMail.ngmail@webmail15> sbenedetto at BerliOS wrote: > + // The controller is now in SUSPEND state, we have 2ms to go OPERATIONAL. > + // In order to do so we need a spinlock > + > + cpu_status former = disable_interrupts(); > + acquire_spinlock(&fSpinLock); This makes no sense, the spinlock is used during init while interrupts are not used. What is it supposed to protect? > +int32 > +OHCI::_Interrupt() > +{ > + static spinlock lock = 0; > + acquire_spinlock(&lock); A static spinlock for the interrupt doesn't make much sense, either. It only prevents multiple ohci controllers to service interrupts at the same time. Spinlocks should be used to protect data structures or device register access where no concurrent access from interrupt and other threads is allowed, and access needs to be serialized. regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From stippi at mail.berlios.de Wed Nov 14 19:08:16 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 14 Nov 2007 19:08:16 +0100 Subject: [Haiku-commits] r22928 - haiku/trunk/src/add-ons/media/plugins/avcodec Message-ID: <200711141808.lAEI8G0w013963@sheep.berlios.de> Author: stippi Date: 2007-11-14 19:08:15 +0100 (Wed, 14 Nov 2007) New Revision: 22928 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22928&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/avcodec/avcodec.cpp Log: * print the codec id a little later when tracing is on, when the id is better knwon Modified: haiku/trunk/src/add-ons/media/plugins/avcodec/avcodec.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/avcodec/avcodec.cpp 2007-11-14 13:37:41 UTC (rev 22927) +++ haiku/trunk/src/add-ons/media/plugins/avcodec/avcodec.cpp 2007-11-14 18:08:15 UTC (rev 22928) @@ -124,10 +124,6 @@ if (BMediaFormats().GetCodeFor(*ioEncodedFormat, gCodecTable[i].family, &descr) == B_OK && gCodecTable[i].type == ioEncodedFormat->type) { - PRINT((" codec id = \"%c%c%c%c\"\n", (descr.u.avi.codec >> 24) & 0xff, - (descr.u.avi.codec >> 16) & 0xff, - (descr.u.avi.codec >> 8) & 0xff, - descr.u.avi.codec & 0xff)); switch(gCodecTable[i].family) { case B_WAV_FORMAT_FAMILY: cid = descr.u.wav.codec; @@ -151,6 +147,9 @@ puts("ERR family"); return B_ERROR; } + PRINT((" codec id = \"%c%c%c%c\"\n", (cid >> 24) & 0xff, + (cid >> 16) & 0xff, (cid >> 8) & 0xff, cid & 0xff)); + if (gCodecTable[i].family == descr.family && gCodecTable[i].fourcc == cid) { fCodec = avcodec_find_decoder(gCodecTable[i].id); if (!fCodec) { From mmlr at mail.berlios.de Wed Nov 14 23:11:06 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Wed, 14 Nov 2007 23:11:06 +0100 Subject: [Haiku-commits] r22929 - in haiku/trunk/src/add-ons/kernel: bus_managers/usb busses/usb Message-ID: <200711142211.lAEMB6Fv009884@sheep.berlios.de> Author: mmlr Date: 2007-11-14 23:11:05 +0100 (Wed, 14 Nov 2007) New Revision: 22929 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22929&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/BusManager.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h Log: Completely redesign the USB explore process. Replaces the scary race conditions of the previous locking mechanism and simplifies handling of device changes by a more centralized approach. Changes are now collected during explore and notifications as well as rescans are done at once. Through this a driver is also not rescanned multiple times anymore. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/BusManager.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/BusManager.cpp 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/BusManager.cpp 2007-11-14 22:11:05 UTC (rev 22929) @@ -269,7 +269,7 @@ status_t -BusManager::CancelQueuedTransfers(Pipe *pipe) +BusManager::CancelQueuedTransfers(Pipe *pipe, bool force) { // virtual function to be overridden return B_ERROR; Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp 2007-11-14 22:11:05 UTC (rev 22929) @@ -15,6 +15,7 @@ : Object(parent), fDeviceDescriptor(desc), fInitOK(false), + fAvailable(true), fConfigurations(NULL), fCurrentConfiguration(NULL), fSpeed(speed), @@ -253,9 +254,28 @@ status_t +Device::Changed(change_item **changeList, bool added) +{ + fAvailable = added; + change_item *changeItem = new(std::nothrow) change_item; + if (!changeItem) + return B_NO_MEMORY; + + changeItem->added = added; + changeItem->device = this; + changeItem->link = *changeList; + *changeList = changeItem; + return B_OK; +} + + +status_t Device::GetDescriptor(uint8 descriptorType, uint8 index, uint16 languageID, void *data, size_t dataLength, size_t *actualLength) { + if (!fAvailable) + return B_ERROR; + return fDefaultPipe->SendRequest( USB_REQTYPE_DEVICE_IN | USB_REQTYPE_STANDARD, // type USB_REQUEST_GET_DESCRIPTOR, // request @@ -304,6 +324,8 @@ status_t Device::SetConfigurationAt(uint8 index) { + if (!fAvailable) + return B_ERROR; if (index >= fDeviceDescriptor.num_configurations) return B_BAD_VALUE; if (&fConfigurations[index] == fCurrentConfiguration) @@ -382,7 +404,7 @@ // another configuration unconfigure will be called with // atDevice = false. otherwise we explicitly want to unconfigure // the device and have to send it the corresponding request. - if (atDeviceLevel) { + if (atDeviceLevel && fAvailable) { status_t result = fDefaultPipe->SendRequest( USB_REQTYPE_DEVICE_OUT | USB_REQTYPE_STANDARD, // type USB_REQUEST_SET_CONFIGURATION, // request @@ -426,7 +448,7 @@ status_t Device::ReportDevice(usb_support_descriptor *supportDescriptors, uint32 supportDescriptorCount, const usb_notify_hooks *hooks, - usb_driver_cookie **cookies, bool added) + usb_driver_cookie **cookies, bool added, bool recursive) { TRACE(("USB Device %d: reporting device\n", fDeviceAddress)); bool supported = false; @@ -526,6 +548,9 @@ status_t Device::SetFeature(uint16 selector) { + if (!fAvailable) + return B_ERROR; + return fDefaultPipe->SendRequest( USB_REQTYPE_STANDARD | USB_REQTYPE_DEVICE_OUT, USB_REQUEST_SET_FEATURE, @@ -541,6 +566,9 @@ status_t Device::ClearFeature(uint16 selector) { + if (!fAvailable) + return B_ERROR; + return fDefaultPipe->SendRequest( USB_REQTYPE_STANDARD | USB_REQTYPE_DEVICE_OUT, USB_REQUEST_CLEAR_FEATURE, @@ -556,6 +584,9 @@ status_t Device::GetStatus(uint16 *status) { + if (!fAvailable) + return B_ERROR; + return fDefaultPipe->SendRequest( USB_REQTYPE_STANDARD | USB_REQTYPE_DEVICE_IN, USB_REQUEST_GET_STATUS, Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp 2007-11-14 22:11:05 UTC (rev 22929) @@ -30,11 +30,6 @@ // Set to false again for the hub init. fInitOK = false; - if (benaphore_init(&fLock, "usb hub lock") < B_OK) { - TRACE_ERROR(("USB Hub %d: failed to create hub lock\n", DeviceAddress())); - return; - } - if (fDeviceDescriptor.device_class != 9) { TRACE_ERROR(("USB Hub %d: wrong class! bailing out\n", DeviceAddress())); return; @@ -97,36 +92,26 @@ Hub::~Hub() { - Lock(); - benaphore_destroy(&fLock); - - // Remove all child devices - for (int32 i = 0; i < fHubDescriptor.num_ports; i++) { - if (!fChildren[i]) - continue; - - TRACE(("USB Hub %d: removing device 0x%08lx\n", DeviceAddress(), fChildren[i])); - rescan_item *rescanList = NULL; - GetStack()->NotifyDeviceChange(fChildren[i], &rescanList, false); - GetBusManager()->FreeDevice(fChildren[i]); - GetStack()->RescanDrivers(rescanList); - } - delete fInterruptPipe; } -bool -Hub::Lock() +status_t +Hub::Changed(change_item **changeList, bool added) { - return (benaphore_lock(&fLock) == B_OK); -} + status_t result = Device::Changed(changeList, added); + if (added || result < B_OK) + return result; + for (int32 i = 0; i < fHubDescriptor.num_ports; i++) { + if (fChildren[i] == NULL) + continue; -void -Hub::Unlock() -{ - benaphore_unlock(&fLock); + fChildren[i]->Changed(changeList, false); + fChildren[i] = NULL; + } + + return B_OK; } @@ -189,7 +174,7 @@ void -Hub::Explore() +Hub::Explore(change_item **changeList) { for (int32 i = 0; i < fHubDescriptor.num_ports; i++) { status_t result = UpdatePortStatus(i); @@ -209,7 +194,6 @@ USB_REQUEST_CLEAR_FEATURE, C_PORT_CONNECTION, i + 1, 0, NULL, 0, NULL); - rescan_item *rescanList = NULL; if (fPortStatus[i].status & PORT_STATUS_CONNECTION) { // new device attached! TRACE(("USB Hub %d: new device connected\n", DeviceAddress())); @@ -234,18 +218,8 @@ if (fChildren[i]) { TRACE_ERROR(("USB Hub %d: new device on a port that is already in use\n", DeviceAddress())); - - // Remove previous device first - TRACE(("USB Hub %d: removing device 0x%08lx\n", DeviceAddress(), fChildren[i])); - GetStack()->NotifyDeviceChange(fChildren[i], &rescanList, false); - - if (Lock()) { - GetBusManager()->FreeDevice(fChildren[i]); - fChildren[i] = NULL; - Unlock(); - } - - GetStack()->RescanDrivers(rescanList); + fChildren[i]->Changed(changeList, false); + fChildren[i] = NULL; } usb_speed speed = USB_SPEED_FULLSPEED; @@ -256,15 +230,10 @@ Device *newDevice = GetBusManager()->AllocateDevice(this, speed); - if (newDevice && Lock()) { + if (newDevice) { + newDevice->Changed(changeList, true); fChildren[i] = newDevice; - Unlock(); - GetStack()->NotifyDeviceChange(fChildren[i], &rescanList, true); - GetStack()->RescanDrivers(rescanList); } else { - if (newDevice) - GetBusManager()->FreeDevice(newDevice); - // the device failed to setup correctly, disable the port // so that the device doesn't get in the way of future // addressing. @@ -277,15 +246,8 @@ TRACE(("USB Hub %d: device removed\n", DeviceAddress())); if (fChildren[i]) { TRACE(("USB Hub %d: removing device 0x%08lx\n", DeviceAddress(), fChildren[i])); - GetStack()->NotifyDeviceChange(fChildren[i], &rescanList, false); - - if (Lock()) { - GetBusManager()->FreeDevice(fChildren[i]); - fChildren[i] = NULL; - Unlock(); - } - - GetStack()->RescanDrivers(rescanList); + fChildren[i]->Changed(changeList, false); + fChildren[i] = NULL; } } } @@ -325,7 +287,7 @@ if (!fChildren[i] || (fChildren[i]->Type() & USB_OBJECT_HUB) == 0) continue; - ((Hub *)fChildren[i])->Explore(); + ((Hub *)fChildren[i])->Explore(changeList); } } @@ -357,28 +319,26 @@ status_t Hub::ReportDevice(usb_support_descriptor *supportDescriptors, uint32 supportDescriptorCount, const usb_notify_hooks *hooks, - usb_driver_cookie **cookies, bool added) + usb_driver_cookie **cookies, bool added, bool recursive) { TRACE(("USB Hub %d: reporting hub\n", DeviceAddress())); // Report ourselfs first status_t result = Device::ReportDevice(supportDescriptors, - supportDescriptorCount, hooks, cookies, added); + supportDescriptorCount, hooks, cookies, added, recursive); - // Then report all of our children - if (!Lock()) - return B_ERROR; + if (!recursive) + return result; for (int32 i = 0; i < fHubDescriptor.num_ports; i++) { if (!fChildren[i]) continue; if (fChildren[i]->ReportDevice(supportDescriptors, - supportDescriptorCount, hooks, cookies, added) == B_OK) + supportDescriptorCount, hooks, cookies, added, true) == B_OK) result = B_OK; } - Unlock(); return result; } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp 2007-11-14 22:11:05 UTC (rev 22929) @@ -26,7 +26,7 @@ Pipe::~Pipe() { - CancelQueuedTransfers(); + CancelQueuedTransfers(true); GetBusManager()->NotifyPipeChange(this, USB_CHANGE_DESTROYED); } @@ -40,9 +40,9 @@ status_t -Pipe::CancelQueuedTransfers() +Pipe::CancelQueuedTransfers(bool force) { - return GetBusManager()->CancelQueuedTransfers(this); + return GetBusManager()->CancelQueuedTransfers(this, force); } @@ -309,7 +309,7 @@ if (actualLength) *actualLength = 0; - CancelQueuedTransfers(); + CancelQueuedTransfers(false); return B_TIMED_OUT; } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp 2007-11-14 22:11:05 UTC (rev 22929) @@ -28,11 +28,16 @@ { TRACE(("USB Stack: stack init\n")); - if (benaphore_init(&fLock, "usb stack lock") < B_OK) { - TRACE_ERROR(("USB Stack: failed to create benaphore lock\n")); + if (benaphore_init(&fStackLock, "usb stack lock") < B_OK) { + TRACE_ERROR(("USB Stack: failed to create stack lock\n")); return; } + if (benaphore_init(&fExploreLock, "usb explore lock") < B_OK) { + TRACE_ERROR(("USB Stack: failed to create explore lock\n")); + return; + } + size_t objectArraySize = fObjectMaxCount * sizeof(Object *); fObjectArray = (Object **)malloc(objectArraySize); memset(fObjectArray, 0, objectArraySize); @@ -85,8 +90,10 @@ fStopThreads = true; wait_for_thread(fExploreThread, &result); - Lock(); - benaphore_destroy(&fLock); + benaphore_lock(&fStackLock); + benaphore_destroy(&fStackLock); + benaphore_lock(&fExploreLock); + benaphore_destroy(&fExploreLock); //Release the bus modules for (Vector::Iterator i = fBusManagers.Begin(); @@ -111,14 +118,14 @@ bool Stack::Lock() { - return (benaphore_lock(&fLock) == B_OK); + return (benaphore_lock(&fStackLock) == B_OK); } void Stack::Unlock() { - benaphore_unlock(&fLock); + benaphore_unlock(&fStackLock); } @@ -189,13 +196,33 @@ Stack *stack = (Stack *)data; while (!stack->fStopThreads) { + if (benaphore_lock(&stack->fExploreLock) != B_OK) + break; + + rescan_item *rescanList = NULL; + change_item *changeItem = NULL; for (int32 i = 0; i < stack->fBusManagers.Count(); i++) { Hub *rootHub = stack->fBusManagers.ElementAt(i)->GetRootHub(); if (rootHub) - rootHub->Explore(); + rootHub->Explore(&changeItem); } + while (changeItem) { + stack->NotifyDeviceChange(changeItem->device, &rescanList, changeItem->added); + if (!changeItem->added) { + // everyone possibly holding a reference is now notified so we + // can delete the device + changeItem->device->GetBusManager()->FreeDevice(changeItem->device); + } + + change_item *next = changeItem->link; + delete changeItem; + changeItem = next; + } + stack->fFirstExploreDone = true; + benaphore_unlock(&stack->fExploreLock); + stack->RescanDrivers(rescanList); snooze(USB_DELAY_HUB_EXPLORE); } @@ -277,19 +304,33 @@ while (element) { status_t result = device->ReportDevice(element->support_descriptors, element->support_descriptor_count, &element->notify_hooks, - &element->cookies, added); + &element->cookies, added, false); if (result >= B_OK) { - rescan_item *item = new(std::nothrow) rescan_item; - if (!item) - return; - - item->name = element->driver_name; + const char *driverName = element->driver_name; if (element->republish_driver_name) - item->name = element->republish_driver_name; + driverName = element->republish_driver_name; - item->link = *rescanList; - *rescanList = item; + bool already = false; + rescan_item *rescanItem = *rescanList; + while (rescanItem) { + if (strcmp(rescanItem->name, driverName) == 0) { + // this driver is going to be rescanned already + already = true; + break; + } + rescanItem = rescanItem->link; + } + + if (!already) { + rescanItem = new(std::nothrow) rescan_item; + if (!rescanItem) + return; + + rescanItem->name = driverName; + rescanItem->link = *rescanList; + *rescanList = rescanItem; + } } element = element->link; @@ -403,6 +444,9 @@ usb_driver_info *element = fDriverList; while (element) { if (strcmp(element->driver_name, driverName) == 0) { + if (benaphore_lock(&fExploreLock) != B_OK) + return B_ERROR; + // inform driver about any already present devices for (int32 i = 0; i < fBusManagers.Count(); i++) { Hub *rootHub = fBusManagers.ElementAt(i)->GetRootHub(); @@ -410,12 +454,13 @@ // Report device will recurse down the whole tree rootHub->ReportDevice(element->support_descriptors, element->support_descriptor_count, hooks, - &element->cookies, true); + &element->cookies, true, true); } } element->notify_hooks.device_added = hooks->device_added; element->notify_hooks.device_removed = hooks->device_removed; + benaphore_unlock(&fExploreLock); return B_OK; } @@ -434,17 +479,21 @@ usb_driver_info *element = fDriverList; while (element) { if (strcmp(element->driver_name, driverName) == 0) { + if (benaphore_lock(&fExploreLock) != B_OK) + return B_ERROR; + // trigger the device removed hook for (int32 i = 0; i < fBusManagers.Count(); i++) { Hub *rootHub = fBusManagers.ElementAt(i)->GetRootHub(); if (rootHub) rootHub->ReportDevice(element->support_descriptors, element->support_descriptor_count, - &element->notify_hooks, &element->cookies, false); + &element->notify_hooks, &element->cookies, false, true); } element->notify_hooks.device_added = NULL; element->notify_hooks.device_removed = NULL; + benaphore_unlock(&fExploreLock); return B_OK; } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb.cpp 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb.cpp 2007-11-14 22:11:05 UTC (rev 22929) @@ -318,7 +318,7 @@ if (!object || (object->Type() & USB_OBJECT_PIPE) == 0) return B_DEV_INVALID_PIPE; - return ((Pipe *)object)->CancelQueuedTransfers(); + return ((Pipe *)object)->CancelQueuedTransfers(false); } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h 2007-11-14 22:11:05 UTC (rev 22929) @@ -60,6 +60,13 @@ }; +struct change_item { + bool added; + Device *device; + change_item *link; +}; + + struct rescan_item { const char *name; rescan_item *link; @@ -141,7 +148,8 @@ bool fFirstExploreDone; bool fStopThreads; - benaphore fLock; + benaphore fStackLock; + benaphore fExploreLock; PhysicalMemoryAllocator *fAllocator; uint32 fObjectIndex; @@ -178,7 +186,8 @@ virtual status_t Stop(); virtual status_t SubmitTransfer(Transfer *transfer); -virtual status_t CancelQueuedTransfers(Pipe *pipe); +virtual status_t CancelQueuedTransfers(Pipe *pipe, + bool force); virtual status_t NotifyPipeChange(Pipe *pipe, usb_change change); @@ -260,7 +269,7 @@ virtual void SetDataToggle(bool toggle) { fDataToggle = toggle; }; status_t SubmitTransfer(Transfer *transfer); - status_t CancelQueuedTransfers(); + status_t CancelQueuedTransfers(bool force); // Convenience functions for standard requests virtual status_t SetFeature(uint16 selector); @@ -414,6 +423,9 @@ status_t InitCheck(); +virtual status_t Changed(change_item **changeList, + bool added); + virtual uint32 Type() { return USB_OBJECT_DEVICE; }; ControlPipe *DefaultPipe() { return fDefaultPipe; }; @@ -437,7 +449,7 @@ uint32 supportDescriptorCount, const usb_notify_hooks *hooks, usb_driver_cookie **cookies, - bool added); + bool added, bool recursive); virtual status_t BuildDeviceName(char *string, uint32 *index, size_t bufferSize, Device *device); @@ -452,6 +464,7 @@ bool fInitOK; private: + bool fAvailable; usb_configuration_info *fConfigurations; usb_configuration_info *fCurrentConfiguration; usb_speed fSpeed; @@ -468,8 +481,8 @@ usb_speed speed); virtual ~Hub(); - bool Lock(); - void Unlock(); +virtual status_t Changed(change_item **changeList, + bool added); virtual uint32 Type() { return USB_OBJECT_DEVICE | USB_OBJECT_HUB; }; @@ -480,7 +493,7 @@ status_t UpdatePortStatus(uint8 index); status_t ResetPort(uint8 index); - void Explore(); + void Explore(change_item **changeList); static void InterruptCallback(void *cookie, status_t status, void *data, size_t actualLength); @@ -490,14 +503,12 @@ uint32 supportDescriptorCount, const usb_notify_hooks *hooks, usb_driver_cookie **cookies, - bool added); + bool added, bool recursive); virtual status_t BuildDeviceName(char *string, uint32 *index, size_t bufferSize, Device *device); private: - benaphore fLock; - InterruptPipe *fInterruptPipe; usb_hub_descriptor fHubDescriptor; Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-14 22:11:05 UTC (rev 22929) @@ -864,7 +864,7 @@ status_t -EHCI::CancelQueuedTransfers(Pipe *pipe) +EHCI::CancelQueuedTransfers(Pipe *pipe, bool force) { if (!Lock()) return B_ERROR; @@ -879,7 +879,13 @@ descriptor = (ehci_qtd *)descriptor->next_log; } - current->transfer->Finished(B_CANCELED, 0); + if (!force) { + // if the transfer is canceled by force, the one causing the + // cancel is probably not the one who initiated the transfer + // and the callback is likely not safe anymore + current->transfer->Finished(B_CANCELED, 0); + } + current->canceled = true; } Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h 2007-11-14 22:11:05 UTC (rev 22929) @@ -37,7 +37,7 @@ virtual status_t SubmitTransfer(Transfer *transfer); status_t SubmitPeriodicTransfer(Transfer *transfer); status_t SubmitAsyncTransfer(Transfer *transfer); -virtual status_t CancelQueuedTransfers(Pipe *pipe); +virtual status_t CancelQueuedTransfers(Pipe *pipe, bool force); virtual status_t NotifyPipeChange(Pipe *pipe, usb_change change); Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-14 22:11:05 UTC (rev 22929) @@ -791,7 +791,7 @@ status_t -OHCI::CancelQueuedTransfers(Pipe *pipe) +OHCI::CancelQueuedTransfers(Pipe *pipe, bool force) { return B_ERROR; } Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-14 22:11:05 UTC (rev 22929) @@ -57,7 +57,8 @@ status_t Start(); virtual status_t SubmitTransfer(Transfer *transfer); -virtual status_t CancelQueuedTransfers(Pipe *pipe); +virtual status_t CancelQueuedTransfers(Pipe *pipe, + bool force); status_t SubmitRequest(Transfer *transfer); virtual status_t NotifyPipeChange(Pipe *pipe, Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp 2007-11-14 22:11:05 UTC (rev 22929) @@ -603,7 +603,7 @@ status_t -UHCI::CancelQueuedTransfers(Pipe *pipe) +UHCI::CancelQueuedTransfers(Pipe *pipe, bool force) { if (pipe->Type() & USB_OBJECT_ISO_PIPE) return CancelQueuedIsochronousTransfers(pipe); @@ -621,7 +621,13 @@ descriptor = (uhci_td *)descriptor->link_log; } - current->transfer->Finished(B_CANCELED, 0); + if (!force) { + // if the transfer is canceled by force, the one causing the + // cancel is probably not the one who initiated the transfer + // and the callback is likely not safe anymore + current->transfer->Finished(B_CANCELED, 0); + } + current->canceled = true; } current = current->link; Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h 2007-11-14 18:08:15 UTC (rev 22928) +++ haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h 2007-11-14 22:11:05 UTC (rev 22929) @@ -91,7 +91,7 @@ status_t Start(); virtual status_t SubmitTransfer(Transfer *transfer); -virtual status_t CancelQueuedTransfers(Pipe *pipe); +virtual status_t CancelQueuedTransfers(Pipe *pipe, bool force); status_t CancelQueuedIsochronousTransfers(Pipe *pipe); status_t SubmitRequest(Transfer *transfer); status_t SubmitIsochronous(Transfer *transfer); From emitrax at gmail.com Thu Nov 15 11:54:07 2007 From: emitrax at gmail.com (Salvatore Benedetto) Date: Thu, 15 Nov 2007 10:54:07 +0000 Subject: [Haiku-commits] r22927 - haiku/trunk/src/add-ons/kernel/busses/usb In-Reply-To: <15400465.1195050047948.JavaMail.ngmail@webmail15> References: <200711141337.lAEDbfnW013967@sheep.berlios.de> <15400465.1195050047948.JavaMail.ngmail@webmail15> Message-ID: On Nov 14, 2007 2:20 PM, Marcus Overhagen wrote: > sbenedetto at BerliOS wrote: > > > + cpu_status former = disable_interrupts(); > > + acquire_spinlock(&fSpinLock); > > This makes no sense, the spinlock is used during init while > interrupts are not used. What is it supposed to protect? You're right, disabling interrupts to ensure that the code gets executed in 2ms should be enough. I "trusted" too much someone else code :) I'll fix this in the next commit. > > +int32 > > +OHCI::_Interrupt() > > +{ > > + static spinlock lock = 0; > > + acquire_spinlock(&lock); > > A static spinlock for the interrupt doesn't make much sense, either. > It only prevents multiple ohci controllers to service interrupts at the same time. To be honest, I just copied & pasted this from EHCI/UHCI code without worrying too much. I've asked Michael about it, and if I understood correctly it is used in order to avoid that different CPUs handle different interrupts of the same controller (if that's ever possible), so that they don't write to the device registers at the same time. > > Spinlocks should be used to protect data structures or device register > access where no concurrent access from interrupt and other threads > is allowed, and access needs to be serialized. > > regards > Marcus > Thanks, Salvo -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer and Telecommunications Engineering University of Messina (Italy) www.messinalug.org Please do not send me any word, excel or power point file http://www.gnu.org/philosophy/no-word-attachments.html From axeld at mail.berlios.de Thu Nov 15 16:06:51 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 15 Nov 2007 16:06:51 +0100 Subject: [Haiku-commits] r22930 - haiku/trunk/src/kits/interface Message-ID: <200711151506.lAFF6p9L001310@sheep.berlios.de> Author: axeld Date: 2007-11-15 16:06:51 +0100 (Thu, 15 Nov 2007) New Revision: 22930 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22930&view=rev Modified: haiku/trunk/src/kits/interface/View.cpp Log: Added Flush() to SetMouseEventMask(); this should definitely be sent immediately. Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2007-11-14 22:11:05 UTC (rev 22929) +++ haiku/trunk/src/kits/interface/View.cpp 2007-11-15 15:06:51 UTC (rev 22930) @@ -1626,6 +1626,7 @@ fOwner->fLink->StartMessage(AS_LAYER_SET_MOUSE_EVENT_MASK); fOwner->fLink->Attach(mask); fOwner->fLink->Attach(options); + fOwner->fLink->Flush(); return B_OK; } From stefano.ceccherini at gmail.com Thu Nov 15 16:13:16 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 15 Nov 2007 16:13:16 +0100 Subject: [Haiku-commits] r22930 - haiku/trunk/src/kits/interface In-Reply-To: <200711151506.lAFF6p9L001310@sheep.berlios.de> References: <200711151506.lAFF6p9L001310@sheep.berlios.de> Message-ID: <894b9700711150713n223772d2k27849ff863199487@mail.gmail.com> 2007/11/15, axeld at BerliOS : > Author: axeld > Date: 2007-11-15 16:06:51 +0100 (Thu, 15 Nov 2007) > New Revision: 22930 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22930&view=rev > > Modified: > haiku/trunk/src/kits/interface/View.cpp > Log: > Added Flush() to SetMouseEventMask(); this should definitely be sent immediately. > Thanks :) From mmlr at mail.berlios.de Thu Nov 15 21:17:18 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Thu, 15 Nov 2007 21:17:18 +0100 Subject: [Haiku-commits] r22931 - haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <200711152017.lAFKHIbj007993@sheep.berlios.de> Author: mmlr Date: 2007-11-15 21:17:18 +0100 (Thu, 15 Nov 2007) New Revision: 22931 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22931&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h Log: Add a small cookie function to the Pipe. This can be used by the controller to store internal data related to a specific transfer pipe. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h 2007-11-15 15:06:51 UTC (rev 22930) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h 2007-11-15 20:17:18 UTC (rev 22931) @@ -271,6 +271,9 @@ status_t SubmitTransfer(Transfer *transfer); status_t CancelQueuedTransfers(bool force); + void SetControllerCookie(void *cookie) { fControllerCookie = cookie; }; + void *ControllerCookie() { return fControllerCookie; }; + // Convenience functions for standard requests virtual status_t SetFeature(uint16 selector); virtual status_t ClearFeature(uint16 selector); @@ -283,6 +286,7 @@ usb_speed fSpeed; size_t fMaxPacketSize; bool fDataToggle; + void *fControllerCookie; }; From sbenedetto at mail.berlios.de Thu Nov 15 22:25:17 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Thu, 15 Nov 2007 22:25:17 +0100 Subject: [Haiku-commits] r22932 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711152125.lAFLPH3Q012955@sheep.berlios.de> Author: sbenedetto Date: 2007-11-15 22:25:16 +0100 (Thu, 15 Nov 2007) New Revision: 22932 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22932&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h Log: * Completed SubmitTransfer * Added SubmitAsyncTransfer and SubmitPeriodicTransfer (not implemented) * Removed unecessary spinlock * Wrapped some lines to follow coding guidelines Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-15 20:17:18 UTC (rev 22931) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-15 21:25:16 UTC (rev 22932) @@ -66,7 +66,6 @@ fPCIInfo(info), fStack(stack), fRegisterArea(-1), - fSpinLock(0), fHccaArea(-1), fDummyControl(NULL), fDummyBulk(NULL), @@ -264,10 +263,9 @@ } // The controller is now in SUSPEND state, we have 2ms to go OPERATIONAL. - // In order to do so we need a spinlock + // In order to do so we need to disable interrupts. cpu_status former = disable_interrupts(); - acquire_spinlock(&fSpinLock); // Set up host controller register _WriteReg(OHCI_HCCA, (uint32)hccaPhysicalAddress); @@ -286,7 +284,6 @@ // And finally start the controller _WriteReg(OHCI_CONTROL, control); - release_spinlock(&fSpinLock); restore_interrupts(former); // The controller is now OPERATIONAL. @@ -429,11 +426,38 @@ if (transfer->TransferPipe()->DeviceAddress() == fRootHubAddress) return fRootHub->ProcessTransfer(this, transfer); + uint32 type = transfer->TransferPipe()->Type(); + if ((type & USB_OBJECT_CONTROL_PIPE) || (type & USB_OBJECT_BULK_PIPE)) { + TRACE(("usb_ohci: submitting async transfer\n")); + return _SubmitAsyncTransfer(transfer); + } + + if ((type & USB_OBJECT_INTERRUPT_PIPE) || (type & USB_OBJECT_ISO_PIPE)) { + TRACE(("usb_ohci: submitting periodic transfer\n")); + return _SubmitPeriodicTransfer(transfer); + } + + TRACE_ERROR(("usb_ohci: tried to submit transfer for unknow pipe" + " type %lu\n", type)); return B_ERROR; } status_t +OHCI::_SubmitAsyncTransfer(Transfer *transfer) +{ + return B_ERROR; +} + + +status_t +OHCI::_SubmitPeriodicTransfer(Transfer *transfer) +{ + return B_ERROR; +} + + +status_t OHCI::NotifyPipeChange(Pipe *pipe, usb_change change) { TRACE(("usb_ohci::%s(%p, %d)\n", __FUNCTION__, pipe, (int)change)); Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-15 20:17:18 UTC (rev 22931) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-15 21:25:16 UTC (rev 22932) @@ -59,7 +59,6 @@ virtual status_t SubmitTransfer(Transfer *transfer); virtual status_t CancelQueuedTransfers(Pipe *pipe, bool force); - status_t SubmitRequest(Transfer *transfer); virtual status_t NotifyPipeChange(Pipe *pipe, usb_change change); @@ -68,7 +67,8 @@ // Port operations uint8 PortCount() { return fPortCount; }; - status_t GetPortStatus(uint8 index, usb_port_status *status); + status_t GetPortStatus(uint8 index, + usb_port_status *status); status_t SetPortFeature(uint8 index, uint16 feature); status_t ClearPortFeature(uint8 index, uint16 feature); @@ -82,9 +82,13 @@ static int32 _FinishThread(void *data); void _FinishTransfer(); + + status_t _SubmitAsyncTransfer(Transfer *transfer); + status_t _SubmitPeriodicTransfer(Transfer *transfer); // Endpoint related methods - status_t _CreateEndpoint(Pipe *pipe, bool isIsochronous); + status_t _CreateEndpoint(Pipe *pipe, + bool isIsochronous); ohci_endpoint_descriptor *_AllocateEndpoint(); void _FreeEndpoint( ohci_endpoint_descriptor *endpoint); @@ -109,8 +113,6 @@ uint32 *fOperationalRegisters; area_id fRegisterArea; - spinlock fSpinLock; - // Host Controller Communication Area related stuff area_id fHccaArea; ohci_hcca *fHcca; From axeld at pinc-software.de Thu Nov 15 22:41:24 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 15 Nov 2007 22:41:24 +0100 CET Subject: [Haiku-commits] r22932 - haiku/trunk/src/add-ons/kernel/busses/usb In-Reply-To: <200711152125.lAFLPH3Q012955@sheep.berlios.de> Message-ID: <25291594225-BeMail@zon> sbenedetto at BerliOS wrote: > // The controller is now in SUSPEND state, we have 2ms to go > OPERATIONAL. > - // In order to do so we need a spinlock > + // In order to do so we need to disable interrupts. > > cpu_status former = disable_interrupts(); That doesn't really look right: at least the scheduler could kick in right before disabling interrupts, so the suspend state shouldn't be set before the comment (just looking at the commit, so I don't know if the comment led me the wrong way here). Bye, Axel. From mmu_man at mail.berlios.de Thu Nov 15 23:59:36 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 15 Nov 2007 23:59:36 +0100 Subject: [Haiku-commits] r22933 - haiku/trunk/src/system/libroot/os/arch/m68k Message-ID: <200711152259.lAFMxalJ021072@sheep.berlios.de> Author: mmu_man Date: 2007-11-15 23:59:35 +0100 (Thu, 15 Nov 2007) New Revision: 22933 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22933&view=rev Modified: haiku/trunk/src/system/libroot/os/arch/m68k/syscalls.inc Log: Add macros for syscalls with 11 to 13 args. Modified: haiku/trunk/src/system/libroot/os/arch/m68k/syscalls.inc =================================================================== --- haiku/trunk/src/system/libroot/os/arch/m68k/syscalls.inc 2007-11-15 21:25:16 UTC (rev 22932) +++ haiku/trunk/src/system/libroot/os/arch/m68k/syscalls.inc 2007-11-15 22:59:35 UTC (rev 22933) @@ -74,3 +74,21 @@ trap #0 ; \ rts +#define SYSCALL11(name, n) \ +FUNC(name) \ + move.l IMM n,%d0 ; \ + trap #0 ; \ + rts + +#define SYSCALL12(name, n) \ +FUNC(name) \ + move.l IMM n,%d0 ; \ + trap #0 ; \ + rts + +#define SYSCALL13(name, n) \ +FUNC(name) \ + move.l IMM n,%d0 ; \ + trap #0 ; \ + rts + From emitrax at gmail.com Fri Nov 16 11:05:12 2007 From: emitrax at gmail.com (Salvatore Benedetto) Date: Fri, 16 Nov 2007 10:05:12 +0000 Subject: [Haiku-commits] r22932 - haiku/trunk/src/add-ons/kernel/busses/usb In-Reply-To: <25291594225-BeMail@zon> References: <200711152125.lAFLPH3Q012955@sheep.berlios.de> <25291594225-BeMail@zon> Message-ID: On Nov 15, 2007 9:41 PM, Axel D?rfler wrote: > sbenedetto at BerliOS wrote: > > // The controller is now in SUSPEND state, we have 2ms to go > > OPERATIONAL. > > - // In order to do so we need a spinlock > > + // In order to do so we need to disable interrupts. > > > > cpu_status former = disable_interrupts(); > > That doesn't really look right: at least the scheduler could kick in > right before disabling interrupts, so the suspend state shouldn't be > set before the comment (just looking at the commit, so I don't know if > the comment led me the wrong way here). Yes, I should disable interrupts right before I reset, no after. > > Bye, > Axel. > Thanks, Salvo -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer and Telecommunications Engineering University of Messina (Italy) www.messinalug.org Please do not send me any word, excel or power point file http://www.gnu.org/philosophy/no-word-attachments.html From sbenedetto at mail.berlios.de Fri Nov 16 11:11:02 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Fri, 16 Nov 2007 11:11:02 +0100 Subject: [Haiku-commits] r22934 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711161011.lAGAB2sA005427@sheep.berlios.de> Author: sbenedetto Date: 2007-11-16 11:11:02 +0100 (Fri, 16 Nov 2007) New Revision: 22934 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22934&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h Log: * Moved disable_interrupt right before resetting the controller * Reworked on NotifyPipeChange * Added _RemoveEndpointForPipe (not implemented) Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-15 22:59:35 UTC (rev 22933) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-16 10:11:02 UTC (rev 22934) @@ -249,8 +249,10 @@ // We now own the host controller and the bus has been reset uint32 frameInterval = _ReadReg(OHCI_FRAME_INTERVAL); uint32 intervalValue = OHCI_GET_INTERVAL_VALUE(frameInterval); + + // Disable interrupts right before we reset + cpu_status former = disable_interrupts(); _WriteReg(OHCI_COMMAND_STATUS, OHCI_HOST_CONTROLLER_RESET); - for (uint32 i = 0; i < 10; i++) { snooze(10); if (!(_ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET)) @@ -259,14 +261,13 @@ if (_ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET) { TRACE_ERROR(("usb_ohci: Error resetting the host controller (timeout)\n")); + restore_interrupts(former); return; } // The controller is now in SUSPEND state, we have 2ms to go OPERATIONAL. - // In order to do so we need to disable interrupts. + // Interrupts are disabled. - cpu_status former = disable_interrupts(); - // Set up host controller register _WriteReg(OHCI_HCCA, (uint32)hccaPhysicalAddress); _WriteReg(OHCI_CONTROL_HEAD_ED, (uint32)fDummyControl->physical_address); @@ -437,7 +438,7 @@ return _SubmitPeriodicTransfer(transfer); } - TRACE_ERROR(("usb_ohci: tried to submit transfer for unknow pipe" + TRACE_ERROR(("usb_ohci: tried to submit transfer for unknown pipe" " type %lu\n", type)); return B_ERROR; } @@ -460,21 +461,26 @@ status_t OHCI::NotifyPipeChange(Pipe *pipe, usb_change change) { - TRACE(("usb_ohci::%s(%p, %d)\n", __FUNCTION__, pipe, (int)change)); - if (InitCheck()) - return B_ERROR; - + TRACE(("usb_ohci: pipe change %d for pipe 0x%08lx\n", change, (uint32)pipe)); switch (change) { - case USB_CHANGE_CREATED: - return _InsertEndpointForPipe(pipe); - case USB_CHANGE_DESTROYED: - // Do something - return B_ERROR; - case USB_CHANGE_PIPE_POLICY_CHANGED: - default: - break; + case USB_CHANGE_CREATED: { + TRACE(("usb_ohci: inserting endpoint\n")); + return _InsertEndpointForPipe(pipe); + } + case USB_CHANGE_DESTROYED: { + TRACE(("usb_ohci: removing endpoint\n")); + return _RemoveEndpointForPipe(pipe); + } + case USB_CHANGE_PIPE_POLICY_CHANGED: { + TRACE(("usb_ohci: pipe policy changing unhandled!\n")); + break; + } + default: { + TRACE_ERROR(("usb_ohci: unknown pipe change!\n")); + return B_ERROR; + } } - return B_ERROR; //We should never go here + return B_OK; } @@ -706,7 +712,7 @@ status_t -OHCI::_InsertEndpointForPipe(Pipe *p) +OHCI::_InsertEndpointForPipe(Pipe *pipe) { #if 0 TRACE(("OHCI: Inserting Endpoint for device %u function %u\n", p->DeviceAddress(), p->EndpointAddress())); @@ -800,6 +806,13 @@ } +status_t +OHCI::_RemoveEndpointForPipe(Pipe *pipe) +{ + return B_ERROR; +} + + inline void OHCI::_WriteReg(uint32 reg, uint32 value) { Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-15 22:59:35 UTC (rev 22933) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-16 10:11:02 UTC (rev 22934) @@ -85,14 +85,15 @@ status_t _SubmitAsyncTransfer(Transfer *transfer); status_t _SubmitPeriodicTransfer(Transfer *transfer); - + // Endpoint related methods + status_t _InsertEndpointForPipe(Pipe *pipe); + status_t _RemoveEndpointForPipe(Pipe *pipe); status_t _CreateEndpoint(Pipe *pipe, bool isIsochronous); ohci_endpoint_descriptor *_AllocateEndpoint(); void _FreeEndpoint( ohci_endpoint_descriptor *endpoint); - status_t _InsertEndpointForPipe(Pipe *pipe); // Transfer descriptor related methods ohci_general_descriptor *_CreateGeneralDescriptor(); From axeld at pinc-software.de Fri Nov 16 11:29:10 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 16 Nov 2007 11:29:10 +0100 CET Subject: [Haiku-commits] r22934 - haiku/trunk/src/add-ons/kernel/busses/usb In-Reply-To: <200711161011.lAGAB2sA005427@sheep.berlios.de> Message-ID: <9250817542-BeMail@zon> sbenedetto at BerliOS wrote: > + // Disable interrupts right before we reset > + cpu_status former = disable_interrupts(); > _WriteReg(OHCI_COMMAND_STATUS, OHCI_HOST_CONTROLLER_RESET); > - > for (uint32 i = 0; i < 10; i++) { > snooze(10); Sorry for not having had a look earlier, but you shouldn't have used snooze() here before, and you cannot use it anymore now that you've disabled interrupts. snooze() is waiting on a semaphore (which you must not do when interrupts are disabled), but it's also not adequate for short waits, because its overhead is larger. So busy waiting would be preferrable here (using spin()). An alternative to disabling interrupts would be to temporarily bump your thread's priority to real time priority - if you need some more time (100 usec are probably still acceptable, though), it would at least make sure that other interrupts can still fire (which should be handled in less time than 2ms, anyway :-)). BTW, we still have 2007 over here :-) Bye, Axel. From emitrax at gmail.com Fri Nov 16 11:58:29 2007 From: emitrax at gmail.com (Salvatore Benedetto) Date: Fri, 16 Nov 2007 10:58:29 +0000 Subject: [Haiku-commits] r22934 - haiku/trunk/src/add-ons/kernel/busses/usb In-Reply-To: <9250817542-BeMail@zon> References: <200711161011.lAGAB2sA005427@sheep.berlios.de> <9250817542-BeMail@zon> Message-ID: On Nov 16, 2007 10:29 AM, Axel D?rfler wrote: > sbenedetto at BerliOS wrote: > > + // Disable interrupts right before we reset > > + cpu_status former = disable_interrupts(); > > _WriteReg(OHCI_COMMAND_STATUS, OHCI_HOST_CONTROLLER_RESET); > > - > > for (uint32 i = 0; i < 10; i++) { > > snooze(10); > > Sorry for not having had a look earlier, but you shouldn't have used > snooze() here before, and you cannot use it anymore now that you've > disabled interrupts. > snooze() is waiting on a semaphore (which you must not do when > interrupts are disabled), but it's also not adequate for short waits, > because its overhead is larger. So busy waiting would be preferrable > here (using spin()). So substituting snooze with spin should be enough? > An alternative to disabling interrupts would be to temporarily bump > your thread's priority to real time priority - if you need some more > time (100 usec are probably still acceptable, though), it would at > least make sure that other interrupts can still fire (which should be > handled in less time than 2ms, anyway :-)). If it's ok, I'd leave it like that :-) > > BTW, we still have 2007 over here :-) (?) > > Bye, > Axel. > Thanks, Salvo -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer and Telecommunications Engineering University of Messina (Italy) www.messinalug.org Please do not send me any word, excel or power point file http://www.gnu.org/philosophy/no-word-attachments.html From axeld at pinc-software.de Fri Nov 16 13:06:19 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 16 Nov 2007 13:06:19 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r22934_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/busses/usb?= In-Reply-To: Message-ID: <15079380688-BeMail@zon> "Salvatore Benedetto" wrote: > > snooze() is waiting on a semaphore (which you must not do when > > interrupts are disabled), but it's also not adequate for short > > waits, > > because its overhead is larger. So busy waiting would be > > preferrable > > here (using spin()). > So substituting snooze with spin should be enough? In this case I'd say yes, but I haven't looked at the other uses of snooze() - if you need exact timing below 1000 us, snooze() is probably not the right choice, at least :-) > > An alternative to disabling interrupts would be to temporarily bump > > your thread's priority to real time priority - if you need some > > more > > time (100 usec are probably still acceptable, though), it would at > > least make sure that other interrupts can still fire (which should > > be > > handled in less time than 2ms, anyway :-)). > If it's ok, I'd leave it like that :-) Sure, I just wanted to point out an alternative. > > BTW, we still have 2007 over here :-) > (?) The copyright header of ohci.cpp spans into the future :-) Bye, Axel. From emitrax at gmail.com Fri Nov 16 14:29:39 2007 From: emitrax at gmail.com (Salvatore Benedetto) Date: Fri, 16 Nov 2007 13:29:39 +0000 Subject: [Haiku-commits] r22934 - haiku/trunk/src/add-ons/kernel/busses/usb In-Reply-To: <15079380688-BeMail@zon> References: <15079380688-BeMail@zon> Message-ID: On Nov 16, 2007 12:06 PM, Axel D?rfler wrote: > "Salvatore Benedetto" wrote: > > So substituting snooze with spin should be enough? > > In this case I'd say yes, but I haven't looked at the other uses of > snooze() - if you need exact timing below 1000 us, snooze() is probably > not the right choice, at least :-) I'll keep that in mind, thanks. > > > BTW, we still have 2007 over here :-) > > (?) > > The copyright header of ohci.cpp spans into the future :-) Oh, that's because it's probably going to be 2008 by the time I finish the driver :-) > > > Bye, > Axel. Salvo > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer and Telecommunications Engineering University of Messina (Italy) www.messinalug.org Please do not send me any word, excel or power point file http://www.gnu.org/philosophy/no-word-attachments.html From sbenedetto at mail.berlios.de Sat Nov 17 12:03:16 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 17 Nov 2007 12:03:16 +0100 Subject: [Haiku-commits] r22935 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711171103.lAHB3GpS017565@sheep.berlios.de> Author: sbenedetto Date: 2007-11-17 12:03:16 +0100 (Sat, 17 Nov 2007) New Revision: 22935 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22935&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp Log: * Replaced snooze with spin (Thanks Axel) * Fixing TRACE messages * minor clean up Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-16 10:11:02 UTC (rev 22934) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-17 11:03:16 UTC (rev 22935) @@ -15,10 +15,10 @@ #include "ohci.h" pci_module_info *OHCI::sPCIModule = NULL; - + static int32 -ohci_std_ops( int32 op , ... ) +ohci_std_ops(int32 op, ...) { switch (op) { case B_MODULE_INIT: @@ -157,7 +157,7 @@ } fDummyIsochronous->flags |= OHCI_ENDPOINT_SKIP; - // Create the interrupt tree + // Static endpoints that get linked in the HCCA fInterruptEndpoints = new(std::nothrow) ohci_endpoint_descriptor *[OHCI_NUMBER_OF_INTERRUPTS]; if (!fInterruptEndpoints) { @@ -168,11 +168,11 @@ _FreeEndpoint(fDummyIsochronous); return; } - - // Static endpoints that get linked in the HCCA for (uint32 i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) { fInterruptEndpoints[i] = _AllocateEndpoint(); if (!fInterruptEndpoints[i]) { + TRACE_ERROR(("ohci_usb: cannot allocate memory for" + " fInterruptEndpoints[%d] endpoint\n", i)); while (--i >= 0) _FreeEndpoint(fInterruptEndpoints[i]); _FreeEndpoint(fDummyBulk); @@ -180,42 +180,16 @@ _FreeEndpoint(fDummyIsochronous); return; } + // Make them point all to the dummy isochronous endpoint fInterruptEndpoints[i]->flags |= OHCI_ENDPOINT_SKIP; fInterruptEndpoints[i]->next_physical_endpoint = fDummyIsochronous->physical_address; } -#if 0 - ohci_endpoint_descriptor *current; - for( uint32 i = 0; i < OHCI_NUMBER_OF_ENDPOINTS; i++) { - current = _AllocateEndpoint(); - if (!current) { - TRACE_ERROR(("usb_ohci: failed to create interrupts tree\n")); - while (--i >= 0) - _FreeEndpoint(fInterruptEndpoints[i]); - _FreeEndpoint(fDummyBulk); - _FreeEndpoint(fDummyControl); - _FreeEndpoint(fDummyIsochronous); - return; - } - fInterruptEndpoints[i] = current; - current->flags |= OHCI_ENDPOINT_SKIP; - if (i != 0) - previous = fInterruptEndpoints[(i - 1) / 2]; - else - previous = fDummyIsochronous; - current->next_logical_endpoint = previous; - current->next_physical_endpoint = previous->physical_address; - } -#endif - - // Fill HCCA interrupt table. The bit reversal is to get - // the tree set up properly to spread the interrupts. + // Fill HCCA interrupt table. for (uint32 i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) - fHcca->interrupt_table[revbits[i]] = - fInterruptEndpoints[OHCI_NUMBER_OF_ENDPOINTS - OHCI_NUMBER_OF_INTERRUPTS + i]->physical_address; + fHcca->interrupt_table[i] = fInterruptEndpoints[i]->physical_address; - // Determine in what context we are running (Kindly copied from FreeBSD) uint32 control = _ReadReg(OHCI_CONTROL); if (control & OHCI_INTERRUPT_ROUTING) { @@ -254,7 +228,7 @@ cpu_status former = disable_interrupts(); _WriteReg(OHCI_COMMAND_STATUS, OHCI_HOST_CONTROLLER_RESET); for (uint32 i = 0; i < 10; i++) { - snooze(10); + spin(10); if (!(_ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET)) break; } @@ -330,8 +304,6 @@ install_io_interrupt_handler(fPCIInfo->u.h0.interrupt_line, _InterruptHandler, (void *)this, 0); - // TODO: Enable interrupts. Maybe disable first somewhere before :) - TRACE(("usb_ohci: OHCI Host Controller Driver constructed\n")); fInitOK = true; } @@ -339,6 +311,11 @@ OHCI::~OHCI() { + int32 result = 0; + fStopFinishThread = true; + delete_sem(fFinishTransfersSem); + wait_for_thread(fFinishThread, &result); + if (fHccaArea > 0) delete_area(fHccaArea); if (fRegisterArea > 0) @@ -355,6 +332,7 @@ if (fInterruptEndpoints[i]) _FreeEndpoint(fInterruptEndpoints[i]); delete [] fInterruptEndpoints; + put_module(B_PCI_MODULE_NAME); } @@ -390,9 +368,13 @@ void OHCI::_FinishTransfer() { - // TODO: block on the semaphore + while (!fStopFinishThread) { + if (acquire_sem(fFinishTransfersSem) < B_OK) + continue; + } } + status_t OHCI::Start() { @@ -495,14 +477,13 @@ if (!sPCIModule) { status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule); if (status < B_OK) { - TRACE_ERROR(("usb_ohci: AddTo(): getting pci module failed! 0x%08lx\n", + TRACE_ERROR(("usb_ohci: getting pci module failed! 0x%08lx\n", status)); return status; } } - TRACE(("usb_ohci: AddTo(): setting up hardware\n")); - + TRACE(("usb_ohci: searching devices\n")); bool found = false; pci_info *item = new(std::nothrow) pci_info; if (!item) { @@ -517,12 +498,12 @@ && item->class_api == PCI_usb_ohci) { if (item->u.h0.interrupt_line == 0 || item->u.h0.interrupt_line == 0xFF) { - TRACE_ERROR(("usb_ohci: AddTo(): found with invalid IRQ -" + TRACE_ERROR(("usb_ohci: found device with invalid IRQ -" " check IRQ assignement\n")); continue; } - TRACE(("usb_ohci: AddTo(): found at IRQ %u\n", + TRACE(("usb_ohci: found device at IRQ %u\n", item->u.h0.interrupt_line)); OHCI *bus = new(std::nothrow) OHCI(item, stack); if (!bus) { @@ -533,8 +514,7 @@ } if (bus->InitCheck() < B_OK) { - TRACE_ERROR(("usb_ohci: AddTo(): InitCheck() failed 0x%08lx\n", - bus->InitCheck())); + TRACE_ERROR(("usb_ohci: bus failed init check\n")); delete bus; continue; } @@ -551,6 +531,7 @@ if (!found) { TRACE_ERROR(("usb_ohci: no devices found\n")); delete item; + sPCIModule = NULL; put_module(B_PCI_MODULE_NAME); return ENODEV; } @@ -675,6 +656,9 @@ void OHCI::_FreeEndpoint(ohci_endpoint_descriptor *endpoint) { + if (!endpoint) + return; + fStack->FreeChunk((void *)endpoint, (void *)endpoint->physical_address, sizeof(ohci_endpoint_descriptor)); } @@ -716,28 +700,19 @@ { #if 0 TRACE(("OHCI: Inserting Endpoint for device %u function %u\n", p->DeviceAddress(), p->EndpointAddress())); - - if (InitCheck()) - return B_ERROR; - - //Endpoint *endpoint = _AllocateEndpoint(); ohci_endpoint_descriptor *endpoint = _AllocateEndpoint(); - if (!endpoint) + if (!endpoint) { + TRACE_ERROR(("usb_ohci: cannot allocate memory for endpoint\n")); return B_NO_MEMORY; - - //Set up properties of the endpoint - //TODO: does this need its own utility function? - { - uint32 properties = 0; + } + endpoint->flags |= OHCI_ENDPOINT_SKIP; + + // Set up properties of the endpoint + endpoints->flags |= OHCI_ENDPOINT_SET_DEVICE_ADDRESS(pipe->DeviceAddress()) + | OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(pipe->EndpointAddress()); - //Set the device address - properties |= OHCI_ENDPOINT_SET_DEVICE_ADDRESS(p->DeviceAddress()); - - //Set the endpoint number - properties |= OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(p->EndpointAddress()); - //Set the direction - switch (p->Direction()) { + switch (pipe->Direction()) { case Pipe::In: properties |= OHCI_ENDPOINT_DIRECTION_IN; break; From mmlr at mail.berlios.de Sat Nov 17 12:38:43 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sat, 17 Nov 2007 12:38:43 +0100 Subject: [Haiku-commits] r22936 - haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <200711171138.lAHBchWM007952@sheep.berlios.de> Author: mmlr Date: 2007-11-17 12:38:38 +0100 (Sat, 17 Nov 2007) New Revision: 22936 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22936&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h Log: Store the polling interval in the InterruptPipe class to make it accessible to the controller. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp 2007-11-17 11:03:16 UTC (rev 22935) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp 2007-11-17 11:38:38 UTC (rev 22936) @@ -383,7 +383,7 @@ pipe = new(std::nothrow) InterruptPipe(this, fDeviceAddress, endpoint->descr->endpoint_address & 0x0f, (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, - fSpeed, endpoint->descr->max_packet_size); + fSpeed, endpoint->descr->max_packet_size, endpoint->descr->interval); break; } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp 2007-11-17 11:03:16 UTC (rev 22935) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp 2007-11-17 11:38:38 UTC (rev 22936) @@ -102,9 +102,10 @@ InterruptPipe::InterruptPipe(Object *parent, int8 deviceAddress, uint8 endpointAddress, pipeDirection direction, usb_speed speed, - size_t maxPacketSize) + size_t maxPacketSize, uint8 interval) : Pipe(parent, deviceAddress, endpointAddress, direction, speed, - maxPacketSize) + maxPacketSize), + fInterval(interval) { } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h 2007-11-17 11:03:16 UTC (rev 22935) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h 2007-11-17 11:38:38 UTC (rev 22936) @@ -333,7 +333,8 @@ uint8 endpointAddress, pipeDirection direction, usb_speed speed, - size_t maxPacketSize); + size_t maxPacketSize, + uint8 interval); virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_INTERRUPT_PIPE; }; @@ -341,6 +342,11 @@ size_t dataLength, usb_callback_func callback, void *callbackCookie); + + uint8 Interval() { return fInterval; }; + +private: + uint8 fInterval; }; From axeld at mail.berlios.de Sat Nov 17 15:15:31 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 17 Nov 2007 15:15:31 +0100 Subject: [Haiku-commits] r22937 - haiku/trunk/src/apps/sudoku Message-ID: <200711171415.lAHEFVKm019972@sheep.berlios.de> Author: axeld Date: 2007-11-17 15:15:31 +0100 (Sat, 17 Nov 2007) New Revision: 22937 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22937&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp haiku/trunk/src/apps/sudoku/SudokuView.h Log: When having set/removed a value or hint, you can duplicate that action (or remove the hint for that value) by dragging the mouse over other fields with the mouse button held. Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2007-11-17 11:38:38 UTC (rev 22936) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2007-11-17 14:15:31 UTC (rev 22937) @@ -437,7 +437,7 @@ if (clicks == 2 && fLastHintValue == value && fLastField == field || (buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) { - // double click + // double click or other buttons set a value if ((fField->FlagsAt(x, y) & kInitialValue) == 0) { if (fField->ValueAt(x, y) > 0) { fField->SetValueAt(x, y, 0); @@ -449,16 +449,22 @@ } _InvalidateField(x, y); + + // allow dragging to remove the hint from other fields + fLastHintValueSet = false; + fLastHintValue = value; } return; } uint32 hintMask = fField->HintMaskAt(x, y); uint32 valueMask = 1UL << value; - if (hintMask & valueMask) + fLastHintValueSet = (hintMask & valueMask) == 0; + + if (fLastHintValueSet) + hintMask |= valueMask; + else hintMask &= ~valueMask; - else - hintMask |= valueMask; fField->SetHintMaskAt(x, y, hintMask); _InvalidateHintField(x, y, hintX, hintY); @@ -493,6 +499,25 @@ if (fShowHintX == x && fShowHintY == y) return; + int32 buttons = 0; + if (Looper() != NULL && Looper()->CurrentMessage() != NULL) + Looper()->CurrentMessage()->FindInt32("buttons", &buttons); + + uint32 field = x + y * fField->Size(); + + if (buttons != 0 && field != fLastField) { + // if a button is pressed, we drag the last hint selection + // (either set or removal) to the field under the mouse + uint32 hintMask = fField->HintMaskAt(x, y); + uint32 valueMask = 1UL << fLastHintValue; + if (fLastHintValueSet) + hintMask |= valueMask; + else + hintMask &= ~valueMask; + + fField->SetHintMaskAt(x, y, hintMask); + } + _RemoveHint(); fShowHintX = x; fShowHintY = y; Modified: haiku/trunk/src/apps/sudoku/SudokuView.h =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.h 2007-11-17 11:38:38 UTC (rev 22936) +++ haiku/trunk/src/apps/sudoku/SudokuView.h 2007-11-17 14:15:31 UTC (rev 22937) @@ -85,6 +85,7 @@ float fHintHeight, fHintWidth, fHintBaseline; uint32 fShowHintX, fShowHintY; uint32 fLastHintValue; + bool fLastHintValueSet; uint32 fLastField; uint32 fKeyboardX, fKeyboardY; uint32 fHintFlags; From sbenedetto at mail.berlios.de Sat Nov 17 16:12:32 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 17 Nov 2007 16:12:32 +0100 Subject: [Haiku-commits] r22938 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711171512.lAHFCWtt025005@sheep.berlios.de> Author: sbenedetto Date: 2007-11-17 16:12:31 +0100 (Sat, 17 Nov 2007) New Revision: 22938 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22938&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h Log: * Implemented _InsertEndpointForPipe * usual clean up Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-17 14:15:31 UTC (rev 22937) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-17 15:12:31 UTC (rev 22938) @@ -133,7 +133,7 @@ return; } - memset((void*)fHcca, 0, sizeof(ohci_hcca)); + memset((void *)fHcca, 0, sizeof(ohci_hcca)); // Set Up Host controller // Dummy endpoints @@ -172,7 +172,7 @@ fInterruptEndpoints[i] = _AllocateEndpoint(); if (!fInterruptEndpoints[i]) { TRACE_ERROR(("ohci_usb: cannot allocate memory for" - " fInterruptEndpoints[%d] endpoint\n", i)); + " fInterruptEndpoints[%ld] endpoint\n", i)); while (--i >= 0) _FreeEndpoint(fInterruptEndpoints[i]); _FreeEndpoint(fDummyBulk); @@ -640,6 +640,7 @@ TRACE_ERROR(("usb_ohci: failed to allocate endpoint descriptor\n")); return NULL; } + memset((void *)endpoint, 0, sizeof(ohci_endpoint_descriptor)); endpoint->physical_address = (addr_t)physicalAddress; @@ -698,89 +699,100 @@ status_t OHCI::_InsertEndpointForPipe(Pipe *pipe) { -#if 0 - TRACE(("OHCI: Inserting Endpoint for device %u function %u\n", p->DeviceAddress(), p->EndpointAddress())); + TRACE(("OHCI: Inserting Endpoint for device %u function %u\n", + pipe->DeviceAddress(), pipe->EndpointAddress())); + ohci_endpoint_descriptor *endpoint = _AllocateEndpoint(); if (!endpoint) { TRACE_ERROR(("usb_ohci: cannot allocate memory for endpoint\n")); return B_NO_MEMORY; } - endpoint->flags |= OHCI_ENDPOINT_SKIP; - // Set up properties of the endpoint - endpoints->flags |= OHCI_ENDPOINT_SET_DEVICE_ADDRESS(pipe->DeviceAddress()) + uint32 flags = 0; + flags |= OHCI_ENDPOINT_SKIP; + + // Set up flag field for the endpoint + flags |= OHCI_ENDPOINT_SET_DEVICE_ADDRESS(pipe->DeviceAddress()) | OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(pipe->EndpointAddress()); - - //Set the direction - switch (pipe->Direction()) { + + // Set the direction + switch (pipe->Direction()) { case Pipe::In: - properties |= OHCI_ENDPOINT_DIRECTION_IN; + flags |= OHCI_ENDPOINT_DIRECTION_IN; break; case Pipe::Out: - properties |= OHCI_ENDPOINT_DIRECTION_OUT; + flags |= OHCI_ENDPOINT_DIRECTION_OUT; break; case Pipe::Default: - properties |= OHCI_ENDPOINT_DIRECTION_DESCRIPTOR; + flags |= OHCI_ENDPOINT_DIRECTION_DESCRIPTOR; break; default: - //TODO: error - break; - } - - //Set the speed - switch (p->Speed()) { + TRACE_ERROR(("usb_ohci: direction unknown. Wrong value!\n")); + _FreeEndpoint(endpoint); + return B_ERROR; + } + + // Set up the speed + switch (pipe->Speed()) { case USB_SPEED_LOWSPEED: - //the bit is 0 + flags |= OHCI_ENDPOINT_LOW_SPEED; break; case USB_SPEED_FULLSPEED: - properties |= OHCI_ENDPOINT_SPEED; + flags |= OHCI_ENDPOINT_FULL_SPEED; break; case USB_SPEED_HIGHSPEED: default: - //TODO: error + TRACE_ERROR(("usb_ohci: unaccetable speed. Wrong value!\n")); + _FreeEndpoint(endpoint); + return B_ERROR; + } + + // Set the maximum packet size + flags |= OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(pipe->MaxPacketSize()); + + endpoint->flags = flags; + + // Add the endpoint to the appropriate list + ohci_endpoint_descriptor *head = NULL; + switch (pipe->Type()) { + case USB_OBJECT_CONTROL_PIPE: + head = fDummyControl; break; - } - - //Assign the format. Isochronous endpoints require this switch - if (p->Type() & USB_OBJECT_ISO_PIPE) - properties |= OHCI_ENDPOINT_ISOCHRONOUS_FORMAT; - - //Set the maximum packet size - properties |= OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(p->MaxPacketSize()); - - endpoint->ed->flags = properties; + case USB_OBJECT_BULK_PIPE: + head = fDummyBulk; + break; + case USB_OBJECT_ISO_PIPE: + // Set the isochronous bit format + endpoint->flags = OHCI_ENDPOINT_ISOCHRONOUS_FORMAT; + head = fDummyIsochronous; + break; + case USB_OBJECT_INTERRUPT_PIPE: + head = _FindInterruptEndpoint((static_cast(pipe))->Interval()); + break; + default: + TRACE_ERROR(("usb_ohci: unknown type of pipe. Wrong value!\n")); + _FreeEndpoint(endpoint); + return B_ERROR; } - - //Check which list we need to add the endpoint in - Endpoint *listhead; - if (p->Type() & USB_OBJECT_CONTROL_PIPE) - listhead = fDummyControl; - else if (p->Type() & USB_OBJECT_BULK_PIPE) - listhead = fDummyBulk; - else if (p->Type() & USB_OBJECT_ISO_PIPE) - listhead = fDummyIsochronous; - else { - _FreeEndpoint(endpoint); - return B_ERROR; - } - //Add the endpoint to the queues - if ((p->Type() & USB_OBJECT_ISO_PIPE) == 0) { - //Link the endpoint into the head of the list - endpoint->SetNext(listhead->next); - listhead->SetNext(endpoint); - } else { - //Link the endpoint into the tail of the list - Endpoint *tail = listhead; - while (tail->next != 0) - tail = tail->next; - tail->SetNext(endpoint); - } -#endif + Lock(); + endpoint->next_logical_endpoint = head->next_logical_endpoint; + endpoint->next_physical_endpoint = head->next_physical_endpoint; + head->next_logical_endpoint = (void *)endpoint; + head->next_physical_endpoint = (uint32)endpoint->physical_address; + Unlock(); + return B_OK; } +ohci_endpoint_descriptor* +OHCI::_FindInterruptEndpoint(uint8 interval) +{ + return NULL; +} + + status_t OHCI::_RemoveEndpointForPipe(Pipe *pipe) { Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-17 14:15:31 UTC (rev 22937) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-17 15:12:31 UTC (rev 22938) @@ -91,6 +91,7 @@ status_t _RemoveEndpointForPipe(Pipe *pipe); status_t _CreateEndpoint(Pipe *pipe, bool isIsochronous); + ohci_endpoint_descriptor *_FindInterruptEndpoint(uint8 interval); ohci_endpoint_descriptor *_AllocateEndpoint(); void _FreeEndpoint( ohci_endpoint_descriptor *endpoint); Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h 2007-11-17 14:15:31 UTC (rev 22937) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h 2007-11-17 15:12:31 UTC (rev 22938) @@ -307,25 +307,26 @@ void *next_logical_endpoint; // Logical pointer to the next endpoint }; -#define OHCI_ENDPOINT_ADDRESS_MASK 0x0000007f -#define OHCI_ENDPOINT_GET_DEVICE_ADDRESS(s) ((s) & 0x7f) -#define OHCI_ENDPOINT_SET_DEVICE_ADDRESS(s) (s) -#define OHCI_ENDPOINT_GET_ENDPOINT_NUMBER(s) (((s) >> 7) & 0xf) -#define OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(s) ((s) << 7) -#define OHCI_ENDPOINT_DIRECTION_MASK 0x00001800 +#define OHCI_ENDPOINT_ADDRESS_MASK 0x0000007f +#define OHCI_ENDPOINT_GET_DEVICE_ADDRESS(s) ((s) & 0x7f) +#define OHCI_ENDPOINT_SET_DEVICE_ADDRESS(s) (s) +#define OHCI_ENDPOINT_GET_ENDPOINT_NUMBER(s) (((s) >> 7) & 0xf) +#define OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(s) ((s) << 7) +#define OHCI_ENDPOINT_DIRECTION_MASK 0x00001800 #define OHCI_ENDPOINT_DIRECTION_DESCRIPTOR 0x00000000 #define OHCI_ENDPOINT_DIRECTION_OUT 0x00000800 #define OHCI_ENDPOINT_DIRECTION_IN 0x00001000 -#define OHCI_ENDPOINT_SPEED 0x00002000 -#define OHCI_ENDPOINT_SKIP 0x00004000 -#define OHCI_ENDPOINT_GENERAL_FORMAT 0x00000000 -#define OHCI_ENDPOINT_ISOCHRONOUS_FORMAT 0x00008000 -#define OHCI_ENDPOINT_MAX_PACKET_SIZE_MASK (0x7ff << 16) -#define OHCI_ENDPOINT_GET_MAX_PACKET_SIZE(s) (((s) >> 16) & 0x07ff) -#define OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(s) ((s) << 16) -#define OHCI_ENDPOINT_HALTED 0x00000001 -#define OHCI_ENDPOINT_TOGGLE_CARRY 0x00000002 -#define OHCI_ENDPOINT_HEAD_MASK 0xfffffffc +#define OHCI_ENDPOINT_LOW_SPEED 0x00002000 +#define OHCI_ENDPOINT_FULL_SPEED 0x00000000 +#define OHCI_ENDPOINT_SKIP 0x00004000 +#define OHCI_ENDPOINT_GENERAL_FORMAT 0x00000000 +#define OHCI_ENDPOINT_ISOCHRONOUS_FORMAT 0x00008000 +#define OHCI_ENDPOINT_MAX_PACKET_SIZE_MASK (0x7ff << 16) +#define OHCI_ENDPOINT_GET_MAX_PACKET_SIZE(s) (((s) >> 16) & 0x07ff) +#define OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(s) ((s) << 16) +#define OHCI_ENDPOINT_HALTED 0x00000001 +#define OHCI_ENDPOINT_TOGGLE_CARRY 0x00000002 +#define OHCI_ENDPOINT_HEAD_MASK 0xfffffffc // -------------------------------- From oruizdorantes at mail.berlios.de Sat Nov 17 21:48:51 2007 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Sat, 17 Nov 2007 21:48:51 +0100 Subject: [Haiku-commits] r22939 - in haiku/trunk/src/add-ons/kernel/drivers: . bluetooth bluetooth/h2 bluetooth/h2/h2generic Message-ID: <200711172048.lAHKmpRb026424@sheep.berlios.de> Author: oruizdorantes Date: 2007-11-17 21:48:50 +0100 (Sat, 17 Nov 2007) New Revision: 22939 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22939&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.h Log: Auxiliary structure to handle with BT commands and events. To consider later moving to a module. This is part of the USB-BT driver Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c 2007-11-17 15:12:31 UTC (rev 22938) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c 2007-11-17 20:48:50 UTC (rev 22939) @@ -0,0 +1,215 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#include "snet_buffer.h" + + +struct snet_buffer { + struct list_link link; + + uint8* buffer; + + uint16 allocatedSize; + uint16 expectedSize; + uint16 puttingSize; + uint16 pullingSize; + + void* cookie; + +}; + + +snet_buffer* +snb_create(uint16 size) +{ + /* TODO: pointer checking */ + +#ifdef SNB_BUFFER_ATTACHED + /* Allocating these 2 buffers together might prevent memory fragmentation? */ + snet_buffer* snb = (snet_buffer*) malloc(sizeof(snet_buffer) + size); + snb->buffer = ((uint8*)snb) + sizeof(snet_buffer); +#else + snet_buffer* snb = malloc(sizeof (snet_buffer)); + snb->buffer = malloc(size); +#endif + + snb->pullingSize = snb->puttingSize = 0; + snb->expectedSize = snb->allocatedSize = size; + + return snb; + +} + + +void +snb_put(snet_buffer* snb, void* data, uint16 size) +{ + /* TODO: check overflow */ + memcpy( &snb->buffer[snb->puttingSize], data, size); + snb->puttingSize+=size; +} + + +void* +snb_pull(snet_buffer* snb, uint16 size) +{ + /* TODO: check overflow */ + snb->pullingSize+=size; + return &snb->buffer[snb->pullingSize-size]; + +} + + +inline void +snb_reset(snet_buffer* snb) +{ + snb->puttingSize = snb->pullingSize = 0; +} + + +void +snb_free(snet_buffer* snb) +{ + if (snb == NULL) + return; + +#ifdef SNB_BUFFER_ATTACHED + free(snb); +#else + free(snb->buffer); + free(snb); +#endif + +} + + +inline void* +snb_get(snet_buffer* snb) +{ + /* TODO: pointer checking */ + return snb->buffer; +} + + +inline uint16 +snb_size(snet_buffer* snb) +{ + /* TODO: pointer checking */ + return snb->expectedSize; +} + + +inline void* +snb_cookie(snet_buffer* snb) +{ + /* TODO: pointer checking */ + return snb->cookie; +} + + +inline void +snb_set_cookie(snet_buffer* snb, void* cookie) +{ + /* TODO: pointer checking */ + snb->cookie = cookie; +} + + +/* Return true if we canot "put" more data in the buffer */ +inline bool snb_completed(snet_buffer* snb) +{ + return (snb != NULL && (snb->expectedSize == snb->puttingSize)); +} + + +/* Return true if we cannot pull more more data from the buffer */ +inline bool snb_finished(snet_buffer* snb) +{ + return (snb != NULL && (snb->expectedSize == snb->pullingSize)); +} + + +inline bool snb_remaining_to_put(snet_buffer* snb) +{ + return (snb != NULL && (snb->expectedSize - snb->puttingSize)); +} + + +inline bool snb_remaining_to_pull(snet_buffer* snb) +{ + return (snb != NULL && (snb->expectedSize - snb->pullingSize)); +} + + +/* ISSUE1: Number of packets in the worst case(we always need a bigger + buffer than before) increases, never decreases: + + SOL1: Delete the smallest when the queue is bigger than X elements + SOL2: ? + + ISSUE2: If the queue is not gonna be used for long time, Memory c + ould be freed + + SOL1: Provide purge func. + SOL2: ? + + */ +static snet_buffer* +snb_attempt_reuse(snet_buffer* snb, uint16 size) +{ + if ( snb == NULL || + ((int16)snb->allocatedSize - (int16)size) < 0 ) { + + /* Impossible or not worth, Creating a new one */ + snb_free(snb); + return snb_create(size); + + } + else { + snb_reset(snb); + snb->expectedSize = size; + return snb; + } + +} + + +void +snb_park(struct list* l, snet_buffer* snb) +{ + snet_buffer* item = NULL; + /* insert it by order */ + while ((item = list_get_next_item(l, item)) != NULL) { + if (item->allocatedSize > snb->allocatedSize) + list_insert_item_before(l, item, snb); + } +} + + +snet_buffer* +snb_fetch(struct list* l, uint16 size) +{ + + snet_buffer* item = NULL; + snet_buffer* previous = NULL; + + if (!list_is_empty(l)) + while ((item = list_get_next_item(l, item)) != NULL) { + if (item->allocatedSize == size) { + /* This one is for us*/ + break; + } + else if (item->allocatedSize > size) { + /* get the previous*/ + item = previous; + break; + } + previous = item; + } + + return snb_attempt_reuse(item, size); +} Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.h 2007-11-17 15:12:31 UTC (rev 22938) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.h 2007-11-17 20:48:50 UTC (rev 22939) @@ -0,0 +1,81 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + + +#ifndef _SNET_BUFFER_H_ +#define _SNET_BUFFER_H_ + +#include + +/* + * This is a simple data structure to hold network buffers. + * It drops many functionality that the Haiku net_buffer provides. + * + * - Inspired by linux sk_buff/bsd mbuf (put/pull) + * - Contiguoussafe (no push operation) + * + * So snet_buffers are ONLY meant to be used when: + * 1) You know exactily the maximun/final size of the frame + * before allocating it, and you will never exceed it. + * 2) You are not supposed to prepend data, only append. + * + */ + +/* Configuration parameters */ +#define SNB_BUFFER_ATTACHED +//#define SNB_PERFORMS_OVERFLOW_CHECKS +//#define SNB_PERFORMS_POINTER_CHECKS + +struct snet_buffer; + +typedef struct snet_buffer snet_buffer; + +/* Creates a snb_buffer allocating size space for its full content */ +snet_buffer* snb_create(uint16 size); +/* Free the snb_buffer*/ +void snb_free(snet_buffer* snb); +/* Free the snb_buffer*/ +void* snb_get(snet_buffer* snb); +/* Size of the snb_buffer*/ +uint16 snb_size(snet_buffer* snb); + +/* Cookie of the snb_buffer*/ +void* snb_cookie(snet_buffer* snb); +/* Get Cookie of the snb_buffer*/ +void snb_set_cookie(snet_buffer* snb, void* cookie); + +/* Place the memory given by data to the "tail" of the snb */ +void snb_put(snet_buffer* snb, void* data, uint16 size); +/* Returns a header chunk of size data */ +void* snb_pull(snet_buffer* snb, uint16 size); +/* Discards all data put or pulled from the buffer */ +void snb_reset(snet_buffer* snb); + +/* Return true if we canot "put" more data in the buffer */ +bool snb_completed(snet_buffer* snb); +/* Return true if we cannot pull more more data from the buffer */ +bool snb_finished(snet_buffer* snb); +/* Return the amount of data we can still put in the buffer */ +bool snb_remaining_to_put(snet_buffer* snb); +/* Return the amount of data we can still pull in the buffer */ +bool snb_remaining_to_pull(snet_buffer* snb); + +/* These to functions are provided to avoid memory fragmentation + * allocating and freeing many snb_buffers and its possible overhead. + * Thypical scenario would be + * that you create a snb_buffer to send data, once you send you free it, + * and need another one to hold the response. The idea would be once you send + * that buffer, to snb_park the buffer, and whenever you need to allocate another + * one snb_fetch it. That funcion will reuse most appropiated previous used one + * snb_buff by its memory use. + */ +void snb_park(struct list* l, snet_buffer* snb); +snet_buffer* snb_fetch(struct list* l, uint16 size); + + + +#endif From mmu_man at mail.berlios.de Sat Nov 17 23:26:18 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 17 Nov 2007 23:26:18 +0100 Subject: [Haiku-commits] r22940 - haiku/trunk/build/scripts Message-ID: <200711172226.lAHMQIxN030965@sheep.berlios.de> Author: mmu_man Date: 2007-11-17 23:26:17 +0100 (Sat, 17 Nov 2007) New Revision: 22940 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22940&view=rev Modified: haiku/trunk/build/scripts/build_haiku_image Log: Finally got a fix for attribute errors when building on linux without xattr. After copying the mime db or packages the files were removed, but not the corresponding attribute storage files. So when an inode got reused the file inherited those leftover attributes. We now remove them before removing the files. Modified: haiku/trunk/build/scripts/build_haiku_image =================================================================== --- haiku/trunk/build/scripts/build_haiku_image 2007-11-17 20:48:50 UTC (rev 22939) +++ haiku/trunk/build/scripts/build_haiku_image 2007-11-17 22:26:17 UTC (rev 22940) @@ -56,6 +56,15 @@ fi +# attribute-safe rm -rf +# This makes sure there are no leftover attribute file before removing each file +attrrmrf() +{ + test -e "$1" || return + find "$1" -print0 | xargs -0 stat -c %i | awk "{ print \"$outputDir/attributes/\" \$1 }" | xargs rm -rf + rm -rf "$1" +} + unzipFile() { # unzipFile @@ -66,13 +75,13 @@ if [ $isImage ]; then unzipDir=$tmpDir/unzip - rm -rf $unzipDir + attrrmrf $unzipDir mkdir -p $unzipDir $unzip -q -d $unzipDir $zipFile $cp -r ${sPrefix}$unzipDir/. ${tPrefix}$targetUnzipDir - rm -rf $unzipDir + attrrmrf $unzipDir else $unzip -q -d ${tPrefix}$targetUnzipDir ${sPrefix}$zipFile fi @@ -158,7 +167,7 @@ done # cleanup tmp dir - rm -rf $mimeTmpDir + attrrmrf $mimeTmpDir fi # ! updateOnly From mmu_man at mail.berlios.de Sun Nov 18 00:46:02 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 18 Nov 2007 00:46:02 +0100 Subject: [Haiku-commits] r22941 - haiku/trunk/build/jam Message-ID: <200711172346.lAHNk2j5003097@sheep.berlios.de> Author: mmu_man Date: 2007-11-18 00:46:01 +0100 (Sun, 18 Nov 2007) New Revision: 22941 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22941&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Add Opensound port as optional package Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-17 22:26:17 UTC (rev 22940) +++ haiku/trunk/build/jam/HaikuImage 2007-11-17 23:46:01 UTC (rev 22941) @@ -468,6 +468,14 @@ : /boot/apps/WonderBrush/WonderBrush ; } +# OpenSound drivers +if [ IsOptionalHaikuImagePackageAdded OpenSound ] { + InstallOptionalHaikuImagePackage OpenSound + : http://revolf.free.fr/beos/oss-beos-v4.1test-bin.zip + : + ; + #UnzipArchiveToHaikuImage home : data/vv.mp3.zip : 0 ; +} #pragma mark - Build The Image From mmlr at mail.berlios.de Sun Nov 18 02:05:40 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 18 Nov 2007 02:05:40 +0100 Subject: [Haiku-commits] r22942 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711180105.lAI15eLa025648@sheep.berlios.de> Author: mmlr Date: 2007-11-18 02:05:39 +0100 (Sun, 18 Nov 2007) New Revision: 22942 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22942&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h haiku/trunk/src/add-ons/kernel/busses/usb/ehci_hardware.h Log: * Implement interrupt transfers in EHCI * Uses a "collapsed binary tree" (for lack of a better name) to support the different intervals * Remove a leftover variable declaration that was hiding error conditions away... * Some cleanup Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-17 23:46:01 UTC (rev 22941) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-18 01:05:39 UTC (rev 22942) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku Inc. All rights reserved. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -238,18 +238,69 @@ // allocate the periodic frame list fPeriodicFrameListArea = fStack->AllocateArea((void **)&fPeriodicFrameList, - (void **)&physicalAddress, B_PAGE_SIZE, "USB EHCI Periodic Framelist"); + (void **)&physicalAddress, B_PAGE_SIZE * 2, "USB EHCI Periodic Framelist"); if (fPeriodicFrameListArea < B_OK) { TRACE_ERROR(("usb_ehci: unable to allocate periodic framelist\n")); return; } - // terminate all elements - for (int32 i = 0; i < 1024; i++) - fPeriodicFrameList[i] = EHCI_PFRAMELIST_TERM; - + // set the periodic frame list base on the controller WriteOpReg(EHCI_PERIODICLISTBASE, (uint32)physicalAddress); + // create the interrupt entries to support different polling intervals + TRACE(("usb_ehci: creating interrupt entries\n")); + addr_t physicalBase = physicalAddress + B_PAGE_SIZE; + uint8 *logicalBase = (uint8 *)fPeriodicFrameList + B_PAGE_SIZE; + memset(logicalBase, 0, B_PAGE_SIZE); + + fInterruptEntries = (interrupt_entry *)logicalBase; + for (int32 i = 0; i < 10; i++) { + ehci_qh *queueHead = &fInterruptEntries[i].queue_head; + queueHead->this_phy = physicalBase; + queueHead->current_qtd_phy = EHCI_QTD_TERMINATE; + queueHead->overlay.next_phy = EHCI_QTD_TERMINATE; + queueHead->overlay.alt_next_phy = EHCI_QTD_TERMINATE; + queueHead->overlay.token = EHCI_QTD_STATUS_HALTED; + + // set dummy endpoint information + queueHead->endpoint_chars = EHCI_QH_CHARS_EPS_HIGH + | (3 << EHCI_QH_CHARS_RL_SHIFT) | (64 << EHCI_QH_CHARS_MPL_SHIFT) + | EHCI_QH_CHARS_TOGGLE; + queueHead->endpoint_caps = (1 << EHCI_QH_CAPS_MULT_SHIFT) + | (0xff << EHCI_QH_CAPS_ISM_SHIFT); + + physicalBase += sizeof(interrupt_entry); + } + + // build flat interrupt tree + TRACE(("usb_ehci: build up interrupt links\n")); + uint32 interval = 1024; + uint32 intervalIndex = 9; + while (interval > 1) { + uint32 insertIndex = interval / 2; + while (insertIndex < 1024) { + uint32 entry = fInterruptEntries[intervalIndex].queue_head.this_phy; + fPeriodicFrameList[insertIndex] = entry | EHCI_PFRAMELIST_QH; + insertIndex += interval; + } + + intervalIndex--; + interval /= 2; + } + + // setup the empty slot in the list and linking of all -> first + ehci_qh *firstLogical = &fInterruptEntries[0].queue_head; + uint32 firstPhysical = firstLogical->this_phy | EHCI_QH_TYPE_QH; + fPeriodicFrameList[0] = firstPhysical; + for (int32 i = 1; i < 10; i++) { + fInterruptEntries[i].queue_head.next_phy = firstPhysical; + fInterruptEntries[i].queue_head.next_log = firstLogical; + } + + // terminate the first entry + firstLogical->next_phy = EHCI_QH_TERMINATE; + firstLogical->next_log = NULL; + // allocate a queue head that will always stay in the async frame list fAsyncQueueHead = CreateQueueHead(); if (!fAsyncQueueHead) { @@ -387,36 +438,13 @@ } Pipe *pipe = transfer->TransferPipe(); - switch (pipe->Speed()) { - case USB_SPEED_LOWSPEED: - queueHead->endpoint_chars = EHCI_QH_CHARS_EPS_LOW; - break; - case USB_SPEED_FULLSPEED: - queueHead->endpoint_chars = EHCI_QH_CHARS_EPS_FULL; - break; - case USB_SPEED_HIGHSPEED: - queueHead->endpoint_chars = EHCI_QH_CHARS_EPS_HIGH; - break; - default: - TRACE_ERROR(("usb_ehci: unknown pipe speed\n")); - FreeQueueHead(queueHead); - return B_ERROR; + status_t result = InitQueueHead(queueHead, pipe); + if (result < B_OK) { + TRACE_ERROR(("usb_ehci: failed to init queue head\n")); + FreeQueueHead(queueHead); + return result; } - if (pipe->Type() & USB_OBJECT_CONTROL_PIPE) { - queueHead->endpoint_chars |= - (pipe->Speed() != USB_SPEED_HIGHSPEED ? EHCI_QH_CHARS_CONTROL : 0); - } - - queueHead->endpoint_chars |= (3 << EHCI_QH_CHARS_RL_SHIFT) - | (pipe->MaxPacketSize() << EHCI_QH_CHARS_MPL_SHIFT) - | (pipe->EndpointAddress() << EHCI_QH_CHARS_EPT_SHIFT) - | (pipe->DeviceAddress() << EHCI_QH_CHARS_DEV_SHIFT) - | EHCI_QH_CHARS_TOGGLE; - queueHead->endpoint_caps = (1 << EHCI_QH_CAPS_MULT_SHIFT) - | (0x1c << EHCI_QH_CAPS_SCM_SHIFT); - - status_t result; bool directionIn; ehci_qtd *dataDescriptor; if (pipe->Type() & USB_OBJECT_CONTROL_PIPE) @@ -458,14 +486,62 @@ status_t EHCI::SubmitPeriodicTransfer(Transfer *transfer) { - return B_ERROR; + Pipe *pipe = transfer->TransferPipe(); + if ((pipe->Type() & USB_OBJECT_INTERRUPT_PIPE) == 0) + return B_ERROR; + + ehci_qh *queueHead = CreateQueueHead(); + if (!queueHead) { + TRACE_ERROR(("usb_ehci: failed to allocate periodic queue head\n")); + return B_NO_MEMORY; + } + + status_t result = InitQueueHead(queueHead, pipe); + if (result < B_OK) { + TRACE_ERROR(("usb_ehci: failed to init queue head\n")); + FreeQueueHead(queueHead); + return result; + } + + bool directionIn; + ehci_qtd *dataDescriptor; + result = FillQueueWithData(transfer, queueHead, &dataDescriptor, + &directionIn); + + if (result < B_OK) { + TRACE_ERROR(("usb_ehci: failed to fill transfer queue with data\n")); + FreeQueueHead(queueHead); + return result; + } + + result = AddPendingTransfer(transfer, queueHead, dataDescriptor, directionIn); + if (result < B_OK) { + TRACE_ERROR(("usb_ehci: failed to add pending transfer\n")); + FreeQueueHead(queueHead); + return result; + } + +#ifdef TRACE_USB + TRACE(("usb_ehci: linking interrupt queue\n")); + print_queue(queueHead); +#endif + + result = LinkInterruptQueueHead(queueHead, + ((InterruptPipe *)pipe)->Interval()); + if (result < B_OK) { + TRACE_ERROR(("usb_ehci: failed to link queue head to the async list\n")); + FreeQueueHead(queueHead); + return result; + } + + return B_OK; } status_t EHCI::NotifyPipeChange(Pipe *pipe, usb_change change) { - TRACE_ERROR(("usb_ehci: pipe change %d for pipe 0x%08lx\n", change, (uint32)pipe)); + TRACE(("usb_ehci: pipe change %d for pipe 0x%08lx\n", change, (uint32)pipe)); switch (change) { case USB_CHANGE_CREATED: case USB_CHANGE_DESTROYED: { @@ -966,7 +1042,6 @@ // a transfer error occured TRACE_ERROR(("usb_ehci: qtd (0x%08lx) error: 0x%08lx\n", descriptor->this_phy, status)); - status_t callbackStatus = B_ERROR; uint8 errorCount = status >> EHCI_QTD_ERRCOUNT_SHIFT; errorCount &= EHCI_QTD_ERRCOUNT_MASK; if (errorCount == 0) { @@ -1177,6 +1252,43 @@ } +status_t +EHCI::InitQueueHead(ehci_qh *queueHead, Pipe *pipe) +{ + switch (pipe->Speed()) { + case USB_SPEED_LOWSPEED: + queueHead->endpoint_chars = EHCI_QH_CHARS_EPS_LOW; + break; + case USB_SPEED_FULLSPEED: + queueHead->endpoint_chars = EHCI_QH_CHARS_EPS_FULL; + break; + case USB_SPEED_HIGHSPEED: + queueHead->endpoint_chars = EHCI_QH_CHARS_EPS_HIGH; + break; + default: + TRACE_ERROR(("usb_ehci: unknown pipe speed\n")); + return B_ERROR; + } + + if (pipe->Type() & USB_OBJECT_CONTROL_PIPE) { + queueHead->endpoint_chars |= + (pipe->Speed() != USB_SPEED_HIGHSPEED ? EHCI_QH_CHARS_CONTROL : 0); + } + + queueHead->endpoint_chars |= (3 << EHCI_QH_CHARS_RL_SHIFT) + | (pipe->MaxPacketSize() << EHCI_QH_CHARS_MPL_SHIFT) + | (pipe->EndpointAddress() << EHCI_QH_CHARS_EPT_SHIFT) + | (pipe->DeviceAddress() << EHCI_QH_CHARS_DEV_SHIFT) + | EHCI_QH_CHARS_TOGGLE; + queueHead->endpoint_caps = (1 << EHCI_QH_CAPS_MULT_SHIFT); + + if (pipe->Type() & USB_OBJECT_INTERRUPT_PIPE) + queueHead->endpoint_caps |= (0xff << EHCI_QH_CAPS_ISM_SHIFT); + + return B_OK; +} + + void EHCI::FreeQueueHead(ehci_qh *queueHead) { @@ -1209,6 +1321,34 @@ status_t +EHCI::LinkInterruptQueueHead(ehci_qh *queueHead, uint8 interval) +{ + if (!Lock()) + return B_ERROR; + + // this should not happen + if (interval < 1) + interval = 1; + + // this may happen as intervals can go up to 16; we limit the value to + // 10 as you cannot support intervals above that with a frame list of + // just 1024 entries... + if (interval > 10) + interval = 10; + + ehci_qh *interruptQueue = &fInterruptEntries[interval - 1].queue_head; + queueHead->next_log = interruptQueue->next_log; + queueHead->next_phy = interruptQueue->next_phy; + queueHead->prev_log = interruptQueue; + interruptQueue->next_log = queueHead; + interruptQueue->next_phy = queueHead->this_phy | EHCI_QH_TYPE_QH; + + Unlock(); + return B_OK; +} + + +status_t EHCI::UnlinkQueueHead(ehci_qh *queueHead, ehci_qh **freeListHead) { if (!Lock()) @@ -1220,7 +1360,6 @@ prevHead->next_log = queueHead->next_log; nextHead->prev_log = queueHead->prev_log; queueHead->next_phy = fAsyncQueueHead->this_phy | EHCI_QH_TYPE_QH; - queueHead->next_log = NULL; queueHead->prev_log = NULL; queueHead->next_log = *freeListHead; Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h 2007-11-17 23:46:01 UTC (rev 22941) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h 2007-11-18 01:05:39 UTC (rev 22942) @@ -76,9 +76,13 @@ // Queue Head functions ehci_qh *CreateQueueHead(); + status_t InitQueueHead(ehci_qh *queueHead, + Pipe *pipe); void FreeQueueHead(ehci_qh *queueHead); status_t LinkQueueHead(ehci_qh *queueHead); + status_t LinkInterruptQueueHead(ehci_qh *queueHead, + uint8 interval); status_t UnlinkQueueHead(ehci_qh *queueHead, ehci_qh **freeList); @@ -133,11 +137,12 @@ pci_info *fPCIInfo; Stack *fStack; - // Framelist memory + // Periodic transfer framelist and interrupt entries area_id fPeriodicFrameListArea; addr_t *fPeriodicFrameList; + interrupt_entry *fInterruptEntries; - // Async frame list management + // Async transfer queue management ehci_qh *fAsyncQueueHead; sem_id fAsyncAdvanceSem; Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci_hardware.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci_hardware.h 2007-11-17 23:46:01 UTC (rev 22941) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci_hardware.h 2007-11-18 01:05:39 UTC (rev 22942) @@ -190,6 +190,12 @@ } ehci_qh; +typedef struct { + ehci_qh queue_head; + uint32 padding[2]; +} interrupt_entry; + + // Applies to ehci_qh.link_phy #define EHCI_QH_TYPE_ITD (0 << 1) #define EHCI_QH_TYPE_QH (1 << 1) From mmlr at mail.berlios.de Sun Nov 18 02:25:07 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 18 Nov 2007 02:25:07 +0100 Subject: [Haiku-commits] r22943 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711180125.lAI1P7oQ027851@sheep.berlios.de> Author: mmlr Date: 2007-11-18 02:25:04 +0100 (Sun, 18 Nov 2007) New Revision: 22943 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22943&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h Log: * Removed the two extra submit functions and combined them directly into SubmitTransfer() * The sparation based on async and periodic schedule made no sense as it is a question of queued/non-queued * Therefore removed the near complete code duplication for adding interrupt transfers (that are also queued) Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-18 01:05:39 UTC (rev 22942) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-18 01:25:04 UTC (rev 22943) @@ -410,34 +410,18 @@ if (transfer->TransferPipe()->DeviceAddress() == fRootHubAddress) return fRootHub->ProcessTransfer(this, transfer); - uint32 type = transfer->TransferPipe()->Type(); - if ((type & USB_OBJECT_CONTROL_PIPE) > 0 - || (type & USB_OBJECT_BULK_PIPE) > 0) { - TRACE(("usb_ehci: submitting async transfer\n")); - return SubmitAsyncTransfer(transfer); + Pipe *pipe = transfer->TransferPipe(); + if (pipe->Type() & USB_OBJECT_ISO_PIPE) { + // ToDo: implement isochronous transfers... + return B_ERROR; } - if ((type & USB_OBJECT_INTERRUPT_PIPE) > 0 - || (type & USB_OBJECT_ISO_PIPE) > 0) { - TRACE(("usb_ehci: submitting periodic transfer\n")); - return SubmitPeriodicTransfer(transfer); - } - - TRACE_ERROR(("usb_ehci: tried to submit transfer for unknown pipe type %lu\n", type)); - return B_ERROR; -} - - -status_t -EHCI::SubmitAsyncTransfer(Transfer *transfer) -{ ehci_qh *queueHead = CreateQueueHead(); if (!queueHead) { - TRACE_ERROR(("usb_ehci: failed to allocate async queue head\n")); + TRACE_ERROR(("usb_ehci: failed to allocate queue head\n")); return B_NO_MEMORY; } - Pipe *pipe = transfer->TransferPipe(); status_t result = InitQueueHead(queueHead, pipe); if (result < B_OK) { TRACE_ERROR(("usb_ehci: failed to init queue head\n")); @@ -447,12 +431,13 @@ bool directionIn; ehci_qtd *dataDescriptor; - if (pipe->Type() & USB_OBJECT_CONTROL_PIPE) + if (pipe->Type() & USB_OBJECT_CONTROL_PIPE) { result = FillQueueWithRequest(transfer, queueHead, &dataDescriptor, &directionIn); - else + } else { result = FillQueueWithData(transfer, queueHead, &dataDescriptor, &directionIn); + } if (result < B_OK) { TRACE_ERROR(("usb_ehci: failed to fill transfer queue with data\n")); @@ -472,68 +457,18 @@ print_queue(queueHead); #endif - result = LinkQueueHead(queueHead); - if (result < B_OK) { - TRACE_ERROR(("usb_ehci: failed to link queue head to the async list\n")); - FreeQueueHead(queueHead); - return result; - } + if (pipe->Type() & USB_OBJECT_INTERRUPT_PIPE) { + uint8 interval = ((InterruptPipe *)pipe)->Interval(); + result = LinkInterruptQueueHead(queueHead, interval); + } else + result = LinkQueueHead(queueHead); - return B_OK; -} - - -status_t -EHCI::SubmitPeriodicTransfer(Transfer *transfer) -{ - Pipe *pipe = transfer->TransferPipe(); - if ((pipe->Type() & USB_OBJECT_INTERRUPT_PIPE) == 0) - return B_ERROR; - - ehci_qh *queueHead = CreateQueueHead(); - if (!queueHead) { - TRACE_ERROR(("usb_ehci: failed to allocate periodic queue head\n")); - return B_NO_MEMORY; - } - - status_t result = InitQueueHead(queueHead, pipe); if (result < B_OK) { - TRACE_ERROR(("usb_ehci: failed to init queue head\n")); + TRACE_ERROR(("usb_ehci: failed to link queue head\n")); FreeQueueHead(queueHead); return result; } - bool directionIn; - ehci_qtd *dataDescriptor; - result = FillQueueWithData(transfer, queueHead, &dataDescriptor, - &directionIn); - - if (result < B_OK) { - TRACE_ERROR(("usb_ehci: failed to fill transfer queue with data\n")); - FreeQueueHead(queueHead); - return result; - } - - result = AddPendingTransfer(transfer, queueHead, dataDescriptor, directionIn); - if (result < B_OK) { - TRACE_ERROR(("usb_ehci: failed to add pending transfer\n")); - FreeQueueHead(queueHead); - return result; - } - -#ifdef TRACE_USB - TRACE(("usb_ehci: linking interrupt queue\n")); - print_queue(queueHead); -#endif - - result = LinkInterruptQueueHead(queueHead, - ((InterruptPipe *)pipe)->Interval()); - if (result < B_OK) { - TRACE_ERROR(("usb_ehci: failed to link queue head to the async list\n")); - FreeQueueHead(queueHead); - return result; - } - return B_OK; } Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h 2007-11-18 01:05:39 UTC (rev 22942) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.h 2007-11-18 01:25:04 UTC (rev 22943) @@ -35,8 +35,6 @@ status_t Start(); virtual status_t SubmitTransfer(Transfer *transfer); - status_t SubmitPeriodicTransfer(Transfer *transfer); - status_t SubmitAsyncTransfer(Transfer *transfer); virtual status_t CancelQueuedTransfers(Pipe *pipe, bool force); virtual status_t NotifyPipeChange(Pipe *pipe, From axeld at mail.berlios.de Sun Nov 18 12:57:36 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 18 Nov 2007 12:57:36 +0100 Subject: [Haiku-commits] r22944 - haiku/trunk/src/system/kernel Message-ID: <200711181157.lAIBvaCT017308@sheep.berlios.de> Author: axeld Date: 2007-11-18 12:57:35 +0100 (Sun, 18 Nov 2007) New Revision: 22944 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22944&view=rev Modified: haiku/trunk/src/system/kernel/team.cpp Log: The KDL command "teams" now also prints the team ID in decimal rather than hex. Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2007-11-18 01:25:04 UTC (rev 22943) +++ haiku/trunk/src/system/kernel/team.cpp 2007-11-18 11:57:35 UTC (rev 22944) @@ -155,11 +155,11 @@ struct hash_iterator iterator; struct team *team; - kprintf("team id parent name\n"); + kprintf("team id parent name\n"); hash_open(sTeamHash, &iterator); while ((team = (struct team*)hash_next(sTeamHash, &iterator)) != NULL) { - kprintf("%p%6lx %p %s\n", team, team->id, team->parent, team->name); + kprintf("%p%7ld %p %s\n", team, team->id, team->parent, team->name); } hash_close(sTeamHash, &iterator, false); From axeld at mail.berlios.de Sun Nov 18 12:59:54 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 18 Nov 2007 12:59:54 +0100 Subject: [Haiku-commits] r22945 - haiku/trunk/src/system/kernel Message-ID: <200711181159.lAIBxsIs019736@sheep.berlios.de> Author: axeld Date: 2007-11-18 12:59:53 +0100 (Sun, 18 Nov 2007) New Revision: 22945 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22945&view=rev Modified: haiku/trunk/src/system/kernel/thread.cpp Log: * Fixed a bug reported by Ryan: the stack_end pointer of a thread was reported one too low in comparison with BeOS (ie. the end pointer was inclusive, now it's exclusive). * Moved static functions fill_thread_info(), and {send|receive}_data_etc() to the private function section. Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2007-11-18 11:57:35 UTC (rev 22944) +++ haiku/trunk/src/system/kernel/thread.cpp 2007-11-18 11:59:53 UTC (rev 22945) @@ -63,9 +63,6 @@ thread_id id; }; -static status_t receive_data_etc(thread_id *_sender, void *buffer, - size_t bufferSize, int32 flags); - // global spinlock thread_spinlock = 0; @@ -655,6 +652,152 @@ } +/*! + Fills the thread_info structure with information from the specified + thread. + The thread lock must be held when called. +*/ +static void +fill_thread_info(struct thread *thread, thread_info *info, size_t size) +{ + info->thread = thread->id; + info->team = thread->team->id; + + strlcpy(info->name, thread->name, B_OS_NAME_LENGTH); + + if (thread->state == B_THREAD_WAITING) { + if (thread->sem.blocking == sSnoozeSem) + info->state = B_THREAD_ASLEEP; + else if (thread->sem.blocking == thread->msg.read_sem) + info->state = B_THREAD_RECEIVING; + else + info->state = B_THREAD_WAITING; + } else + info->state = (thread_state)thread->state; + + info->priority = thread->priority; + info->sem = thread->sem.blocking; + info->user_time = thread->user_time; + info->kernel_time = thread->kernel_time; + info->stack_base = (void *)thread->user_stack_base; + info->stack_end = (void *)(thread->user_stack_base + + thread->user_stack_size); +} + + +static status_t +send_data_etc(thread_id id, int32 code, const void *buffer, + size_t bufferSize, int32 flags) +{ + struct thread *target; + sem_id cachedSem; + cpu_status state; + status_t status; + cbuf *data; + + state = disable_interrupts(); + GRAB_THREAD_LOCK(); + target = thread_get_thread_struct_locked(id); + if (!target) { + RELEASE_THREAD_LOCK(); + restore_interrupts(state); + return B_BAD_THREAD_ID; + } + cachedSem = target->msg.write_sem; + RELEASE_THREAD_LOCK(); + restore_interrupts(state); + + if (bufferSize > THREAD_MAX_MESSAGE_SIZE) + return B_NO_MEMORY; + + status = acquire_sem_etc(cachedSem, 1, flags, 0); + if (status == B_INTERRUPTED) { + // We got interrupted by a signal + return status; + } + if (status != B_OK) { + // Any other acquisition problems may be due to thread deletion + return B_BAD_THREAD_ID; + } + + if (bufferSize > 0) { + data = cbuf_get_chain(bufferSize); + if (data == NULL) + return B_NO_MEMORY; + status = cbuf_user_memcpy_to_chain(data, 0, buffer, bufferSize); + if (status < B_OK) { + cbuf_free_chain(data); + return B_NO_MEMORY; + } + } else + data = NULL; + + state = disable_interrupts(); + GRAB_THREAD_LOCK(); + + // The target thread could have been deleted at this point + target = thread_get_thread_struct_locked(id); + if (target == NULL) { + RELEASE_THREAD_LOCK(); + restore_interrupts(state); + cbuf_free_chain(data); + return B_BAD_THREAD_ID; + } + + // Save message informations + target->msg.sender = thread_get_current_thread()->id; + target->msg.code = code; + target->msg.size = bufferSize; + target->msg.buffer = data; + cachedSem = target->msg.read_sem; + + RELEASE_THREAD_LOCK(); + restore_interrupts(state); + + release_sem(cachedSem); + return B_OK; +} + + +static int32 +receive_data_etc(thread_id *_sender, void *buffer, size_t bufferSize, + int32 flags) +{ + struct thread *thread = thread_get_current_thread(); + status_t status; + size_t size; + int32 code; + + status = acquire_sem_etc(thread->msg.read_sem, 1, flags, 0); + if (status < B_OK) { + // Actually, we're not supposed to return error codes + // but since the only reason this can fail is that we + // were killed, it's probably okay to do so (but also + // meaningless). + return status; + } + + if (buffer != NULL && bufferSize != 0) { + size = min_c(bufferSize, thread->msg.size); + status = cbuf_user_memcpy_from_chain(buffer, thread->msg.buffer, + 0, size); + if (status < B_OK) { + cbuf_free_chain(thread->msg.buffer); + release_sem(thread->msg.write_sem); + return status; + } + } + + *_sender = thread->msg.sender; + code = thread->msg.code; + + cbuf_free_chain(thread->msg.buffer); + release_sem(thread->msg.write_sem); + + return code; +} + + // #pragma mark - debugger calls @@ -1789,80 +1932,6 @@ } -static status_t -send_data_etc(thread_id id, int32 code, const void *buffer, - size_t bufferSize, int32 flags) -{ - struct thread *target; - sem_id cachedSem; - cpu_status state; - status_t status; - cbuf *data; - - state = disable_interrupts(); - GRAB_THREAD_LOCK(); - target = thread_get_thread_struct_locked(id); - if (!target) { - RELEASE_THREAD_LOCK(); - restore_interrupts(state); - return B_BAD_THREAD_ID; - } - cachedSem = target->msg.write_sem; - RELEASE_THREAD_LOCK(); - restore_interrupts(state); - - if (bufferSize > THREAD_MAX_MESSAGE_SIZE) - return B_NO_MEMORY; - - status = acquire_sem_etc(cachedSem, 1, flags, 0); - if (status == B_INTERRUPTED) { - // We got interrupted by a signal - return status; - } - if (status != B_OK) { - // Any other acquisition problems may be due to thread deletion - return B_BAD_THREAD_ID; - } - - if (bufferSize > 0) { - data = cbuf_get_chain(bufferSize); - if (data == NULL) - return B_NO_MEMORY; - status = cbuf_user_memcpy_to_chain(data, 0, buffer, bufferSize); - if (status < B_OK) { - cbuf_free_chain(data); - return B_NO_MEMORY; - } - } else - data = NULL; - - state = disable_interrupts(); - GRAB_THREAD_LOCK(); - - // The target thread could have been deleted at this point - target = thread_get_thread_struct_locked(id); - if (target == NULL) { - RELEASE_THREAD_LOCK(); - restore_interrupts(state); - cbuf_free_chain(data); - return B_BAD_THREAD_ID; - } - - // Save message informations - target->msg.sender = thread_get_current_thread()->id; - target->msg.code = code; - target->msg.size = bufferSize; - target->msg.buffer = data; - cachedSem = target->msg.read_sem; - - RELEASE_THREAD_LOCK(); - restore_interrupts(state); - - release_sem(cachedSem); - return B_OK; -} - - status_t send_data(thread_id thread, int32 code, const void *buffer, size_t bufferSize) { @@ -1870,45 +1939,6 @@ } -static int32 -receive_data_etc(thread_id *_sender, void *buffer, size_t bufferSize, - int32 flags) -{ - struct thread *thread = thread_get_current_thread(); - status_t status; - size_t size; - int32 code; - - status = acquire_sem_etc(thread->msg.read_sem, 1, flags, 0); - if (status < B_OK) { - // Actually, we're not supposed to return error codes - // but since the only reason this can fail is that we - // were killed, it's probably okay to do so (but also - // meaningless). - return status; - } - - if (buffer != NULL && bufferSize != 0) { - size = min_c(bufferSize, thread->msg.size); - status = cbuf_user_memcpy_from_chain(buffer, thread->msg.buffer, - 0, size); - if (status < B_OK) { - cbuf_free_chain(thread->msg.buffer); - release_sem(thread->msg.write_sem); - return status; - } - } - - *_sender = thread->msg.sender; - code = thread->msg.code; - - cbuf_free_chain(thread->msg.buffer); - release_sem(thread->msg.write_sem); - - return code; -} - - int32 receive_data(thread_id *sender, void *buffer, size_t bufferSize) { @@ -1929,39 +1959,6 @@ } -/*! - Fills the thread_info structure with information from the specified - thread. - The thread lock must be held when called. -*/ -static void -fill_thread_info(struct thread *thread, thread_info *info, size_t size) -{ - info->thread = thread->id; - info->team = thread->team->id; - - strlcpy(info->name, thread->name, B_OS_NAME_LENGTH); - - if (thread->state == B_THREAD_WAITING) { - if (thread->sem.blocking == sSnoozeSem) - info->state = B_THREAD_ASLEEP; - else if (thread->sem.blocking == thread->msg.read_sem) - info->state = B_THREAD_RECEIVING; - else - info->state = B_THREAD_WAITING; - } else - info->state = (thread_state)thread->state; - - info->priority = thread->priority; - info->sem = thread->sem.blocking; - info->user_time = thread->user_time; - info->kernel_time = thread->kernel_time; - info->stack_base = (void *)thread->user_stack_base; - info->stack_end = (void *)(thread->user_stack_base - + thread->user_stack_size - 1); -} - - status_t _get_thread_info(thread_id id, thread_info *info, size_t size) { From bonefish at mail.berlios.de Sun Nov 18 16:10:37 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 18 Nov 2007 16:10:37 +0100 Subject: [Haiku-commits] r22946 - in haiku/trunk/src/build: libbe libroot Message-ID: <200711181510.lAIFAaVe009693@sheep.berlios.de> Author: bonefish Date: 2007-11-18 16:10:36 +0100 (Sun, 18 Nov 2007) New Revision: 22946 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22946&view=rev Modified: haiku/trunk/src/build/libbe/Jamfile haiku/trunk/src/build/libroot/Jamfile Log: Link libroot_build.so and libbe_build.so against the C++ runtime. Should fix build problems on MacOS X. Modified: haiku/trunk/src/build/libbe/Jamfile =================================================================== --- haiku/trunk/src/build/libbe/Jamfile 2007-11-18 11:59:53 UTC (rev 22945) +++ haiku/trunk/src/build/libbe/Jamfile 2007-11-18 15:10:36 UTC (rev 22946) @@ -13,7 +13,7 @@ storage_kit.o support_kit.o - $(HOST_LIBSTDC++) + $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ; SubInclude HAIKU_TOP src build libbe app ; Modified: haiku/trunk/src/build/libroot/Jamfile =================================================================== --- haiku/trunk/src/build/libroot/Jamfile 2007-11-18 11:59:53 UTC (rev 22945) +++ haiku/trunk/src/build/libroot/Jamfile 2007-11-18 15:10:36 UTC (rev 22946) @@ -42,7 +42,7 @@ strnlen.c : - $(HOST_LIBSTDC++) + $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ; SEARCH on [ FGristFiles $(strlSources) strnlen.c ] From bonefish at mail.berlios.de Sun Nov 18 17:39:19 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 18 Nov 2007 17:39:19 +0100 Subject: [Haiku-commits] r22947 - in haiku/trunk: headers/posix src/system/libroot/posix/signal Message-ID: <200711181639.lAIGdJfh015250@sheep.berlios.de> Author: bonefish Date: 2007-11-18 17:39:18 +0100 (Sun, 18 Nov 2007) New Revision: 22947 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22947&view=rev Added: haiku/trunk/src/system/libroot/posix/signal/set_signal_disposition.cpp Modified: haiku/trunk/headers/posix/signal.h haiku/trunk/src/system/libroot/posix/signal/Jamfile Log: Patch by Vasilis Kaoutsis (modified by myself): Implemented sigset(). Modified: haiku/trunk/headers/posix/signal.h =================================================================== --- haiku/trunk/headers/posix/signal.h 2007-11-18 15:10:36 UTC (rev 22946) +++ haiku/trunk/headers/posix/signal.h 2007-11-18 16:39:18 UTC (rev 22947) @@ -147,6 +147,7 @@ #endif sighandler_t signal(int sig, sighandler_t signalHandler); +sighandler_t sigset(int sig, sighandler_t signalHandler); int raise(int sig); int kill(pid_t pid, int sig); int send_signal(pid_t tid, unsigned int sig); Modified: haiku/trunk/src/system/libroot/posix/signal/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/signal/Jamfile 2007-11-18 15:10:36 UTC (rev 22946) +++ haiku/trunk/src/system/libroot/posix/signal/Jamfile 2007-11-18 16:39:18 UTC (rev 22947) @@ -7,6 +7,7 @@ killpg.cpp raise.c send_signal.c + set_signal_disposition.cpp set_signal_stack.c sigaction.c sigaltstack.c Added: haiku/trunk/src/system/libroot/posix/signal/set_signal_disposition.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/signal/set_signal_disposition.cpp 2007-11-18 15:10:36 UTC (rev 22946) +++ haiku/trunk/src/system/libroot/posix/signal/set_signal_disposition.cpp 2007-11-18 16:39:18 UTC (rev 22947) @@ -0,0 +1,49 @@ +/* + * Copyright 2007, Vasilis Kaoutsis, kaoutsis at sch.gr + * Distributed under the terms of the MIT License. + */ + + +#include + + +sighandler_t +sigset(int signal, sighandler_t signalHandler) +{ + struct sigaction newAction; + struct sigaction oldAction; + + newAction.sa_handler = signalHandler; + newAction.sa_flags = 0; + if (signal == SIGCHLD && signalHandler == SIG_IGN) { + // In case of SIGCHLD the specification requires SA_NOCLDWAIT behavior. + newAction.sa_flags |= SA_NOCLDWAIT; + } + + sigemptyset(&newAction.sa_mask); + if (sigaction(signal, signalHandler == SIG_HOLD ? NULL : &newAction, + &oldAction) == -1) { + return SIG_ERR; + } + + sigset_t newSet; + sigset_t oldSet; + + sigemptyset(&newSet); + sigaddset(&newSet, signal); + + if (signalHandler == SIG_HOLD) { + if (sigprocmask(SIG_BLOCK, &newSet, &oldSet) == -1) + return SIG_ERR; + } else { + // Disposition is not equal to SIG_HOLD, so sig will be + // removed from the calling process' signal mask. + if (sigprocmask(SIG_UNBLOCK, &newSet, &oldSet) == -1) + return SIG_ERR; + } + + if (sigismember(&oldSet, signal)) + return SIG_HOLD; + else + return oldAction.sa_handler; +} From bonefish at mail.berlios.de Sun Nov 18 17:44:51 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 18 Nov 2007 17:44:51 +0100 Subject: [Haiku-commits] r22948 - in haiku/trunk/src/tests/system/libroot/posix/posixtestsuite: . conformance/interfaces conformance/interfaces/difftime conformance/interfaces/fork conformance/interfaces/kill conformance/interfaces/sighold conformance/interfaces/sigignore conformance/interfaces/signal conformance/interfaces/sigprocmask conformance/interfaces/sigrelse conformance/interfaces/sigset conformance/interfaces/sigsuspend Message-ID: <200711181644.lAIGipKE015645@sheep.berlios.de> Author: bonefish Date: 2007-11-18 17:44:49 +0100 (Sun, 18 Nov 2007) New Revision: 22948 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22948&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/10-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/3-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/4-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/5-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/6-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/7-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/8-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/9-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/Jamfile Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/difftime/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/12-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/3-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/4-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/6-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/8-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/9-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/kill/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/3-core-buildonly.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/4-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/5-core-buildonly.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-2.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/3-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/5-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/12-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-2.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-3.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/3-core-buildonly.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigsuspend/6-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh Log: Patch by Vasilis Kaoutsis: * Added sigset() tests to the posix test suite (changes by me: fixed tests 5, 6, and 7). * Modified output to include the name of the test. Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-11-18 16:44:49 UTC (rev 22948) @@ -12,4 +12,5 @@ SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigprocmask ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigrelse ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces signal ; +SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigset ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigsuspend ; Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/difftime/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/difftime/1-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/difftime/1-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -33,7 +33,7 @@ return PTS_FAIL; } - printf("Test PASSED\n"); + printf("difftime_1-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/12-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/12-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/12-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -277,7 +277,7 @@ /* Test passed */ #if VERBOSE > 0 - output( "Test passed\n" ); + output( "fork_12-1: Test PASSED\n" ); #endif Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/3-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/3-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/3-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -125,7 +125,7 @@ /* Test passed */ #if VERBOSE > 0 - output("Test passed\n"); + output("fork_3-1: Test PASSED\n"); #endif PASSED; Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/4-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/4-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/4-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -118,7 +118,7 @@ /* Test passed */ #if VERBOSE > 0 - output("Test passed\n"); + output("fork_4-1: Test PASSED\n"); #endif PASSED; Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/6-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/6-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/6-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -189,7 +189,7 @@ /* Test passed */ #if VERBOSE > 0 - output( "Test passed\n" ); + output( "fork_6-1: Test PASSED\n" ); #endif Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/8-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/8-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/8-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -226,7 +226,7 @@ /* Test passed */ #if VERBOSE > 0 - output( "Test passed\n" ); + output( "fork_8-1: Test PASSED\n" ); #endif Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/9-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/9-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/fork/9-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -143,7 +143,7 @@ /* Test passed */ #if VERBOSE > 0 - output( "Test passed\n" ); + output( "fork_9-1: Test PASSED\n" ); #endif Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/kill/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/kill/2-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/kill/2-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -24,7 +24,7 @@ return PTS_FAIL; } - printf("Test PASSED\n"); + printf("kill_2-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/1-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/1-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -58,7 +58,7 @@ return PTS_FAIL; } - printf("sighold(): Test PASSED: signal was blocked\n"); + printf("sighold_1-1: Test PASSED: signal was blocked\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/2-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/2-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -22,6 +22,6 @@ perror("sighold failed -- returned -- test aborted"); return PTS_UNRESOLVED; } - printf("sighold passed\n"); + printf("sighold_2-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/3-core-buildonly.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/3-core-buildonly.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sighold/3-core-buildonly.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -74,8 +74,8 @@ if (TEST_RETURN == -1) { if (EINVAL == errno) { - printf ("errno set to EINVAL\n"); - printf("sighold(): Test passed\n"); + printf ("sighold_3-core-buildonly %s: successfully set errno to EINVAL\n", argv[1]); + printf("sighold_3-core-buildonly %s: Test PASSED\n", argv[1]); return PTS_PASS; } else { printf ("errno not set to EINVAL\n"); Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/1-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/1-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -51,7 +51,7 @@ printf("FAIL: Signal was not ignored\n"); return PTS_FAIL; } - printf("PASS\n"); + printf("sigignore_1-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/4-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/4-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/4-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -22,6 +22,6 @@ perror("sigignore failed -- returned -- test aborted"); return PTS_UNRESOLVED; } - printf("sigignore passed\n"); + printf("sigignore_4-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/5-core-buildonly.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/5-core-buildonly.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/5-core-buildonly.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -53,7 +53,8 @@ if (sigignore(signo) == -1) { if (EINVAL == errno) { - printf ("errno set to EINVAL\n"); + printf ("sigignore_5-core-buildonly %s: successfully set errno to EINVAL\n", argv[1]); + printf("sigignore_5-core-buildonly %s: Test PASSED\n", argv[1]); return PTS_PASS; } else { printf ("errno not set to EINVAL\n"); Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -23,7 +23,8 @@ { if (sigignore(SIGKILL) == -1) { if (EINVAL == errno) { - printf ("errno set to EINVAL\n"); + printf ("sigignore_6-1: successfully set errno to EINVAL\n"); + printf("sigignore_6-1: Test PASSED\n"); return PTS_PASS; } else { printf ("errno not set to EINVAL\n"); Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-2.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-2.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigignore/6-2.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -23,7 +23,8 @@ { if (sigignore(SIGSTOP) == -1) { if (EINVAL == errno) { - printf ("errno set to EINVAL\n"); + printf ("sigignore_6-2: successfully set errno to EINVAL\n"); + printf("sigignore_6-2: Test PASSED\n"); return PTS_PASS; } else { printf ("errno not set to EINVAL\n"); Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/1-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/1-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -26,7 +26,7 @@ void myhandler(int signo) { - printf("SIGCHLD called. Inside handler\n"); + printf("signal_1-1: SIGCHLD called. Inside handler\n"); handler_called = 1; } @@ -48,6 +48,6 @@ printf("Test FAILED: handler was called even though default was expected\n"); return PTS_FAIL; } - printf("signal(): Test passed\n"); + printf("signal_1-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/2-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/2-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -25,7 +25,7 @@ void myhandler(int signo) { - printf("SIGCHLD called. Inside handler\n"); + printf("signal_2-1: SIGCHLD called. Inside handler\n"); handler_called = 1; } @@ -47,6 +47,6 @@ printf("Test FAILED: handler was called even though default was expected\n"); return PTS_FAIL; } - printf("signal(): Test passed\n"); + printf("signal_2-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/3-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/3-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/3-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -23,7 +23,7 @@ void myhandler(int signo) { - printf("SIGCHLD called. Inside handler\n"); + printf("signal_3-1: SIGCHLD called. Inside handler\n"); handler_called = 1; } @@ -40,6 +40,6 @@ printf("Test FAILED: handler was called even though default was expected\n"); return PTS_FAIL; } - printf("signal(): Test passed\n"); + printf("signal_3-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/5-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/5-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/5-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -24,12 +24,12 @@ void SIGUSR1_handler(int signo) { - printf("do nothing useful\n"); + printf("signal_5-1: inside SIGUSR1_handler\n"); } void SIGUSR2_handler(int signo) { - printf("do nothing useful\n"); + printf("signal_5-1: inside SIGUSR2_handler\n"); } int main() @@ -48,6 +48,6 @@ printf("signal did not return the last handler that was associated with SIGUSR1\n"); return PTS_FAIL; } - printf("signal(): Test passed\n"); + printf("signal_5-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/6-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -19,7 +19,7 @@ void myhandler(int signo) { - printf("handler does nothing useful.\n"); + printf("signal_6-1: inside handler\n"); } int main() @@ -35,6 +35,6 @@ printf("Test FAILED: errno wasn't set to EINVAL even though invalid signal number was passed to the signal() function\n"); return PTS_FAIL; } - printf("signal(): Test passed\n"); + printf("signal_6-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/signal/7-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -19,7 +19,7 @@ void myhandler(int signo) { - printf("handler does nothing useful.\n"); + printf("signal_7-1: inside handler\n"); } int main() @@ -35,6 +35,6 @@ printf("Test FAILED: errno wasn't set to EINVAL even though a non-catchable signal was passed to the signal() function\n"); return PTS_FAIL; } - printf("signal(): Test passed\n"); + printf("signal_7-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/12-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/12-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/12-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -81,6 +81,6 @@ return PTS_FAIL; } - printf("PASS: signal mask was not changed.\n"); + printf("sigprocmask_12-1: Test PASSED: signal mask was not changed.\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -58,6 +58,6 @@ if (is_changed(oactl, SIGABRT)) { return PTS_FAIL; } - printf("PASS: signal mask was not changed.\n"); + printf("sigprocmask_8-1: Test PASSED: signal mask was not changed.\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-2.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-2.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-2.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -59,6 +59,6 @@ if (is_changed(oactl, SIGABRT)) { return PTS_FAIL; } - printf("PASS: signal mask was not changed.\n"); + printf("sigprocmask_8-2: Test PASSED: signal mask was not changed.\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-3.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-3.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigprocmask/8-3.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -58,6 +58,6 @@ if (is_changed(oactl, SIGABRT)) { return PTS_FAIL; } - printf("PASS: signal mask was not changed.\n"); + printf("sigprocmask_8-3: Test PASSED: signal mask was not changed.\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/1-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/1-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -64,7 +64,7 @@ sleep(1); if (handler_called) { - printf("sigrelse(): Test PASSED: SIGABRT successfully removed from signal mask\n"); + printf("sigrelse_1-1: Test PASSED: SIGABRT successfully removed from signal mask\n"); return PTS_PASS; } printf("FAIL\n"); Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/2-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/2-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -22,6 +22,6 @@ perror("sigrelse failed -- returned -- test aborted"); return PTS_UNRESOLVED; } - printf("sigrelse(): Test PASSED\n"); + printf("sigrelse_2-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/3-core-buildonly.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/3-core-buildonly.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigrelse/3-core-buildonly.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -75,8 +75,8 @@ if (TEST_RETURN == -1) { if (EINVAL == errno) { - printf ("errno set to EINVAL\n"); - printf("sigrelse(): Test PASSED\n"); + printf ("sigrelse_3-core-buildonly %s: successfully set errno to EINVAL\n", argv[1]); + printf("sigrelse_3-core-buildonly %s: Test PASSED\n", argv[1]); return PTS_PASS; } else { printf ("errno not set to EINVAL\n"); Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/1-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/1-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that the default handling of the + signal shall occur if the value of the disp parameter is SIG_DFL. + + How this program tests this assertion by setting up a handler + "myhandler" for SIGCHLD. Then another call to sigset() is made about + SIGCHLD, this time with SIG_DFL as the value of the func parameter. + The default action for SIGCHLD is to be ignored, so unless myhandler + gets called when SIGCHLD is raised, the test passess, otherwise + returns failure. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include "posixtest.h" + +int handler_called = 0; + +void myhandler(int signo) +{ + printf("sigset_1-1: SIGCHLD called. Inside handler\n"); + handler_called = 1; +} + +int main() +{ + + struct sigaction act; + act.sa_handler = myhandler; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + + if (sigaction(SIGCHLD, &act, 0) != 0) { + perror("Unexpected error while using sigaction()"); + return PTS_UNRESOLVED; + } + + if (sigset(SIGCHLD,SIG_DFL) != myhandler) { + perror("Unexpected error while using signal()"); + return PTS_UNRESOLVED; + } + + raise(SIGCHLD); + + if (handler_called == 1) { + printf("Test FAILED: handler was called even though default was expected\n"); + return PTS_FAIL; + } + printf("sigset_1-1: Test PASSED\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/10-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/10-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/10-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that when unsuccessful, SIG_ERROR + shall be returned, and errno set to EINVAL. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include +#include "posixtest.h" + +int main() +{ + if (sigset(SIGKILL,SIG_IGN) == SIG_ERR) { + if (errno != EINVAL) { + printf("Test FAILED: sigset() returned SIG_ERR but didn't set errno to EINVAL\n"); + return PTS_FAIL; + } + } else { + printf("Test FAILED: sigset() didn't return SIG_ERROR even though SIGKILL was passed to it\n"); + return PTS_FAIL; + } + printf("sigset_10-1: Test PASSED\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/2-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/2-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that the signal shall be ignored + if the value of the dist parameter is SIG_IGN. + + How this program tests this assertion is by setting up a handler + "myhandler" for SIGUSR1. Then another call to signal() is made about + SIGUSR1, this time with SIG_IGN as the value of the func parameter. + SIGUSR1 should be ignored now, so unless myhandler gets called when + SIGUSR1 is raised, the test passes, otherwise returns failure. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include "posixtest.h" + +int handler_called = 0; + +void myhandler(int signo) +{ + printf("sigset_2-1: SIGUSR1 called. Inside handler\n"); + handler_called = 1; +} + +int main() +{ + struct sigaction act; + act.sa_flags = 0; + act.sa_handler = myhandler; + sigemptyset(&act.sa_mask); + + if (sigaction(SIGUSR1, &act, 0) != 0) { + perror("Unexpected error while using sigaction()"); + return PTS_UNRESOLVED; + } + + if (sigset(SIGUSR1,SIG_IGN) != myhandler) { + perror("Unexpected error while using signal()"); + return PTS_UNRESOLVED; + } + + raise(SIGUSR1); + + if (handler_called == 1) { + printf("Test FAILED: handler was called even though default was expected\n"); + return PTS_FAIL; + } + printf("sigset_2-1: Test PASSED\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/3-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/3-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/3-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that the function shall be executed + when the signal occurs if the disp parameter is the address of a function. + + How this program tests this assertion is by setting up a handler + "myhandler" for SIGCHLD, and then raising that signal. If the + handler_called variable is anything but 1, then fail, otherwise pass. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include "posixtest.h" + +int handler_called = 0; + +void myhandler(int signo) +{ + printf("sigset_3-1: SIGCHLD called. Inside handler\n"); + handler_called = 1; +} + +int main() +{ + if (sigset(SIGCHLD, myhandler) == SIG_ERR) { + perror("Unexpected error while using sigset()"); + return PTS_UNRESOLVED; + } + + raise(SIGCHLD); + + if (handler_called != 1) { + printf("Test FAILED: handler was called even though default was expected\n"); + return PTS_FAIL; + } + printf("sigset_3-1: Test PASSED\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/4-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/4-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/4-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that the signal will be added to the + signal mask before its handler is executed. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include "posixtest.h" + +int signal_blocked = 0; + +void myhandler(int signo) +{ + sigset_t mask; + printf("sigset_4-1: SIGCHLD called. Inside handler\n"); + sigprocmask(SIG_SETMASK, NULL, &mask); + if(sigismember(&mask, SIGCHLD)) { + signal_blocked = 1; + } +} + +int main() +{ + if (sigset(SIGCHLD, myhandler) == SIG_ERR) { + perror("Unexpected error while using sigset()"); + return PTS_UNRESOLVED; + } + + raise(SIGCHLD); + + if (signal_blocked != 1) { + printf("Test FAILED: handler was called even though default was expected\n"); + return PTS_FAIL; + } + printf("sigset_4-1: Test PASSED\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/5-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/5-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/5-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that the process's signal mask will be + restored to the state that it was in prior to the delivery of the signal + + Steps: + 1. Empty the signal mask + 2. Deliver the signal + 3. When we return from the signal handler, verify that the signal mask + is still empty, otherwise fail. + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include "posixtest.h" + +#define NUMSIGNALS 26 + +int is_empty(sigset_t *set) { + + int i; + int siglist[] = {SIGABRT, SIGALRM, SIGBUS, SIGCHLD, + SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT, + SIGPIPE, SIGQUIT, SIGSEGV, + SIGTERM, SIGTSTP, SIGTTIN, SIGTTOU, + SIGUSR1, SIGUSR2, SIGPOLL, SIGPROF, SIGSYS, + SIGTRAP, SIGURG, SIGVTALRM, SIGXCPU, SIGXFSZ }; + + for (i=0; i +#include +#include +#include "posixtest.h" + + +void myhandler(int signo) +{ + printf("sigset_6-1: SIGCHLD called. Inside handler\n"); +} + +int main() +{ + sigset_t pendingset; + struct sigaction act; + act.sa_handler = myhandler; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + + if (sigaction(SIGCHLD, &act, 0) != 0) { + perror("Unexpected error while using sigaction()"); + return PTS_UNRESOLVED; + } + + if (sigset(SIGCHLD,SIG_HOLD) == SIG_ERR) { + perror("Unexpected error while using sigset()"); + return PTS_UNRESOLVED; + } + + raise(SIGCHLD); + + if (sigpending(&pendingset) == -1) { + printf("Error calling sigpending()\n"); + return PTS_UNRESOLVED; + } + + if (sigismember(&pendingset, SIGCHLD) != 1) { + printf("Test FAILED: Signal SIGCHLD was not successfully blocked\n"); + return PTS_FAIL; + } + printf("sigset_6-1: Test PASSED\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/7-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/7-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/7-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that if disp is SIG_HOLD, then the + signal's disposition shall remain unchanged + + Steps: + 1. Register SIGCHLD with myhandler + 2. Add SIGCHLD to the process's signal mask using sigset with disp + equal to SIG_HOLD + 3. raise SIGCHLD + 4. remove SIGCHLD from the signal mask + 5. Verify that the original disposition hasn't been changed, by making + sure that SIGCHLD is still handled by myhandler. +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include "posixtest.h" + +int handler_called = 0; + +void myhandler(int signo) +{ + printf("sigset_7-1: SIGCHLD called. Inside handler\n"); + handler_called = 1; +} + +int main() +{ + sigset_t pendingset; + struct sigaction act; + act.sa_handler = myhandler; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + + if (sigaction(SIGCHLD, &act, 0) != 0) { + perror("Unexpected error while using sigaction()"); + return PTS_UNRESOLVED; + } + + if (sigset(SIGCHLD,SIG_HOLD) == SIG_ERR) { + perror("Unexpected error while using sigset()"); + return PTS_UNRESOLVED; + } + + raise(SIGCHLD); + + if (sigpending(&pendingset) == -1) { + printf("Error calling sigpending()\n"); + return PTS_UNRESOLVED; + } + + if (sigismember(&pendingset, SIGCHLD) != 1) { + printf("Test UNRESOLVED: Signal SIGCHLD was not successfully blocked\n"); + return PTS_UNRESOLVED; + } + + sigrelse(SIGCHLD); + + if (handler_called != 1) { + printf("Test FAILED: Signal wasn't delivered even though it was removed from the signal mask\n"); + return PTS_FAIL; + } + printf("sigset_7-1: Test PASSED\n"); + return PTS_PASS; +} Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/8-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/8-1.c 2007-11-18 16:39:18 UTC (rev 22947) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/sigset/8-1.c 2007-11-18 16:44:49 UTC (rev 22948) @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003, Intel Corporation. All rights reserved. + * Created by: salwan.searty REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + This program tests the assertion that if signal has been blocked, then + sigset shall return SIG_HOLD + +*/ + +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include "posixtest.h" + +int main() [... truncated: 126 lines follow ...] From leavengood at mail.berlios.de Sun Nov 18 17:54:49 2007 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Sun, 18 Nov 2007 17:54:49 +0100 Subject: [Haiku-commits] r22949 - haiku/trunk/headers/posix Message-ID: <200711181654.lAIGsnT8016297@sheep.berlios.de> Author: leavengood Date: 2007-11-18 17:54:48 +0100 (Sun, 18 Nov 2007) New Revision: 22949 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22949&view=rev Modified: haiku/trunk/headers/posix/math.h Log: Added trunc to the math headers. I need this for JavaScriptCore. It is already defined in libroot. Modified: haiku/trunk/headers/posix/math.h =================================================================== --- haiku/trunk/headers/posix/math.h 2007-11-18 16:44:49 UTC (rev 22948) +++ haiku/trunk/headers/posix/math.h 2007-11-18 16:54:48 UTC (rev 22949) @@ -138,6 +138,7 @@ extern double sqrt(double x); extern double tan(double x); extern double tanh(double x); +extern double trunc(double x); /* long double math functions */ extern long double roundl(long double x); From ingo_weinhold at gmx.de Sun Nov 18 18:20:38 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 18 Nov 2007 18:20:38 +0100 Subject: [Haiku-commits] r22940 - haiku/trunk/build/scripts In-Reply-To: <200711172226.lAHMQIxN030965@sheep.berlios.de> References: <200711172226.lAHMQIxN030965@sheep.berlios.de> Message-ID: <20071118182038.7402.3@knochen-vm.nameserver> On 2007-11-17 at 23:26:18 [+0100], mmu_man at BerliOS wrote: > Author: mmu_man > Date: 2007-11-17 23:26:17 +0100 (Sat, 17 Nov 2007) > New Revision: 22940 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22940&view=rev > > Modified: > haiku/trunk/build/scripts/build_haiku_image > Log: > Finally got a fix for attribute errors when building on linux without xattr. > After copying the mime db or packages the files were removed, but not the > corresponding attribute storage files. > So when an inode got reused the file inherited those leftover attributes. > We now remove them before removing the files. > > > Modified: haiku/trunk/build/scripts/build_haiku_image > =================================================================== > --- haiku/trunk/build/scripts/build_haiku_image 2007-11-17 20:48:50 UTC > (rev 22939) > +++ haiku/trunk/build/scripts/build_haiku_image 2007-11-17 22:26:17 UTC > (rev 22940) > @@ -56,6 +56,15 @@ > fi > > > +# attribute-safe rm -rf > +# This makes sure there are no leftover attribute file before removing > each file > +attrrmrf() > +{ > + test -e "$1" || return > + find "$1" -print0 | xargs -0 stat -c %i | awk "{ print > \"$outputDir/attributes/\" \$1 }" | xargs rm -rf > + rm -rf "$1" > +} > + > unzipFile() > { > # unzipFile > @@ -66,13 +75,13 @@ > > if [ $isImage ]; then > unzipDir=$tmpDir/unzip > - rm -rf $unzipDir > + attrrmrf $unzipDir > mkdir -p $unzipDir > > $unzip -q -d $unzipDir $zipFile > $cp -r ${sPrefix}$unzipDir/. ${tPrefix}$targetUnzipDir > > - rm -rf $unzipDir > + attrrmrf $unzipDir > else > $unzip -q -d ${tPrefix}$targetUnzipDir ${sPrefix}$zipFile > fi > @@ -158,7 +167,7 @@ > done > > # cleanup tmp dir > - rm -rf $mimeTmpDir > + attrrmrf $mimeTmpDir > fi # ! updateOnly I'd prefer, if that would be conditional (i.e. check once, if there is an attribute directory in the first place and only then use the attrrmrf function). There's no need to punish people using BeOS or Linux with xattr support by invoking an unnecessary "rm" for every file to be removed. CU, Ingo From revol at free.fr Sun Nov 18 18:30:36 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 18 Nov 2007 18:30:36 +0100 CET Subject: [Haiku-commits] r22940 - haiku/trunk/build/scripts In-Reply-To: <20071118182038.7402.3@knochen-vm.nameserver> Message-ID: <387934728-BeMail@laptop> > > Log: > > Finally got a fix for attribute errors when building on linux > > without xattr. > > After copying the mime db or packages the files were removed, but > > not the > > corresponding attribute storage files. > > So when an inode got reused the file inherited those leftover > > attributes. > > We now remove them before removing the files. > > I'd prefer, if that would be conditional (i.e. check once, if there > is an > attribute directory in the first place and only then use the attrrmrf > function). There's no need to punish people using BeOS or Linux with > xattr > support by invoking an unnecessary "rm" for every file to be removed. > Yes I was thinking about it today, will just skip the find stuff if it's not there. Fran?ois. From bonefish at mail.berlios.de Sun Nov 18 19:41:25 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 18 Nov 2007 19:41:25 +0100 Subject: [Haiku-commits] r22950 - haiku/trunk/src/add-ons/kernel/generic/ide_adapter Message-ID: <200711181841.lAIIfPq9009767@sheep.berlios.de> Author: bonefish Date: 2007-11-18 19:41:24 +0100 (Sun, 18 Nov 2007) New Revision: 22950 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22950&view=rev Modified: haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c Log: Filter PCI_address_space bit out of bus_master_base in ide_adapter_probe_controller(). ide_adapter_detect_controller() does that itself, but ide_adapter_detect_channel() doesn't. Fixes off-by-one bus master status register access. Shouldn't have caused any serious problems, though. Modified: haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c 2007-11-18 16:54:48 UTC (rev 22949) +++ haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c 2007-11-18 18:41:24 UTC (rev 22950) @@ -716,6 +716,8 @@ if (res != B_OK || controller_node == NULL) goto err; + bus_master_base &= ~PCI_address_space; + // ignore errors during registration of channels - could be a simple rescan collision ide_adapter_detect_channel(pci, device, controller_node, channel_module_name, can_dma, command_block_base[0], control_block_base[0], bus_master_base, From marcusoverhagen at arcor.de Mon Nov 19 00:53:12 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Mon, 19 Nov 2007 00:53:12 +0100 (CET) Subject: [Haiku-commits] r22950 - haiku/trunk/src/add-ons/kernel/generic/ide_adapter In-Reply-To: <200711181841.lAIIfPq9009767@sheep.berlios.de> References: <200711181841.lAIIfPq9009767@sheep.berlios.de> Message-ID: <5098531.1195429992854.JavaMail.ngmail@webmail18> Hi Ingo, PCI_address_space is defined as 1, but this bit is always 0 for memory BARs, so thats no issue here. However, other bits may be set, so the save way would be to use bus_master_base &= PCI_address_memory_32_mask; Marcus ----- Original Nachricht ---- Von: bonefish at BerliOS An: haiku-commits at lists.berlios.de Datum: 18.11.2007 19:41 Betreff: [Haiku-commits] r22950 - haiku/trunk/src/add-ons/kernel/generic/ide_adapter > Author: bonefish > Date: 2007-11-18 19:41:24 +0100 (Sun, 18 Nov 2007) > New Revision: 22950 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22950&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c > Log: > Filter PCI_address_space bit out of bus_master_base in > ide_adapter_probe_controller(). ide_adapter_detect_controller() does > that itself, but ide_adapter_detect_channel() doesn't. Fixes off-by-one > bus master status register access. Shouldn't have caused any serious > problems, though. > > > Modified: haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c > =================================================================== > --- haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c > 2007-11-18 16:54:48 UTC (rev 22949) > +++ haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c > 2007-11-18 18:41:24 UTC (rev 22950) > @@ -716,6 +716,8 @@ > if (res != B_OK || controller_node == NULL) > goto err; > > + bus_master_base &= ~PCI_address_space; > + > // ignore errors during registration of channels - could be a simple > rescan collision > ide_adapter_detect_channel(pci, device, controller_node, > channel_module_name, > can_dma, command_block_base[0], control_block_base[0], bus_master_base, > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From mmu_man at mail.berlios.de Mon Nov 19 01:30:01 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Mon, 19 Nov 2007 01:30:01 +0100 Subject: [Haiku-commits] r22951 - haiku/trunk/build/scripts Message-ID: <200711190030.lAJ0U1GH032296@sheep.berlios.de> Author: mmu_man Date: 2007-11-19 01:30:00 +0100 (Mon, 19 Nov 2007) New Revision: 22951 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22951&view=rev Modified: haiku/trunk/build/scripts/build_haiku_image Log: Only remove attribute storage files if generated/attributes/ exists, else skip the slow find. Modified: haiku/trunk/build/scripts/build_haiku_image =================================================================== --- haiku/trunk/build/scripts/build_haiku_image 2007-11-18 18:41:24 UTC (rev 22950) +++ haiku/trunk/build/scripts/build_haiku_image 2007-11-19 00:30:00 UTC (rev 22951) @@ -61,7 +61,9 @@ attrrmrf() { test -e "$1" || return - find "$1" -print0 | xargs -0 stat -c %i | awk "{ print \"$outputDir/attributes/\" \$1 }" | xargs rm -rf + if [ -d "$outputDir/attributes" ]; then + find "$1" -print0 | xargs -0 stat -c %i | awk "{ print \"$outputDir/attributes/\" \$1 }" | xargs rm -rf + fi rm -rf "$1" } From ingo_weinhold at gmx.de Mon Nov 19 01:35:18 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 19 Nov 2007 01:35:18 +0100 Subject: [Haiku-commits] r22950 - haiku/trunk/src/add-ons/kernel/generic/ide_adapter In-Reply-To: <5098531.1195429992854.JavaMail.ngmail@webmail18> References: <200711181841.lAIIfPq9009767@sheep.berlios.de> <5098531.1195429992854.JavaMail.ngmail@webmail18> Message-ID: <20071119013518.338.1@knochen-vm.nameserver> On 2007-11-19 at 00:53:12 [+0100], Marcus Overhagen wrote: > > PCI_address_space is defined as 1, but this bit is always > 0 for memory BARs, so thats no issue here. Not that I know what I'm talking about, but at least under VMware the bit is set (and the ide_adapter code seems to require that), resulting in the "BM-VIDE: Write to unknown VIDE BM-DMA register offset 3" message in the vmware.log. I was hoping this was related to the annoying bug #1176, so I tracked the cause down, but, alas, it isn't. > However, other bits may be set, so the save way > would be to use > > bus_master_base &= PCI_address_memory_32_mask; Interestingly the ide_adapter consequently uses ~PCI_address_space instead of that mask (respectively PCI_address_io_mask). CU, Ingo From axeld at mail.berlios.de Mon Nov 19 10:15:05 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 19 Nov 2007 10:15:05 +0100 Subject: [Haiku-commits] r22952 - haiku/trunk/src/apps/sudoku Message-ID: <200711190915.lAJ9F51u023558@sheep.berlios.de> Author: axeld Date: 2007-11-19 10:15:04 +0100 (Mon, 19 Nov 2007) New Revision: 22952 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22952&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp Log: The "drag&duplicate value" feature was not working reliably when removing hints after a value was set, as fLastField was not updated. Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2007-11-19 00:30:00 UTC (rev 22951) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2007-11-19 09:15:04 UTC (rev 22952) @@ -453,6 +453,7 @@ // allow dragging to remove the hint from other fields fLastHintValueSet = false; fLastHintValue = value; + fLastField = field; } return; } From stippi at mail.berlios.de Mon Nov 19 11:17:52 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 19 Nov 2007 11:17:52 +0100 Subject: [Haiku-commits] r22953 - in haiku/trunk/src/apps/icon-o-matic: . gui import_export/flat_icon Message-ID: <200711191017.lAJAHqiB026649@sheep.berlios.de> Author: stippi Date: 2007-11-19 11:17:52 +0100 (Mon, 19 Nov 2007) New Revision: 22953 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22953&view=rev Added: haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/SourceExporter.cpp haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/SourceExporter.h Modified: haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h haiku/trunk/src/apps/icon-o-matic/Jamfile haiku/trunk/src/apps/icon-o-matic/gui/SavePanel.cpp haiku/trunk/src/apps/icon-o-matic/gui/SavePanel.h Log: * add a new export format to get the vector icon data as C source Modified: haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp 2007-11-19 09:15:04 UTC (rev 22952) +++ haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp 2007-11-19 10:17:52 UTC (rev 22953) @@ -44,6 +44,7 @@ #include "SavePanel.h" #include "ShapeContainer.h" #include "SimpleFileSaver.h" +#include "SourceExporter.h" #include "SVGExporter.h" #include "SVGImporter.h" @@ -532,6 +533,9 @@ case EXPORT_MODE_ICON_RDEF: saver = new SimpleFileSaver(new RDefExporter(), ref); break; + case EXPORT_MODE_ICON_SOURCE: + saver = new SimpleFileSaver(new SourceExporter(), ref); + break; case EXPORT_MODE_BITMAP: saver = new SimpleFileSaver(new BitmapExporter(64), ref); Modified: haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h 2007-11-19 09:15:04 UTC (rev 22952) +++ haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h 2007-11-19 10:17:52 UTC (rev 22953) @@ -40,6 +40,7 @@ EXPORT_MODE_ICON_ATTR, EXPORT_MODE_ICON_MIME_ATTR, EXPORT_MODE_ICON_RDEF, + EXPORT_MODE_ICON_SOURCE, }; typedef enum { Modified: haiku/trunk/src/apps/icon-o-matic/Jamfile =================================================================== --- haiku/trunk/src/apps/icon-o-matic/Jamfile 2007-11-19 09:15:04 UTC (rev 22952) +++ haiku/trunk/src/apps/icon-o-matic/Jamfile 2007-11-19 10:17:52 UTC (rev 22953) @@ -222,6 +222,7 @@ # import_export/flat_icon FlatIconExporter.cpp RDefExporter.cpp + SourceExporter.cpp # import_export/message MessageExporter.cpp Modified: haiku/trunk/src/apps/icon-o-matic/gui/SavePanel.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/SavePanel.cpp 2007-11-19 09:15:04 UTC (rev 22952) +++ haiku/trunk/src/apps/icon-o-matic/gui/SavePanel.cpp 2007-11-19 10:17:52 UTC (rev 22953) @@ -243,6 +243,9 @@ case EXPORT_MODE_ICON_RDEF: fRDefMI->SetMarked(true); break; + case EXPORT_MODE_ICON_SOURCE: + fSourceMI->SetMarked(true); + break; } if (mode != EXPORT_MODE_MESSAGE) @@ -386,6 +389,10 @@ EXPORT_MODE_ICON_RDEF); fFormatM->AddItem(fRDefMI); + fSourceMI = new SaveItem("HVIF Source Code", new BMessage(MSG_FORMAT), + EXPORT_MODE_ICON_SOURCE); + fFormatM->AddItem(fSourceMI); + fFormatM->AddSeparatorItem(); fSVGMI = new SaveItem("SVG", new BMessage(MSG_FORMAT), Modified: haiku/trunk/src/apps/icon-o-matic/gui/SavePanel.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/SavePanel.h 2007-11-19 09:15:04 UTC (rev 22952) +++ haiku/trunk/src/apps/icon-o-matic/gui/SavePanel.h 2007-11-19 10:17:52 UTC (rev 22953) @@ -75,6 +75,7 @@ SaveItem* fNativeMI; SaveItem* fHVIFMI; SaveItem* fRDefMI; + SaveItem* fSourceMI; SaveItem* fSVGMI; SaveItem* fBitmapMI; SaveItem* fBitmapSetMI; Added: haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/SourceExporter.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/SourceExporter.cpp 2007-11-19 09:15:04 UTC (rev 22952) +++ haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/SourceExporter.cpp 2007-11-19 10:17:52 UTC (rev 22953) @@ -0,0 +1,122 @@ +/* + * Copyright 2006-2007, Haiku. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan A?mus + */ + +#include "SourceExporter.h" + +#include + +#include + +// constructor +SourceExporter::SourceExporter() + : FlatIconExporter() +{ +} + +// destructor +SourceExporter::~SourceExporter() +{ +} + +// Export +status_t +SourceExporter::Export(const Icon* icon, BPositionIO* stream) +{ + BMallocIO buffer; + status_t ret = FlatIconExporter::Export(icon, &buffer); + if (ret < B_OK) + return ret; + + return _Export((const uint8*)buffer.Buffer(), buffer.BufferLength(), + stream); +} + +// MIMEType +const char* +SourceExporter::MIMEType() +{ + return "text/x-source-code"; +} + +// #pragma mark - + +// _Export +status_t +SourceExporter::_Export(const uint8* source, size_t sourceSize, + BPositionIO* stream) const +{ + char buffer[2048]; + // write header + sprintf(buffer, "\nconst unsigned char kIconName = {\n"); + size_t size = strlen(buffer); + + ssize_t written = stream->Write(buffer, size); + if (written < 0) + return (status_t)written; + if (written < (ssize_t)size) + return B_ERROR; + + status_t ret = B_OK; + const uint8* b = source; + + // print one line (12 values) + while (sourceSize > 12) { + sprintf(buffer, " 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x" + ", 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x" + ", 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x,\n", + b[0], b[1], b[2], b[3], + b[4], b[5], b[6], b[7], + b[8], b[9], b[10], b[11]); + + size = strlen(buffer); + written = stream->Write(buffer, size); + if (written != (ssize_t)size) { + if (written >= 0) + ret = B_ERROR; + else + ret = (status_t)written; + break; + } + + sourceSize -= 12; + b += 12; + } + // last line (up to 12 values) + if (ret >= B_OK && sourceSize > 0) { + for (size_t i = 0; i < sourceSize; i++) { + if (i == 0) + sprintf(buffer, " 0x%.2x", b[i]); + else + sprintf(buffer, ", 0x%.2x", b[i]); + size = strlen(buffer); + written = stream->Write(buffer, size); + if (written != (ssize_t)size) { + if (written >= 0) + ret = B_ERROR; + else + ret = (status_t)written; + break; + } + } + } + if (ret >= B_OK) { + // finish + sprintf(buffer, "\n};\n"); + size = strlen(buffer); + written = stream->Write(buffer, size); + if (written != (ssize_t)size) { + if (written >= 0) + ret = B_ERROR; + else + ret = (status_t)written; + } + } + + return ret; +} + Added: haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/SourceExporter.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/SourceExporter.h 2007-11-19 09:15:04 UTC (rev 22952) +++ haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/SourceExporter.h 2007-11-19 10:17:52 UTC (rev 22953) @@ -0,0 +1,31 @@ +/* + * Copyright 2006-2007, Haiku. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan A?mus + */ + +#ifndef SOURCE_EXPORTER_H +#define SOURCE_EXPORTER_H + +#include "FlatIconExporter.h" + +class SourceExporter : public FlatIconExporter { + public: + SourceExporter(); + virtual ~SourceExporter(); + + // FlatIconExporter interface + virtual status_t Export(const Icon* icon, + BPositionIO* stream); + + virtual const char* MIMEType(); + + private: + status_t _Export(const uint8* source, + size_t sourceSize, + BPositionIO* stream) const; +}; + +#endif // SOURCE_EXPORTER_H From stippi at mail.berlios.de Mon Nov 19 12:15:05 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 19 Nov 2007 12:15:05 +0100 Subject: [Haiku-commits] r22954 - haiku/trunk/src/apps/mail Message-ID: <200711191115.lAJBF5uW032728@sheep.berlios.de> Author: stippi Date: 2007-11-19 12:15:04 +0100 (Mon, 19 Nov 2007) New Revision: 22954 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22954&view=rev Modified: haiku/trunk/src/apps/mail/MailWindow.cpp Log: * enabled status of "Save As Draft" menu item should now be correctly maintained Modified: haiku/trunk/src/apps/mail/MailWindow.cpp =================================================================== --- haiku/trunk/src/apps/mail/MailWindow.cpp 2007-11-19 10:17:52 UTC (rev 22953) +++ haiku/trunk/src/apps/mail/MailWindow.cpp 2007-11-19 11:15:04 UTC (rev 22954) @@ -833,10 +833,14 @@ BTextView *textView; if (!fIncoming) { - enable = strlen(fHeaderView->fTo->Text()) - || strlen(fHeaderView->fBcc->Text()); - fSendNow->SetEnabled(enable); - fSendLater->SetEnabled(enable); + bool gotToField = fHeaderView->fTo->Text()[0] != 0; + bool gotCcField = fHeaderView->fCc->Text()[0] != 0; + bool gotBccField = fHeaderView->fBcc->Text()[0] != 0; + bool gotSubjectField = fHeaderView->fSubject->Text()[0] != 0; + bool gotText = fContentView->fTextView->Text()[0] != 0; + fSendNow->SetEnabled(gotToField || gotBccField); + fSendLater->SetEnabled(fChanged && (gotToField || gotCcField + || gotBccField || gotSubjectField || gotText)); be_clipboard->Lock(); fPaste->SetEnabled(be_clipboard->Data()->HasData("text/plain", B_MIME_TYPE) From axeld at mail.berlios.de Mon Nov 19 12:32:46 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 19 Nov 2007 12:32:46 +0100 Subject: [Haiku-commits] r22955 - in haiku/trunk/src/add-ons/accelerants: common nvidia radeon Message-ID: <200711191132.lAJBWktk006893@sheep.berlios.de> Author: axeld Date: 2007-11-19 12:32:45 +0100 (Mon, 19 Nov 2007) New Revision: 22955 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22955&view=rev Modified: haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp haiku/trunk/src/add-ons/accelerants/nvidia/ProposeDisplayMode.c haiku/trunk/src/add-ons/accelerants/radeon/ProposeDisplayMode.c Log: Replaced the old 1920x1200 resolution mode line with another one with a slightly higher pixel clock, tested by Dr. Hartmut Reh. Modified: haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp 2007-11-19 11:15:04 UTC (rev 22954) +++ haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp 2007-11-19 11:32:45 UTC (rev 22955) @@ -55,7 +55,7 @@ {{147100, 1680, 1784, 1968, 2256, 1050, 1051, 1054, 1087, POSITIVE_SYNC}, B_CMAP8, 1680, 1050, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1680X1050) */ - {{154000, 1920, 1968, 2000, 2080, 1200, 1203, 1209, 1235, POSITIVE_SYNC}, B_CMAP8, 1920, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1920X1200) */ + {{160000, 1920, 2010, 2060, 2110, 1200, 1202, 1208, 1235, POSITIVE_SYNC}, B_CMAP8, 1920, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1920X1200) */ }; static const uint32 kNumBaseModes = sizeof(kBaseModeList) / sizeof(display_mode); Modified: haiku/trunk/src/add-ons/accelerants/nvidia/ProposeDisplayMode.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/ProposeDisplayMode.c 2007-11-19 11:15:04 UTC (rev 22954) +++ haiku/trunk/src/add-ons/accelerants/nvidia/ProposeDisplayMode.c 2007-11-19 11:32:45 UTC (rev 22955) @@ -86,7 +86,7 @@ /* 16:10 panel mode; 1.764M pixels */ { { 147100, 1680, 1784, 1968, 2256, 1050, 1051, 1054, 1087, T_POSITIVE_SYNC}, B_CMAP8, 1680, 1050, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1680X1050) */ /* 16:10 panel mode; 2.304M pixels */ -{ { 154000, 1920, 1968, 2000, 2080, 1200, 1203, 1209, 1235, T_POSITIVE_SYNC}, B_CMAP8, 1920, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1920X1200) */ +{ { 160000, 1920, 2010, 2060, 2110, 1200, 1202, 1208, 1235, T_POSITIVE_SYNC}, B_CMAP8, 1920, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1920X1200) */ /* 16:9 panel mode; 1280x720 */ { { 74520, 1280, 1368, 1424, 1656, 720, 724, 730, 750, T_POSITIVE_SYNC}, B_CMAP8, 1280, 720, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1280X720) */ }; Modified: haiku/trunk/src/add-ons/accelerants/radeon/ProposeDisplayMode.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/radeon/ProposeDisplayMode.c 2007-11-19 11:15:04 UTC (rev 22954) +++ haiku/trunk/src/add-ons/accelerants/radeon/ProposeDisplayMode.c 2007-11-19 11:32:45 UTC (rev 22955) @@ -82,7 +82,7 @@ { { 106500, 1440, 1520, 1672, 1904, 900, 901, 904, 932, T_POSITIVE_SYNC}, B_CMAP8, 1440, 900, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1440X900) */ { { 147100, 1680, 1784, 1968, 2256, 1050, 1051, 1054, 1087, T_POSITIVE_SYNC}, B_CMAP8, 1680, 1050, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1680X1050) */ /* 16:10 panel mode; 2.304M pixels */ -{ { 154000, 1920, 1968, 2000, 2080, 1200, 1203, 1209, 1235, T_POSITIVE_SYNC}, B_CMAP8, 1920, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1920X1200) */ +{ { 160000, 1920, 2010, 2060, 2110, 1200, 1202, 1208, 1235, T_POSITIVE_SYNC}, B_CMAP8, 1920, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1920X1200) */ // widescreen resolutions, 16:9 { { 74520, 1280, 1368, 1424, 1656, 720, 724, 730, 750, T_POSITIVE_SYNC}, B_CMAP8, 1280, 720, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(1280X720) */ }; From marcusoverhagen at arcor.de Mon Nov 19 14:49:07 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Mon, 19 Nov 2007 14:49:07 +0100 (CET) Subject: [Haiku-commits] r22950 - haiku/trunk/src/add-ons/kernel/generic/ide_adapter In-Reply-To: <20071119013518.338.1@knochen-vm.nameserver> References: <20071119013518.338.1@knochen-vm.nameserver> <200711181841.lAIIfPq9009767@sheep.berlios.de> <5098531.1195429992854.JavaMail.ngmail@webmail18> Message-ID: <27655187.1195480147309.JavaMail.ngmail@webmail11> Ingo Weinhold wrote: > On 2007-11-19 at 00:53:12 [+0100], Marcus Overhagen > wrote: > > > > PCI_address_space is defined as 1, but this bit is always > > 0 for memory BARs, so thats no issue here. > > Not that I know what I'm talking about, but at least under VMware the bit is > set (and the ide_adapter code seems to require that), resulting in the That's because it's an IO-BAR and I was wrong. > "BM-VIDE: Write to unknown VIDE BM-DMA register offset 3" message in the > vmware.log. I was hoping this was related to the annoying bug #1176, so I > tracked the cause down, but, alas, it isn't. Bummer. You change looks correct. I just don't understand how it was possible for DMA to work before. This comment: > > However, other bits may be set, so the save way would be to use > > bus_master_base &= PCI_address_memory_32_mask; is correct for memory bars only. > Interestingly the ide_adapter consequently uses ~PCI_address_space instead > of that mask (respectively PCI_address_io_mask). Since IO bars don't have any additional bits, those two are equivalent. regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From axeld at mail.berlios.de Mon Nov 19 14:57:47 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 19 Nov 2007 14:57:47 +0100 Subject: [Haiku-commits] r22956 - haiku/trunk/src/apps/diskprobe Message-ID: <200711191357.lAJDvlHN029585@sheep.berlios.de> Author: axeld Date: 2007-11-19 14:57:46 +0100 (Mon, 19 Nov 2007) New Revision: 22956 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22956&view=rev Modified: haiku/trunk/src/apps/diskprobe/DataEditor.cpp Log: If a device returns an invalid size, we shouldn't crash. Modified: haiku/trunk/src/apps/diskprobe/DataEditor.cpp =================================================================== --- haiku/trunk/src/apps/diskprobe/DataEditor.cpp 2007-11-19 11:32:45 UTC (rev 22955) +++ haiku/trunk/src/apps/diskprobe/DataEditor.cpp 2007-11-19 13:57:46 UTC (rev 22956) @@ -491,7 +491,8 @@ fSize = 1LL * geometry.head_count * geometry.cylinder_count * geometry.sectors_per_track * geometry.bytes_per_sector; - + if (fSize < 0) + fSize = 0; if (!isFileSystem) fBlockSize = geometry.bytes_per_sector; } else if (entry.IsDirectory() || entry.IsSymLink()) { From superstippi at gmx.de Mon Nov 19 15:09:56 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 19 Nov 2007 15:09:56 +0100 Subject: [Haiku-commits] r22950 - haiku/trunk/src/add-ons/kernel/generic/ide_adapter In-Reply-To: <27655187.1195480147309.JavaMail.ngmail@webmail11> References: <20071119013518.338.1@knochen-vm.nameserver> <200711181841.lAIIfPq9009767@sheep.berlios.de> <5098531.1195429992854.JavaMail.ngmail@webmail18> <27655187.1195480147309.JavaMail.ngmail@webmail11> Message-ID: <20071119150956.25839.4@stippis2.1195467523.fake> Hi, Marcus Overhagen wrote (2007-11-19, 14:49:07 [+0100]): > Ingo Weinhold wrote: > > "BM-VIDE: Write to unknown VIDE BM-DMA register offset 3" message in > > the vmware.log. I was hoping this was related to the annoying bug > > #1176, so I tracked the cause down, but, alas, it isn't. > Bummer. You change looks correct. I just don't understand how it was > possible for DMA to work before. Well, it doesn't on two out of four machines here. Though I have not tested now after Ingo's patch. Will do ASAP. Best regards, -Stephan From ingo_weinhold at gmx.de Mon Nov 19 15:27:05 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 19 Nov 2007 15:27:05 +0100 Subject: [Haiku-commits] r22950 - haiku/trunk/src/add-ons/kernel/generic/ide_adapter In-Reply-To: <27655187.1195480147309.JavaMail.ngmail@webmail11> References: <20071119013518.338.1@knochen-vm.nameserver> <200711181841.lAIIfPq9009767@sheep.berlios.de> <5098531.1195429992854.JavaMail.ngmail@webmail18> <27655187.1195480147309.JavaMail.ngmail@webmail11> Message-ID: <20071119152705.581.4@knochen-vm.nameserver> On 2007-11-19 at 14:49:07 [+0100], Marcus Overhagen wrote: > Ingo Weinhold wrote: [...] > > "BM-VIDE: Write to unknown VIDE BM-DMA register offset 3" message in the > > vmware.log. I was hoping this was related to the annoying bug #1176, so I > > tracked the cause down, but, alas, it isn't. > Bummer. You change looks correct. I just don't understand how it was > possible > for DMA to work before. The wrong bus master base address was only used in ide_adapter_detect_channel() to read the status register for a check for simplex mode. The address stored in the device attributes was set correctly, so this bug really shouldn't have had any effect, unless one had a simplex controller. CU, Ingo From axeld at mail.berlios.de Mon Nov 19 16:30:32 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 19 Nov 2007 16:30:32 +0100 Subject: [Haiku-commits] r22957 - haiku/trunk/src/preferences/filetypes Message-ID: <200711191530.lAJFUWtg002814@sheep.berlios.de> Author: axeld Date: 2007-11-19 16:30:32 +0100 (Mon, 19 Nov 2007) New Revision: 22957 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22957&view=rev Modified: haiku/trunk/src/preferences/filetypes/FileTypes.cpp Log: Now opens the types window on B_SILENT_RELAUNCH if it's not already open. This fixes bug #1628. Modified: haiku/trunk/src/preferences/filetypes/FileTypes.cpp =================================================================== --- haiku/trunk/src/preferences/filetypes/FileTypes.cpp 2007-11-19 13:57:46 UTC (rev 22956) +++ haiku/trunk/src/preferences/filetypes/FileTypes.cpp 2007-11-19 15:30:32 UTC (rev 22957) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2006-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -372,6 +372,13 @@ break; } + case B_SILENT_RELAUNCH: + // In case we were launched via the add-on, there is no types + // window yet. + if (fTypesWindow == NULL) + PostMessage(kMsgOpenTypesWindow); + break; + case B_CANCEL: if (fWindowCount == 0) PostMessage(B_QUIT_REQUESTED); @@ -393,7 +400,7 @@ { BAlert *alert = new BAlert("about", "FileTypes\n" "\twritten by Axel D?rfler\n" - "\tCopyright 2006, Haiku.\n", "Ok"); + "\tCopyright 2006-2007, Haiku.\n", "Ok"); BTextView *view = alert->TextView(); BFont font; From marcusoverhagen at mail.berlios.de Mon Nov 19 20:12:37 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Mon, 19 Nov 2007 20:12:37 +0100 Subject: [Haiku-commits] r22958 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200711191912.lAJJCbjw004911@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-19 20:12:37 +0100 (Mon, 19 Nov 2007) New Revision: 22958 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22958&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp Log: improved debug output 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 2007-11-19 15:30:32 UTC (rev 22957) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-11-19 19:12:37 UTC (rev 22958) @@ -654,11 +654,14 @@ FLOW("prdbc %ld\n", fCommandList->prdbc); - if (status < B_OK || (tfd & ATA_ERR)) { - TRACE("device error\n"); + if (status < B_OK) { + TRACE("ScsiReadWrite port %d: device timeout\n", fIndex); request->subsys_status = SCSI_REQ_ABORTED; + } else if (tfd & ATA_ERR) { + TRACE("ScsiReadWrite port %d: device error\n", fIndex); + request->subsys_status = SCSI_REQ_ABORTED; } else if (fCommandList->prdbc != bytecount) { - TRACE("should never happen\n"); + TRACE("ScsiReadWrite port %d: should never happen\n", fIndex); request->subsys_status = SCSI_REQ_CMP_ERR; } else { request->subsys_status = SCSI_REQ_CMP; From marcusoverhagen at mail.berlios.de Mon Nov 19 20:14:47 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Mon, 19 Nov 2007 20:14:47 +0100 Subject: [Haiku-commits] r22959 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200711191914.lAJJEl5g005039@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-19 20:14:46 +0100 (Mon, 19 Nov 2007) New Revision: 22959 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22959&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h Log: Workaround for ICH6M: ports implemented mask 0 is no longer an error. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-11-19 19:12:37 UTC (rev 22958) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-11-19 19:14:46 UTC (rev 22959) @@ -24,6 +24,7 @@ , fCommandSlotCount(0) , fPortCountMax(0) , fPortCountAvail(0) + , fPortImplementedMask(0) , fIRQ(0) , fInstanceCheck(-1) { @@ -126,13 +127,15 @@ fCommandSlotCount = 1 + ((fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); fPortCountMax = 1 + ((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); - fPortCountAvail = count_bits_set(fRegs->pi); - if (fRegs->pi == 0) { - TRACE("controller doesn't implement any ports\n"); - goto err; + fPortImplementedMask = fRegs->pi; + if (fPortImplementedMask == 0) { + fPortImplementedMask = 0xffffffff >> (32 - fPortCountMax); + TRACE("ports-implemented mask is zero, using 0x%lx instead.\n", fPortImplementedMask); } + fPortCountAvail = count_bits_set(fPortImplementedMask); + TRACE("cap: Interface Speed Support: generation %lu\n", (fRegs->cap >> CAP_ISS_SHIFT) & CAP_ISS_MASK); TRACE("cap: Number of Command Slots: %d (raw %#lx)\n", fCommandSlotCount, (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); TRACE("cap: Number of Ports: %d (raw %#lx)\n", fPortCountMax, (fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); @@ -152,7 +155,7 @@ TRACE("cap: Supports AHCI mode only: %s\n", (fRegs->cap & CAP_SAM) ? "yes" : "no"); TRACE("ghc: AHCI Enable: %s\n", (fRegs->ghc & GHC_AE) ? "yes" : "no"); - TRACE("Ports Implemented Mask: %#08lx\n", fRegs->pi); + TRACE("Ports Implemented Mask: %#08lx\n", fPortImplementedMask); TRACE("Number of Available Ports: %d\n", fPortCountAvail); TRACE("AHCI Version %lu.%lu\n", fRegs->vs >> 16, fRegs->vs & 0xff); TRACE("Interrupt %u\n", fIRQ); @@ -164,7 +167,7 @@ } for (int i = 0; i <= fPortCountMax; i++) { - if (fRegs->pi & (1 << i)) { + if (fPortImplementedMask & (1 << i)) { fPort[i] = new (std::nothrow)AHCIPort(this, i); if (!fPort[i]) { TRACE("out of memory creating port %d", i); @@ -271,7 +274,7 @@ AHCIController::Interrupt(void *data) { AHCIController *self = (AHCIController *)data; - uint32 int_stat = self->fRegs->is & self->fRegs->pi; + uint32 int_stat = self->fRegs->is & self->fPortImplementedMask; if (int_stat == 0) return B_UNHANDLED_INTERRUPT; Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-11-19 19:12:37 UTC (rev 22958) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-11-19 19:14:46 UTC (rev 22959) @@ -48,6 +48,7 @@ int fCommandSlotCount; int fPortCountMax; int fPortCountAvail; + uint32 fPortImplementedMask; uint8 fIRQ; AHCIPort * fPort[32]; From korli at mail.berlios.de Mon Nov 19 20:50:38 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 19 Nov 2007 20:50:38 +0100 Subject: [Haiku-commits] r22960 - haiku/trunk/headers/private/fs_shell Message-ID: <200711191950.lAJJocqO007471@sheep.berlios.de> Author: korli Date: 2007-11-19 20:50:38 +0100 (Mon, 19 Nov 2007) New Revision: 22960 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22960&view=rev Modified: haiku/trunk/headers/private/fs_shell/fssh_types.h Log: this macro is preferred Modified: haiku/trunk/headers/private/fs_shell/fssh_types.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_types.h 2007-11-19 19:14:46 UTC (rev 22959) +++ haiku/trunk/headers/private/fs_shell/fssh_types.h 2007-11-19 19:50:38 UTC (rev 22960) @@ -7,7 +7,7 @@ typedef volatile int32_t vint32_t; typedef volatile int64_t vint64_t; -#ifdef __x86_64__ +#ifdef HAIKU_HOST_PLATFORM_64_BIT typedef uint64_t fssh_addr_t; #else typedef uint32_t fssh_addr_t; From jackburton at mail.berlios.de Mon Nov 19 23:48:19 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 19 Nov 2007 23:48:19 +0100 Subject: [Haiku-commits] r22961 - haiku/trunk/src/tests/kits/game/chart Message-ID: <200711192248.lAJMmJrh017914@sheep.berlios.de> Author: jackburton Date: 2007-11-19 23:48:19 +0100 (Mon, 19 Nov 2007) New Revision: 22961 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22961&view=rev Modified: haiku/trunk/src/tests/kits/game/chart/ChartRender.cpp Log: Apparently the calculations used to distribute the load don't work correctly under vmware, and the star count could become negative. At least we check that and set it to 0 in that case. Fixes bug #89 Modified: haiku/trunk/src/tests/kits/game/chart/ChartRender.cpp =================================================================== --- haiku/trunk/src/tests/kits/game/chart/ChartRender.cpp 2007-11-19 19:50:38 UTC (rev 22960) +++ haiku/trunk/src/tests/kits/game/chart/ChartRender.cpp 2007-11-19 22:48:19 UTC (rev 22961) @@ -567,6 +567,12 @@ int32 i, min_count; star *s; + // TODO: For some reason, when selecting the "2 threads" option under vmware, + // some weird timing calculations finish with setting the star packet count to + // a negative number. This screws all the next calculations, and the animation + // then comes to a stop. + sp->count = max_c(sp->count, 0); + /* Calculate the number of stars that were process during the previous frame and still need to be process for that frame. */ min_count = sp->erase_count; From jackburton at mail.berlios.de Tue Nov 20 09:41:19 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 20 Nov 2007 09:41:19 +0100 Subject: [Haiku-commits] r22962 - haiku/trunk/src/kits/media Message-ID: <200711200841.lAK8fJao026101@sheep.berlios.de> Author: jackburton Date: 2007-11-20 09:41:18 +0100 (Tue, 20 Nov 2007) New Revision: 22962 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22962&view=rev Modified: haiku/trunk/src/kits/media/Sound.cpp Log: Return an error in BSound methods, since they aren't implemented. Should fix bug #1573, although I can't really test. Modified: haiku/trunk/src/kits/media/Sound.cpp =================================================================== --- haiku/trunk/src/kits/media/Sound.cpp 2007-11-19 22:48:19 UTC (rev 22961) +++ haiku/trunk/src/kits/media/Sound.cpp 2007-11-20 08:41:18 UTC (rev 22962) @@ -30,21 +30,21 @@ { UNIMPLEMENTED(); - return B_OK; + return B_ERROR; } BSound * BSound::AcquireRef() { UNIMPLEMENTED(); - return 0; + return NULL; } bool BSound::ReleaseRef() { UNIMPLEMENTED(); - return 0; + return false; } int32 @@ -72,7 +72,7 @@ BSound::Data() const { UNIMPLEMENTED(); - return 0; + return NULL; } /* returns NULL for files */ /* virtual */ off_t @@ -89,7 +89,7 @@ size_t * out_used) { UNIMPLEMENTED(); - return 0; + return false; } /************************************************************* @@ -105,7 +105,7 @@ BSound::Perform(int32 code,...) { UNIMPLEMENTED(); - return 0; + return B_ERROR; } /************************************************************* @@ -139,7 +139,7 @@ BSound::load_entry(void * arg) { UNIMPLEMENTED(); - return 0; + return B_ERROR; } void @@ -152,7 +152,7 @@ BSound::check_stop() { UNIMPLEMENTED(); - return 0; + return false; } /************************************************************* @@ -164,14 +164,14 @@ const media_raw_audio_format & format) { UNIMPLEMENTED(); - return 0; + return B_ERROR; } /* virtual */ status_t BSound::UnbindFrom(BSoundPlayer * player) { UNIMPLEMENTED(); - return 0; + return B_ERROR; } /************************************************************* From jackburton at mail.berlios.de Tue Nov 20 13:58:51 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 20 Nov 2007 13:58:51 +0100 Subject: [Haiku-commits] r22963 - haiku/trunk/src/kits/interface Message-ID: <200711201258.lAKCwp82030088@sheep.berlios.de> Author: jackburton Date: 2007-11-20 13:58:50 +0100 (Tue, 20 Nov 2007) New Revision: 22963 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22963&view=rev Modified: haiku/trunk/src/kits/interface/Menu.cpp Log: Moved call to _DeleteMenuWindow() to a better place Modified: haiku/trunk/src/kits/interface/Menu.cpp =================================================================== --- haiku/trunk/src/kits/interface/Menu.cpp 2007-11-20 08:41:18 UTC (rev 22962) +++ haiku/trunk/src/kits/interface/Menu.cpp 2007-11-20 12:58:50 UTC (rev 22963) @@ -1327,7 +1327,7 @@ void BMenu::_Hide() { - BMenuWindow *window = static_cast(Window()); + BMenuWindow *window = dynamic_cast(Window()); if (window == NULL || !window->Lock()) return; @@ -1338,15 +1338,15 @@ window->DetachMenu(); // we don't want to be deleted when the window is removed - // Delete the menu window used by our submenus - _DeleteMenuWindow(); - if (fSuper != NULL) window->Unlock(); else { // it's our window, quit it window->Quit(); - } + } + + // Delete the menu window used by our submenus + _DeleteMenuWindow(); } From jackburton at mail.berlios.de Tue Nov 20 13:59:17 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 20 Nov 2007 13:59:17 +0100 Subject: [Haiku-commits] r22964 - haiku/trunk/src/kits/interface Message-ID: <200711201259.lAKCxHx4030163@sheep.berlios.de> Author: jackburton Date: 2007-11-20 13:59:17 +0100 (Tue, 20 Nov 2007) New Revision: 22964 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22964&view=rev Modified: haiku/trunk/src/kits/interface/BMCPrivate.cpp Log: small cleanups Modified: haiku/trunk/src/kits/interface/BMCPrivate.cpp =================================================================== --- haiku/trunk/src/kits/interface/BMCPrivate.cpp 2007-11-20 12:58:50 UTC (rev 22963) +++ haiku/trunk/src/kits/interface/BMCPrivate.cpp 2007-11-20 12:59:17 UTC (rev 22964) @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -57,18 +58,16 @@ _BMCMenuBar_::_BMCMenuBar_(BRect frame, bool fixedSize, BMenuField *menuField) : BMenuBar(frame, "_mc_mb_", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_ITEMS_IN_ROW, - !fixedSize) + !fixedSize), + fMenuField(menuField), + fFixedSize(fixedSize), + fRunner(NULL), + fShowPopUpMarker(true) { SetFlags(Flags() | B_FRAME_EVENTS); SetBorder(B_BORDER_CONTENTS); - fMenuField = menuField; - fFixedSize = fixedSize; - fRunner = NULL; - fShowPopUpMarker = true; - float left, top, right, bottom; - GetItemMargins(&left, &top, &right, &bottom); // give a bit more space to draw the small thumb left -= 1; @@ -82,21 +81,23 @@ _BMCMenuBar_::_BMCMenuBar_(BMessage *data) - : BMenuBar(data) + : BMenuBar(data), + fMenuField(NULL), + fFixedSize(true), + fRunner(NULL), + fShowPopUpMarker(true) { SetFlags(Flags() | B_FRAME_EVENTS); - bool rsize_to_fit; - - if (data->FindBool("_rsize_to_fit", &rsize_to_fit) == B_OK) - fFixedSize = !rsize_to_fit; - else - fFixedSize = true; + bool resizeToFit; + if (data->FindBool("_rsize_to_fit", &resizeToFit) == B_OK) + fFixedSize = !resizeToFit; } _BMCMenuBar_::~_BMCMenuBar_() { + delete fRunner; } From jackburton at mail.berlios.de Tue Nov 20 14:00:00 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 20 Nov 2007 14:00:00 +0100 Subject: [Haiku-commits] r22965 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200711201300.lAKD00T3030214@sheep.berlios.de> Author: jackburton Date: 2007-11-20 13:59:59 +0100 (Tue, 20 Nov 2007) New Revision: 22965 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22965&view=rev Modified: haiku/trunk/headers/os/interface/MenuField.h haiku/trunk/src/kits/interface/MenuField.cpp Log: cleanups Modified: haiku/trunk/headers/os/interface/MenuField.h =================================================================== --- haiku/trunk/headers/os/interface/MenuField.h 2007-11-20 12:59:17 UTC (rev 22964) +++ haiku/trunk/headers/os/interface/MenuField.h 2007-11-20 12:59:59 UTC (rev 22965) @@ -114,7 +114,10 @@ void InitObject2(); void DrawLabel(BRect bounds, BRect update); static void InitMenu(BMenu* menu); - static long MenuTask(void* arg); + + int32 _MenuTask(); + static int32 _thread_entry(void *arg); + void _UpdateFrame(); void _InitMenuBar(BMenu* menu, BRect frame, bool fixedSize); Modified: haiku/trunk/src/kits/interface/MenuField.cpp =================================================================== --- haiku/trunk/src/kits/interface/MenuField.cpp 2007-11-20 12:59:17 UTC (rev 22964) +++ haiku/trunk/src/kits/interface/MenuField.cpp 2007-11-20 12:59:59 UTC (rev 22965) @@ -303,8 +303,8 @@ fMenuBar->StartMenuBar(0, false, true, &bounds); - fMenuTaskID = spawn_thread((thread_func)MenuTask, "_m_task_", B_NORMAL_PRIORITY, this); - if (fMenuTaskID) + fMenuTaskID = spawn_thread((thread_func)_thread_entry, "_m_task_", B_NORMAL_PRIORITY, this); + if (fMenuTaskID >= 0) resume_thread(fMenuTaskID); } @@ -827,35 +827,41 @@ } -long -BMenuField::MenuTask(void *arg) +/* static */ +int32 +BMenuField::_thread_entry(void *arg) { - BMenuField *menuField = static_cast(arg); + return static_cast(arg)->_MenuTask(); +} - if (!menuField->LockLooper()) + +int32 +BMenuField::_MenuTask() +{ + if (!LockLooper()) return 0; - menuField->fSelected = true; - menuField->fTransition = true; - menuField->Invalidate(); - menuField->UnlockLooper(); + fSelected = true; + fTransition = true; + Invalidate(); + UnlockLooper(); bool tracking; do { snooze(20000); - if (!menuField->LockLooper()) + if (!LockLooper()) return 0; - tracking = menuField->fMenuBar->fTracking; + tracking = fMenuBar->fTracking; - menuField->UnlockLooper(); + UnlockLooper(); } while (tracking); - if (menuField->LockLooper()) { - menuField->fSelected = false; - menuField->fTransition = true; - menuField->Invalidate(); - menuField->UnlockLooper(); + if (LockLooper()) { + fSelected = false; + fTransition = true; + Invalidate(); + UnlockLooper(); } return 0; From jackburton at mail.berlios.de Tue Nov 20 17:15:27 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 20 Nov 2007 17:15:27 +0100 Subject: [Haiku-commits] r22966 - haiku/trunk/src/system/libroot/os Message-ID: <200711201615.lAKGFR4f014107@sheep.berlios.de> Author: jackburton Date: 2007-11-20 17:15:27 +0100 (Tue, 20 Nov 2007) New Revision: 22966 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22966&view=rev Modified: haiku/trunk/src/system/libroot/os/debug.c Log: Implemented _debuggerAssert(). Modified: haiku/trunk/src/system/libroot/os/debug.c =================================================================== --- haiku/trunk/src/system/libroot/os/debug.c 2007-11-20 12:59:59 UTC (rev 22965) +++ haiku/trunk/src/system/libroot/os/debug.c 2007-11-20 16:15:27 UTC (rev 22966) @@ -252,10 +252,16 @@ int -_debuggerAssert(const char * file, int line, char * message) +_debuggerAssert(const char * file, int line, char *message) { - puts("*** _debuggerAssert call - not yet implemented ***"); - printf("%s:%d:%s\n", file, line, message); + char buffer[1024]; + snprintf(buffer, sizeof(buffer), + "Assert failed: File: %s, Line: %d, %s", + file, line, message); + + debug_printf("%ld: ASSERT: %s\n", find_thread(NULL), buffer); + _kern_debugger(buffer); + return 0; } From axeld at mail.berlios.de Tue Nov 20 22:35:00 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 20 Nov 2007 22:35:00 +0100 Subject: [Haiku-commits] r22967 - haiku/trunk/src/servers/app Message-ID: <200711202135.lAKLZ00Y021502@sheep.berlios.de> Author: axeld Date: 2007-11-20 22:34:59 +0100 (Tue, 20 Nov 2007) New Revision: 22967 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22967&view=rev Modified: haiku/trunk/src/servers/app/ServerScreen.cpp Log: display_mode::[hv]_display_start fields were not set when using a certain Screen::SetMode() method, thanks to Gerald Zajac for reporting this. Modified: haiku/trunk/src/servers/app/ServerScreen.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerScreen.cpp 2007-11-20 16:15:27 UTC (rev 22966) +++ haiku/trunk/src/servers/app/ServerScreen.cpp 2007-11-20 21:34:59 UTC (rev 22967) @@ -107,10 +107,12 @@ const display_timing& timing, bool makeDefault) { display_mode mode; + mode.timing = timing; + mode.space = colorSpace; mode.virtual_width = width; mode.virtual_height = height; - mode.space = colorSpace; - mode.timing = timing; + mode.h_display_start = 0; + mode.v_display_start = 0; mode.flags = 0; return SetMode(mode, makeDefault); From sbenedetto at mail.berlios.de Tue Nov 20 23:16:43 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Tue, 20 Nov 2007 23:16:43 +0100 Subject: [Haiku-commits] r22968 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711202216.lAKMGhl7023327@sheep.berlios.de> Author: sbenedetto Date: 2007-11-20 23:16:42 +0100 (Tue, 20 Nov 2007) New Revision: 22968 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22968&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h Log: * Remove SubmitAsyncTransfer and SubmitPeriodicTransfer * Added _SubmitControlRequest (almost implemented), _LinkDescriptors, _WriteDescriptorChain (basically copied from EHCI, and UHCI) * Renamed ohci_general_descriptor to ohci_general_td, and ohci_isochronous_descriptor to ohci_isochronous_td * Finished _CreateGeneralDescriptor and _FreeGeneralDescriptor * Added buffer_size member to ohci_general_td instead and removed last_logical_byte_address as it looked unnecessary * minor clean up Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-20 21:34:59 UTC (rev 22967) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-20 22:16:42 UTC (rev 22968) @@ -410,16 +410,21 @@ return fRootHub->ProcessTransfer(this, transfer); uint32 type = transfer->TransferPipe()->Type(); - if ((type & USB_OBJECT_CONTROL_PIPE) || (type & USB_OBJECT_BULK_PIPE)) { - TRACE(("usb_ohci: submitting async transfer\n")); - return _SubmitAsyncTransfer(transfer); + if ((type & USB_OBJECT_CONTROL_PIPE)) { + TRACE(("usb_ohci: submitting control request\n")); + return _SubmitControlRequest(transfer); } - if ((type & USB_OBJECT_INTERRUPT_PIPE) || (type & USB_OBJECT_ISO_PIPE)) { - TRACE(("usb_ohci: submitting periodic transfer\n")); - return _SubmitPeriodicTransfer(transfer); + if ((type & USB_OBJECT_INTERRUPT_PIPE) || (type & USB_OBJECT_BULK_PIPE)) { + // TODO + return B_OK; } + if ((type & USB_OBJECT_ISO_PIPE)) { + TRACE(("usb_ohci: submitting isochronous transfer\n")); + return _SubmitIsochronousTransfer(transfer); + } + TRACE_ERROR(("usb_ohci: tried to submit transfer for unknown pipe" " type %lu\n", type)); return B_ERROR; @@ -427,19 +432,152 @@ status_t -OHCI::_SubmitAsyncTransfer(Transfer *transfer) +OHCI::_SubmitControlRequest(Transfer *transfer) { + usb_request_data *requestData = transfer->RequestData(); + bool directionIn = (requestData->RequestType & USB_REQTYPE_DEVICE_IN) > 0; + + ohci_general_td *setupDescriptor + = _CreateGeneralDescriptor(sizeof(usb_request_data)); + if (!setupDescriptor) { + TRACE_ERROR(("usb_ohci: failed to allocate setup descriptor\n")); + return B_NO_MEMORY; + } + // Flags set up could be moved into _CreateGeneralDescriptor + setupDescriptor->flags |= OHCI_TD_DIRECTION_PID_SETUP + | OHCI_TD_NO_CONDITION_CODE + | OHCI_TD_TOGGLE_0 + | OHCI_TD_SET_DELAY_INTERRUPT(6); // Not sure about this. + + ohci_general_td *statusDescriptor + = _CreateGeneralDescriptor(0); + if (!statusDescriptor) { + TRACE_ERROR(("usb_ohci: failed to allocate status descriptor\n")); + _FreeGeneralDescriptor(setupDescriptor); + return B_NO_MEMORY; + } + statusDescriptor->flags + |= (directionIn ? OHCI_TD_DIRECTION_PID_OUT : OHCI_TD_DIRECTION_PID_IN) + | OHCI_TD_NO_CONDITION_CODE + | OHCI_TD_TOGGLE_1 + | OHCI_TD_SET_DELAY_INTERRUPT(1); + + iovec vector; + vector.iov_base = requestData; + vector.iov_len = sizeof(usb_request_data); + _WriteDescriptorChain(setupDescriptor, &vector, 1); + + if (transfer->VectorCount() > 0) { + ohci_general_td *dataDescriptor = NULL; + ohci_general_td *lastDescriptor = NULL; + status_t result = _CreateDescriptorChain(&dataDescriptor, + &lastDescriptor, + directionIn ? OHCI_TD_DIRECTION_PID_OUT : OHCI_TD_DIRECTION_PID_IN, + transfer->VectorLength()); + if (result < B_OK) { + _FreeGeneralDescriptor(setupDescriptor); + _FreeGeneralDescriptor(statusDescriptor); + return result; + } + + if (!directionIn) { + _WriteDescriptorChain(dataDescriptor, transfer->Vector(), + transfer->VectorCount()); + } + + _LinkDescriptors(setupDescriptor, dataDescriptor); + _LinkDescriptors(lastDescriptor, statusDescriptor); + } else { + _LinkDescriptors(setupDescriptor, statusDescriptor); + } + + // TODO + // 1. Insert the chain descriptors to the endpoint + // 2. Clear the Skip bit in the enpoint + _WriteReg(OHCI_COMMAND_STATUS, OHCI_CONTROL_LIST_FILLED); + + return B_OK; +} + + +status_t +OHCI::_SubmitIsochronousTransfer(Transfer *transfer) +{ return B_ERROR; } +void +OHCI::_LinkDescriptors(ohci_general_td *first, ohci_general_td *second) +{ + first->next_physical_descriptor = second->physical_address; + first->next_logical_descriptor = second; +} + + status_t -OHCI::_SubmitPeriodicTransfer(Transfer *transfer) +OHCI::_CreateDescriptorChain(ohci_general_td **_firstDescriptor, + ohci_general_td **_lastDescriptor, uint8 direction, size_t bufferSize) { return B_ERROR; } +size_t +OHCI::_WriteDescriptorChain(ohci_general_td *topDescriptor, iovec *vector, + size_t vectorCount) +{ + ohci_general_td *current = topDescriptor; + size_t actualLength = 0; + size_t vectorIndex = 0; + size_t vectorOffset = 0; + size_t bufferOffset = 0; + + while (current) { + if (!current->buffer_logical) + break; + + while (true) { + size_t length = min_c(current->buffer_size - bufferOffset, + vector[vectorIndex].iov_len - vectorOffset); + + TRACE(("usb_ohci: copying %ld bytes to bufferOffset %ld from" + " vectorOffset %ld at index %ld of %ld\n", length, bufferOffset, + vectorOffset, vectorIndex, vectorCount)); + memcpy((uint8 *)current->buffer_logical + bufferOffset, + (uint8 *)vector[vectorIndex].iov_base + vectorOffset, length); + + actualLength += length; + vectorOffset += length; + bufferOffset += length; + + if (vectorOffset >= vector[vectorIndex].iov_len) { + if (++vectorIndex >= vectorCount) { + TRACE(("usb_ohci: wrote descriptor chain (%ld bytes, no" + " more vectors)\n", actualLength)); + return actualLength; + } + + vectorOffset = 0; + } + + if (bufferOffset >= current->buffer_size) { + bufferOffset = 0; + break; + } + } + + if (!current->next_logical_descriptor) + break; + + current = (ohci_general_td *)current->next_logical_descriptor; + } + + TRACE(("usb_ohci: wrote descriptor chain (%ld bytes)\n", actualLength)); + return actualLength; +} + + status_t OHCI::NotifyPipeChange(Pipe *pipe, usb_change change) { @@ -665,34 +803,54 @@ } -ohci_general_descriptor* -OHCI::_CreateGeneralDescriptor() +ohci_general_td* +OHCI::_CreateGeneralDescriptor(size_t bufferSize) { - ohci_general_descriptor *descriptor; + ohci_general_td *descriptor; void *physicalAddress; if (fStack->AllocateChunk((void **)&descriptor, &physicalAddress, - sizeof(ohci_general_descriptor)) != B_OK) { + sizeof(ohci_general_td)) != B_OK) { TRACE_ERROR(("usb_ohci: failed to allocate general descriptor\n")); return NULL; } - - // TODO: Finish methods - memset((void *)descriptor, 0, sizeof(ohci_general_descriptor)); + memset((void *)descriptor, 0, sizeof(ohci_general_td)); descriptor->physical_address = (addr_t)physicalAddress; + if (!bufferSize) { + descriptor->buffer_physical = 0; + descriptor->buffer_logical = NULL; + descriptor->last_physical_byte_address = 0; + return descriptor; + } + + if (fStack->AllocateChunk(&descriptor->buffer_logical, + (void **)&descriptor->buffer_physical, bufferSize) != B_OK) { + TRACE_ERROR(("usb_ohci: failed to allocate space for buffer\n")); + fStack->FreeChunk(descriptor, (void *)descriptor->physical_address, + sizeof(ohci_general_td)); + return NULL; + } + descriptor->last_physical_byte_address + = descriptor->buffer_physical + bufferSize - 1; + return descriptor; -} +} void -OHCI::_FreeGeneralDescriptor(ohci_general_descriptor *descriptor) +OHCI::_FreeGeneralDescriptor(ohci_general_td *descriptor) { if (!descriptor) return; + if (descriptor->buffer_logical) { + fStack->FreeChunk(descriptor->buffer_logical, + (void *)descriptor->buffer_physical, descriptor->buffer_size); + } + fStack->FreeChunk((void *)descriptor, (void *)descriptor->physical_address, - sizeof(ohci_general_descriptor)); + sizeof(ohci_general_td)); } Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-20 21:34:59 UTC (rev 22967) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2007-11-20 22:16:42 UTC (rev 22968) @@ -31,7 +31,7 @@ // -------------------------------------- typedef struct hcd_soft_itransfer { - ohci_isochronous_descriptor itd; + ohci_isochronous_td itd; struct hcd_soft_itransfer *nextitd; // mirrors nexttd in ITD struct hcd_soft_itransfer *dnext; // next in done list addr_t physaddr; // physical address to the host controller isonchronous transfer @@ -83,27 +83,44 @@ static int32 _FinishThread(void *data); void _FinishTransfer(); - status_t _SubmitAsyncTransfer(Transfer *transfer); - status_t _SubmitPeriodicTransfer(Transfer *transfer); + status_t _SubmitControlRequest(Transfer *transfer); + status_t _SubmitIsochronousTransfer( + Transfer *transfer); // Endpoint related methods + ohci_endpoint_descriptor *_AllocateEndpoint(); + void _FreeEndpoint( + ohci_endpoint_descriptor *endpoint); status_t _InsertEndpointForPipe(Pipe *pipe); status_t _RemoveEndpointForPipe(Pipe *pipe); - status_t _CreateEndpoint(Pipe *pipe, - bool isIsochronous); ohci_endpoint_descriptor *_FindInterruptEndpoint(uint8 interval); - ohci_endpoint_descriptor *_AllocateEndpoint(); - void _FreeEndpoint( - ohci_endpoint_descriptor *endpoint); // Transfer descriptor related methods - ohci_general_descriptor *_CreateGeneralDescriptor(); + ohci_general_td *_CreateGeneralDescriptor( + size_t bufferSize); + status_t _CreateDescriptorChain( + ohci_general_td **firstDescriptor, + ohci_general_td **lastDescriptor, + uint8 direction, + size_t bufferSize); + void _FreeGeneralDescriptor( - ohci_general_descriptor *descriptor); - ohci_isochronous_descriptor *_CreateIsochronousDescriptor(); + ohci_general_td *descriptor); + void _FreeDescriptorChain( + ohci_general_td *topDescriptor); + + void _LinkDescriptors(ohci_general_td *first, + ohci_general_td *second); + + ohci_isochronous_td *_CreateIsochronousDescriptor(); void _FreeIsochronousDescriptor( - ohci_isochronous_descriptor *descriptor); + ohci_isochronous_td *descriptor); + size_t _WriteDescriptorChain( + ohci_general_td *topDescriptor, + iovec *vector, + size_t vectorCount); + // Register functions inline void _WriteReg(uint32 reg, uint32 value); inline uint32 _ReadReg(uint32 reg); Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h 2007-11-20 21:34:59 UTC (rev 22967) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h 2007-11-20 22:16:42 UTC (rev 22968) @@ -333,7 +333,7 @@ // General transfer descriptor structure (section 4.3.1) // -------------------------------- -typedef struct ohci_general_descriptor +typedef struct ohci_general_td { // Hardware part uint32 flags; // Flags field @@ -344,7 +344,7 @@ addr_t physical_address; // Physical pointer to this address void *buffer_logical; // Logical pointer to the buffer void *next_logical_descriptor; // Logical pointer next descriptor - void *last_logical_byte_address; // Logical pointer buffer end + size_t buffer_size; // Size of the buffer }; #define OHCI_BUFFER_ROUNDING 0x00040000 @@ -371,7 +371,7 @@ // -------------------------------- #define OHCI_ITD_NOFFSET 8 -typedef struct ohci_isochronous_descriptor +typedef struct ohci_isochronous_td { uint32 flags; uint32 buffer_page_byte_0; // Physical page number of byte 0 From bonefish at mail.berlios.de Wed Nov 21 01:54:06 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 21 Nov 2007 01:54:06 +0100 Subject: [Haiku-commits] r22969 - haiku/trunk/build/jam Message-ID: <200711210054.lAL0s6G5016238@sheep.berlios.de> Author: bonefish Date: 2007-11-21 01:54:06 +0100 (Wed, 21 Nov 2007) New Revision: 22969 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22969&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Missed to commit that part of Vasilis' patch. Adds sigset() tests to the image. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-20 22:16:42 UTC (rev 22968) +++ haiku/trunk/build/jam/HaikuImage 2007-11-21 00:54:06 UTC (rev 22969) @@ -442,6 +442,9 @@ : sigrelse_1-1 sigrelse_2-1 sigrelse_3-core-buildonly ; AddFilesToHaikuImage home posixtestsuite conformance interfaces signal : signal_1-1 signal_2-1 signal_3-1 signal_5-1 signal_6-1 signal_7-1 ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces sigset + : sigset_1-1 sigset_2-1 sigset_3-1 sigset_4-1 sigset_5-1 sigset_6-1 + sigset_7-1 sigset_8-1 sigset_9-1 sigset_10-1 ; } From axeld at mail.berlios.de Wed Nov 21 13:41:59 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 21 Nov 2007 13:41:59 +0100 Subject: [Haiku-commits] r22970 - haiku/trunk/src/add-ons/kernel/file_systems/iso9660 Message-ID: <200711211241.lALCfxcp027374@sheep.berlios.de> Author: axeld Date: 2007-11-21 13:41:58 +0100 (Wed, 21 Nov 2007) New Revision: 22970 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22970&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp Log: * Removed fs_get_file_map(); for a file system that only has contiguous files, there is no need for the file map service. * Added and implemented fs_read_pages() - this should fix bug #1633; the file system had not been ported to the new file cache API yet. * Cleanup. Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp 2007-11-21 00:54:06 UTC (rev 22969) +++ haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp 2007-11-21 12:41:58 UTC (rev 22970) @@ -93,31 +93,16 @@ } +// #pragma mark - FS hooks + + static status_t fs_mount(dev_t mountID, const char *device, uint32 flags, - const char *args, void **_data, ino_t *_rootID) + const char *args, void **_volume, ino_t *_rootID) { - /* - Kernel passes in nspace_id, (representing a disk or partition?) - and a string representing the device (eg, "/dev/scsi/disk/030/raw) - Flags will be used for things like specifying read-only mounting. - parms is parameters passed in as switches from the mount command, - and len is the length of the otions. data is a pointer to a - driver-specific struct that should be allocated in this routine. - It will then be passed back in by the kernel to a number of the other - fs driver functions. vnid should also be passed back to the kernel, - representing the vnode id of the root vnode. - */ - status_t result = EINVAL; - // return EINVAL if it's not a device compatible with the driver. bool allowJoliet = true; - nspace *vol; + nspace *volume; - (void)flags; - - /* Create semaphore if it's not already created. When do we need to - use semaphores? */ - // Check for a 'nojoliet' parm // all we check for is the existance of 'nojoliet' in the parms. if (args != NULL) { @@ -134,30 +119,24 @@ spot = strstr(buf, "nojoliet"); if (spot != NULL) allowJoliet = false; - + free(buf); } // Try and mount volume as an ISO volume. - result = ISOMount(device, O_RDONLY, &vol, allowJoliet); - - // If it is ISO ? - if (result == B_NO_ERROR) { - //ino_t rootID = vol->rootDirRec.startLBN[FS_DATA_FORMAT]; - //*vnid = rootID; + status_t result = ISOMount(device, O_RDONLY, &volume, allowJoliet); + if (result == B_OK) { *_rootID = ISO_ROOTNODE_ID; - *_data = (void*)vol; - - vol->id = mountID; + *_volume = volume; - // You MUST do this. Create the vnode for the root. - result = publish_vnode(mountID, *_rootID, (void*)&(vol->rootDirRec)); - if (result != B_NO_ERROR) { - block_cache_delete(vol->fBlockCache, false); - free(vol); - result = EINVAL; - } else - result = B_NO_ERROR; + volume->id = mountID; + + result = publish_vnode(mountID, *_rootID, &volume->rootDirRec); + if (result != B_OK) { + block_cache_delete(volume->fBlockCache, false); + free(volume); + result = B_ERROR; + } } return result; } @@ -188,51 +167,30 @@ static status_t fs_read_fs_stat(void *_ns, struct fs_info *fss) { - // Fill in fs_info struct for device. nspace *ns = (nspace *)_ns; int i; - - TRACE(("fs_read_fs_stat - ENTER\n")); - - // Fill in device id. - //fss->dev = ns->fd; - - // Root vnode ID - //fss->root = ISO_ROOTNODE_ID; - - // File system flags. + fss->flags = B_FS_IS_PERSISTENT | B_FS_IS_READONLY; - - // FS block size. fss->block_size = ns->logicalBlkSize[FS_DATA_FORMAT]; - - // IO size - specifies buffer size for file copying fss->io_size = 65536; - - // Total blocks? fss->total_blocks = ns->volSpaceSize[FS_DATA_FORMAT]; - - // Free blocks = 0, read only fss->free_blocks = 0; - - // Device name. + strncpy(fss->device_name, ns->devicePath, sizeof(fss->device_name)); strncpy(fss->volume_name, ns->volIDString, sizeof(fss->volume_name)); - for (i = strlen(fss->volume_name)-1; i >=0 ; i--) + for (i = strlen(fss->volume_name) - 1; i >=0 ; i--) { if (fss->volume_name[i] != ' ') break; + } if (i < 0) strcpy(fss->volume_name, "UNKNOWN"); else fss->volume_name[i + 1] = 0; - - // File system name + strcpy(fss->fsh_name, "iso9660"); - - TRACE(("fs_read_fs_stat - EXIT\n")); - return 0; + return B_OK; } @@ -246,180 +204,155 @@ } -/* fs_walk - the walk function just "walks" through a directory looking for - the specified file. When you find it, call get_vnode on its vnid to init - it for the kernel. -*/ static status_t fs_walk(void *_ns, void *base, const char *file, ino_t *_vnodeID, int *_type) { - /* Starting at the base, find file in the subdir, and return path - string and vnode id of file. */ nspace *ns = (nspace *)_ns; vnode *baseNode = (vnode*)base; - uint32 dataLen = baseNode->dataLen[FS_DATA_FORMAT]; vnode *newNode = NULL; - status_t result = ENOENT; - bool done = FALSE; - uint32 totalRead = 0; - off_t block = baseNode->startLBN[FS_DATA_FORMAT]; TRACE(("fs_walk - looking for %s in dir file of length %d\n", file, baseNode->dataLen[FS_DATA_FORMAT])); - + if (strcmp(file, ".") == 0) { // base directory TRACE(("fs_walk - found \".\" file.\n")); *_vnodeID = baseNode->id; *_type = S_IFDIR; - if (get_vnode(ns->id, *_vnodeID, (void **)&newNode) != 0) - result = EINVAL; - else - result = B_NO_ERROR; + return get_vnode(ns->id, *_vnodeID, (void **)&newNode); } else if (strcmp(file, "..") == 0) { // parent directory TRACE(("fs_walk - found \"..\" file.\n")); *_vnodeID = baseNode->parID; *_type = S_IFDIR; - if (get_vnode(ns->id, *_vnodeID, (void **)&newNode) != 0) - result = EINVAL; - else - result = B_NO_ERROR; - } else { - // look up file in the directory - char *blockData; + return get_vnode(ns->id, *_vnodeID, (void **)&newNode); + } - while ((totalRead < dataLen) && !done) { - off_t cachedBlock = block; - - blockData = (char *)block_cache_get_etc(ns->fBlockCache, block, 0, ns->logicalBlkSize[FS_DATA_FORMAT]); - if (blockData != NULL) { - int bytesRead = 0; - off_t blockBytesRead = 0; - vnode node; - int initResult; + // look up file in the directory + uint32 dataLength = baseNode->dataLen[FS_DATA_FORMAT]; + status_t result = ENOENT; + uint32 totalRead = 0; + off_t block = baseNode->startLBN[FS_DATA_FORMAT]; + bool done = false; - TRACE(("fs_walk - read buffer from disk at LBN %Ld into buffer 0x%x.\n", - block, blockData)); + while (totalRead < dataLength && !done) { + off_t cachedBlock = block; + char *blockData = (char *)block_cache_get_etc(ns->fBlockCache, block, 0, + ns->logicalBlkSize[FS_DATA_FORMAT]); + if (blockData != NULL) { + int bytesRead = 0; + off_t blockBytesRead = 0; + vnode node; + int initResult; - // Move to the next 2-block set if necessary - // Don't go over end of buffer, if dir record sits on boundary. - - node.fileIDString = NULL; - node.attr.slName = NULL; - - while (blockBytesRead < 2*ns->logicalBlkSize[FS_DATA_FORMAT] - && totalRead + blockBytesRead < dataLen - && blockData[0] != 0 - && !done) - { - initResult = InitNode(&node, blockData, &bytesRead, ns->joliet_level); - TRACE(("fs_walk - InitNode returned %s, filename %s, %d bytes read\n", strerror(initResult), node.fileIDString, bytesRead)); - - if (initResult == B_NO_ERROR) { - if (strlen(node.fileIDString) == strlen(file) - && !strncmp(node.fileIDString, file, strlen(file))) - { - TRACE(("fs_walk - success, found vnode at block %Ld, pos %Ld\n", block, blockBytesRead)); - *_vnodeID = (block << 30) + (blockBytesRead & 0xFFFFFFFF); - TRACE(("fs_walk - New vnode id is %Ld\n", *_vnodeID)); + TRACE(("fs_walk - read buffer from disk at LBN %Ld into buffer 0x%x.\n", + block, blockData)); - if (get_vnode(ns->id, *_vnodeID, (void **)&newNode) != 0) - result = EINVAL; - else { - newNode->parID = baseNode->id; - done = TRUE; - result = B_NO_ERROR; - } - } else { - if (node.fileIDString != NULL) { - free(node.fileIDString); - node.fileIDString = NULL; - } - if (node.attr.slName != NULL) { - free(node.attr.slName); - node.attr.slName = NULL; - } + // Move to the next 2-block set if necessary + // Don't go over end of buffer, if dir record sits on boundary. + + node.fileIDString = NULL; + node.attr.slName = NULL; + + while (blockBytesRead < 2 * ns->logicalBlkSize[FS_DATA_FORMAT] + && totalRead + blockBytesRead < dataLength + && blockData[0] != 0 + && !done) { + initResult = InitNode(&node, blockData, &bytesRead, + ns->joliet_level); + TRACE(("fs_walk - InitNode returned %s, filename %s, %d bytes read\n", strerror(initResult), node.fileIDString, bytesRead)); + + if (initResult == B_OK) { + if (!strcmp(node.fileIDString, file)) { + TRACE(("fs_walk - success, found vnode at block %Ld, pos %Ld\n", block, blockBytesRead)); + *_vnodeID = (block << 30) + + (blockBytesRead & 0xffffffff); + TRACE(("fs_walk - New vnode id is %Ld\n", *_vnodeID)); + + result = get_vnode(ns->id, *_vnodeID, + (void **)&newNode); + if (result == B_OK) { + newNode->parID = baseNode->id; + done = true; } - } else { - result = initResult; - if (bytesRead == 0) - done = TRUE; + } else { + free(node.fileIDString); + node.fileIDString = NULL; + free(node.attr.slName); + node.attr.slName = NULL; } - blockData += bytesRead; - blockBytesRead += bytesRead; - - TRACE(("fs_walk - Adding %d bytes to blockBytes read (total %Ld/%Ld).\n", - bytesRead, blockBytesRead, baseNode->dataLen[FS_DATA_FORMAT])); + } else { + result = initResult; + if (bytesRead == 0) + done = TRUE; } - totalRead += ns->logicalBlkSize[FS_DATA_FORMAT]; - block++; - - TRACE(("fs_walk - moving to next block %Ld, total read %Ld\n", block, totalRead)); - block_cache_put(ns->fBlockCache, cachedBlock); + blockData += bytesRead; + blockBytesRead += bytesRead; - } else - done = TRUE; - } + TRACE(("fs_walk - Adding %d bytes to blockBytes read (total %Ld/%Ld).\n", + bytesRead, blockBytesRead, baseNode->dataLen[FS_DATA_FORMAT])); + } + totalRead += ns->logicalBlkSize[FS_DATA_FORMAT]; + block++; + + TRACE(("fs_walk - moving to next block %Ld, total read %Ld\n", block, totalRead)); + block_cache_put(ns->fBlockCache, cachedBlock); - if (newNode) - *_type = newNode->attr.stat[FS_DATA_FORMAT].st_mode; - + } else + done = TRUE; } - TRACE(("fs_walk - EXIT, result is %s, vnid is %Lu\n", strerror(result), *_vnodeID)); + + if (newNode) + *_type = newNode->attr.stat[FS_DATA_FORMAT].st_mode; + + TRACE(("fs_walk - EXIT, result is %s, vnid is %Lu\n", + strerror(result), *_vnodeID)); return result; } static status_t -fs_read_vnode(void *_ns, ino_t vnid, void **node, bool reenter) +fs_read_vnode(void *_ns, ino_t vnodeID, void **_node, bool reenter) { - uint32 block, pos; nspace *ns = (nspace*)_ns; - status_t result = B_NO_ERROR; + vnode *newNode = (vnode*)calloc(sizeof(vnode), 1); + if (newNode == NULL) + return B_NO_MEMORY; - (void)reenter; + uint32 pos = vnodeID & 0x3fffffff; + uint32 block = vnodeID >> 30; - pos = (vnid & 0x3FFFFFFF); - block = (vnid >> 30); + TRACE(("fs_read_vnode - block = %ld, pos = %ld, raw = %Lu node 0x%x\n", + block, pos, vnodeID, newNode)); - TRACE(("fs_read_vnode - ENTER, block = %ld, pos = %ld, raw = %Lu node 0x%x\n", - block, pos, vnid, newNode)); + if (pos > ns->logicalBlkSize[FS_DATA_FORMAT]) + return B_BAD_VALUE; - if (newNode != NULL) { - if (vnid == ISO_ROOTNODE_ID) { - TRACE(("fs_read_vnode - root node requested.\n")); - memcpy(newNode, &(ns->rootDirRec), sizeof(vnode)); - *node = (void*)newNode; - } else { - char *blockData = (char *)block_cache_get_etc(ns->fBlockCache, block, 0, ns->logicalBlkSize[FS_DATA_FORMAT]); + char *data = (char *)block_cache_get_etc(ns->fBlockCache, + block, 0, ns->logicalBlkSize[FS_DATA_FORMAT]); + if (data == NULL) { + free(newNode); + return B_IO_ERROR; + } - if (pos > ns->logicalBlkSize[FS_DATA_FORMAT]) { - if (blockData != NULL) - block_cache_put(ns->fBlockCache, block); + status_t result = InitNode(newNode, data + pos, NULL, ns->joliet_level); + block_cache_put(ns->fBlockCache, block); + + if (result < B_OK) { + free(newNode); + return result; + } + + newNode->id = vnodeID; + *_node = (void *)newNode; - result = EINVAL; - } else if (blockData != NULL) { - result = InitNode(newNode, blockData + pos, NULL, ns->joliet_level); - block_cache_put(ns->fBlockCache, block); - newNode->id = vnid; - - TRACE(("fs_read_vnode - init result is %s\n", strerror(result))); - *node = (void *)newNode; - TRACE(("fs_read_vnode - new file %s, size %ld\n", newNode->fileIDString, newNode->dataLen[FS_DATA_FORMAT])); - } - } - } else - result = ENOMEM; - - if (result == B_OK && !(newNode->flags & ISO_ISDIR)) { - newNode->cache = file_cache_create(ns->id, vnid, + if ((newNode->flags & ISO_ISDIR) == 0) { + newNode->cache = file_cache_create(ns->id, vnodeID, newNode->dataLen[FS_DATA_FORMAT]); } - TRACE(("fs_read_vnode - EXIT, result is %s\n", strerror(result))); - return result; + return B_OK; } @@ -453,97 +386,33 @@ static status_t -fs_get_file_map(fs_volume _fs, fs_vnode _node, off_t pos, size_t reqLen, - struct file_io_vec *vecs, size_t *_count) +fs_read_pages(fs_volume _fs, fs_vnode _node, fs_cookie _cookie, off_t pos, + const iovec *vecs, size_t count, size_t *_numBytes, bool reenter) { - nspace *ns = (nspace *)_fs; // global stuff - vnode *node = (vnode *)_node; // The read file vnode. - uint16 blockSize = ns->logicalBlkSize[FS_DATA_FORMAT]; - uint32 startBlock = node->startLBN[FS_DATA_FORMAT] + (pos / blockSize); - off_t blockPos = pos % blockSize; - off_t numBlocks = 0; - uint32 dataLen = node->dataLen[FS_DATA_FORMAT]; - size_t endLen = 0; - size_t startLen = 0; - size_t index = 0, max = *_count; + nspace *ns = (nspace *)_fs; + vnode *node = (vnode *)_node; - TRACE(("fs_get_file_map - ENTER (0x%x)\n", node)); + uint32 fileSize = node->dataLen[FS_DATA_FORMAT]; + size_t bytesLeft = *_numBytes; - // Allow an open to work on a dir, but no reads - if (node->flags & ISO_ISDIR) - return EISDIR; - - if (pos < 0) - pos = 0; - *_count = 0; - - // If passed-in requested length is bigger than file size, change it to - // file size. - if (reqLen + pos > dataLen) - reqLen = dataLen - pos; - - // Compute the length of the partial start-block read, if any. - if (reqLen + blockPos <= blockSize) - startLen = reqLen; - else if (blockPos > 0) - startLen = blockSize - blockPos; - - if (blockPos == 0 && reqLen >= blockSize) { - TRACE(("Setting startLen to 0\n")); - startLen = 0; - } - - // Compute the length of the partial end-block read, if any. - if (reqLen + blockPos > blockSize) - endLen = (reqLen + blockPos) % blockSize; - - // Compute the number of middle blocks to read. - numBlocks = ((reqLen - endLen - startLen) / blockSize); - - if (pos >= dataLen) { - // If pos >= file length, return + if (pos >= fileSize) { + *_numBytes = 0; return B_OK; } - - // Read in the first, potentially partial, block. - if (startLen > 0) { - vecs[index].offset = startBlock * blockSize + blockPos; - vecs[index].length = startLen; - startBlock++; - index++; - if (index >= max) { - // we're out of file_io_vecs; let's bail out - *_count = index; - return B_BUFFER_OVERFLOW; - } + if (pos + bytesLeft > fileSize) { + bytesLeft = fileSize - pos; + *_numBytes = bytesLeft; } - // Read in the middle blocks. - if (numBlocks > 0) { - for (int32 i = startBlock; i < startBlock + numBlocks; i++) { - vecs[index].offset = i * blockSize; - vecs[index].length = blockSize; - index++; - if (index >= max) { - // we're out of file_io_vecs; let's bail out - *_count = index; - return B_BUFFER_OVERFLOW; - } - } - } + file_io_vec fileVec; + fileVec.offset = pos + node->startLBN[FS_DATA_FORMAT] + * ns->logicalBlkSize[FS_DATA_FORMAT]; + fileVec.length = bytesLeft; - // Read in the last partial block. - if (endLen > 0) { - off_t endBlock = startBlock + numBlocks; - vecs[index].offset = endBlock * blockSize; - vecs[index].length = endLen; - index++; - } - - *_count = index; - - TRACE(("fs_get_file_map - EXIT\n")); - return B_OK; + uint32 vecIndex = 0; + size_t vecOffset = 0; + return read_file_io_vec_pages(ns->fd, &fileVec, 1, vecs, count, + &vecIndex, &vecOffset, &bytesLeft); } @@ -595,129 +464,25 @@ static status_t -fs_read(void *_ns, void *_node, void *cookie, off_t pos, void *buf, size_t *len) +fs_read(void *_ns, void *_node, void *cookie, off_t pos, void *buffer, + size_t *_length) { -#if 0 - nspace *ns = (nspace *)_ns; // global stuff - vnode *node = (vnode *)_node; // The read file vnode. - uint16 blockSize = ns->logicalBlkSize[FS_DATA_FORMAT]; - uint32 startBlock = node->startLBN[FS_DATA_FORMAT] + (pos / blockSize); - off_t blockPos = pos % blockSize; - off_t numBlocks = 0; - uint32 dataLen = node->dataLen[FS_DATA_FORMAT]; - status_t result = B_NO_ERROR; - size_t endLen = 0; - size_t reqLen = *len; - size_t startLen = 0; + vnode *node = (vnode *)_node; - (void)cookie; - - // Allow an open to work on a dir, but no reads if (node->flags & ISO_ISDIR) return EISDIR; - if (pos < 0) - pos = 0; - *len = 0; + uint32 fileSize = node->dataLen[FS_DATA_FORMAT]; - // If passed-in requested length is bigger than file size, change it to - // file size. - if (reqLen + pos > dataLen) - reqLen = dataLen - pos; - - // Compute the length of the partial start-block read, if any. - - if (reqLen + blockPos <= blockSize) - startLen = reqLen; - else if (blockPos > 0) - startLen = blockSize - blockPos; - - if (blockPos == 0 && reqLen >= blockSize) { - TRACE(("Setting startLen to 0, even block read\n")); - startLen = 0; - } - - // Compute the length of the partial end-block read, if any. - if (reqLen + blockPos > blockSize) - endLen = (reqLen + blockPos) % blockSize; - - // Compute the number of middle blocks to read. - numBlocks = ((reqLen - endLen - startLen) / blockSize); - - //dprintf("fs_read - ENTER, pos is %Ld, len is %lu\n", pos, reqLen); - //dprintf("fs_read - filename is %s\n", node->fileIDString); - //dprintf("fs_read - total file length is %lu\n", dataLen); - //dprintf("fs_read - start block of file is %lu\n", node->startLBN[FS_DATA_FORMAT]); - //dprintf("fs_read - block pos is %Lu\n", blockPos); - //dprintf("fs_read - read block will be %lu\n", startBlock); - //dprintf("fs_read - startLen is %lu\n", startLen); - //dprintf("fs_read - endLen is %lu\n", endLen); - //dprintf("fs_read - num blocks to read is %Ld\n", numBlocks); - - if (pos >= dataLen) { - // If pos >= file length, return length of 0. - *len = 0; - return B_OK; - } - - // Read in the first, potentially partial, block. - if (startLen > 0) { - off_t cachedBlock = startBlock; - char *blockData = (char *)block_cache_get_etc(ns->fBlockCache, startBlock, 0, blockSize); - if (blockData != NULL) { - //dprintf("fs_read - copying first block, len is %d.\n", startLen); - memcpy(buf, blockData+blockPos, startLen); - *len += startLen; - block_cache_put(ns->fBlockCache, cachedBlock); - startBlock++; - } else - result = EIO; - } - - // Read in the middle blocks. - if (numBlocks > 0 && result == B_NO_ERROR) { - TRACE(("fs_read - getting middle blocks\n")); - char *endBuf = ((char *)buf) + startLen; - for (int32 i=startBlock; ifBlockCache, i, 0, blockSize); - memcpy(endBuf, blockData, blockSize); - *len += blockSize; - endBuf += blockSize; - block_cache_put(ns->fBlockCache, i); - } - } - - // Read in the last partial block. - if (result == B_NO_ERROR && endLen > 0) { - off_t endBlock = startBlock + numBlocks; - char *endBlockData = (char*)block_cache_get_etc(ns->fBlockCache, endBlock, 0, blockSize); - if (endBlockData != NULL) { - char *endBuf = ((char *)buf) + (reqLen - endLen); - - memcpy(endBuf, endBlockData, endLen); - block_cache_put(ns->fBlockCache, endBlock); - *len += endLen; - } else - result = EIO; - } - - TRACE(("fs_read - EXIT, result is %s\n", strerror(result))); - return result; -#else - vnode *node = (vnode *)_node; // The read file vnode. - uint32 dataLen = node->dataLen[FS_DATA_FORMAT]; - // set/check boundaries for pos/length - if (pos < 0) { + if (pos < 0) return B_BAD_VALUE; - } - if (pos >= dataLen) { - // If pos >= file length, return length of 0. - *len = 0; + if (pos >= fileSize) { + *_length = 0; return B_OK; } - return file_cache_read(node->cache, NULL, pos, buf, len); -#endif + + return file_cache_read(node->cache, NULL, pos, buffer, _length); } @@ -728,11 +493,10 @@ (void)node; (void)cookie; - //dprintf("fs_close - ENTER\n"); - //dprintf("fs_close - EXIT\n"); return B_OK; } + static status_t fs_free_cookie(void *ns, void *node, void *cookie) { @@ -740,14 +504,10 @@ (void)node; (void)cookie; - // We don't allocate file cookies, so we do nothing here. - //dprintf("fs_free_cookie - ENTER\n"); - //if (cookie != NULL) free (cookie); - //dprintf("fs_free_cookie - EXIT\n"); return B_OK; } -// fs_access - checks permissions for access. + static status_t fs_access(void *ns, void *node, int mode) { @@ -755,35 +515,27 @@ (void)node; (void)mode; - // ns - global, fs-specific struct for device - // node - node to check permissions for - // mode - requested permissions on node. - //dprintf("fs_access - ENTER\n"); - //dprintf("fs_access - EXIT\n"); return B_OK; } + static status_t -fs_read_link(void *_ns, void *_node, char *buffer, size_t *_bufferSize) +fs_read_link(void */*_volume*/, void *_node, char *buffer, size_t *_bufferSize) { vnode *node = (vnode *)_node; - status_t result = EINVAL; - (void)_ns; + if (!S_ISLNK(node->attr.stat[FS_DATA_FORMAT].st_mode)) + return B_BAD_VALUE; - if (S_ISLNK(node->attr.stat[FS_DATA_FORMAT].st_mode)) { - size_t length = strlen(node->attr.slName); - if (length > *_bufferSize) - memcpy(buffer, node->attr.slName, *_bufferSize); - else { - memcpy(buffer, node->attr.slName, length); - *_bufferSize = length; - } - - result = B_NO_ERROR; + size_t length = strlen(node->attr.slName); + if (length > *_bufferSize) + memcpy(buffer, node->attr.slName, *_bufferSize); + else { + memcpy(buffer, node->attr.slName, length); + *_bufferSize = length; } - return result; + return B_OK; } @@ -791,28 +543,24 @@ fs_open_dir(void *_ns, void *_node, void **cookie) { vnode *node = (vnode *)_node; - status_t result = B_NO_ERROR; - dircookie *dirCookie = (dircookie *)malloc(sizeof(dircookie)); - (void)_ns; + TRACE(("fs_open_dir - node is 0x%x\n", _node)); - TRACE(("fs_open_dir - ENTER, node is 0x%x\n", _node)); - if (!(node->flags & ISO_ISDIR)) - result = EMFILE; + return B_NOT_A_DIRECTORY; - if (dirCookie != NULL) { - dirCookie->startBlock = node->startLBN[FS_DATA_FORMAT]; - dirCookie->block = node->startLBN[FS_DATA_FORMAT]; - dirCookie->totalSize = node->dataLen[FS_DATA_FORMAT]; - dirCookie->pos = 0; - dirCookie->id = node->id; - *cookie = (void *)dirCookie; - } else - result = ENOMEM; + dircookie *dirCookie = (dircookie *)malloc(sizeof(dircookie)); + if (dirCookie == NULL) + return B_NO_MEMORY; - TRACE(("fs_open_dir - EXIT\n")); - return result; + dirCookie->startBlock = node->startLBN[FS_DATA_FORMAT]; + dirCookie->block = node->startLBN[FS_DATA_FORMAT]; + dirCookie->totalSize = node->dataLen[FS_DATA_FORMAT]; + dirCookie->pos = 0; + dirCookie->id = node->id; + *cookie = (void *)dirCookie; + + return B_OK; } @@ -820,18 +568,15 @@ fs_read_dir(void *_ns, void *_node, void *_cookie, struct dirent *buffer, size_t bufferSize, uint32 *num) { - status_t result = B_NO_ERROR; nspace *ns = (nspace *)_ns; dircookie *dirCookie = (dircookie *)_cookie; - (void)_node; - TRACE(("fs_read_dir - ENTER\n")); - result = ISOReadDirEnt(ns, dirCookie, buffer, bufferSize); + status_t result = ISOReadDirEnt(ns, dirCookie, buffer, bufferSize); // If we succeeded, return 1, the number of dirents we read. - if (result == B_NO_ERROR) + if (result == B_OK) *num = 1; else *num = 0; @@ -840,7 +585,7 @@ // a zero in *num. if (result == ENOENT) - result = B_NO_ERROR; + result = B_OK; TRACE(("fs_read_dir - EXIT, result is %s\n", strerror(result))); return result; @@ -850,35 +595,17 @@ static status_t fs_rewind_dir(void *ns, void *node, void* _cookie) { - status_t result = EINVAL; dircookie *cookie = (dircookie*)_cookie; - (void)ns; - (void)node; - - //dprintf("fs_rewind_dir - ENTER\n"); - if (cookie != NULL) { - cookie->block = cookie->startBlock; - cookie->pos = 0; - result = B_NO_ERROR; - } - //dprintf("fs_rewind_dir - EXIT, result is %s\n", strerror(result)); - return result; + cookie->block = cookie->startBlock; + cookie->pos = 0; + return B_OK; } static status_t fs_close_dir(void *ns, void *node, void *cookie) { - (void)ns; - (void)node; - (void)cookie; - - // ns - global, fs-specific struct for device - // node - directory to close - // cookie - current cookie for directory. - //dprintf("fs_close_dir - ENTER\n"); - //dprintf("fs_close_dir - EXIT\n"); return B_OK; } @@ -886,20 +613,11 @@ static status_t fs_free_dir_cookie(void *ns, void *node, void *cookie) { - (void)ns; - (void)node; - - // ns - global, fs-specific struct for device - // node - directory related to cookie - // cookie - current cookie for directory, to free. - //dprintf("fs_free_dir_cookie - ENTER\n"); - if (cookie != NULL) - free(cookie); - - //dprintf("fs_free_dir_cookie - EXIT\n"); + free(cookie); return B_OK; } + // #pragma mark - @@ -908,7 +626,6 @@ { switch (op) { case B_MODULE_INIT: - return B_OK; case B_MODULE_UNINIT: return B_OK; default: @@ -944,43 +661,43 @@ &fs_get_vnode_name, &fs_read_vnode, &fs_release_vnode, - NULL, // &fs_remove_vnode() + NULL, // fs_remove_vnode() /* VM file access */ - NULL, // &fs_can_page - NULL, // &fs_read_pages - NULL, // &fs_write_pages + NULL, // fs_can_page + &fs_read_pages, + NULL, // fs_write_pages - &fs_get_file_map, + NULL, // fs_get_file_map - NULL, // &fs_ioctl - NULL, // &fs_set_flags - NULL, // &fs_select - NULL, // &fs_deselect - NULL, // &fs_fsync + NULL, // fs_ioctl + NULL, // fs_set_flags + NULL, // fs_select + NULL, // fs_deselect + NULL, // fs_fsync &fs_read_link, - NULL, // &fs_create_symlink, + NULL, // fs_create_symlink - NULL, // &fs_link, - NULL, // &fs_unlink - NULL, // &fs_rename + NULL, // fs_link, + NULL, // fs_unlink + NULL, // fs_rename &fs_access, &fs_read_stat, - NULL, // &fs_write_stat + NULL, // fs_write_stat /* file operations */ - NULL, // &fs_create + NULL, // fs_create &fs_open, &fs_close, &fs_free_cookie, &fs_read, - NULL, // &fs_write + NULL, // fs_write /* directory operations */ - NULL, // &fs_create_dir - NULL, // &fs_remove_dir + NULL, // fs_create_dir + NULL, // fs_remove_dir &fs_open_dir, &fs_close_dir, &fs_free_dir_cookie, @@ -988,42 +705,42 @@ &fs_rewind_dir, /* attribute directory operations */ - NULL, // &fs_open_attr_dir - NULL, // &fs_close_attr_dir - NULL, // &fs_free_attr_dir_cookie - NULL, // &fs_read_attr_dir - NULL, // &fs_rewind_attr_dir + NULL, // fs_open_attr_dir + NULL, // fs_close_attr_dir + NULL, // fs_free_attr_dir_cookie + NULL, // fs_read_attr_dir + NULL, // fs_rewind_attr_dir /* attribute operations */ - NULL, // &fs_create_attr - NULL, // &fs_open_attr - NULL, // &fs_close_attr - NULL, // &fs_free_attr_cookie - NULL, // &fs_read_attr - NULL, // &fs_write_attr + NULL, // fs_create_attr + NULL, // fs_open_attr + NULL, // fs_close_attr + NULL, // fs_free_attr_cookie + NULL, // fs_read_attr + NULL, // fs_write_attr - NULL, // &fs_read_attr_stat - NULL, // &fs_write_attr_stat - NULL, // &fs_rename_attr - NULL, // &fs_remove_attr + NULL, // fs_read_attr_stat + NULL, // fs_write_attr_stat + NULL, // fs_rename_attr + NULL, // fs_remove_attr [... truncated: 35 lines follow ...] From axeld at mail.berlios.de Wed Nov 21 16:45:12 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 21 Nov 2007 16:45:12 +0100 Subject: [Haiku-commits] r22971 - haiku/trunk/src/servers/app/drawing Message-ID: <200711211545.lALFjCpe013104@sheep.berlios.de> Author: axeld Date: 2007-11-21 16:45:12 +0100 (Wed, 21 Nov 2007) New Revision: 22971 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22971&view=rev Modified: haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp Log: * IsDoubleBuffered() was not correct - fModeList has nothing to do with the back buffer. This fixes bug #1631. * Cleanup. Modified: haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp 2007-11-21 12:41:58 UTC (rev 22970) +++ haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp 2007-11-21 15:45:12 UTC (rev 22971) @@ -6,6 +6,7 @@ * Michael Lotz * DarkWyrm * Stephan A?mus + * Axel D?rfler, axeld at pinc-software.de */ /*! Accelerant based HWInterface implementation */ @@ -94,51 +95,51 @@ AccelerantHWInterface::AccelerantHWInterface() - : HWInterface(), - fCardFD(-1), - fAccelerantImage(-1), - fAccelerantHook(NULL), - fEngineToken(NULL), - fSyncToken(), + : HWInterface(), + fCardFD(-1), + fAccelerantImage(-1), + fAccelerantHook(NULL), + fEngineToken(NULL), + fSyncToken(), - // required hooks - fAccAcquireEngine(NULL), - fAccReleaseEngine(NULL), - fAccSyncToToken(NULL), - fAccGetModeCount(NULL), - fAccGetModeList(NULL), - fAccGetFrameBufferConfig(NULL), - fAccSetDisplayMode(NULL), - fAccGetDisplayMode(NULL), - fAccGetPixelClockLimits(NULL), + // required hooks + fAccAcquireEngine(NULL), + fAccReleaseEngine(NULL), + fAccSyncToToken(NULL), + fAccGetModeCount(NULL), + fAccGetModeList(NULL), + fAccGetFrameBufferConfig(NULL), + fAccSetDisplayMode(NULL), + fAccGetDisplayMode(NULL), + fAccGetPixelClockLimits(NULL), - // optional accelerant hooks - fAccGetTimingConstraints(NULL), - fAccProposeDisplayMode(NULL), - fAccFillRect(NULL), - fAccInvertRect(NULL), - fAccScreenBlit(NULL), - fAccSetCursorShape(NULL), - fAccMoveCursor(NULL), - fAccShowCursor(NULL), + // optional accelerant hooks + fAccGetTimingConstraints(NULL), + fAccProposeDisplayMode(NULL), + fAccFillRect(NULL), + fAccInvertRect(NULL), + fAccScreenBlit(NULL), + fAccSetCursorShape(NULL), + fAccMoveCursor(NULL), + fAccShowCursor(NULL), - // dpms hooks - fAccDPMSCapabilities(NULL), - fAccDPMSMode(NULL), - fAccSetDPMSMode(NULL), + // dpms hooks + fAccDPMSCapabilities(NULL), + fAccDPMSMode(NULL), + fAccSetDPMSMode(NULL), - fModeCount(0), - fModeList(NULL), + fModeCount(0), + fModeList(NULL), - fBackBuffer(NULL), - fFrontBuffer(new (nothrow) AccelerantBuffer()), + fBackBuffer(NULL), + fFrontBuffer(new (nothrow) AccelerantBuffer()), - fInitialModeSwitch(true), + fInitialModeSwitch(true), - fRectParams(new (nothrow) fill_rect_params[kDefaultParamsCount]), - fRectParamsCount(kDefaultParamsCount), - fBlitParams(new (nothrow) blit_params[kDefaultParamsCount]), - fBlitParamsCount(kDefaultParamsCount) + fRectParams(new (nothrow) fill_rect_params[kDefaultParamsCount]), + fRectParamsCount(kDefaultParamsCount), + fBlitParams(new (nothrow) blit_params[kDefaultParamsCount]), + fBlitParamsCount(kDefaultParamsCount) { fDisplayMode.virtual_width = 640; fDisplayMode.virtual_height = 480; @@ -296,7 +297,8 @@ } init_accelerant initAccelerant; - initAccelerant = (init_accelerant)fAccelerantHook(B_INIT_ACCELERANT, NULL); + initAccelerant = (init_accelerant)fAccelerantHook( + B_INIT_ACCELERANT, NULL); if (!initAccelerant || initAccelerant(device) != B_OK) { ATRACE(("InitAccelerant unsuccessful\n")); unload_add_on(fAccelerantImage); @@ -383,7 +385,8 @@ AccelerantHWInterface::Shutdown() { if (fAccelerantHook) { - uninit_accelerant UninitAccelerant = (uninit_accelerant)fAccelerantHook(B_UNINIT_ACCELERANT, NULL); + uninit_accelerant UninitAccelerant = (uninit_accelerant) + fAccelerantHook(B_UNINIT_ACCELERANT, NULL); if (UninitAccelerant) UninitAccelerant(); } @@ -547,7 +550,8 @@ // Update the frame buffer used by the on-screen KDL #ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST - uint32 depth = (fFrameBufferConfig.bytes_per_row / fDisplayMode.virtual_width) << 3; + uint32 depth = (fFrameBufferConfig.bytes_per_row + / fDisplayMode.virtual_width) << 3; if (fDisplayMode.space == B_RGB15) depth = 15; @@ -578,7 +582,7 @@ if (doubleBuffered) { fBackBuffer = new(nothrow) MallocBuffer(fDisplayMode.virtual_width, - fDisplayMode.virtual_height); + fDisplayMode.virtual_height); status = fBackBuffer ? fBackBuffer->InitCheck() : B_NO_MEMORY; if (status < B_OK) { @@ -597,11 +601,12 @@ _SetGrayscalePalette(); // update acceleration hooks - fAccFillRect = (fill_rectangle)fAccelerantHook(B_FILL_RECTANGLE, (void *)&fDisplayMode); + fAccFillRect = (fill_rectangle)fAccelerantHook(B_FILL_RECTANGLE, + (void *)&fDisplayMode); fAccInvertRect = (invert_rectangle)fAccelerantHook(B_INVERT_RECTANGLE, (void *)&fDisplayMode); - fAccScreenBlit = (screen_to_screen_blit)fAccelerantHook(B_SCREEN_TO_SCREEN_BLIT, - (void *)&fDisplayMode); + fAccScreenBlit = (screen_to_screen_blit)fAccelerantHook( + B_SCREEN_TO_SCREEN_BLIT, (void *)&fDisplayMode); _NotifyFrameBufferChanged(); @@ -657,7 +662,9 @@ status_t AccelerantHWInterface::GetDeviceInfo(accelerant_device_info *info) { - get_accelerant_device_info GetAccelerantDeviceInfo = (get_accelerant_device_info)fAccelerantHook(B_GET_ACCELERANT_DEVICE_INFO, NULL); + get_accelerant_device_info GetAccelerantDeviceInfo + = (get_accelerant_device_info)fAccelerantHook( + B_GET_ACCELERANT_DEVICE_INFO, NULL); if (!GetAccelerantDeviceInfo) { ATRACE(("No B_GET_ACCELERANT_DEVICE_INFO hook found\n")); return B_UNSUPPORTED; @@ -779,11 +786,13 @@ // find preferred mode from EDID info for (uint32 i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i) { - if (info.detailed_monitor[i].monitor_desc_type != EDID1_IS_DETAILED_TIMING) + if (info.detailed_monitor[i].monitor_desc_type + != EDID1_IS_DETAILED_TIMING) continue; // construct basic mode and find it in the mode list - const edid1_detailed_timing& timing = info.detailed_monitor[i].data.detailed_timing; + const edid1_detailed_timing& timing + = info.detailed_monitor[i].data.detailed_timing; if (timing.h_active < 640 || timing.v_active < 350) continue; @@ -796,11 +805,13 @@ mode.timing.pixel_clock = timing.pixel_clock * 10; mode.timing.h_display = timing.h_active; mode.timing.h_sync_start = timing.h_active + timing.h_sync_off; - mode.timing.h_sync_end = mode.timing.h_sync_start + timing.h_sync_width; + mode.timing.h_sync_end = mode.timing.h_sync_start + + timing.h_sync_width; mode.timing.h_total = timing.h_active + timing.h_blank; mode.timing.v_display = timing.v_active; mode.timing.v_sync_start = timing.v_active + timing.v_sync_off; - mode.timing.v_sync_end = mode.timing.v_sync_start + timing.v_sync_width; + mode.timing.v_sync_end = mode.timing.v_sync_start + + timing.v_sync_width; mode.timing.v_total = timing.v_active + timing.v_blank; mode.space = B_RGB32; mode.virtual_width = timing.h_active; @@ -905,7 +916,8 @@ AccelerantHWInterface::RetraceSemaphore() { accelerant_retrace_semaphore AccelerantRetraceSemaphore = - (accelerant_retrace_semaphore)fAccelerantHook(B_ACCELERANT_RETRACE_SEMAPHORE, NULL); + (accelerant_retrace_semaphore)fAccelerantHook( + B_ACCELERANT_RETRACE_SEMAPHORE, NULL); if (!AccelerantRetraceSemaphore) return B_UNSUPPORTED; @@ -918,7 +930,9 @@ { AutoReadLocker _(this); - accelerant_retrace_semaphore AccelerantRetraceSemaphore = (accelerant_retrace_semaphore)fAccelerantHook(B_ACCELERANT_RETRACE_SEMAPHORE, NULL); + accelerant_retrace_semaphore AccelerantRetraceSemaphore + = (accelerant_retrace_semaphore)fAccelerantHook( + B_ACCELERANT_RETRACE_SEMAPHORE, NULL); if (!AccelerantRetraceSemaphore) return B_UNSUPPORTED; @@ -985,8 +999,9 @@ // all of our drivers) char path[B_PATH_NAME_LENGTH]; get_accelerant_clone_info getCloneInfo; - getCloneInfo = (get_accelerant_clone_info)fAccelerantHook(B_GET_ACCELERANT_CLONE_INFO, NULL); - + getCloneInfo = (get_accelerant_clone_info)fAccelerantHook( + B_GET_ACCELERANT_CLONE_INFO, NULL); + if (getCloneInfo == NULL) return B_NOT_SUPPORTED; @@ -1100,7 +1115,8 @@ const overlay_buffer* -AccelerantHWInterface::AllocateOverlayBuffer(int32 width, int32 height, color_space space) +AccelerantHWInterface::AllocateOverlayBuffer(int32 width, int32 height, + color_space space) { if (fAccAllocateOverlayBuffer == NULL) return NULL; @@ -1133,22 +1149,26 @@ void AccelerantHWInterface::HideOverlay(Overlay* overlay) { - fAccConfigureOverlay(overlay->OverlayToken(), overlay->OverlayBuffer(), NULL, NULL); + fAccConfigureOverlay(overlay->OverlayToken(), overlay->OverlayBuffer(), + NULL, NULL); } // CopyRegion void AccelerantHWInterface::CopyRegion(const clipping_rect* sortedRectList, - uint32 count, int32 xOffset, int32 yOffset) + uint32 count, int32 xOffset, int32 yOffset) { if (fAccScreenBlit && fAccAcquireEngine) { - if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) { + if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, + &fEngineToken) >= B_OK) { // make sure the blit_params cache is large enough if (fBlitParamsCount < count) { - fBlitParamsCount = (count / kDefaultParamsCount + 1) * kDefaultParamsCount; + fBlitParamsCount = (count / kDefaultParamsCount + 1) + * kDefaultParamsCount; // NOTE: realloc() could be used instead... - blit_params* params = new (nothrow) blit_params[fBlitParamsCount]; + blit_params* params + = new (nothrow) blit_params[fBlitParamsCount]; if (params) { delete[] fBlitParams; fBlitParams = params; @@ -1161,12 +1181,17 @@ fBlitParams[i].src_left = (uint16)sortedRectList[i].left; fBlitParams[i].src_top = (uint16)sortedRectList[i].top; - fBlitParams[i].dest_left = (uint16)sortedRectList[i].left + xOffset; - fBlitParams[i].dest_top = (uint16)sortedRectList[i].top + yOffset; + fBlitParams[i].dest_left = (uint16)sortedRectList[i].left + + xOffset; + fBlitParams[i].dest_top = (uint16)sortedRectList[i].top + + yOffset; - // NOTE: width and height are expressed as distance, not pixel count! - fBlitParams[i].width = (uint16)(sortedRectList[i].right - sortedRectList[i].left); - fBlitParams[i].height = (uint16)(sortedRectList[i].bottom - sortedRectList[i].top); + // NOTE: width and height are expressed as distance, not + // pixel count! + fBlitParams[i].width = (uint16)(sortedRectList[i].right + - sortedRectList[i].left); + fBlitParams[i].height = (uint16)(sortedRectList[i].bottom + - sortedRectList[i].top); } // go @@ -1190,8 +1215,7 @@ { if (fAccFillRect && fAccAcquireEngine) { if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, - &fEngineToken) >= B_OK) { - + &fEngineToken) >= B_OK) { // convert the region uint32 count; _RegionToRectParams(®ion, &count); @@ -1215,20 +1239,16 @@ AccelerantHWInterface::InvertRegion(/*const*/ BRegion& region) { if (fAccInvertRect && fAccAcquireEngine) { - if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) { - + if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, + &fEngineToken) >= B_OK) { // convert the region uint32 count; _RegionToRectParams(®ion, &count); - // go fAccInvertRect(fEngineToken, fRectParams, count); - // done if (fAccReleaseEngine) fAccReleaseEngine(fEngineToken, &fSyncToken); - - // sync if (fAccSyncToToken) fAccSyncToToken(&fSyncToken); } @@ -1298,10 +1318,7 @@ bool AccelerantHWInterface::IsDoubleBuffered() const { - if (fModeList) - return fBackBuffer != NULL; - - return HWInterface::IsDoubleBuffered(); + return fBackBuffer != NULL; } // _DrawCursor @@ -1318,13 +1335,15 @@ // _RegionToRectParams void AccelerantHWInterface::_RegionToRectParams(/*const*/ BRegion* region, - uint32* count) const + uint32* count) const { *count = region->CountRects(); if (fRectParamsCount < *count) { - fRectParamsCount = (*count / kDefaultParamsCount + 1) * kDefaultParamsCount; + fRectParamsCount = (*count / kDefaultParamsCount + 1) + * kDefaultParamsCount; // NOTE: realloc() could be used instead... - fill_rect_params* params = new (nothrow) fill_rect_params[fRectParamsCount]; + fill_rect_params* params + = new (nothrow) fill_rect_params[fRectParamsCount]; if (params) { delete[] fRectParams; fRectParams = params; @@ -1367,11 +1386,8 @@ case B_RGBA32_BIG: case B_RGB32_LITTLE: case B_RGBA32_LITTLE: { - uint32 native = (color.alpha << 24) | - (color.red << 16) | - (color.green << 8) | - (color.blue); - return native; + return (uint32)((color.alpha << 24) | (color.red << 16) + | (color.green << 8) | color.blue); } } return 0; From mmlr at mail.berlios.de Wed Nov 21 20:15:17 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Wed, 21 Nov 2007 20:15:17 +0100 Subject: [Haiku-commits] r22972 - in haiku/trunk/src/add-ons/kernel: bus_managers/usb busses/usb Message-ID: <200711211915.lALJFHgp016886@sheep.berlios.de> Author: mmlr Date: 2007-11-21 20:15:16 +0100 (Wed, 21 Nov 2007) New Revision: 22972 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22972&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/BusManager.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h haiku/trunk/src/add-ons/kernel/busses/usb/ehci_rh.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci_rh.cpp haiku/trunk/src/add-ons/kernel/busses/usb/uhci_rh.cpp Log: * Redesign the Pipe constructor to only take the parent object * All other init is done in InitCommon() which only needs to be present in the base class * Adding the hub port a device is attached to to the Device class * Add hub port and hub address to the Pipe class (will be used for split transactions in EHCI) * Update the root hubs to reflect the changes to hub creation Sadly we need pipes that do not belong to devices (default pipe for addressing and to get initial device descriptor). Therefore we cannot resolve hub address and port from the parent device. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/BusManager.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/BusManager.cpp 2007-11-21 15:45:12 UTC (rev 22971) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/BusManager.cpp 2007-11-21 19:15:16 UTC (rev 22972) @@ -115,7 +115,7 @@ Device * -BusManager::AllocateDevice(Hub *parent, usb_speed speed) +BusManager::AllocateDevice(Hub *parent, uint8 port, usb_speed speed) { // Check if there is a free entry in the device map (for the device number) int8 deviceAddress = AllocateAddress(); @@ -126,6 +126,7 @@ TRACE(("USB BusManager: setting device address to %d\n", deviceAddress)); ControlPipe *defaultPipe = _GetDefaultPipe(speed); + defaultPipe->SetHubInfo(parent->DeviceAddress(), port); if (!defaultPipe) { TRACE_ERROR(("USB BusManager: error getting the default pipe for speed %d\n", (int)speed)); @@ -162,7 +163,9 @@ snooze(USB_DELAY_SET_ADDRESS); // Create a temporary pipe with the new address - ControlPipe pipe(parent, deviceAddress, 0, speed, 8); + ControlPipe pipe(fRootObject); + pipe.InitCommon(deviceAddress, 0, speed, Pipe::Default, 8, 0, + parent->DeviceAddress(), port); // Get the device descriptor // Just retrieve the first 8 bytes of the descriptor -> minimum supported @@ -200,7 +203,7 @@ // Create a new instance based on the type (Hub or Device) if (deviceDescriptor.device_class == 0x09) { TRACE(("USB BusManager: creating new hub\n")); - Hub *hub = new(std::nothrow) Hub(parent, deviceDescriptor, + Hub *hub = new(std::nothrow) Hub(parent, port, deviceDescriptor, deviceAddress, speed); if (!hub) { TRACE_ERROR(("USB BusManager: no memory to allocate hub\n")); @@ -219,7 +222,7 @@ } TRACE(("USB BusManager: creating new device\n")); - Device *device = new(std::nothrow) Device(parent, deviceDescriptor, + Device *device = new(std::nothrow) Device(parent, port, deviceDescriptor, deviceAddress, speed); if (!device) { TRACE_ERROR(("USB BusManager: no memory to allocate device\n")); @@ -291,8 +294,8 @@ return NULL; if (fDefaultPipes[speed] == NULL) { - fDefaultPipes[speed] = new(std::nothrow) ControlPipe(fRootObject, - 0, 0, speed, 8); + fDefaultPipes[speed] = new(std::nothrow) ControlPipe(fRootObject); + fDefaultPipes[speed]->InitCommon(0, 0, speed, Pipe::Default, 8, 0, 0, 0); } if (!fDefaultPipes[speed]) { Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp 2007-11-21 15:45:12 UTC (rev 22971) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp 2007-11-21 19:15:16 UTC (rev 22972) @@ -10,8 +10,8 @@ #include "usb_p.h" -Device::Device(Object *parent, usb_device_descriptor &desc, int8 deviceAddress, - usb_speed speed) +Device::Device(Object *parent, int8 hubPort, usb_device_descriptor &desc, + int8 deviceAddress, usb_speed speed) : Object(parent), fDeviceDescriptor(desc), fInitOK(false), @@ -19,17 +19,23 @@ fConfigurations(NULL), fCurrentConfiguration(NULL), fSpeed(speed), - fDeviceAddress(deviceAddress) + fDeviceAddress(deviceAddress), + fHubPort(hubPort) { TRACE(("USB Device %d: creating device\n", fDeviceAddress)); - fDefaultPipe = new(std::nothrow) ControlPipe(this, deviceAddress, 0, - fSpeed, fDeviceDescriptor.max_packet_size_0); + fDefaultPipe = new(std::nothrow) ControlPipe(this); if (!fDefaultPipe) { TRACE_ERROR(("USB Device %d: could not allocate default pipe\n", fDeviceAddress)); return; } + int8 hubAddress = 0; + if (parent->Type() & USB_OBJECT_HUB) + hubAddress = ((Hub *)parent)->DeviceAddress(); + fDefaultPipe->InitCommon(fDeviceAddress, 0, fSpeed, Pipe::Default, + fDeviceDescriptor.max_packet_size_0, 0, hubAddress, fHubPort); + // Get the device descriptor // We already have a part of it, but we want it all size_t actualLength; @@ -351,6 +357,10 @@ // Set current configuration fCurrentConfiguration = &fConfigurations[index]; + int8 hubAddress = 0; + if (Parent() && (Parent()->Type() & USB_OBJECT_HUB)) + hubAddress = ((Hub *)Parent())->DeviceAddress(); + // Initialize all the endpoints that are now active for (size_t j = 0; j < fCurrentConfiguration->interface_count; j++) { usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[j].active; @@ -358,35 +368,33 @@ usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i]; Pipe *pipe = NULL; + Pipe::pipeDirection direction = Pipe::Out; + if (endpoint->descr->endpoint_address & 0x80) + direction = Pipe::In; + switch (endpoint->descr->attributes & 0x03) { case 0x00: /* Control Endpoint */ - pipe = new(std::nothrow) ControlPipe(this, fDeviceAddress, - endpoint->descr->endpoint_address & 0x0f, fSpeed, - endpoint->descr->max_packet_size); + pipe = new(std::nothrow) ControlPipe(this); + direction = Pipe::Default; break; case 0x01: /* Isochronous Endpoint */ - pipe = new(std::nothrow) IsochronousPipe(this, fDeviceAddress, - endpoint->descr->endpoint_address & 0x0f, - (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, - fSpeed, endpoint->descr->max_packet_size); + pipe = new(std::nothrow) IsochronousPipe(this); break; case 0x02: /* Bulk Endpoint */ - pipe = new(std::nothrow) BulkPipe(this, fDeviceAddress, - endpoint->descr->endpoint_address & 0x0f, - (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, - fSpeed, endpoint->descr->max_packet_size); + pipe = new(std::nothrow) BulkPipe(this); break; case 0x03: /* Interrupt Endpoint */ - pipe = new(std::nothrow) InterruptPipe(this, fDeviceAddress, - endpoint->descr->endpoint_address & 0x0f, - (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, - fSpeed, endpoint->descr->max_packet_size, endpoint->descr->interval); + pipe = new(std::nothrow) InterruptPipe(this); break; } + pipe->InitCommon(fDeviceAddress, + endpoint->descr->endpoint_address & 0x0f, + fSpeed, direction, endpoint->descr->max_packet_size, + endpoint->descr->interval, hubAddress, fHubPort); endpoint->handle = pipe->USBID(); } } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp 2007-11-21 15:45:12 UTC (rev 22971) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp 2007-11-21 19:15:16 UTC (rev 22972) @@ -11,9 +11,9 @@ #include -Hub::Hub(Object *parent, usb_device_descriptor &desc, int8 deviceAddress, - usb_speed speed) - : Device(parent, desc, deviceAddress, speed), +Hub::Hub(Object *parent, int8 hubPort, usb_device_descriptor &desc, + int8 deviceAddress, usb_speed speed) + : Device(parent, hubPort, desc, deviceAddress, speed), fInterruptPipe(NULL) { TRACE(("USB Hub %d: creating hub\n", DeviceAddress())); @@ -228,7 +228,7 @@ if (fPortStatus[i].status & PORT_STATUS_HIGH_SPEED) speed = USB_SPEED_HIGHSPEED; - Device *newDevice = GetBusManager()->AllocateDevice(this, speed); + Device *newDevice = GetBusManager()->AllocateDevice(this, i, speed); if (newDevice) { newDevice->Changed(changeList, true); Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp 2007-11-21 15:45:12 UTC (rev 22971) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp 2007-11-21 19:15:16 UTC (rev 22972) @@ -10,17 +10,12 @@ #include "usb_p.h" -Pipe::Pipe(Object *parent, int8 deviceAddress, uint8 endpointAddress, - pipeDirection direction, usb_speed speed, size_t maxPacketSize) +Pipe::Pipe(Object *parent) : Object(parent), - fDeviceAddress(deviceAddress), - fEndpointAddress(endpointAddress), - fDirection(direction), - fSpeed(speed), - fMaxPacketSize(maxPacketSize), - fDataToggle(false) + fDataToggle(false), + fControllerCookie(NULL) { - GetBusManager()->NotifyPipeChange(this, USB_CHANGE_CREATED); + // all other init is to be done in InitCommon() } @@ -31,6 +26,33 @@ } + + +void +Pipe::InitCommon(int8 deviceAddress, uint8 endpointAddress, usb_speed speed, + pipeDirection direction, size_t maxPacketSize, uint8 interval, + int8 hubAddress, uint8 hubPort) +{ + fDeviceAddress = deviceAddress; + fEndpointAddress = endpointAddress; + fSpeed = speed; + fDirection = direction; + fMaxPacketSize = maxPacketSize; + fHubAddress = hubAddress; + fHubPort = hubPort; + + GetBusManager()->NotifyPipeChange(this, USB_CHANGE_CREATED); +} + + +void +Pipe::SetHubInfo(int8 address, uint8 port) +{ + fHubAddress = address; + fHubPort = port; +} + + status_t Pipe::SubmitTransfer(Transfer *transfer) { @@ -100,12 +122,8 @@ // -InterruptPipe::InterruptPipe(Object *parent, int8 deviceAddress, - uint8 endpointAddress, pipeDirection direction, usb_speed speed, - size_t maxPacketSize, uint8 interval) - : Pipe(parent, deviceAddress, endpointAddress, direction, speed, - maxPacketSize), - fInterval(interval) +InterruptPipe::InterruptPipe(Object *parent) + : Pipe(parent) { } @@ -133,10 +151,8 @@ // -BulkPipe::BulkPipe(Object *parent, int8 deviceAddress, uint8 endpointAddress, - pipeDirection direction, usb_speed speed, size_t maxPacketSize) - : Pipe(parent, deviceAddress, endpointAddress, direction, speed, - maxPacketSize) +BulkPipe::BulkPipe(Object *parent) + : Pipe(parent) { } @@ -182,11 +198,8 @@ // -IsochronousPipe::IsochronousPipe(Object *parent, int8 deviceAddress, - uint8 endpointAddress, pipeDirection direction, usb_speed speed, - size_t maxPacketSize) - : Pipe(parent, deviceAddress, endpointAddress, direction, speed, - maxPacketSize), +IsochronousPipe::IsochronousPipe(Object *parent) + : Pipe(parent), fMaxQueuedPackets(0), fMaxBufferDuration(0), fSampleSize(0) @@ -273,10 +286,8 @@ } transfer_result_data; -ControlPipe::ControlPipe(Object *parent, int8 deviceAddress, - uint8 endpointAddress, usb_speed speed, size_t maxPacketSize) - : Pipe(parent, deviceAddress, endpointAddress, Default, speed, - maxPacketSize) +ControlPipe::ControlPipe(Object *parent) + : Pipe(parent) { } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h 2007-11-21 15:45:12 UTC (rev 22971) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h 2007-11-21 19:15:16 UTC (rev 22972) @@ -179,7 +179,7 @@ void FreeAddress(int8 address); Device *AllocateDevice(Hub *parent, - usb_speed speed); + uint8 port, usb_speed speed); void FreeDevice(Device *device); virtual status_t Start(); @@ -249,22 +249,30 @@ public: enum pipeDirection { In, Out, Default }; - Pipe(Object *parent, - int8 deviceAddress, + Pipe(Object *parent); +virtual ~Pipe(); + + void InitCommon(int8 deviceAddress, uint8 endpointAddress, - pipeDirection direction, usb_speed speed, - size_t maxPacketSize); -virtual ~Pipe(); + pipeDirection direction, + size_t maxPacketSize, + uint8 interval, + int8 hubAddress, uint8 hubPort); virtual uint32 Type() { return USB_OBJECT_PIPE; }; int8 DeviceAddress() { return fDeviceAddress; }; usb_speed Speed() { return fSpeed; }; pipeDirection Direction() { return fDirection; }; - int8 EndpointAddress() { return fEndpointAddress; }; + uint8 EndpointAddress() { return fEndpointAddress; }; size_t MaxPacketSize() { return fMaxPacketSize; }; + uint8 Interval() { return fInterval; }; + void SetHubInfo(int8 address, uint8 port); + int8 HubAddress() { return fHubAddress; }; + uint8 HubPort() { return fHubPort; }; + virtual bool DataToggle() { return fDataToggle; }; virtual void SetDataToggle(bool toggle) { fDataToggle = toggle; }; @@ -285,6 +293,9 @@ pipeDirection fDirection; usb_speed fSpeed; size_t fMaxPacketSize; + uint8 fInterval; + int8 fHubAddress; + uint8 fHubPort; bool fDataToggle; void *fControllerCookie; }; @@ -292,11 +303,7 @@ class ControlPipe : public Pipe { public: - ControlPipe(Object *parent, - int8 deviceAddress, - uint8 endpointAddress, - usb_speed speed, - size_t maxPacketSize); + ControlPipe(Object *parent); virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_CONTROL_PIPE; }; @@ -328,13 +335,7 @@ class InterruptPipe : public Pipe { public: - InterruptPipe(Object *parent, - int8 deviceAddress, - uint8 endpointAddress, - pipeDirection direction, - usb_speed speed, - size_t maxPacketSize, - uint8 interval); + InterruptPipe(Object *parent); virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_INTERRUPT_PIPE; }; @@ -342,22 +343,12 @@ size_t dataLength, usb_callback_func callback, void *callbackCookie); - - uint8 Interval() { return fInterval; }; - -private: - uint8 fInterval; }; class BulkPipe : public Pipe { public: - BulkPipe(Object *parent, - int8 deviceAddress, - uint8 endpointAddress, - pipeDirection direction, - usb_speed speed, - size_t maxPacketSize); + BulkPipe(Object *parent); virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_BULK_PIPE; }; @@ -374,12 +365,7 @@ class IsochronousPipe : public Pipe { public: - IsochronousPipe(Object *parent, - int8 deviceAddress, - uint8 endpointAddress, - pipeDirection direction, - usb_speed speed, - size_t maxPacketSize); + IsochronousPipe(Object *parent); virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_ISO_PIPE; }; @@ -425,7 +411,7 @@ class Device : public Object { public: - Device(Object *parent, + Device(Object *parent, int8 hubPort, usb_device_descriptor &desc, int8 deviceAddress, usb_speed speed); @@ -447,6 +433,7 @@ int8 DeviceAddress() const { return fDeviceAddress; }; const usb_device_descriptor *DeviceDescriptor() const; + usb_speed Speed() const { return fSpeed; }; const usb_configuration_info *Configuration() const; const usb_configuration_info *ConfigurationAt(uint8 index) const; @@ -464,6 +451,8 @@ uint32 *index, size_t bufferSize, Device *device); + int8 HubPort() const { return fHubPort; }; + // Convenience functions for standard requests virtual status_t SetFeature(uint16 selector); virtual status_t ClearFeature(uint16 selector); @@ -479,13 +468,14 @@ usb_configuration_info *fCurrentConfiguration; usb_speed fSpeed; int8 fDeviceAddress; + int8 fHubPort; ControlPipe *fDefaultPipe; }; class Hub : public Device { public: - Hub(Object *parent, + Hub(Object *parent, int8 hubPort, usb_device_descriptor &desc, int8 deviceAddress, usb_speed speed); Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci_rh.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci_rh.cpp 2007-11-21 15:45:12 UTC (rev 22971) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci_rh.cpp 2007-11-21 19:15:16 UTC (rev 22972) @@ -122,7 +122,8 @@ EHCIRootHub::EHCIRootHub(Object *rootObject, int8 deviceAddress) - : Hub(rootObject, sEHCIRootHubDevice, deviceAddress, USB_SPEED_HIGHSPEED) + : Hub(rootObject, rootObject->GetStack()->IndexOfBusManager(rootObject->GetBusManager()), + sEHCIRootHubDevice, deviceAddress, USB_SPEED_HIGHSPEED) { } Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci_rh.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci_rh.cpp 2007-11-21 15:45:12 UTC (rev 22971) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci_rh.cpp 2007-11-21 19:15:16 UTC (rev 22972) @@ -121,7 +121,8 @@ OHCIRootHub::OHCIRootHub(Object *rootObject, int8 deviceAddress) - : Hub(rootObject, sOHCIRootHubDevice, deviceAddress, USB_SPEED_FULLSPEED) + : Hub(rootObject, rootObject->GetStack()->IndexOfBusManager(rootObject->GetBusManager()), + sOHCIRootHubDevice, deviceAddress, USB_SPEED_FULLSPEED) { } Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci_rh.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/uhci_rh.cpp 2007-11-21 15:45:12 UTC (rev 22971) +++ haiku/trunk/src/add-ons/kernel/busses/usb/uhci_rh.cpp 2007-11-21 19:15:16 UTC (rev 22972) @@ -126,7 +126,8 @@ UHCIRootHub::UHCIRootHub(Object *rootObject, int8 deviceAddress) - : Hub(rootObject, sUHCIRootHubDevice, deviceAddress, USB_SPEED_FULLSPEED) + : Hub(rootObject, rootObject->GetStack()->IndexOfBusManager(rootObject->GetBusManager()), + sUHCIRootHubDevice, deviceAddress, USB_SPEED_FULLSPEED) { } From mmlr at mail.berlios.de Wed Nov 21 20:21:22 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Wed, 21 Nov 2007 20:21:22 +0100 Subject: [Haiku-commits] r22973 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711211921.lALJLMxN017132@sheep.berlios.de> Author: mmlr Date: 2007-11-21 20:21:21 +0100 (Wed, 21 Nov 2007) New Revision: 22973 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22973&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ehci_hardware.h Log: Implemented split transactions for control and bulk pipes in EHCI. With this it is possible to use low/fullspeed (USB 1.1) devices below USB 2.0 Hubs. Note though that you cannot yet use mice or keyboards attached to USB 2.0 Hubs as split transactions for interrupt pipes are still missing. Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-21 19:15:16 UTC (rev 22972) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-21 19:21:21 UTC (rev 22973) @@ -522,7 +522,6 @@ } for (int32 i = 0; sPCIModule->get_nth_pci_info(i, item) >= B_OK; i++) { - if (item->class_base == PCI_serial_bus && item->class_sub == PCI_usb && item->class_api == PCI_usb_ehci) { if (item->u.h0.interrupt_line == 0 @@ -1205,21 +1204,24 @@ return B_ERROR; } - if (pipe->Type() & USB_OBJECT_CONTROL_PIPE) { - queueHead->endpoint_chars |= - (pipe->Speed() != USB_SPEED_HIGHSPEED ? EHCI_QH_CHARS_CONTROL : 0); - } - queueHead->endpoint_chars |= (3 << EHCI_QH_CHARS_RL_SHIFT) | (pipe->MaxPacketSize() << EHCI_QH_CHARS_MPL_SHIFT) | (pipe->EndpointAddress() << EHCI_QH_CHARS_EPT_SHIFT) | (pipe->DeviceAddress() << EHCI_QH_CHARS_DEV_SHIFT) | EHCI_QH_CHARS_TOGGLE; + queueHead->endpoint_caps = (1 << EHCI_QH_CAPS_MULT_SHIFT); - if (pipe->Type() & USB_OBJECT_INTERRUPT_PIPE) queueHead->endpoint_caps |= (0xff << EHCI_QH_CAPS_ISM_SHIFT); + if (pipe->Speed() != USB_SPEED_HIGHSPEED) { + if (pipe->Type() & USB_OBJECT_CONTROL_PIPE) + queueHead->endpoint_chars |= EHCI_QH_CHARS_CONTROL; + + queueHead->endpoint_caps |= (pipe->HubPort() << EHCI_QH_CAPS_PORT_SHIFT) + | (pipe->HubAddress() << EHCI_QH_CAPS_HUB_SHIFT); + } + return B_OK; } Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci_hardware.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci_hardware.h 2007-11-21 19:15:16 UTC (rev 22972) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci_hardware.h 2007-11-21 19:21:21 UTC (rev 22973) @@ -224,9 +224,9 @@ // Applies to ehci_qh.endpoint_caps #define EHCI_QH_CAPS_MULT_SHIFT 30 // Transactions per Micro-Frame #define EHCI_QH_CAPS_MULT_MASK 0x03 -#define EHCI_QH_CAPS_PORT_SHIFT 23 // Port Number +#define EHCI_QH_CAPS_PORT_SHIFT 23 // Hub Port (Split-Transaction) #define EHCI_QH_CAPS_PORT_MASK 0x7f -#define EHCI_QH_CAPS_HUB_SHIFT 16 // Hub Address +#define EHCI_QH_CAPS_HUB_SHIFT 16 // Hub Address (Split-Transaction) #define EHCI_QH_CAPS_HUB_MASK 0x7f #define EHCI_QH_CAPS_SCM_SHIFT 8 // Split Completion Mask #define EHCI_QH_CAPS_SCM_MASK 0xff From mmu_man at mail.berlios.de Wed Nov 21 23:57:33 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 21 Nov 2007 23:57:33 +0100 Subject: [Haiku-commits] r22974 - haiku/trunk/headers/private/interface Message-ID: <200711212257.lALMvXjB027859@sheep.berlios.de> Author: mmu_man Date: 2007-11-21 23:57:33 +0100 (Wed, 21 Nov 2007) New Revision: 22974 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22974&view=rev Modified: haiku/trunk/headers/private/interface/Palette.h Log: Fix extra token at end of #endif Modified: haiku/trunk/headers/private/interface/Palette.h =================================================================== --- haiku/trunk/headers/private/interface/Palette.h 2007-11-21 19:21:21 UTC (rev 22973) +++ haiku/trunk/headers/private/interface/Palette.h 2007-11-21 22:57:33 UTC (rev 22974) @@ -95,5 +95,5 @@ { 255, 255, 255, 0 } // B_TRANSPARENT_MAGIC_CMAP8 }; -#endif __PALETTE_H +#endif /* __PALETTE_H */ From bonefish at mail.berlios.de Thu Nov 22 01:40:40 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 22 Nov 2007 01:40:40 +0100 Subject: [Haiku-commits] r22975 - haiku/trunk/src/add-ons/kernel/generic/block_io Message-ID: <200711220040.lAM0ee05021070@sheep.berlios.de> Author: bonefish Date: 2007-11-22 01:40:40 +0100 (Thu, 22 Nov 2007) New Revision: 22975 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22975&view=rev Modified: haiku/trunk/src/add-ons/kernel/generic/block_io/io.c Log: In case of writing a partial block, the complete block is first read into a buffer. The size of the S/G list for that buffer is now temporarily set to the block size for the read request. This works around the problem that the IDE bus manager would erroneously request DMA for the complete buffer (32 KB), but issue a read request only for one block, thus, after a few timeouts and bus resets, needing to resort to PIO mode. Fixes bugs #985 and #1176. Modified: haiku/trunk/src/add-ons/kernel/generic/block_io/io.c =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/block_io/io.c 2007-11-21 22:57:33 UTC (rev 22974) +++ haiku/trunk/src/add-ons/kernel/generic/block_io/io.c 2007-11-22 00:40:40 UTC (rev 22975) @@ -383,9 +383,18 @@ cur_blocks = 1; SHOW_FLOW0(3, "partial write at beginning: reading content of first block"); + + // temporarily restrict the buffer's S/G list size to how much + // we actually want to read + block_io_buffer_phys_vec.total_len = block_size; + block_io_buffer_phys_vec.vec[0].size = block_size; + res = device->interface->read(handle->cookie, &block_io_buffer_phys_vec, block_pos, cur_blocks, block_size, &bytes_transferred); + + block_io_buffer_phys_vec.total_len = block_io_buffer_size; + block_io_buffer_phys_vec.vec[0].size = block_io_buffer_size; } else { // alignment problem or partial block read - find out how many // blocks are spanned by this transfer From mmlr at mail.berlios.de Thu Nov 22 06:35:15 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Thu, 22 Nov 2007 06:35:15 +0100 Subject: [Haiku-commits] r22976 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711220535.lAM5ZF8Q023551@sheep.berlios.de> Author: mmlr Date: 2007-11-22 06:35:13 +0100 (Thu, 22 Nov 2007) New Revision: 22976 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22976&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp Log: Since the interval is now part of the general pipe info we don't have to cast the pipe to an interrupt one anymore. Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-22 00:40:40 UTC (rev 22975) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-22 05:35:13 UTC (rev 22976) @@ -457,10 +457,9 @@ print_queue(queueHead); #endif - if (pipe->Type() & USB_OBJECT_INTERRUPT_PIPE) { - uint8 interval = ((InterruptPipe *)pipe)->Interval(); - result = LinkInterruptQueueHead(queueHead, interval); - } else + if (pipe->Type() & USB_OBJECT_INTERRUPT_PIPE) + result = LinkInterruptQueueHead(queueHead, pipe->Interval()); + else result = LinkQueueHead(queueHead); if (result < B_OK) { From stefano.ceccherini at gmail.com Thu Nov 22 08:11:44 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 22 Nov 2007 08:11:44 +0100 Subject: [Haiku-commits] r22975 - haiku/trunk/src/add-ons/kernel/generic/block_io In-Reply-To: <200711220040.lAM0ee05021070@sheep.berlios.de> References: <200711220040.lAM0ee05021070@sheep.berlios.de> Message-ID: <894b9700711212311h2fbb9e77pe88926a2588f5ef9@mail.gmail.com> 2007/11/22, bonefish at BerliOS : > Author: bonefish > Date: 2007-11-22 01:40:40 +0100 (Thu, 22 Nov 2007) > New Revision: 22975 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22975&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/generic/block_io/io.c > Log: > In case of writing a partial block, the complete block is first read > into a buffer. The size of the S/G list for that buffer is now > temporarily set to the block size for the read request. This works > around the problem that the IDE bus manager would erroneously request > DMA for the complete buffer (32 KB), but issue a read request only for > one block, thus, after a few timeouts and bus resets, needing to resort > to PIO mode. Fixes bugs #985 and #1176. Wow! Great work! From axeld at pinc-software.de Thu Nov 22 10:16:05 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 22 Nov 2007 10:16:05 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r22975_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/generic/block=5Fio?= In-Reply-To: <200711220040.lAM0ee05021070@sheep.berlios.de> Message-ID: <2747400831-BeMail@zon> bonefish at BerliOS wrote: > Log: > In case of writing a partial block, the complete block is first read > into a buffer. The size of the S/G list for that buffer is now > temporarily set to the block size for the read request. This works > around the problem that the IDE bus manager would erroneously request > DMA for the complete buffer (32 KB), but issue a read request only > for > one block, thus, after a few timeouts and bus resets, needing to > resort > to PIO mode. Fixes bugs #985 and #1176. Very cool! I just hope it didn't take too long to find out! Anyway who would write partial blocks, anyway? At least the file cache contains a similar logic... but maybe it doesn't work that way for the end of the file. Bye, Axel. From jackburton at mail.berlios.de Thu Nov 22 11:53:53 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 22 Nov 2007 11:53:53 +0100 Subject: [Haiku-commits] r22977 - haiku/trunk/src/kits/interface Message-ID: <200711221053.lAMArrsx009443@sheep.berlios.de> Author: jackburton Date: 2007-11-22 11:53:53 +0100 (Thu, 22 Nov 2007) New Revision: 22977 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22977&view=rev Modified: haiku/trunk/src/kits/interface/TextView.cpp Log: BTextView::_ScrollToOffset() just didn't work correctly most of the times, since xdiff and ydiff didn't take the point returned by PointAt() into account. Thanks to Andrea Anzani for noticing this. Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2007-11-22 05:35:13 UTC (rev 22976) +++ haiku/trunk/src/kits/interface/TextView.cpp 2007-11-22 10:53:53 UTC (rev 22977) @@ -1909,6 +1909,7 @@ _ScrollToOffset(inOffset, ScrollBar(B_HORIZONTAL) != NULL, ScrollBar(B_VERTICAL) != NULL); } + void BTextView::_ScrollToOffset(int32 inOffset, bool useHorz, bool useVert) { @@ -1917,25 +1918,19 @@ float xdiff = 0.0; float ydiff = 0.0; BPoint point = PointAt(inOffset, &lineHeight); - + if (useHorz) { - if (point.x < bounds.left) { - xdiff = -1 * (bounds.IntegerWidth() / 2); - // normalize scroll value to prevent scrolling past left boundary of view - if (bounds.left < fabs(xdiff)) - xdiff = -1 * bounds.left; - } else if (point.x >= bounds.right) - xdiff = bounds.IntegerWidth() / 2; + if (point.x < bounds.left) + xdiff = point.x - bounds.left - bounds.IntegerWidth() / 2; + else if (point.x >= bounds.right) + xdiff = point.x - bounds.right + bounds.IntegerWidth() / 2; } if (useVert) { - if (point.y < bounds.top) { - ydiff = -1 * (bounds.IntegerHeight() / 2); - // normalize scroll value to prevent scrolling past top of view - if (bounds.top < fabs(ydiff)) - ydiff = -1 * bounds.top; - } else if (point.y >= bounds.bottom) - ydiff = bounds.IntegerHeight() / 2; + if (point.y < bounds.top) + ydiff = point.y - bounds.top - bounds.IntegerHeight() / 2; + else if (point.y >= bounds.bottom) + ydiff = point.y - bounds.bottom + bounds.IntegerHeight() / 2; } ScrollBy(xdiff, ydiff); From jackburton at mail.berlios.de Thu Nov 22 11:56:27 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 22 Nov 2007 11:56:27 +0100 Subject: [Haiku-commits] r22978 - haiku/trunk/src/kits/interface Message-ID: <200711221056.lAMAuRf2009553@sheep.berlios.de> Author: jackburton Date: 2007-11-22 11:56:27 +0100 (Thu, 22 Nov 2007) New Revision: 22978 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22978&view=rev Modified: haiku/trunk/src/kits/interface/TextView.cpp Log: xdiff -> xDiff, useHorz -> useHorizontal... Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2007-11-22 10:53:53 UTC (rev 22977) +++ haiku/trunk/src/kits/interface/TextView.cpp 2007-11-22 10:56:27 UTC (rev 22978) @@ -1911,29 +1911,29 @@ void -BTextView::_ScrollToOffset(int32 inOffset, bool useHorz, bool useVert) +BTextView::_ScrollToOffset(int32 inOffset, bool useHorizontal, bool useVertical) { BRect bounds = Bounds(); float lineHeight = 0.0; - float xdiff = 0.0; - float ydiff = 0.0; + float xDiff = 0.0; + float yDiff = 0.0; BPoint point = PointAt(inOffset, &lineHeight); - if (useHorz) { + if (useHorizontal) { if (point.x < bounds.left) - xdiff = point.x - bounds.left - bounds.IntegerWidth() / 2; + xDiff = point.x - bounds.left - bounds.IntegerWidth() / 2; else if (point.x >= bounds.right) - xdiff = point.x - bounds.right + bounds.IntegerWidth() / 2; + xDiff = point.x - bounds.right + bounds.IntegerWidth() / 2; } - if (useVert) { + if (useVertical) { if (point.y < bounds.top) - ydiff = point.y - bounds.top - bounds.IntegerHeight() / 2; + yDiff = point.y - bounds.top - bounds.IntegerHeight() / 2; else if (point.y >= bounds.bottom) - ydiff = point.y - bounds.bottom + bounds.IntegerHeight() / 2; + yDiff = point.y - bounds.bottom + bounds.IntegerHeight() / 2; } - ScrollBy(xdiff, ydiff); + ScrollBy(xDiff, yDiff); } From philippe.houdoin at free.fr Thu Nov 22 13:55:48 2007 From: philippe.houdoin at free.fr (Philippe Houdoin) Date: Thu, 22 Nov 2007 13:55:48 +0100 Subject: [Haiku-commits] r22968 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <1195736148.47457c542326a@imp.free.fr> > * Renamed ohci_general_descriptor to ohci_general_td, and > ohci_isochronous_descriptor to ohci_isochronous_td The "_td" is for transfer descriptor, right? I notice you keep variables and arguments of these new types being named "descriptor". For future maintenance, it could be confusing. May I suggest, if the initial issue was the typename length, that you keep the desc(riptor) semantic enough visible in the new name: ohci_general_txdesc and ohci_isochronous_txdesc, where "tx" and "desc" will ring a bell in any device writer mind? Sometime a shorter name is too short to be a name... Just my proofreading .02 cent/euros. - Philippe From niels.reedijk at gmail.com Thu Nov 22 14:00:00 2007 From: niels.reedijk at gmail.com (Niels Reedijk) Date: Thu, 22 Nov 2007 14:00:00 +0100 Subject: [Haiku-commits] r22968 - haiku/trunk/src/add-ons/kernel/busses/usb In-Reply-To: <1195736148.47457c542326a@imp.free.fr> References: <1195736148.47457c542326a@imp.free.fr> Message-ID: <507d86c0711220500n64de582bmd36aaf4e8bc8561b@mail.gmail.com> Sorry for top posting. I'd like to add that this kind of naming is used throughout the ohci documentation, so for consistency it might be a good idea to keep the names of the hardware data structures consistent with the docs. On 11/22/07, Philippe Houdoin wrote: > > * Renamed ohci_general_descriptor to ohci_general_td, and > > ohci_isochronous_descriptor to ohci_isochronous_td > > The "_td" is for transfer descriptor, right? > I notice you keep variables and arguments of these new types being named > "descriptor". For future maintenance, it could be confusing. > > May I suggest, if the initial issue was the typename length, that you keep > the > desc(riptor) semantic enough visible in the new name: ohci_general_txdesc > and > ohci_isochronous_txdesc, where "tx" and "desc" will ring a bell in any > device > writer mind? > Sometime a shorter name is too short to be a name... > > Just my proofreading .02 cent/euros. > > - Philippe > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > From jackburton at mail.berlios.de Thu Nov 22 14:05:07 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 22 Nov 2007 14:05:07 +0100 Subject: [Haiku-commits] r22979 - haiku/trunk/src/apps/showimage Message-ID: <200711221305.lAMD57Ns007554@sheep.berlios.de> Author: jackburton Date: 2007-11-22 14:05:06 +0100 (Thu, 22 Nov 2007) New Revision: 22979 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22979&view=rev Modified: haiku/trunk/src/apps/showimage/ShowImageWindow.cpp Log: small cleanup at the code I looked at Modified: haiku/trunk/src/apps/showimage/ShowImageWindow.cpp =================================================================== --- haiku/trunk/src/apps/showimage/ShowImageWindow.cpp 2007-11-22 10:56:27 UTC (rev 22978) +++ haiku/trunk/src/apps/showimage/ShowImageWindow.cpp 2007-11-22 13:05:06 UTC (rev 22979) @@ -1097,23 +1097,20 @@ BPrintJob printJob(name.String()); printJob.SetSettings(new BMessage(*fPrintSettings)); if (printJob.ConfigJob() == B_OK) { - int32 firstPage; - int32 lastPage; BRect printableRect = printJob.PrintableRect(); - float width, imageWidth, imageHeight, w1, w2; - BBitmap* bitmap; - + float width, w1, w2; + // first/lastPage is unused for now - firstPage = printJob.FirstPage(); - lastPage = printJob.LastPage(); + int32 firstPage = printJob.FirstPage(); + int32 lastPage = printJob.LastPage(); if (firstPage < 1) firstPage = 1; if (lastPage < firstPage) lastPage = firstPage; - bitmap = fImageView->GetBitmap(); - imageWidth = bitmap->Bounds().Width() + 1.0; - imageHeight = bitmap->Bounds().Height() + 1.0; + BBitmap* bitmap = fImageView->GetBitmap(); + float imageWidth = bitmap->Bounds().Width() + 1.0; + float imageHeight = bitmap->Bounds().Height() + 1.0; switch (fPrintOptions.Option()) { case PrintOptions::kFitToPage: From ingo_weinhold at gmx.de Thu Nov 22 14:32:22 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 22 Nov 2007 14:32:22 +0100 Subject: [Haiku-commits] r22975 - haiku/trunk/src/add-ons/kernel/generic/block_io In-Reply-To: <2747400831-BeMail@zon> References: <2747400831-BeMail@zon> Message-ID: <20071122143222.393.1@knochen-vm.nameserver> On 2007-11-22 at 10:16:05 [+0100], Axel D?rfler wrote: > bonefish at BerliOS wrote: > > Log: > > In case of writing a partial block, the complete block is first read > > into a buffer. The size of the S/G list for that buffer is now > > temporarily set to the block size for the read request. This works > > around the problem that the IDE bus manager would erroneously request > > DMA for the complete buffer (32 KB), but issue a read request only > > for > > one block, thus, after a few timeouts and bus resets, needing to > > resort > > to PIO mode. Fixes bugs #985 and #1176. > > Very cool! I just hope it didn't take too long to find out! Long enough, unfortunately. :-/ > Anyway who would write partial blocks, anyway? BFS when writing its superblock. CU, Ingo From sbenedetto at mail.berlios.de Fri Nov 23 00:25:38 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Fri, 23 Nov 2007 00:25:38 +0100 Subject: [Haiku-commits] r22980 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711222325.lAMNPcxG010450@sheep.berlios.de> Author: sbenedetto Date: 2007-11-23 00:25:37 +0100 (Fri, 23 Nov 2007) New Revision: 22980 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22980&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp Log: * Fixed init part of the controller Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-22 13:05:06 UTC (rev 22979) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-11-22 23:25:37 UTC (rev 22980) @@ -194,7 +194,8 @@ uint32 control = _ReadReg(OHCI_CONTROL); if (control & OHCI_INTERRUPT_ROUTING) { TRACE(("usb_ohci: SMM is in control of the host controller\n")); - _WriteReg(OHCI_COMMAND_STATUS, OHCI_OWNERSHIP_CHANGE_REQUEST); + uint32 status = _ReadReg(OHCI_COMMAND_STATUS); + _WriteReg(OHCI_COMMAND_STATUS, status | OHCI_OWNERSHIP_CHANGE_REQUEST); for (uint32 i = 0; i < 100 && (control & OHCI_INTERRUPT_ROUTING); i++) { snooze(1000); control = _ReadReg(OHCI_CONTROL); @@ -204,15 +205,9 @@ _WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_RESET); snooze(USB_DELAY_BUS_RESET); } - } else if ((control & OHCI_HC_FUNCTIONAL_STATE_MASK) - != OHCI_HC_FUNCTIONAL_STATE_RESET) { - TRACE(("usb_ohci: BIOS is in control of the host controller\n")); - if ((control & OHCI_HC_FUNCTIONAL_STATE_MASK) - != OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL) { - _WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL); - // TOFIX: shorter delay - snooze(USB_DELAY_BUS_RESET); - } + } else { + TRACE(("usb_ohci: cold started\n")); + snooze(USB_DELAY_BUS_RESET); } // This reset should not be necessary according to the OHCI spec, but @@ -227,13 +222,15 @@ // Disable interrupts right before we reset cpu_status former = disable_interrupts(); _WriteReg(OHCI_COMMAND_STATUS, OHCI_HOST_CONTROLLER_RESET); + // Nominal time for a reset is 10 us + uint32 reset = 0; for (uint32 i = 0; i < 10; i++) { spin(10); - if (!(_ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET)) + reset = _ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET; + if (!reset) break; } - - if (_ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET) { + if (reset) { TRACE_ERROR(("usb_ohci: Error resetting the host controller (timeout)\n")); restore_interrupts(former); return; @@ -380,9 +377,12 @@ { TRACE(("usb_ohci: starting OHCI Host Controller\n")); - if (!(_ReadReg(OHCI_CONTROL) & OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL)) { + if ((_ReadReg(OHCI_CONTROL) & OHCI_HC_FUNCTIONAL_STATE_MASK) + != OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL) { TRACE_ERROR(("usb_ohci: Controller not started!\n")); return B_ERROR; + } else { + TRACE(("usb_ohci: Controller is OPERATIONAL!\n")); } fRootHubAddress = AllocateAddress(); From sbenedetto at mail.berlios.de Fri Nov 23 13:01:44 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Fri, 23 Nov 2007 13:01:44 +0100 Subject: [Haiku-commits] r22981 - haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <200711231201.lANC1iAP004812@sheep.berlios.de> Author: sbenedetto Date: 2007-11-23 13:01:43 +0100 (Fri, 23 Nov 2007) New Revision: 22981 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22981&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp Log: * Added some checks on parameters passed Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp 2007-11-22 23:25:37 UTC (rev 22980) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp 2007-11-23 12:01:43 UTC (rev 22981) @@ -132,6 +132,9 @@ InterruptPipe::QueueInterrupt(void *data, size_t dataLength, usb_callback_func callback, void *callbackCookie) { + if (dataLength > 0 && data == NULL) + return B_BAD_VALUE; + Transfer *transfer = new(std::nothrow) Transfer(this); if (!transfer) return B_NO_MEMORY; @@ -161,6 +164,9 @@ BulkPipe::QueueBulk(void *data, size_t dataLength, usb_callback_func callback, void *callbackCookie) { + if (dataLength > 0 && data == NULL) + return B_BAD_VALUE; + Transfer *transfer = new(std::nothrow) Transfer(this); if (!transfer) return B_NO_MEMORY; @@ -179,6 +185,9 @@ BulkPipe::QueueBulkV(iovec *vector, size_t vectorCount, usb_callback_func callback, void *callbackCookie) { + if (vectorCount > 0 && vector == NULL) + return B_BAD_VALUE; + Transfer *transfer = new(std::nothrow) Transfer(this); if (!transfer) return B_NO_MEMORY; @@ -213,7 +222,10 @@ uint32 *startingFrameNumber, uint32 flags, usb_callback_func callback, void *callbackCookie) { - // TODO: Check if values of input parameters are set correctely + if ((dataLength > 0 && data == NULL) + || (packetCount > 0 && packetDesc == NULL)) + return B_BAD_VALUE; + usb_isochronous_data *isochronousData = new(std::nothrow) usb_isochronous_data; @@ -354,6 +366,9 @@ uint16 index, uint16 length, void *data, size_t dataLength, usb_callback_func callback, void *callbackCookie) { + if (dataLength > 0 && data == NULL) + return B_BAD_VALUE; + usb_request_data *requestData = new(std::nothrow) usb_request_data; if (!requestData) return B_NO_MEMORY; From sbenedetto at mail.berlios.de Fri Nov 23 13:19:49 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Fri, 23 Nov 2007 13:19:49 +0100 Subject: [Haiku-commits] r22982 - haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <200711231219.lANCJnZk002005@sheep.berlios.de> Author: sbenedetto Date: 2007-11-23 13:19:49 +0100 (Fri, 23 Nov 2007) New Revision: 22982 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22982&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Jamfile haiku/trunk/src/add-ons/kernel/bus_managers/usb/Transfer.cpp Log: * Removed #ifndef HAIKU_TARGET_PLATFORM_HAIKU in InitKernelAccess and PreparKernelAccess as it made those fuctions useless in HAIKU, and those functions are needed to pass data back to the user space buffer. * Fixed Jamfile Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Jamfile 2007-11-23 12:01:43 UTC (rev 22981) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Jamfile 2007-11-23 12:19:49 UTC (rev 22982) @@ -8,6 +8,9 @@ UsePrivateHeaders [ FDirName kernel ] ; if $(TARGET_PLATFORM) != haiku { UsePublicHeaders [ FDirName drivers ] ; +} else { + UseArchHeaders $(TARGET_ARCH) ; + UsePrivateHeaders [ FDirName kernel boot platform $(TARGET_BOOT_PLATFORM) ] ; } KernelStaticLibrary libusb.a : Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Transfer.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Transfer.cpp 2007-11-23 12:01:43 UTC (rev 22981) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Transfer.cpp 2007-11-23 12:19:49 UTC (rev 22982) @@ -8,6 +8,9 @@ */ #include "usb_p.h" +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + #include +#endif Transfer::Transfer(Pipe *pipe) : fPipe(pipe), @@ -123,7 +126,6 @@ status_t Transfer::InitKernelAccess() { -#ifndef HAIKU_TARGET_PLATFORM_HAIKU // we might need to access a buffer in userspace. this will not // be possible in the kernel space finisher thread unless we // get the proper area id for the space we need and then clone it @@ -132,8 +134,11 @@ for (size_t i = 0; i < fVectorCount; i++) { if (IS_USER_ADDRESS(vector[i].iov_base)) { fUserArea = area_for(vector[i].iov_base); - if (fUserArea < B_OK) + if (fUserArea < B_OK) { + TRACE_ERROR(("USB Transfer: failed to find area for user" + " space buffer!\n")); return B_BAD_ADDRESS; + } break; } } @@ -143,8 +148,10 @@ return B_OK; area_info areaInfo; - if (fUserArea < B_OK || get_area_info(fUserArea, &areaInfo) < B_OK) + if (fUserArea < B_OK || get_area_info(fUserArea, &areaInfo) < B_OK) { + TRACE_ERROR(("USB Transfer: couldn't get user area info\n")); return B_BAD_ADDRESS; + } for (size_t i = 0; i < fVectorCount; i++) { (uint8 *)vector[i].iov_base -= (uint8 *)areaInfo.address; @@ -155,8 +162,6 @@ return B_BAD_ADDRESS; } } -#endif // !HAIKU_TARGET_PLATFORM_HAIKU - return B_OK; } @@ -164,7 +169,6 @@ status_t Transfer::PrepareKernelAccess() { -#ifndef HAIKU_TARGET_PLATFORM_HAIKU // done if there is no userspace buffer or if we already cloned its area if (fUserArea < B_OK || fClonedArea >= B_OK) return B_OK; @@ -180,8 +184,6 @@ for (size_t i = 0; i < fVectorCount; i++) (uint8 *)fVector[i].iov_base += (addr_t)clonedMemory; -#endif // !HAIKU_TARGET_PLATFORM_HAIKU - return B_OK; } @@ -269,7 +271,5 @@ // Round up and set the value in microseconds fBandwidth = (bandwidthNS + 500) / 1000; - // For debugging purposes - TRACE(("USB Transfer: bandwidth neded %d\n", fBandwidth)); return B_OK; } From sbenedetto at mail.berlios.de Fri Nov 23 13:56:00 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Fri, 23 Nov 2007 13:56:00 +0100 Subject: [Haiku-commits] r22983 - haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <200711231256.lANCu0XC017684@sheep.berlios.de> Author: sbenedetto Date: 2007-11-23 13:55:59 +0100 (Fri, 23 Nov 2007) New Revision: 22983 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22983&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h Log: * Added SetAltInterface method which allows to set an alternate interface for the device * Added InitEndpoint and ClearEndpoint to avoid code duplication * Usual clean up Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp 2007-11-23 12:19:49 UTC (rev 22982) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp 2007-11-23 12:55:59 UTC (rev 22983) @@ -67,7 +67,8 @@ fConfigurations = (usb_configuration_info *)malloc( fDeviceDescriptor.num_configurations * sizeof(usb_configuration_info)); if (fConfigurations == NULL) { - TRACE_ERROR(("USB Device %d: out of memory during config creations!\n", fDeviceAddress)); + TRACE_ERROR(("USB Device %d: out of memory during config creations!\n", + fDeviceAddress)); return; } @@ -78,7 +79,8 @@ &actualLength); if (status < B_OK || actualLength != sizeof(usb_configuration_descriptor)) { - TRACE_ERROR(("USB Device %d: error fetching configuration %ld\n", fDeviceAddress, i)); + TRACE_ERROR(("USB Device %d: error fetching configuration %ld\n", + fDeviceAddress, i)); return; } @@ -97,11 +99,13 @@ (void *)configData, configDescriptor.total_length, &actualLength); if (status < B_OK || actualLength != configDescriptor.total_length) { - TRACE_ERROR(("USB Device %d: error fetching full configuration descriptor %ld\n", fDeviceAddress, i)); + TRACE_ERROR(("USB Device %d: error fetching full configuration" + " descriptor %ld\n", fDeviceAddress, i)); return; } - usb_configuration_descriptor *configuration = (usb_configuration_descriptor *)configData; + usb_configuration_descriptor *configuration + = (usb_configuration_descriptor *)configData; fConfigurations[i].descr = configuration; fConfigurations[i].interface_count = configuration->number_interfaces; fConfigurations[i].interface = (usb_interface_list *)malloc( @@ -115,7 +119,8 @@ switch (configData[descriptorStart + 1]) { case USB_DESCRIPTOR_INTERFACE: { TRACE(("USB Device %d: got interface descriptor\n", fDeviceAddress)); - usb_interface_descriptor *interfaceDescriptor = (usb_interface_descriptor *)&configData[descriptorStart]; + usb_interface_descriptor *interfaceDescriptor + = (usb_interface_descriptor *)&configData[descriptorStart]; TRACE(("\tlength:.............%d\n", interfaceDescriptor->length)); TRACE(("\tdescriptor_type:....0x%02x\n", interfaceDescriptor->descriptor_type)); TRACE(("\tinterface_number:...%d\n", interfaceDescriptor->interface_number)); @@ -126,17 +131,19 @@ TRACE(("\tinterface_protocol:.0x%02x\n", interfaceDescriptor->interface_protocol)); TRACE(("\tinterface:..........%d\n", interfaceDescriptor->interface)); - usb_interface_list *interfaceList = - &fConfigurations[i].interface[interfaceDescriptor->interface_number]; + usb_interface_list *interfaceList + = &fConfigurations[i].interface[interfaceDescriptor->interface_number]; - /* allocate this alternate */ + /* Allocate this alternate */ interfaceList->alt_count++; interfaceList->alt = (usb_interface_info *)realloc( interfaceList->alt, interfaceList->alt_count * sizeof(usb_interface_info)); + + /* Set active interface always to the first one */ interfaceList->active = interfaceList->alt; - /* setup this alternate */ + /* Setup this alternate */ usb_interface_info *interfaceInfo = &interfaceList->alt[interfaceList->alt_count - 1]; interfaceInfo->descr = interfaceDescriptor; @@ -145,6 +152,7 @@ interfaceInfo->generic_count = 0; interfaceInfo->generic = NULL; + // TODO: Remove all Interface class related code. Interface *interface = new(std::nothrow) Interface(this, interfaceDescriptor->interface_number); interfaceInfo->handle = interface->USBID(); @@ -155,7 +163,8 @@ case USB_DESCRIPTOR_ENDPOINT: { TRACE(("USB Device %d: got endpoint descriptor\n", fDeviceAddress)); - usb_endpoint_descriptor *endpointDescriptor = (usb_endpoint_descriptor *)&configData[descriptorStart]; + usb_endpoint_descriptor *endpointDescriptor + = (usb_endpoint_descriptor *)&configData[descriptorStart]; TRACE(("\tlength:.............%d\n", endpointDescriptor->length)); TRACE(("\tdescriptor_type:....0x%02x\n", endpointDescriptor->descriptor_type)); TRACE(("\tendpoint_address:...0x%02x\n", endpointDescriptor->endpoint_address)); @@ -183,7 +192,8 @@ default: TRACE(("USB Device %d: got generic descriptor\n", fDeviceAddress)); - usb_generic_descriptor *genericDescriptor = (usb_generic_descriptor *)&configData[descriptorStart]; + usb_generic_descriptor *genericDescriptor + = (usb_generic_descriptor *)&configData[descriptorStart]; TRACE(("\tlength:.............%d\n", genericDescriptor->length)); TRACE(("\tdescriptor_type:....0x%02x\n", genericDescriptor->descriptor_type)); @@ -210,7 +220,8 @@ // Set default configuration TRACE(("USB Device %d: setting default configuration\n", fDeviceAddress)); if (SetConfigurationAt(0) < B_OK) { - TRACE_ERROR(("USB Device %d: failed to set default configuration\n", fDeviceAddress)); + TRACE_ERROR(("USB Device %d: failed to set default configuration\n", + fDeviceAddress)); return; } @@ -357,11 +368,22 @@ // Set current configuration fCurrentConfiguration = &fConfigurations[index]; + // Initialize all the endpoints that are now active + InitEndpoints(); + + // Wait some for the configuration being finished + snooze(USB_DELAY_SET_CONFIGURATION); + return B_OK; +} + + +void +Device::InitEndpoints() +{ int8 hubAddress = 0; if (Parent() && (Parent()->Type() & USB_OBJECT_HUB)) hubAddress = ((Hub *)Parent())->DeviceAddress(); - // Initialize all the endpoints that are now active for (size_t j = 0; j < fCurrentConfiguration->interface_count; j++) { usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[j].active; for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) { @@ -398,13 +420,8 @@ endpoint->handle = pipe->USBID(); } } - - // Wait some for the configuration being finished - snooze(USB_DELAY_SET_CONFIGURATION); - return B_OK; } - status_t Device::Unconfigure(bool atDeviceLevel) { @@ -431,7 +448,16 @@ if (!fCurrentConfiguration) return B_OK; + ClearEndpoints(); + fCurrentConfiguration = NULL; + return B_OK; +} + + +void +Device::ClearEndpoints() +{ for (size_t j = 0; j < fCurrentConfiguration->interface_count; j++) { usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[j].active; for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) { @@ -440,12 +466,38 @@ endpoint->handle = 0; } } +} - fCurrentConfiguration = NULL; - return B_OK; + +status_t +Device::SetAltInterface(const usb_interface_info *interface) +{ + // Tell the device to set the alternate settings + status_t result = fDefaultPipe->SendRequest( + USB_REQTYPE_INTERFACE_OUT | USB_REQTYPE_STANDARD, // type + USB_REQUEST_SET_INTERFACE, // request + interface->descr->alternate_setting, // value + interface->descr->interface_number, // index + 0, // length + NULL, // buffer + 0, // buffer length + NULL); + + if (result < B_OK) + return result; + + // Update descriptor + usb_interface_list *interfaceList + = &fCurrentConfiguration->interface[interface->descr->interface_number]; + interfaceList->active + = &interfaceList->alt[interface->descr->alternate_setting]; + + ClearEndpoints(); + InitEndpoints(); + + return result; } - const usb_device_descriptor * Device::DeviceDescriptor() const { Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb.cpp 2007-11-23 12:19:49 UTC (rev 22982) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb.cpp 2007-11-23 12:55:59 UTC (rev 22983) @@ -151,7 +151,7 @@ if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0) return B_DEV_INVALID_PIPE; - return B_ERROR; + return ((Device *)object)->SetAltInterface(interface); } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h 2007-11-23 12:19:49 UTC (rev 22982) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h 2007-11-23 12:55:59 UTC (rev 22983) @@ -441,6 +441,11 @@ status_t SetConfigurationAt(uint8 index); status_t Unconfigure(bool atDeviceLevel); + status_t SetAltInterface(const usb_interface_info *interface); + + void InitEndpoints(); + void ClearEndpoints(); + virtual status_t ReportDevice( usb_support_descriptor *supportDescriptors, uint32 supportDescriptorCount, From axeld at mail.berlios.de Fri Nov 23 14:45:06 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 23 Nov 2007 14:45:06 +0100 Subject: [Haiku-commits] r22984 - haiku/trunk/src/bin/addattr Message-ID: <200711231345.lANDj6m3020662@sheep.berlios.de> Author: axeld Date: 2007-11-23 14:45:05 +0100 (Fri, 23 Nov 2007) New Revision: 22984 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22984&view=rev Modified: haiku/trunk/src/bin/addattr/main.cpp Log: * Now reports a proper error when the attribute file is empty (instead of just printing the usage info). * Minor cleanup. Modified: haiku/trunk/src/bin/addattr/main.cpp =================================================================== --- haiku/trunk/src/bin/addattr/main.cpp 2007-11-23 12:55:59 UTC (rev 22983) +++ haiku/trunk/src/bin/addattr/main.cpp 2007-11-23 13:45:05 UTC (rev 22984) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. * Copyright 2002, Sebastian Nozzi. * * Distributed under the terms of the MIT license. @@ -17,7 +17,8 @@ #include -// supported types (if you add any, make sure that writeAttr() handles them properly) +// supported types (if you add any, make sure that writeAttr() handles +// them properly) const struct { type_code type; @@ -43,19 +44,19 @@ {B_RAW_TYPE, "raw"}, }; -const uint32 kNumSupportedTypes = sizeof(kSupportedTypes) / sizeof(kSupportedTypes[0]); +const uint32 kNumSupportedTypes = sizeof(kSupportedTypes) + / sizeof(kSupportedTypes[0]); char *gProgramName; -/** For the given string that the user specifies as attribute type - * in the command line, this function tries to figure out the - * corresponding Be API value. - * - * On success, "result" will contain that value - * On failure, B_BAD_VALUE is returned and "result" is not modified - */ +/*! For the given string that the user specifies as attribute type + in the command line, this function tries to figure out the + corresponding Be API value. + On success, "result" will contain that value + On failure, B_BAD_VALUE is returned and "result" is not modified +*/ static status_t typeForString(const char *string, type_code *_result) { @@ -107,9 +108,11 @@ void invalidAttrType(const char *attrTypeName) { - fprintf(stderr, "%s: attribute type \"%s\" is not valid\n", gProgramName, attrTypeName); + fprintf(stderr, "%s: attribute type \"%s\" is not valid\n", gProgramName, + attrTypeName); fprintf(stderr, "\tTry one of: string, mime, int, llong, float, double,\n"); - fprintf(stderr, "\t\tbool, raw, or a numeric value (ie. 0x1234, 42, 'ABCD', ...)\n"); + fprintf(stderr, "\t\tbool, raw, or a numeric value (ie. 0x1234, 42, 'ABCD'" + ", ...)\n"); exit(1); } @@ -118,7 +121,8 @@ void invalidBoolValue(const char *value) { - fprintf(stderr, "%s: attribute value \"%s\" is not valid\n", gProgramName, value); + fprintf(stderr, "%s: attribute value \"%s\" is not valid\n", gProgramName, + value); fprintf(stderr, "\tBool accepts: 0, f, false, disabled, off,\n"); fprintf(stderr, "\t\t1, t, true, enabled, on\n"); @@ -160,6 +164,12 @@ status = file.GetSize(&size); if (status == B_OK) { + if (size == 0) { + fprintf(stderr, "%s: attribute value is empty: 0 bytes\n", + gProgramName); + + return 1; + } if (size > 4 * 1024 * 1024) { fprintf(stderr, "%s: attribute value is too large: %Ld bytes\n", gProgramName, size); From sbenedetto at mail.berlios.de Fri Nov 23 15:01:18 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Fri, 23 Nov 2007 15:01:18 +0100 Subject: [Haiku-commits] r22985 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200711231401.lANE1I7t021634@sheep.berlios.de> Author: sbenedetto Date: 2007-11-23 15:01:17 +0100 (Fri, 23 Nov 2007) New Revision: 22985 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22985&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h Log: * Small clean up Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp 2007-11-23 13:45:05 UTC (rev 22984) +++ haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp 2007-11-23 14:01:17 UTC (rev 22985) @@ -12,7 +12,6 @@ #include #include #include -#include #include "uhci.h" @@ -34,7 +33,7 @@ } return B_OK; -} +} host_controller_info uhci_module = { @@ -318,7 +317,7 @@ fRegisterBase = sPCIModule->read_pci_config(fPCIInfo->bus, fPCIInfo->device, fPCIInfo->function, PCI_memory_base, 4); fRegisterBase &= PCI_address_io_mask; - TRACE_ERROR(("usb_uhci: iospace offset: 0x%08lx\n", fRegisterBase)); + TRACE(("usb_uhci: iospace offset: 0x%08lx\n", fRegisterBase)); if (fRegisterBase == 0) { fRegisterBase = fPCIInfo->u.h0.base_registers[0]; @@ -395,7 +394,7 @@ // Create the array that will keep bandwidth information fFrameBandwidth = new(std::nothrow) uint16[NUMBER_OF_FRAMES]; - // create lists for managing isochronous transfer descriptors + // Create lists for managing isochronous transfer descriptors fFirstIsochronousDescriptor = new(std::nothrow) uhci_td *[NUMBER_OF_FRAMES]; if (!fFirstIsochronousDescriptor) { TRACE_ERROR(("usb_uhci: cannot allocate memory\n")); @@ -564,7 +563,8 @@ if (transfer->TransferPipe()->DeviceAddress() == fRootHubAddress) return fRootHub->ProcessTransfer(this, transfer); - TRACE(("usb_uhci: submit transfer called for device %d\n", transfer->TransferPipe()->DeviceAddress())); + TRACE(("usb_uhci: submit transfer called for device %d\n", + transfer->TransferPipe()->DeviceAddress())); if (transfer->TransferPipe()->Type() & USB_OBJECT_CONTROL_PIPE) return SubmitRequest(transfer); Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h 2007-11-23 13:45:05 UTC (rev 22984) +++ haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h 2007-11-23 14:01:17 UTC (rev 22985) @@ -232,6 +232,7 @@ UHCIRootHub *fRootHub; uint8 fRootHubAddress; uint8 fPortResetChange; + }; From fekdahl at gmail.com Sat Nov 24 07:23:17 2007 From: fekdahl at gmail.com (Fredrik Ekdahl) Date: Sat, 24 Nov 2007 07:23:17 +0100 Subject: [Haiku-commits] r22983 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <200711231256.lANCu0XC017684@sheep.berlios.de> References: <200711231256.lANCu0XC017684@sheep.berlios.de> Message-ID: <1195885397.5799.2.camel@ekdahl> Build is broken with gcc 4. Here's the error message: C++ generated/objects/haiku/x86/release/add-ons/kernel/bus_managers/usb/Transfer.o src/add-ons/kernel/bus_managers/usb/Transfer.cpp: In member function 'status_t Transfer::InitKernelAccess()': src/add-ons/kernel/bus_managers/usb/Transfer.cpp:157: error: invalid lvalue in assignment src/add-ons/kernel/bus_managers/usb/Transfer.cpp: In member function 'status_t Transfer::PrepareKernelAccess()': src/add-ons/kernel/bus_managers/usb/Transfer.cpp:186: error: invalid lvalue in assignment /media/data/develop/haiku/trunk/generated/cross-tools/bin/i586-pc-haiku-gcc -c "src/add-ons/kernel/bus_managers/usb/Transfer.cpp" -O -Wall -Wno-trigraphs -nostdinc -Wno-multichar -Wno-deprecated -fno-rtti -D_ZETA_USING_DEPRECATED_API_=1 -D_ZETA_TS_FIND_DIR_=1 -finline -fno-builtin -fno-exceptions -Wno-multichar -DBOCHS_DEBUG_HACK=0 -D_KERNEL_MODE -fno-use-cxa-atexit -fno-pic -D__HAIKU__ -DHAIKU_DISTRO_COMPATIBILITY_DEFAULT -D__INTEL__ -DARCH_x86 -DHAIKU_TARGET_PLATFORM_HAIKU -iquote src/add-ons/kernel/bus_managers/usb -iquote generated/objects/common/add-ons/kernel/bus_managers/usb -iquote generated/objects/linux/x86/common/add-ons/kernel/bus_managers/usb -iquote generated/objects/haiku/x86/common/add-ons/kernel/bus_managers/usb -I src/add-ons/kernel/bus_managers/usb -I headers/private/kernel -I headers/private/kernel/arch/x86 -I headers/private/kernel/boot/platform/bios_ia32 -I headers -I headers/posix -I headers/gnu -I headers/glibc -I headers/os -I headers/os/add-ons -I headers/os/add-ons/file_system -I headers/os/add-ons/graphics -I headers/os/add-ons/input_server -I headers/os/add-ons/registrar -I headers/os/add-ons/screen_saver -I headers/os/add-ons/tracker -I headers/os/app -I headers/os/device -I headers/os/drivers -I headers/os/game -I headers/os/interface -I headers/os/kernel -I headers/os/media -I headers/os/mail -I headers/os/midi -I headers/os/midi2 -I headers/os/net -I headers/os/opengl -I headers/os/storage -I headers/os/support -I headers/os/translation -I headers/private/. -I /media/data/develop/haiku/trunk/generated/cross-tools/lib/gcc/i586-pc-haiku/4.1.2/../../../../include/c++/4.1.2 -I /media/data/develop/haiku/trunk/generated/cross-tools/lib/gcc/i586-pc-haiku/4.1.2/../../../../include/c++/4.1.2/i586-pc-haiku -I /media/data/develop/haiku/trunk/generated/cross-tools/lib/gcc/i586-pc-haiku/4.1.2/../../../../include/c++/4.1.2/backward -I /media/data/develop/haiku/trunk/generated/cross-tools/lib/gcc/i586-pc-haiku/4.1.2/../../../../include/c++/4.1.2/ext -I /media/data/develop/haiku/trunk/generated/cross-tools/lib/gcc/i586-pc-haiku/4.1.2/include -o "generated/objects/haiku/x86/release/add-ons/kernel/bus_managers/usb/Transfer.o" ; ...failed C++ generated/objects/haiku/x86/release/add-ons/kernel/bus_managers/usb/Transfer.o ... /Fredrik Ekdahl From emitrax at gmail.com Sat Nov 24 10:42:00 2007 From: emitrax at gmail.com (Salvatore Benedetto) Date: Sat, 24 Nov 2007 09:42:00 +0000 Subject: [Haiku-commits] r22983 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <1195885397.5799.2.camel@ekdahl> References: <200711231256.lANCu0XC017684@sheep.berlios.de> <1195885397.5799.2.camel@ekdahl> Message-ID: On Nov 24, 2007 6:23 AM, Fredrik Ekdahl wrote: > Build is broken with gcc 4. Here's the error message: > > C++ > generated/objects/haiku/x86/release/add-ons/kernel/bus_managers/usb/Transfer.o > src/add-ons/kernel/bus_managers/usb/Transfer.cpp: In member function > 'status_t Transfer::InitKernelAccess()': > src/add-ons/kernel/bus_managers/usb/Transfer.cpp:157: error: invalid > lvalue in assignment > src/add-ons/kernel/bus_managers/usb/Transfer.cpp: In member function > 'status_t Transfer::PrepareKernelAccess()': > src/add-ons/kernel/bus_managers/usb/Transfer.cpp:186: error: invalid > lvalue in assignment > > /media/data/develop/haiku/trunk/generated/cross-tools/bin/i586-pc-haiku-gcc -c "src/add-ons/kernel/bus_managers/usb/Transfer.cpp" -O -Wall -Wno-trigraphs -nostdinc -Wno-multichar -Wno-deprecated -fno-rtti -D_ZETA_USING_DEPRECATED_API_=1 -D_ZETA_TS_FIND_DIR_=1 -finline -fno-builtin -fno-exceptions -Wno-multichar -DBOCHS_DEBUG_HACK=0 -D_KERNEL_MODE -fno-use-cxa-atexit -fno-pic -D__HAIKU__ -DHAIKU_DISTRO_COMPATIBILITY_DEFAULT -D__INTEL__ -DARCH_x86 -DHAIKU_TARGET_PLATFORM_HAIKU -iquote src/add-ons/kernel/bus_managers/usb -iquote generated/objects/common/add-ons/kernel/bus_managers/usb -iquote generated/objects/linux/x86/common/add-ons/kernel/bus_managers/usb -iquote generated/objects/haiku/x86/common/add-ons/kernel/bus_managers/usb -I src/add-ons/kernel/bus_managers/usb -I headers/private/kernel -I headers/private/kernel/arch/x86 -I headers/private/kernel/boot/platform/bios_ia32 -I headers -I headers/posix -I headers/gnu -I headers/glibc -I headers/os -I headers/os/add-ons -I he > aders/os/add-ons/file_system -I headers/os/add-ons/graphics -I headers/os/add-ons/input_server -I headers/os/add-ons/registrar -I headers/os/add-ons/screen_saver -I headers/os/add-ons/tracker -I headers/os/app -I headers/os/device -I headers/os/drivers -I headers/os/game -I headers/os/interface -I headers/os/kernel -I headers/os/media -I headers/os/mail -I headers/os/midi -I headers/os/midi2 -I headers/os/net -I headers/os/opengl -I headers/os/storage -I headers/os/support -I headers/os/translation -I headers/private/. -I /media/data/develop/haiku/trunk/generated/cross-tools/lib/gcc/i586-pc-haiku/4.1.2/../../../../include/c++/4.1.2 -I /media/data/develop/haiku/trunk/generated/cross-tools/lib/gcc/i586-pc-haiku/4.1.2/../../../../include/c++/4.1.2/i586-pc-haiku -I /media/data/develop/haiku/trunk/generated/cross-tools/lib/gcc/i586-pc-haiku/4.1.2/../../../../include/c++/4.1.2/backward -I /media/data/develop/haiku/trunk/generated/cross-tools/lib/gcc/i586-pc-haiku/4.1.2/../../../.. > /include/c++/4.1.2/ext -I /media/data/develop/haiku/trunk/generated/cross-tools/lib/gcc/i586-pc-haiku/4.1.2/include -o "generated/objects/haiku/x86/release/add-ons/kernel/bus_managers/usb/Transfer.o" ; > > ...failed C++ > generated/objects/haiku/x86/release/add-ons/kernel/bus_managers/usb/Transfer.o ... > > /Fredrik Ekdahl Thanks for reporting Frederik. This are the incriminated lines (uint8 *)vector[i].iov_base -= (uint8 *)areaInfo.address; ... (uint8 *)fVector[i].iov_base += (addr_t)clonedMemory; and all the values are void * type. I'm not a gcc-4 expert, but by googling I think it should be something like vector[i].iov_base -= (void *)areaInfo.address; fVector[i].iov_base += (void *)clonedMemory; on gcc-4, but it does not compile on gcc-2.95. Could you confirm if it works with gcc-4? Anyone else has an idea? Salvo -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer and Telecommunications Engineering University of Messina (Italy) www.messinalug.org Please do not send me any word, excel or power point file http://www.gnu.org/philosophy/no-word-attachments.html From fekdahl at gmail.com Sat Nov 24 10:53:02 2007 From: fekdahl at gmail.com (Fredrik Ekdahl) Date: Sat, 24 Nov 2007 10:53:02 +0100 Subject: [Haiku-commits] r22983 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: References: <200711231256.lANCu0XC017684@sheep.berlios.de> <1195885397.5799.2.camel@ekdahl> Message-ID: <1195897982.5799.5.camel@ekdahl> l?r 2007-11-24 klockan 09:42 +0000 skrev Salvatore Benedetto: ... > This are the incriminated lines > > (uint8 *)vector[i].iov_base -= (uint8 *)areaInfo.address; > ... > (uint8 *)fVector[i].iov_base += (addr_t)clonedMemory; > > and all the values are void * type. I'm not a gcc-4 expert, but by googling > I think it should be something like > > vector[i].iov_base -= (void *)areaInfo.address; > fVector[i].iov_base += (void *)clonedMemory; > > on gcc-4, but it does not compile on gcc-2.95. Could you confirm if it > works with gcc-4? > It does not work. I get the following error messages now: C++ generated/objects/haiku/x86/release/add-ons/kernel/bus_managers/usb/Transfer.o src/add-ons/kernel/bus_managers/usb/Transfer.cpp: In member function 'status_t Transfer::InitKernelAccess()': src/add-ons/kernel/bus_managers/usb/Transfer.cpp:157: error: invalid use of 'void' src/add-ons/kernel/bus_managers/usb/Transfer.cpp:157: error: in evaluation of 'operator-=(void*, void*)' src/add-ons/kernel/bus_managers/usb/Transfer.cpp: In member function 'status_t Transfer::PrepareKernelAccess()': src/add-ons/kernel/bus_managers/usb/Transfer.cpp:186: error: invalid operands of types 'void*' and 'void*' to binary 'operator+' src/add-ons/kernel/bus_managers/usb/Transfer.cpp:186: error: in evaluation of 'operator+=(void*, void*)' > Anyone else has an idea? > > Salvo > /Fredrik From axeld at pinc-software.de Sat Nov 24 11:46:30 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sat, 24 Nov 2007 11:46:30 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r22983_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/bus=5Fmanagers/usb?= In-Reply-To: Message-ID: <1294073863-BeMail@zon> "Salvatore Benedetto" wrote: > and all the values are void * type. I'm not a gcc-4 expert, but by > googling > I think it should be something like > > vector[i].iov_base -= (void *)areaInfo.address; > fVector[i].iov_base += (void *)clonedMemory; > > on gcc-4, but it does not compile on gcc-2.95. Could you confirm if > it > works with gcc-4? > > Anyone else has an idea? Yes, you are not supposed to do arithmetics with void pointers (they are void, so the compiler pretends it doesn't know how to do this). Correct would be this form: vector[i].iov_base = (void *)((uint8 *)vector[i].iov_base - (uint8 *)areaInfo.address); fVector[i].iov_base = (void *)((uint8 *)fVector[i].iov_base + (uint8 *)clonedMemory); Alternatively, you could cast them to "addr_t", too, but that type did not exist on BeOS. Bye, Axel. From marcusoverhagen at mail.berlios.de Sat Nov 24 12:20:39 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 24 Nov 2007 12:20:39 +0100 Subject: [Haiku-commits] r22986 - haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <200711241120.lAOBKdL0011510@sheep.berlios.de> Author: marcusoverhagen Date: 2007-11-24 12:20:38 +0100 (Sat, 24 Nov 2007) New Revision: 22986 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22986&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Transfer.cpp Log: gcc4 build fix Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Transfer.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Transfer.cpp 2007-11-23 14:01:17 UTC (rev 22985) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Transfer.cpp 2007-11-24 11:20:38 UTC (rev 22986) @@ -114,7 +114,7 @@ continue; } - fVector[i].iov_base = (void *)((uint8 *)fVector[i].iov_base + length); + fVector[i].iov_base = (uint8 *)fVector[i].iov_base + length; fVector[i].iov_len -= length; break; } @@ -154,7 +154,7 @@ } for (size_t i = 0; i < fVectorCount; i++) { - (uint8 *)vector[i].iov_base -= (uint8 *)areaInfo.address; + vector[i].iov_base = (uint8 *)vector[i].iov_base - (addr_t)areaInfo.address; if ((size_t)vector[i].iov_base > areaInfo.size || (size_t)vector[i].iov_base + vector[i].iov_len > areaInfo.size) { @@ -183,7 +183,7 @@ return fClonedArea; for (size_t i = 0; i < fVectorCount; i++) - (uint8 *)fVector[i].iov_base += (addr_t)clonedMemory; + fVector[i].iov_base = (uint8 *)fVector[i].iov_base + (addr_t)clonedMemory; return B_OK; } From marcusoverhagen at arcor.de Sat Nov 24 12:28:37 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Sat, 24 Nov 2007 12:28:37 +0100 (CET) Subject: [Haiku-commits] r22983 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <1294073863-BeMail@zon> References: <1294073863-BeMail@zon> Message-ID: <4833440.1195903717168.JavaMail.ngmail@webmail18> Axel D?rfler wrote: > Yes, you are not supposed to do arithmetics with void pointers (they There is more that is wrong with the code. Subtracting a pointer from a pointer results in an offset, not a pointer. And you are not supposed to add two pointers either, because that has no defined result. > are void, so the compiler pretends it doesn't know how to do this). > Correct would be this form: > vector[i].iov_base = (void *)((uint8 *)vector[i].iov_base - (uint8 > *)areaInfo.address); > fVector[i].iov_base = (void *)((uint8 *)fVector[i].iov_base + > (uint8 *)clonedMemory); I checked in a build fix that converts areaInfo.address and clonedMemory to addr_t to use it as an offset, that saves a few casts. > Alternatively, you could cast them to "addr_t", too, but that type did > not exist on BeOS. Yes thats a nice type. unsigned long might not be large enough on 64 bit platforms in the future. regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From emitrax at gmail.com Sat Nov 24 13:07:33 2007 From: emitrax at gmail.com (Salvatore Benedetto) Date: Sat, 24 Nov 2007 12:07:33 +0000 Subject: [Haiku-commits] r22983 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <4833440.1195903717168.JavaMail.ngmail@webmail18> References: <1294073863-BeMail@zon> <4833440.1195903717168.JavaMail.ngmail@webmail18> Message-ID: Thanks to both for the help. Salvo -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer and Telecommunications Engineering University of Messina (Italy) www.messinalug.org Please do not send me any word, excel or power point file http://www.gnu.org/philosophy/no-word-attachments.html From axeld at mail.berlios.de Sat Nov 24 15:36:14 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 24 Nov 2007 15:36:14 +0100 Subject: [Haiku-commits] r22987 - haiku/trunk/src/apps/sudoku Message-ID: <200711241436.lAOEaEFk009136@sheep.berlios.de> Author: axeld Date: 2007-11-24 15:36:13 +0100 (Sat, 24 Nov 2007) New Revision: 22987 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22987&view=rev Modified: haiku/trunk/src/apps/sudoku/Jamfile haiku/trunk/src/apps/sudoku/SudokuView.cpp haiku/trunk/src/apps/sudoku/SudokuView.h haiku/trunk/src/apps/sudoku/SudokuWindow.cpp haiku/trunk/src/apps/sudoku/SudokuWindow.h Log: * Renamed "Store Current" to "Snapshot Current", and "Restore Saved" to "Restore Snapshot". * Implemented a simple undo/redo. Modified: haiku/trunk/src/apps/sudoku/Jamfile =================================================================== --- haiku/trunk/src/apps/sudoku/Jamfile 2007-11-24 11:20:38 UTC (rev 22986) +++ haiku/trunk/src/apps/sudoku/Jamfile 2007-11-24 14:36:13 UTC (rev 22987) @@ -2,6 +2,8 @@ SetSubDirSupportedPlatformsBeOSCompatible ; +UsePrivateHeaders shared ; + Application Sudoku : CenteredViewContainer.cpp ProgressWindow.cpp Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2007-11-24 11:20:38 UTC (rev 22986) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2007-11-24 14:36:13 UTC (rev 22987) @@ -144,6 +144,7 @@ } } + _PushUndo(); status = fField->SetTo(_BaseCharacter(), buffer); Invalidate(); return status; @@ -164,6 +165,7 @@ if (status < B_OK) return B_BAD_VALUE; + _PushUndo(); status = fField->SetTo(_BaseCharacter(), buffer); Invalidate(); return status; @@ -176,6 +178,7 @@ if (field == NULL || field == fField) return B_BAD_VALUE; + _PushUndo(); delete fField; fField = field; @@ -222,6 +225,8 @@ void SudokuView::ClearChanged() { + _PushUndo(); + for (uint32 y = 0; y < fField->Size(); y++) { for (uint32 x = 0; x < fField->Size(); x++) { if ((fField->FlagsAt(x, y) & kInitialValue) == 0) @@ -236,6 +241,7 @@ void SudokuView::ClearAll() { + _PushUndo(); fField->Reset(); Invalidate(); } @@ -414,6 +420,55 @@ void +SudokuView::_UndoRedo(BObjectList& undos, + BObjectList& redos) +{ + if (undos.IsEmpty()) + return; + + BMessage* undo = undos.RemoveItemAt(undos.CountItems() - 1); + + BMessage* redo = new BMessage; + if (fField->Archive(redo, true) == B_OK) + redos.AddItem(redo); + + SudokuField field(undo); + delete undo; + + fField->SetTo(&field); + + SendNotices(kUndoRedoChanged); + Invalidate(); +} + + +void +SudokuView::Undo() +{ + _UndoRedo(fUndos, fRedos); +} + + +void +SudokuView::Redo() +{ + _UndoRedo(fRedos, fUndos); +} + + +void +SudokuView::_PushUndo() +{ + fRedos.MakeEmpty(); + + BMessage* undo = new BMessage; + if (fField->Archive(undo, true) == B_OK + && fUndos.AddItem(undo)) + SendNotices(kUndoRedoChanged); +} + + +void SudokuView::MouseDown(BPoint where) { uint32 x, y; @@ -433,6 +488,7 @@ uint32 value = hintX + hintY * fBlockSize; uint32 field = x + y * fField->Size(); + _PushUndo(); if (clicks == 2 && fLastHintValue == value && fLastField == field || (buttons & (B_SECONDARY_MOUSE_BUTTON @@ -540,6 +596,7 @@ if (value == 0) return; + _PushUndo(); uint32 hintMask = fField->HintMaskAt(fKeyboardX, fKeyboardY); uint32 valueMask = 1UL << (value - 1); if (modifiers & B_OPTION_KEY) @@ -550,6 +607,7 @@ fField->SetValueAt(fKeyboardX, fKeyboardY, 0); fField->SetHintMaskAt(fKeyboardX, fKeyboardY, hintMask); } else { + _PushUndo(); fField->SetValueAt(fKeyboardX, fKeyboardY, value); if (value) BMessenger(this).SendMessage(kMsgCheckSolved); @@ -638,6 +696,14 @@ } break; + case B_UNDO: + Undo(); + break; + + case B_REDO: + Redo(); + break; + case kMsgSolveSudoku: { SudokuSolver solver; @@ -647,6 +713,7 @@ printf("found %ld solutions in %g msecs\n", solver.CountSolutions(), (system_time() - start) / 1000.0); if (solver.CountSolutions() > 0) { + _PushUndo(); fField->SetTo(solver.SolutionAt(0)); Invalidate(); } else @@ -668,6 +735,8 @@ printf("found %ld solutions in %g msecs\n", solver.CountSolutions(), (system_time() - start) / 1000.0); if (solver.CountSolutions() > 0) { + _PushUndo(); + // find free spot uint32 x, y; do { Modified: haiku/trunk/src/apps/sudoku/SudokuView.h =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.h 2007-11-24 11:20:38 UTC (rev 22986) +++ haiku/trunk/src/apps/sudoku/SudokuView.h 2007-11-24 14:36:13 UTC (rev 22987) @@ -7,6 +7,7 @@ #include +#include class SudokuField; struct entry_ref; @@ -43,6 +44,11 @@ void SetEditable(bool editable); bool Editable() const { return fEditable; } + bool CanUndo() { return !fUndos.IsEmpty(); } + bool CanRedo() { return !fRedos.IsEmpty(); } + void Undo(); + void Redo(); + protected: virtual void AttachedToWindow(); @@ -75,9 +81,13 @@ void _FitFont(BFont& font, float width, float height); void _DrawKeyboardFocus(); void _DrawHints(uint32 x, uint32 y); + void _UndoRedo(BObjectList& undos, BObjectList& redos); + void _PushUndo(); rgb_color fBackgroundColor; SudokuField* fField; + BObjectList fUndos; + BObjectList fRedos; uint32 fBlockSize; float fWidth, fHeight, fBaseline; BFont fFieldFont; @@ -98,4 +108,7 @@ static const uint32 kMsgSolveSudoku = 'slvs'; static const uint32 kMsgSolveSingle = 'slsg'; +// you can observe these: +static const int32 kUndoRedoChanged = 'unre'; + #endif // SUDOKU_VIEW_H Modified: haiku/trunk/src/apps/sudoku/SudokuWindow.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuWindow.cpp 2007-11-24 11:20:38 UTC (rev 22986) +++ haiku/trunk/src/apps/sudoku/SudokuWindow.cpp 2007-11-24 14:36:13 UTC (rev 22987) @@ -210,8 +210,7 @@ new BMessage(B_ABOUT_REQUESTED))); menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), - 'Q', B_COMMAND_KEY)); + menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); menu->SetTargetForItems(this); item->SetTarget(be_app); menuBar->AddItem(menu); @@ -231,8 +230,15 @@ // "Help" menu menu = new BMenu("Help"); - menu->AddItem(new BMenuItem("Store Current", new BMessage(kMsgStoreState))); - menu->AddItem(fRestoreStateItem = new BMenuItem("Restore Saved", + menu->AddItem(fUndoItem = new BMenuItem("Undo", new BMessage(B_UNDO), 'Z')); + fUndoItem->SetEnabled(false); + menu->AddItem(fRedoItem = new BMenuItem("Redo", new BMessage(B_REDO), 'Z', + B_SHIFT_KEY)); + fRedoItem->SetEnabled(false); + menu->AddSeparatorItem(); + + menu->AddItem(new BMenuItem("Snapshot Current", new BMessage(kMsgStoreState))); + menu->AddItem(fRestoreStateItem = new BMenuItem("Restore Snapshot", new BMessage(kMsgRestoreState))); fRestoreStateItem->SetEnabled(fStoredState != NULL); menu->AddSeparatorItem(); @@ -248,6 +254,9 @@ fSavePanel = new BFilePanel(B_SAVE_PANEL); fSavePanel->SetTarget(this); + fSudokuView->StartWatching(this, kUndoRedoChanged); + // we like to know whenever the undo/redo state changes + fProgressWindow = new ProgressWindow(this, new BMessage(kMsgAbortSudokuGenerator)); } @@ -499,6 +508,19 @@ B_WIDTH_AS_USUAL, B_IDEA_ALERT))->Go(); break; + case B_OBSERVER_NOTICE_CHANGE: + { + int32 what; + if (message->FindInt32(B_OBSERVE_WHAT_CHANGE, &what) != B_OK) + break; + + if (what == kUndoRedoChanged) { + fUndoItem->SetEnabled(fSudokuView->CanUndo()); + fRedoItem->SetEnabled(fSudokuView->CanRedo()); + } + break; + } + default: BWindow::MessageReceived(message); break; Modified: haiku/trunk/src/apps/sudoku/SudokuWindow.h =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuWindow.h 2007-11-24 11:20:38 UTC (rev 22986) +++ haiku/trunk/src/apps/sudoku/SudokuWindow.h 2007-11-24 14:36:13 UTC (rev 22987) @@ -39,6 +39,8 @@ SudokuView* fSudokuView; GenerateSudoku* fGenerator; BMenuItem* fRestoreStateItem; + BMenuItem* fUndoItem; + BMenuItem* fRedoItem; BMessage* fStoredState; }; From axeld at mail.berlios.de Sat Nov 24 16:35:08 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 24 Nov 2007 16:35:08 +0100 Subject: [Haiku-commits] r22988 - haiku/trunk/src/preferences/backgrounds Message-ID: <200711241535.lAOFZ8kE013167@sheep.berlios.de> Author: axeld Date: 2007-11-24 16:35:07 +0100 (Sat, 24 Nov 2007) New Revision: 22988 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22988&view=rev Modified: haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp haiku/trunk/src/preferences/backgrounds/Jamfile Log: Include specifically, instead of adding the header directory. Modified: haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp =================================================================== --- haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp 2007-11-24 14:36:13 UTC (rev 22987) +++ haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp 2007-11-24 15:35:07 UTC (rev 22988) @@ -11,12 +11,12 @@ #include "BackgroundsView.h" #include "ImageFilePanel.h" +#include +#include + #include #include -#include -#include #include -#include #include #include #include @@ -24,7 +24,9 @@ #include #include +#include + static const uint32 kMsgApplySettings = 'aply'; static const uint32 kMsgRevertSettings = 'rvrt'; Modified: haiku/trunk/src/preferences/backgrounds/Jamfile =================================================================== --- haiku/trunk/src/preferences/backgrounds/Jamfile 2007-11-24 14:36:13 UTC (rev 22987) +++ haiku/trunk/src/preferences/backgrounds/Jamfile 2007-11-24 15:35:07 UTC (rev 22988) @@ -4,7 +4,6 @@ AddSubDirSupportedPlatforms libbe_test ; UsePrivateHeaders shared ; -UsePublicHeaders [ FDirName be_apps Tracker ] ; Preference Backgrounds : BackgroundImage.cpp From axeld at mail.berlios.de Sat Nov 24 16:38:06 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 24 Nov 2007 16:38:06 +0100 Subject: [Haiku-commits] r22989 - haiku/trunk/src/add-ons/kernel/bus_managers/ide Message-ID: <200711241538.lAOFc6UD013599@sheep.berlios.de> Author: axeld Date: 2007-11-24 16:38:05 +0100 (Sat, 24 Nov 2007) New Revision: 22989 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22989&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_device_infoblock.h Log: Minor cleanup. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c 2007-11-24 15:35:07 UTC (rev 22988) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c 2007-11-24 15:38:05 UTC (rev 22989) @@ -97,8 +97,8 @@ /** create device info */ -static -ide_device_info *create_device(ide_bus_info *bus, bool is_device1) +static ide_device_info * +create_device(ide_bus_info *bus, bool is_device1) { ide_device_info *device; Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_device_infoblock.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_device_infoblock.h 2007-11-24 15:35:07 UTC (rev 22988) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_device_infoblock.h 2007-11-24 15:38:05 UTC (rev 22989) @@ -70,15 +70,14 @@ IORDY_can_disable : 1, IORDY_supported : 1 ); - + uint16 dummy6[1]; // 64 LBITFIELD2 ( // 66 (51) obsolete: PIO modes? _51_obs1 : 8, PIO_mode : 8 ); uint16 dummy7[1]; // 68 - - + LBITFIELD3 ( // 6a (53) validity _54_58_valid : 1, _64_70_valid : 1, @@ -87,15 +86,15 @@ uint16 current_cylinders; // 6c (54) uint16 current_heads; // 6e uint16 current_sectors; // 70 - + uint16 capacity_low; // 72 (57) ALIGNMENT SPLIT - don't merge uint16 capacity_high; - + uint16 dummy8[1]; - + uint32 LBA_total_sectors; // 78 (60) uint16 dummy9[1]; // 7c - + LBITFIELD7 ( // 7e (63) MDMA modes MDMA0_supported : 1, MDMA1_supported : 1, From axeld at mail.berlios.de Sat Nov 24 16:43:46 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 24 Nov 2007 16:43:46 +0100 Subject: [Haiku-commits] r22990 - haiku/trunk/docs/develop/kernel Message-ID: <200711241543.lAOFhkn9013964@sheep.berlios.de> Author: axeld Date: 2007-11-24 16:43:46 +0100 (Sat, 24 Nov 2007) New Revision: 22990 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22990&view=rev Added: haiku/trunk/docs/develop/kernel/VM_TODOs Modified: haiku/trunk/docs/develop/kernel/VM_Locking Log: Minor update; even though the TODO file isn't that long anymore, it doesn't hurt to have it in the repository. Modified: haiku/trunk/docs/develop/kernel/VM_Locking =================================================================== --- haiku/trunk/docs/develop/kernel/VM_Locking 2007-11-24 15:38:05 UTC (rev 22989) +++ haiku/trunk/docs/develop/kernel/VM_Locking 2007-11-24 15:43:46 UTC (rev 22990) @@ -23,6 +23,7 @@ mappings: guarded by the global sMappingLock (currently a spinlock) address_space_next: vm_address_space::sem hash_next: sAreaHashLock + cache: guarded by vm_area_get_locked_cache()/sAreaCacheLock cache_next|prev: cache_ref::lock vm_cache_ref: Added: haiku/trunk/docs/develop/kernel/VM_TODOs =================================================================== --- haiku/trunk/docs/develop/kernel/VM_TODOs 2007-11-24 15:38:05 UTC (rev 22989) +++ haiku/trunk/docs/develop/kernel/VM_TODOs 2007-11-24 15:43:46 UTC (rev 22990) @@ -0,0 +1,2 @@ +- unmap the page of all areas from the cache when a newly added page shadows one + in a deeper cache From axeld at mail.berlios.de Sun Nov 25 12:29:52 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 25 Nov 2007 12:29:52 +0100 Subject: [Haiku-commits] r22991 - in haiku/trunk/src: add-ons/kernel/drivers/network/3com/pci add-ons/kernel/drivers/network/ipro1000/dev/em add-ons/kernel/drivers/network/rtl8139/pci add-ons/kernel/drivers/network/via_rhine/pci libs/compat/freebsd_network libs/compat/freebsd_network/compat/dev/pci libs/compat/freebsd_network/compat/machine libs/compat/freebsd_network/compat/net libs/compat/freebsd_network/compat/netinet libs/compat/freebsd_network/compat/sys libs/compat/freebsd_network/compat/vm Message-ID: <200711251129.lAPBTqKM004375@sheep.berlios.de> Author: axeld Date: 2007-11-25 12:29:29 +0100 (Sun, 25 Nov 2007) New Revision: 22991 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22991&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_80003es2lan.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_80003es2lan.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_82540.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_82541.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_82541.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_82542.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_82543.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_82543.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_82571.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_82571.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_82575.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_82575.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_api.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_api.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_defines.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_hw.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_ich8lan.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_ich8lan.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_mac.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_mac.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_manage.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_manage.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_nvm.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_nvm.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_osdep.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_phy.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_phy.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_regs.h haiku/trunk/src/libs/compat/freebsd_network/compat/netinet/ip6.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/_bus_dma.h Removed: haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/if_em_hw.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/if_em_hw.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/if_em_osdep.h haiku/trunk/src/libs/compat/freebsd_network/README Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xlreg.h haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/LICENSE haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/README haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/if_em.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/if_em.h haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/if_rl.c haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/if_rlreg.h haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/pci/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/pci/if_vr.c haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/pci/if_vrreg.h haiku/trunk/src/libs/compat/freebsd_network/Jamfile haiku/trunk/src/libs/compat/freebsd_network/bus.c haiku/trunk/src/libs/compat/freebsd_network/compat.c haiku/trunk/src/libs/compat/freebsd_network/compat/dev/pci/pcireg.h haiku/trunk/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h haiku/trunk/src/libs/compat/freebsd_network/compat/machine/atomic.h haiku/trunk/src/libs/compat/freebsd_network/compat/machine/in_cksum.h haiku/trunk/src/libs/compat/freebsd_network/compat/net/bpf.h haiku/trunk/src/libs/compat/freebsd_network/compat/net/ethernet.h haiku/trunk/src/libs/compat/freebsd_network/compat/net/if.h haiku/trunk/src/libs/compat/freebsd_network/compat/net/if_vlan_var.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/bus.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/bus_dma.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/mbuf-fbsd.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/mbuf.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/mutex.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/rman.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/systm.h haiku/trunk/src/libs/compat/freebsd_network/compat/vm/vm.h haiku/trunk/src/libs/compat/freebsd_network/device.c haiku/trunk/src/libs/compat/freebsd_network/if.c haiku/trunk/src/libs/compat/freebsd_network/mbuf.c Log: * Updated the FreeBSD compatibility layer for network drivers to FreeBSD 7 (RELENG_7_BP). * There are many white spots, though, most notable PCI MSI(-X) support, and jumbo frames. * Fixed removing interrupts for the INTR_FAST case. Since FreeBSD 7 added a new interrupt "filter" mechanism, we can finally report if the interface was handled by a device or not (though only very few devices support this yet). * Updated the 3com, rtl8139, e1000, and via_rhine drivers to the latest code base. They all compile, but I haven't tested them after the changes yet! Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c 2007-11-24 15:43:46 UTC (rev 22990) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c 2007-11-25 11:29:29 UTC (rev 22991) @@ -31,7 +31,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/pci/if_xl.c,v 1.190.2.10 2006/08/17 00:13:07 yongari Exp $"); +__FBSDID("$FreeBSD: src/sys/pci/if_xl.c,v 1.210 2007/08/06 14:26:03 rwatson Exp $"); /* * 3Com 3c90x Etherlink XL PCI NIC driver @@ -245,7 +245,7 @@ static void xl_init(void *); static void xl_init_locked(struct xl_softc *); static void xl_stop(struct xl_softc *); -static void xl_watchdog(struct ifnet *); +static int xl_watchdog(struct xl_softc *); static void xl_shutdown(device_t); static int xl_suspend(device_t); static int xl_resume(device_t); @@ -391,7 +391,7 @@ } if (i == XL_TIMEOUT) - if_printf(sc->xl_ifp, "command never completed!\n"); + device_printf(sc->xl_dev, "command never completed!\n"); } /* @@ -656,8 +656,7 @@ if (sc->xl_type == XL_TYPE_905B && sc->xl_media == XL_MEDIAOPT_10FL) { if (bootverbose) - if_printf(sc->xl_ifp, - "found 10baseFL\n"); + device_printf(sc->xl_dev, "found 10baseFL\n"); ifmedia_add(ifm, IFM_ETHER | IFM_10_FL, 0, NULL); ifmedia_add(ifm, IFM_ETHER | IFM_10_FL|IFM_HDX, 0, NULL); @@ -666,14 +665,14 @@ IFM_ETHER | IFM_10_FL | IFM_FDX, 0, NULL); } else { if (bootverbose) - if_printf(sc->xl_ifp, "found AUI\n"); + device_printf(sc->xl_dev, "found AUI\n"); ifmedia_add(ifm, IFM_ETHER | IFM_10_5, 0, NULL); } } if (sc->xl_media & XL_MEDIAOPT_BNC) { if (bootverbose) - if_printf(sc->xl_ifp, "found BNC\n"); + device_printf(sc->xl_dev, "found BNC\n"); ifmedia_add(ifm, IFM_ETHER | IFM_10_2, 0, NULL); } } @@ -695,7 +694,7 @@ } if (i == 100) { - if_printf(sc->xl_ifp, "eeprom failed to come ready\n"); + device_printf(sc->xl_dev, "eeprom failed to come ready\n"); return (1); } @@ -857,9 +856,9 @@ if (m == NULL) return; - bcopy(&IFP2ENADDR(sc->xl_ifp), + bcopy(IF_LLADDR(sc->xl_ifp), mtod(m, struct ether_header *)->ether_dhost, ETHER_ADDR_LEN); - bcopy(&IFP2ENADDR(sc->xl_ifp), + bcopy(IF_LLADDR(sc->xl_ifp), mtod(m, struct ether_header *)->ether_shost, ETHER_ADDR_LEN); mtod(m, struct ether_header *)->ether_type = htons(3); mtod(m, unsigned char *)[14] = 0; @@ -984,7 +983,7 @@ DELAY(800); XL_SEL_WIN(7); - if_printf(sc->xl_ifp, "selecting %s, %s duplex\n", pmsg, dmsg); + device_printf(sc->xl_dev, "selecting %s, %s duplex\n", pmsg, dmsg); } static void @@ -1016,7 +1015,7 @@ } if (i == XL_TIMEOUT) - if_printf(sc->xl_ifp, "reset didn't complete\n"); + device_printf(sc->xl_dev, "reset didn't complete\n"); /* Reset TX and RX. */ /* Note: the RX reset takes an absurd amount of time @@ -1099,20 +1098,20 @@ if (sc->xl_xcvr <= XL_XCVR_AUTO) return; else { - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "bogus xcvr value in EEPROM (%x)\n", sc->xl_xcvr); - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "choosing new default based on card type\n"); } } else { if (sc->xl_type == XL_TYPE_905B && sc->xl_media & XL_MEDIAOPT_10FL) return; - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "WARNING: no media options bits set in the media options register!!\n"); - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "this could be a manufacturing defect in your adapter or system\n"); - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "attempting to guess media type; you should probably consult your vendor\n"); } @@ -1137,7 +1136,7 @@ sc->xl_media = XL_MEDIAOPT_BT; sc->xl_xcvr = XL_XCVR_10BT; if (verbose) - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "guessing 10BaseT transceiver\n"); break; case TC_DEVICEID_BOOMERANG_10BT_COMBO: /* 3c900-COMBO */ @@ -1145,20 +1144,20 @@ sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI; sc->xl_xcvr = XL_XCVR_10BT; if (verbose) - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "guessing COMBO (AUI/BNC/TP)\n"); break; case TC_DEVICEID_KRAKATOA_10BT_TPC: /* 3c900B-TPC */ sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC; sc->xl_xcvr = XL_XCVR_10BT; if (verbose) - if_printf(sc->xl_ifp, "guessing TPC (BNC/TP)\n"); + device_printf(sc->xl_dev, "guessing TPC (BNC/TP)\n"); break; case TC_DEVICEID_CYCLONE_10FL: /* 3c900B-FL */ sc->xl_media = XL_MEDIAOPT_10FL; sc->xl_xcvr = XL_XCVR_AUI; if (verbose) - if_printf(sc->xl_ifp, "guessing 10baseFL\n"); + device_printf(sc->xl_dev, "guessing 10baseFL\n"); break; case TC_DEVICEID_BOOMERANG_10_100BT: /* 3c905-TX */ case TC_DEVICEID_HURRICANE_555: /* 3c555 */ @@ -1175,15 +1174,14 @@ sc->xl_media = XL_MEDIAOPT_MII; sc->xl_xcvr = XL_XCVR_MII; if (verbose) - if_printf(sc->xl_ifp, "guessing MII\n"); + device_printf(sc->xl_dev, "guessing MII\n"); break; case TC_DEVICEID_BOOMERANG_100BT4: /* 3c905-T4 */ case TC_DEVICEID_CYCLONE_10_100BT4: /* 3c905B-T4 */ sc->xl_media = XL_MEDIAOPT_BT4; sc->xl_xcvr = XL_XCVR_MII; if (verbose) - if_printf(sc->xl_ifp, - "guessing 100baseT4/MII\n"); + device_printf(sc->xl_dev, "guessing 100baseT4/MII\n"); break; case TC_DEVICEID_HURRICANE_10_100BT: /* 3c905B-TX */ case TC_DEVICEID_HURRICANE_10_100BT_SERV:/*3c980-TX */ @@ -1194,18 +1192,17 @@ sc->xl_media = XL_MEDIAOPT_BTX; sc->xl_xcvr = XL_XCVR_AUTO; if (verbose) - if_printf(sc->xl_ifp, - "guessing 10/100 internal\n"); + device_printf(sc->xl_dev, "guessing 10/100 internal\n"); break; case TC_DEVICEID_CYCLONE_10_100_COMBO: /* 3c905B-COMBO */ sc->xl_media = XL_MEDIAOPT_BTX|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI; sc->xl_xcvr = XL_XCVR_AUTO; if (verbose) - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "guessing 10/100 plus BNC/AUI\n"); break; default: - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "unknown device ID: %x -- defaulting to 10baseT\n", devid); sc->xl_media = XL_MEDIAOPT_BT; break; @@ -1228,6 +1225,8 @@ uint16_t did; sc = device_get_softc(dev); + sc->xl_dev = dev; + unit = device_get_unit(dev); mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, @@ -1250,13 +1249,18 @@ if (did == TC_DEVICEID_HURRICANE_556B) sc->xl_flags |= XL_FLAG_NO_XCVR_PWR; + if (did == TC_DEVICEID_HURRICANE_575B || + did == TC_DEVICEID_HURRICANE_575C || + did == TC_DEVICEID_HURRICANE_656B || + did == TC_DEVICEID_TORNADO_656C) + sc->xl_flags |= XL_FLAG_FUNCREG; if (did == TC_DEVICEID_HURRICANE_575A || did == TC_DEVICEID_HURRICANE_575B || did == TC_DEVICEID_HURRICANE_575C || did == TC_DEVICEID_HURRICANE_656B || did == TC_DEVICEID_TORNADO_656C) - sc->xl_flags |= XL_FLAG_FUNCREG | XL_FLAG_PHYOK | - XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_8BITROM; + sc->xl_flags |= XL_FLAG_PHYOK | XL_FLAG_EEPROM_OFFSET_30 | + XL_FLAG_8BITROM; if (did == TC_DEVICEID_HURRICANE_656) sc->xl_flags |= XL_FLAG_FUNCREG | XL_FLAG_PHYOK; if (did == TC_DEVICEID_HURRICANE_575B) @@ -1322,7 +1326,7 @@ RF_ACTIVE); if (sc->xl_fres == NULL) { - device_printf(dev, "couldn't map ports/memory\n"); + device_printf(dev, "couldn't map funcreg memory\n"); error = ENXIO; goto fail; } @@ -1376,7 +1380,7 @@ * All of our lists are allocated as a contiguous block * of memory. */ - error = bus_dma_tag_create(NULL, 8, 0, + error = bus_dma_tag_create(bus_get_dma_tag(dev), 8, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, XL_RX_LIST_SZ, 1, XL_RX_LIST_SZ, 0, NULL, NULL, &sc->xl_ldata.xl_rx_tag); @@ -1408,7 +1412,7 @@ goto fail; } - error = bus_dma_tag_create(NULL, 8, 0, + error = bus_dma_tag_create(bus_get_dma_tag(dev), 8, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, XL_TX_LIST_SZ, 1, XL_TX_LIST_SZ, 0, NULL, NULL, &sc->xl_ldata.xl_tx_tag); @@ -1443,7 +1447,7 @@ /* * Allocate a DMA tag for the mapping of mbufs. */ - error = bus_dma_tag_create(NULL, 1, 0, + error = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES * XL_MAXFRAGS, XL_MAXFRAGS, MCLBYTES, 0, NULL, NULL, &sc->xl_mtag); @@ -1477,7 +1481,6 @@ /* Set the TX start threshold for best performance. */ sc->xl_tx_thresh = XL_MIN_FRAMELEN; - ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = xl_ioctl; ifp->if_capabilities = IFCAP_VLAN_MTU; @@ -1494,7 +1497,6 @@ ifp->if_capabilities |= IFCAP_POLLING; #endif ifp->if_start = xl_start; - ifp->if_watchdog = xl_watchdog; ifp->if_init = xl_init; IFQ_SET_MAXLEN(&ifp->if_snd, XL_TX_LIST_CNT - 1); ifp->if_snd.ifq_drv_maxlen = XL_TX_LIST_CNT - 1; @@ -1604,7 +1606,7 @@ ether_ifattach(ifp, eaddr); error = bus_setup_intr(dev, sc->xl_irq, INTR_TYPE_NET | INTR_MPSAFE, - xl_intr, sc, &sc->xl_intrhand); + NULL, xl_intr, sc, &sc->xl_intrhand); if (error) { device_printf(dev, "couldn't set up irq\n"); ether_ifdetach(ifp); @@ -1658,7 +1660,7 @@ *media = IFM_ETHER|IFM_100_FX; break; default: - if_printf(sc->xl_ifp, "unknown XCVR type: %d\n", + device_printf(sc->xl_dev, "unknown XCVR type: %d\n", sc->xl_xcvr); /* * This will probably be wrong, but it prevents @@ -1713,8 +1715,6 @@ callout_drain(&sc->xl_stat_callout); ether_ifdetach(ifp); } - if (ifp) - if_free(ifp); if (sc->xl_miibus) device_delete_child(dev, sc->xl_miibus); bus_generic_detach(dev); @@ -1730,6 +1730,9 @@ if (sc->xl_res) bus_release_resource(dev, res, rid, sc->xl_res); + if (ifp) + if_free(ifp); + if (sc->xl_mtag) { bus_dmamap_destroy(sc->xl_mtag, sc->xl_tmpmap); bus_dma_tag_destroy(sc->xl_mtag); @@ -1905,7 +1908,7 @@ xl_dma_map_rxbuf, &baddr, BUS_DMA_NOWAIT); if (error) { m_freem(m_new); - if_printf(sc->xl_ifp, "can't map mbuf (error %d)\n", + device_printf(sc->xl_dev, "can't map mbuf (error %d)\n", error); return (error); } @@ -2004,7 +2007,7 @@ * If not, something truly strange has happened. */ if (!(rxstat & XL_RXSTAT_UP_CMPLT)) { - if_printf(ifp, + device_printf(sc->xl_dev, "bad receive status -- packet dropped\n"); ifp->if_ierrors++; cur_rx->xl_ptr->xl_status = 0; @@ -2099,12 +2102,10 @@ { struct xl_softc *sc = (struct xl_softc *)arg; - NET_LOCK_GIANT(); XL_LOCK(sc); if (sc->xl_ifp->if_drv_flags & IFF_DRV_RUNNING) xl_rxeof(sc); XL_UNLOCK(sc); - NET_UNLOCK_GIANT(); } /* @@ -2148,8 +2149,7 @@ if (sc->xl_cdata.xl_tx_head == NULL) { ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - /* Clear the timeout timer. */ - ifp->if_timer = 0; + sc->xl_wdog_timer = 0; sc->xl_cdata.xl_tx_tail = NULL; } else { if (CSR_READ_4(sc, XL_DMACTL) & XL_DMACTL_DOWN_STALLED || @@ -2196,7 +2196,7 @@ } if (sc->xl_cdata.xl_tx_cnt == 0) - ifp->if_timer = 0; + sc->xl_wdog_timer = 0; sc->xl_cdata.xl_tx_cons = idx; if (cur_tx != NULL) @@ -2219,7 +2219,7 @@ if (txstat & XL_TXSTATUS_UNDERRUN || txstat & XL_TXSTATUS_JABBER || txstat & XL_TXSTATUS_RECLAIM) { - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "transmission error: %x\n", txstat); CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_TX_RESET); xl_wait(sc); @@ -2247,7 +2247,7 @@ if (txstat & XL_TXSTATUS_UNDERRUN && sc->xl_tx_thresh < XL_PACKET_SIZE) { sc->xl_tx_thresh += XL_MIN_FRAMELEN; - if_printf(sc->xl_ifp, + device_printf(sc->xl_dev, "tx underrun, increasing tx start threshold to %d bytes\n", sc->xl_tx_thresh); } CSR_WRITE_2(sc, XL_COMMAND, @@ -2286,17 +2286,11 @@ } #endif -#ifndef __HAIKU__ while ((status = CSR_READ_2(sc, XL_STATUS)) & XL_INTRS && status != 0xFFFF) { CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ACK|(status & XL_INTRS)); -#else - status = atomic_and((int32 *)&sc->xl_intr_status, 0); -// if (status & XL_INTRS) -// dprintf("GOT %x\n", status & XL_INTRS); - if ((status & XL_INTRS) != 0 && status != 0xFFFF) { -#endif + if (status & XL_STAT_UP_COMPLETE) { int curpkts; @@ -2412,6 +2406,10 @@ struct xl_softc *sc = xsc; XL_LOCK_ASSERT(sc); + + if (xl_watchdog(sc) == EJUSTRETURN) + return; + xl_stats_update_locked(sc); } @@ -2667,7 +2665,7 @@ /* * Set a timeout in case the chip goes out to lunch. */ - ifp->if_timer = 5; + sc->xl_wdog_timer = 5; /* * XXX Under certain conditions, usually on slower machines @@ -2765,7 +2763,7 @@ /* * Set a timeout in case the chip goes out to lunch. */ - ifp->if_timer = 5; + sc->xl_wdog_timer = 5; } static void @@ -2808,7 +2806,7 @@ XL_SEL_WIN(2); for (i = 0; i < ETHER_ADDR_LEN; i++) { CSR_WRITE_1(sc, XL_W2_STATION_ADDR_LO + i, - IFP2ENADDR(sc->xl_ifp)[i]); + IF_LLADDR(sc->xl_ifp)[i]); } /* Clear the station mask. */ @@ -2824,7 +2822,7 @@ /* Init circular RX list. */ error = xl_list_rx_init(sc); if (error) { - if_printf(ifp, "initialization of the rx ring failed (%d)\n", + device_printf(sc->xl_dev, "initialization of the rx ring failed (%d)\n", error); xl_stop(sc); return; @@ -2836,7 +2834,7 @@ else error = xl_list_tx_init(sc); if (error) { - if_printf(ifp, "initialization of the tx ring failed (%d)\n", + device_printf(sc->xl_dev, "initialization of the tx ring failed (%d)\n", error); xl_stop(sc); return; @@ -3000,6 +2998,7 @@ ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + sc->xl_wdog_timer = 0; callout_reset(&sc->xl_stat_callout, hz, xl_stats_update, sc); } @@ -3232,24 +3231,25 @@ return (error); } -/* - * XXX: Invoked from ifnet slow timer. Lock coverage needed. - */ -static void -xl_watchdog(struct ifnet *ifp) +static int +xl_watchdog(struct xl_softc *sc) { - struct xl_softc *sc = ifp->if_softc; + struct ifnet *ifp = sc->xl_ifp; u_int16_t status = 0; - XL_LOCK(sc); + XL_LOCK_ASSERT(sc); + if (sc->xl_wdog_timer == 0 || --sc->xl_wdog_timer != 0) + return (0); + ifp->if_oerrors++; XL_SEL_WIN(4); status = CSR_READ_2(sc, XL_W4_MEDIA_STATUS); - if_printf(ifp, "watchdog timeout\n"); + device_printf(sc->xl_dev, "watchdog timeout\n"); if (status & XL_MEDIASTAT_CARRIER) - if_printf(ifp, "no carrier - transceiver cable problem?\n"); + device_printf(sc->xl_dev, + "no carrier - transceiver cable problem?\n"); xl_txeoc(sc); xl_txeof(sc); @@ -3264,7 +3264,7 @@ xl_start_locked(ifp); } - XL_UNLOCK(sc); + return (EJUSTRETURN); } /* @@ -3279,7 +3279,7 @@ XL_LOCK_ASSERT(sc); - ifp->if_timer = 0; + sc->xl_wdog_timer = 0; CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_DISABLE); CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_STATS_DISABLE); Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xlreg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xlreg.h 2007-11-24 15:43:46 UTC (rev 22990) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xlreg.h 2007-11-25 11:29:29 UTC (rev 22991) @@ -29,7 +29,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/pci/if_xlreg.h,v 1.55.2.1 2005/08/26 14:46:22 jhb Exp $ + * $FreeBSD: src/sys/pci/if_xlreg.h,v 1.59 2006/12/06 02:18:41 marius Exp $ */ #define XL_EE_READ 0x0080 /* read, 5 bit address */ @@ -581,6 +581,7 @@ struct xl_softc { struct ifnet *xl_ifp; /* interface info */ + device_t xl_dev; /* device info */ struct ifmedia ifmedia; /* media info */ bus_space_handle_t xl_bhandle; bus_space_tag_t xl_btag; @@ -602,6 +603,7 @@ struct xl_list_data xl_ldata; struct xl_chain_data xl_cdata; struct callout xl_stat_callout; + int xl_wdog_timer; int xl_flags; struct resource *xl_fres; bus_space_handle_t xl_fhandle; @@ -612,7 +614,7 @@ int rxcycles; #endif #ifdef __HAIKU__ - u_int32_t xl_intr_status; + u_int32_t xl_intr_status; #endif }; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/Jamfile 2007-11-24 15:43:46 UTC (rev 22990) +++ haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/Jamfile 2007-11-25 11:29:29 UTC (rev 22991) @@ -8,8 +8,21 @@ SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 EM_FAST_INTR=1 ] ; KernelAddon e1000 : + e1000_80003es2lan.c + e1000_82540.c + e1000_82541.c + e1000_82542.c + e1000_82543.c + e1000_82571.c + e1000_82575.c + e1000_api.c + e1000_ich8lan.c + e1000_mac.c + e1000_manage.c + e1000_nvm.c + e1000_phy.c if_em.c - if_em_hw.c + glue.c : libfreebsd_network.a ; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/LICENSE =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/LICENSE 2007-11-24 15:43:46 UTC (rev 22990) +++ haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/LICENSE 2007-11-25 11:29:29 UTC (rev 22991) @@ -1,31 +1,31 @@ -$FreeBSD: src/sys/dev/em/LICENSE,v 1.3.2.1 2006/08/08 09:20:26 glebius Exp $ -/*- -Copyright (c) 2001-2005, Intel Corporation -All rights reserved. +$FreeBSD: src/sys/dev/em/LICENSE,v 1.6 2007/05/04 00:00:11 jfv Exp $ -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: + Copyright (c) 2001-2007, Intel Corporation + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/README =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/README 2007-11-24 15:43:46 UTC (rev 22990) +++ haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/README 2007-11-25 11:29:29 UTC (rev 22991) @@ -1,8 +1,8 @@ -$FreeBSD: src/sys/dev/em/README,v 1.10.2.1 2006/08/08 09:20:26 glebius Exp $ -FreeBSD* Driver for the Intel(R) PRO/1000 Family of Adapters -============================================================ +$FreeBSD: src/sys/dev/em/README,v 1.15 2007/05/30 23:32:21 jfv Exp $ +FreeBSD* Driver for Intel Network Connection +============================================= -May 2, 2006 +May 30, 2007 Contents @@ -21,11 +21,11 @@ Overview ======== -This file describes the FreeBSD* driver for the Intel(R) PRO/1000 Family of -Adapters. This driver has been developed for use with FreeBSD, Release 6.x. +This file describes the FreeBSD* driver for Intel Network Connection. +This driver has been developed for use with FreeBSD, Release 7.x. For questions related to hardware requirements, refer to the documentation -supplied with your Intel PRO/1000 adapter. All hardware requirements listed +supplied with your Gigabit adapter. All hardware requirements listed apply to use with FreeBSD. @@ -62,7 +62,7 @@ 2. Untar/unzip the archive: - tar xvfz em-x.x.x.tar.gz + tar xzvf em-x.x.x.tar.gz This will create an em-x.x.x directory. @@ -74,7 +74,7 @@ cd em-x.x.x make - b. To install the compiled module in system directory: + b. To install the compiled module to the system directory: make install @@ -84,35 +84,19 @@ if_em_load="YES" -4. To compile the driver into the kernel: +4. To compile the driver into the kernel, enter: cd em-x.x.x/src + cp *.[ch] /usr/src/sys/dev/em - cp if_em* /usr/src/sys/dev/em + Edit the kernel configuration file (i.e., GENERIC or MYKERNEL) in + /usr/src/sys/i386/conf, and ensure the following line is present: - cp Makefile.kernel /usr/src/sys/modules/em/Makefile - - Edit the /usr/src/sys/conf/files file, and add the following lines only if - they don't already exist: - - dev/em/if_em.c optional em - - dev/em/if_em_hw.c optional em - - Remove the following lines from the /usr/src/sys/conf/files file, - if they exist: - - dev/em/if_em_fxhw.c optional em - dev/em/if_em_phy.c optional em - - Edit the kernel configuration file (i.e., GENERIC or MYKERNEL) in - /usr/src/sys/i386/conf, and ensure the following line is present: - device em - Compile and install the kernel. The system must be rebooted for the kernel - updates to take effect. For additional information on compiling the - kernel, consult the FreeBSD operating system documentation. + Compile and install the kernel. The system must be rebooted for the + kernel updates to take effect. For additional information on compiling + the kernel, consult the FreeBSD operating system documentation. 5. To assign an IP address to the interface, enter the following: @@ -150,7 +134,13 @@ not specified and you are not running at gigabit speed, the driver defaults to half-duplex. +If the interface is currently forced to 100 full duplex, in order to change +to half duplex you must use this command: + ifconfig em media 100baseTX -mediaopt + full-duplex + + This driver supports the following media type options: autoselect - Enables auto-negotiation for speed and duplex. @@ -207,13 +197,15 @@ - Some Intel gigabit adapters that support Jumbo Frames have a frame size limit of 9238 bytes, with a corresponding MTU size limit of 9216 bytes. The adapters with this limitation are based on the Intel(R) 82571EB, - 82572EI, 82573L and 80003ES2LAN controller. These correspond to the - following product names: + 82572EI, 82573L, 82566, 82562, and 80003ES2LAN controller. These + correspond to the following product names: Intel(R) PRO/1000 PT Server Adapter Intel(R) PRO/1000 PT Desktop Adapter Intel(R) PRO/1000 PT Network Connection Intel(R) PRO/1000 PT Dual Port Server Adapter Intel(R) PRO/1000 PT Dual Port Network Connection + Intel(R) PRO/1000 PT Quad Port Server Adapter + Intel(R) PRO/1000 PF Quad Port Server Adapter Intel(R) PRO/1000 PF Server Adapter Intel(R) PRO/1000 PF Network Connection Intel(R) PRO/1000 PF Dual Port Server Adapter @@ -221,6 +213,7 @@ Intel(R) PRO/1000 PL Network Connection Intel(R) PRO/1000 EB Network Connection with I/O Acceleration Intel(R) PRO/1000 EB Backplane Connection with I/O Acceleration + Intel(R) 82566DM-2 Gigabit Network Connection - Adapters based on the Intel(R) 82542 and 82573V/E controller do not support Jumbo Frames. These correspond to the following product names: @@ -236,8 +229,13 @@ Intel(R) 82566DC Gigabit Network Connection Intel(R) 82566MM Gigabit Network Connection Intel(R) 82566MC Gigabit Network Connection + Intel(R) 82562GT 10/100 Network Connection + Intel(R) 82562G 10/100 Network Connection + Intel(R) 82566DC-2 Gigabit Network Connection + Intel(R) 82562V-2 10/100 Network Connection + Intel(R) 82562G-2 10/100 Network Connection + Intel(R) 82562GT-2 10/100 Network Connection - VLANs ----- To create a new VLAN interface: @@ -252,18 +250,19 @@ Example: - ifconfig vlan10 10.0.0.1 netmask 255.255.255.0 vlan10 vlandev em0 + ifconfig vlan10 10.0.0.1 netmask 255.255.255.0 vlan 10 vlandev em0 - In this example, all packets will be marked on egress with 802.1Q VLAN + In this example, all packets will be marked on egress with 802.1Q VLAN tags, specifying a VLAN ID of 10. To remove a VLAN interface: - ifconfig destroy + Intel Network Connection ifconfig destroy Polling ------- + To enable polling in the driver, add the following options to the kernel configuration, and then recompile the kernel: @@ -271,9 +270,9 @@ options HZ=1000 At runtime use: - ifconfig em0 polling to turn polling on - Use: - ifconfig em0 -polling to turn polling off + ifconfig emX polling (to turn polling on) + and: + ifconfig emX -polling (to turn it off) Checksum Offload @@ -306,17 +305,50 @@ See the ifconfig man page for further information. + TSO + --- + The FreeBSD driver offers support for TSO (TCP Segmentation Offload). + + You can enable/disable it in two ways/places: + + - sysctl net.inet.tcp.tso=0 (or 1 to enable it) + + Doing this disables TSO in the stack and will affect all adapters. + + - ifconfig emX -tso + + Doing this will disable TSO only for this adapter. + + To enable: + + - ifconfig emX tso + + NOTES: By default only PCI-Express adapters are ENABLED to do TSO. Others + can be enabled by the user at their own risk + TSO is not supported on 82547 and 82544-based adapters, as well as older adapters. + + Known Limitations ================= - In FreeBSD version 4.x with Symmetric MultiProcessing (SMP), there is a known - issue on some newer hardware. The problem is generic kernel and only in SMP - mode. The workaround is to either use FreeBSD version 4.x in single processor - mode, or use FreeBSD 5.4 or later. + Detected Tx Unit Hang in Quad Port Adapters + ------------------------------------------- + In some cases ports 3 and 4 wont pass traffic. Ports 1 and 2 don't show + any errors and will pass traffic. + + This issue MAY be resolved by updating to the latest BIOS. You can + check your system's BIOS by downloading the Linux Firmware Developer Kit + that can be obtained at http://www.linuxfirmwarekit.org/ + + There are known performance issues with this driver when running UDP traffic with Jumbo Frames. + ---------------------------------------------------------------------------- + 82541/82547 can't link or is slow to link with some link partners + ----------------------------------------------------------------- + There is a known compatibility issue where time to link is slow or link is not established between 82541/82547 controllers and some switches. Known switches include: @@ -325,12 +357,12 @@ The driver can be compiled with the following changes: - Edit ./em.x.x.x/src/if_em.h to uncomment the #define EM_MASTER_SLAVE - from within the comments. For example, change from: + Edit ./em.x.x.x/src/if_em.h to change the #define EM_MASTER_SLAVE + For example, change from: - /* #define EM_MASTER_SLAVE 2 */ + #define EM_MASTER_SLAVE e1000_ms_hw_default to: - #define EM_MASTER_SLAVE 2 + #define EM_MASTER_SLAVE 2 Use one of the following options: 1 = Master mode Added: haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_80003es2lan.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_80003es2lan.c 2007-11-24 15:43:46 UTC (rev 22990) +++ haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/e1000_80003es2lan.c 2007-11-25 11:29:29 UTC (rev 22991) @@ -0,0 +1,1339 @@ +/******************************************************************************* + + Copyright (c) 2001-2007, Intel Corporation + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +*******************************************************************************/ +/*$FreeBSD: src/sys/dev/em/e1000_80003es2lan.c,v 1.3 2007/05/16 00:14:23 jfv Exp $*/ + +/* e1000_80003es2lan + */ + +#include "e1000_api.h" +#include "e1000_80003es2lan.h" + +void e1000_init_function_pointers_80003es2lan(struct e1000_hw *hw); + +STATIC s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw); +STATIC void e1000_release_phy_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw); +STATIC void e1000_release_nvm_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, + u32 offset, + u16 *data); +STATIC s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, + u32 offset, + u16 data); +STATIC s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset, + u16 words, u16 *data); +STATIC s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed, + u16 *duplex); +STATIC s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw); +STATIC void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw); +static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask); +static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex); +static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw); +static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw); +static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw); +static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask); + +/* A table for the GG82563 cable length where the range is defined + * with a lower bound at "index" and the upper bound at + * "index + 5". + */ +static const +u16 e1000_gg82563_cable_length_table[] = + { 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF }; +#define GG82563_CABLE_LENGTH_TABLE_SIZE \ + (sizeof(e1000_gg82563_cable_length_table) / \ + sizeof(e1000_gg82563_cable_length_table[0])) + +/** [... truncated: 30303 lines follow ...] From axeld at mail.berlios.de Sun Nov 25 12:32:03 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 25 Nov 2007 12:32:03 +0100 Subject: [Haiku-commits] r22992 - in haiku/trunk/src/add-ons/kernel/drivers/network: . marvell_yukon marvell_yukon/dev marvell_yukon/dev/mii marvell_yukon/dev/msk Message-ID: <200711251132.lAPBW3Fp008641@sheep.berlios.de> Author: axeld Date: 2007-11-25 12:31:51 +0100 (Sun, 25 Nov 2007) New Revision: 22992 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22992&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/brgphyreg.h haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_mskreg.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile Log: Added FreeBSD 7 driver for the Marvell Yukon chips. Compiles, but is otherwise completely untested yet. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile 2007-11-25 11:29:29 UTC (rev 22991) +++ haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile 2007-11-25 11:31:51 UTC (rev 22992) @@ -15,6 +15,7 @@ # FreeBSD 6.2 drivers SubInclude HAIKU_TOP src add-ons kernel drivers network 3com ; SubInclude HAIKU_TOP src add-ons kernel drivers network ipro100 ; +SubInclude HAIKU_TOP src add-ons kernel drivers network marvell_yukon ; SubInclude HAIKU_TOP src add-ons kernel drivers network pcnet ; SubIncludeGPL HAIKU_TOP src add-ons kernel drivers network bcm440x ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/Jamfile 2007-11-25 11:29:29 UTC (rev 22991) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/Jamfile 2007-11-25 11:31:51 UTC (rev 22992) @@ -0,0 +1,3 @@ +SubDir HAIKU_TOP src add-ons kernel drivers network marvell_yukon ; + +SubInclude HAIKU_TOP src add-ons kernel drivers network marvell_yukon dev ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/Jamfile 2007-11-25 11:29:29 UTC (rev 22991) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/Jamfile 2007-11-25 11:31:51 UTC (rev 22992) @@ -0,0 +1,4 @@ +SubDir HAIKU_TOP src add-ons kernel drivers network marvell_yukon dev ; + +#SubInclude HAIKU_TOP src add-ons kernel drivers network marvell_yukon dev mii ; +SubInclude HAIKU_TOP src add-ons kernel drivers network marvell_yukon dev msk ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/brgphyreg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/brgphyreg.h 2007-11-25 11:29:29 UTC (rev 22991) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/brgphyreg.h 2007-11-25 11:31:51 UTC (rev 22992) @@ -0,0 +1,364 @@ +/*- + * Copyright (c) 2000 + * Bill Paul . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/mii/brgphyreg.h,v 1.6.2.2 2007/06/14 21:07:19 davidch Exp $ + */ + +#ifndef _DEV_MII_BRGPHYREG_H_ +#define _DEV_MII_BRGPHYREG_H_ + +/* + * Broadcom BCM5400 registers + */ + +#define BRGPHY_MII_BMCR 0x00 +#define BRGPHY_BMCR_RESET 0x8000 +#define BRGPHY_BMCR_LOOP 0x4000 +#define BRGPHY_BMCR_SPD0 0x2000 /* Speed select, lower bit */ +#define BRGPHY_BMCR_AUTOEN 0x1000 /* Autoneg enabled */ +#define BRGPHY_BMCR_PDOWN 0x0800 /* Power down */ +#define BRGPHY_BMCR_ISO 0x0400 /* Isolate */ +#define BRGPHY_BMCR_STARTNEG 0x0200 /* Restart autoneg */ +#define BRGPHY_BMCR_FDX 0x0100 /* Duplex mode */ +#define BRGPHY_BMCR_CTEST 0x0080 /* Collision test enable */ +#define BRGPHY_BMCR_SPD1 0x0040 /* Speed select, upper bit */ + +#define BRGPHY_S1000 BRGPHY_BMCR_SPD1 /* 1000mbps */ +#define BRGPHY_S100 BRGPHY_BMCR_SPD0 /* 100mpbs */ +#define BRGPHY_S10 0 /* 10mbps */ + +#define BRGPHY_MII_BMSR 0x01 +#define BRGPHY_BMSR_EXTSTS 0x0100 /* Extended status present */ +#define BRGPHY_BMSR_PRESUB 0x0040 /* Preamble surpression */ +#define BRGPHY_BMSR_ACOMP 0x0020 /* Autoneg complete */ +#define BRGPHY_BMSR_RFAULT 0x0010 /* Remote fault condition occured */ +#define BRGPHY_BMSR_ANEG 0x0008 /* Autoneg capable */ +#define BRGPHY_BMSR_LINK 0x0004 /* Link status */ +#define BRGPHY_BMSR_JABBER 0x0002 /* Jabber detected */ +#define BRGPHY_BMSR_EXT 0x0001 /* Extended capability */ + +#define BRGPHY_MII_ANAR 0x04 +#define BRGPHY_ANAR_NP 0x8000 /* Next page */ +#define BRGPHY_ANAR_RF 0x2000 /* Remote fault */ +#define BRGPHY_ANAR_ASP 0x0800 /* Asymmetric Pause */ +#define BRGPHY_ANAR_PC 0x0400 /* Pause capable */ +#define BRGPHY_ANAR_SEL 0x001F /* Selector field, 00001=Ethernet */ + +#define BRGPHY_MII_ANLPAR 0x05 +#define BRGPHY_ANLPAR_NP 0x8000 /* Next page */ +#define BRGPHY_ANLPAR_RF 0x2000 /* Remote fault */ +#define BRGPHY_ANLPAR_ASP 0x0800 /* Asymmetric Pause */ +#define BRGPHY_ANLPAR_PC 0x0400 /* Pause capable */ +#define BRGPHY_ANLPAR_SEL 0x001F /* Selector field, 00001=Ethernet */ + +#define BRGPHY_SEL_TYPE 0x0001 /* Ethernet */ + +#define BRGPHY_MII_ANER 0x06 +#define BRGPHY_ANER_PDF 0x0010 /* Parallel detection fault */ +#define BRGPHY_ANER_LPNP 0x0008 /* Link partner can next page */ +#define BRGPHY_ANER_NP 0x0004 /* Local PHY can next page */ +#define BRGPHY_ANER_RX 0x0002 /* Next page received */ +#define BRGPHY_ANER_LPAN 0x0001 /* Link partner autoneg capable */ + +#define BRGPHY_MII_NEXTP 0x07 /* Next page */ + +#define BRGPHY_MII_NEXTP_LP 0x08 /* Next page of link partner */ + +#define BRGPHY_MII_1000CTL 0x09 /* 1000baseT control */ +#define BRGPHY_1000CTL_TST 0xE000 /* Test modes */ +#define BRGPHY_1000CTL_MSE 0x1000 /* Master/Slave enable */ +#define BRGPHY_1000CTL_MSC 0x0800 /* Master/Slave configuration */ +#define BRGPHY_1000CTL_RD 0x0400 /* Repeater/DTE */ +#define BRGPHY_1000CTL_AFD 0x0200 /* Advertise full duplex */ +#define BRGPHY_1000CTL_AHD 0x0100 /* Advertise half duplex */ + +#define BRGPHY_MII_1000STS 0x0A /* 1000baseT status */ +#define BRGPHY_1000STS_MSF 0x8000 /* Master/slave fault */ +#define BRGPHY_1000STS_MSR 0x4000 /* Master/slave result */ +#define BRGPHY_1000STS_LRS 0x2000 /* Local receiver status */ +#define BRGPHY_1000STS_RRS 0x1000 /* Remote receiver status */ +#define BRGPHY_1000STS_LPFD 0x0800 /* Link partner can FD */ +#define BRGPHY_1000STS_LPHD 0x0400 /* Link partner can HD */ +#define BRGPHY_1000STS_IEC 0x00FF /* Idle error count */ + +#define BRGPHY_MII_EXTSTS 0x0F /* Extended status */ +#define BRGPHY_EXTSTS_X_FD_CAP 0x8000 /* 1000base-X FD capable */ +#define BRGPHY_EXTSTS_X_HD_CAP 0x4000 /* 1000base-X HD capable */ +#define BRGPHY_EXTSTS_T_FD_CAP 0x2000 /* 1000base-T FD capable */ +#define BRGPHY_EXTSTS_T_HD_CAP 0x1000 /* 1000base-T HD capable */ + +#define BRGPHY_MII_PHY_EXTCTL 0x10 /* PHY extended control */ +#define BRGPHY_PHY_EXTCTL_MAC_PHY 0x8000 /* 10BIT/GMI-interface */ +#define BRGPHY_PHY_EXTCTL_DIS_CROSS 0x4000 /* Disable MDI crossover */ +#define BRGPHY_PHY_EXTCTL_TX_DIS 0x2000 /* TX output disabled */ +#define BRGPHY_PHY_EXTCTL_INT_DIS 0x1000 /* Interrupts disabled */ +#define BRGPHY_PHY_EXTCTL_F_INT 0x0800 /* Force interrupt */ +#define BRGPHY_PHY_EXTCTL_BY_45 0x0400 /* Bypass 4B5B-Decoder */ +#define BRGPHY_PHY_EXTCTL_BY_SCR 0x0200 /* Bypass scrambler */ +#define BRGPHY_PHY_EXTCTL_BY_MLT3 0x0100 /* Bypass MLT3 encoder */ +#define BRGPHY_PHY_EXTCTL_BY_RXA 0x0080 /* Bypass RX alignment */ +#define BRGPHY_PHY_EXTCTL_RES_SCR 0x0040 /* Reset scrambler */ +#define BRGPHY_PHY_EXTCTL_EN_LTR 0x0020 /* Enable LED traffic mode */ +#define BRGPHY_PHY_EXTCTL_LED_ON 0x0010 /* Force LEDs on */ +#define BRGPHY_PHY_EXTCTL_LED_OFF 0x0008 /* Force LEDs off */ +#define BRGPHY_PHY_EXTCTL_EX_IPG 0x0004 /* Extended TX IPG mode */ +#define BRGPHY_PHY_EXTCTL_3_LED 0x0002 /* Three link LED mode */ +#define BRGPHY_PHY_EXTCTL_HIGH_LA 0x0001 /* GMII Fifo Elasticy (?) */ + +#define BRGPHY_MII_PHY_EXTSTS 0x11 /* PHY extended status */ +#define BRGPHY_PHY_EXTSTS_CROSS_STAT 0x2000 /* MDI crossover status */ +#define BRGPHY_PHY_EXTSTS_INT_STAT 0x1000 /* Interrupt status */ +#define BRGPHY_PHY_EXTSTS_RRS 0x0800 /* Remote receiver status */ +#define BRGPHY_PHY_EXTSTS_LRS 0x0400 /* Local receiver status */ +#define BRGPHY_PHY_EXTSTS_LOCKED 0x0200 /* Locked */ +#define BRGPHY_PHY_EXTSTS_LS 0x0100 /* Link status */ +#define BRGPHY_PHY_EXTSTS_RF 0x0080 /* Remove fault */ +#define BRGPHY_PHY_EXTSTS_CE_ER 0x0040 /* Carrier ext error */ +#define BRGPHY_PHY_EXTSTS_BAD_SSD 0x0020 /* Bad SSD */ +#define BRGPHY_PHY_EXTSTS_BAD_ESD 0x0010 /* Bad ESS */ +#define BRGPHY_PHY_EXTSTS_RX_ER 0x0008 /* RX error */ +#define BRGPHY_PHY_EXTSTS_TX_ER 0x0004 /* TX error */ +#define BRGPHY_PHY_EXTSTS_LOCK_ER 0x0002 /* Lock error */ +#define BRGPHY_PHY_EXTSTS_MLT3_ER 0x0001 /* MLT3 code error */ + +#define BRGPHY_MII_RXERRCNT 0x12 /* RX error counter */ + +#define BRGPHY_MII_FCERRCNT 0x13 /* False carrier sense counter */ +#define BGRPHY_FCERRCNT 0x00FF /* False carrier counter */ + +#define BRGPHY_MII_RXNOCNT 0x14 /* RX not OK counter */ +#define BRGPHY_RXNOCNT_LOCAL 0xFF00 /* Local RX not OK counter */ +#define BRGPHY_RXNOCNT_REMOTE 0x00FF /* Local RX not OK counter */ + +#define BRGPHY_MII_DSP_RW_PORT 0x15 /* DSP coefficient r/w port */ + +#define BRGPHY_MII_DSP_ADDR_REG 0x17 /* DSP coefficient addr register */ + +#define BRGPHY_DSP_TAP_NUMBER_MASK 0x00 +#define BRGPHY_DSP_AGC_A 0x00 +#define BRGPHY_DSP_AGC_B 0x01 +#define BRGPHY_DSP_MSE_PAIR_STATUS 0x02 +#define BRGPHY_DSP_SOFT_DECISION 0x03 +#define BRGPHY_DSP_PHASE_REG 0x04 +#define BRGPHY_DSP_SKEW 0x05 +#define BRGPHY_DSP_POWER_SAVER_UPPER_BOUND 0x06 +#define BRGPHY_DSP_POWER_SAVER_LOWER_BOUND 0x07 +#define BRGPHY_DSP_LAST_ECHO 0x08 +#define BRGPHY_DSP_FREQUENCY 0x09 +#define BRGPHY_DSP_PLL_BANDWIDTH 0x0A +#define BRGPHY_DSP_PLL_PHASE_OFFSET 0x0B + +#define BRGPHYDSP_FILTER_DCOFFSET 0x0C00 +#define BRGPHY_DSP_FILTER_FEXT3 0x0B00 +#define BRGPHY_DSP_FILTER_FEXT2 0x0A00 +#define BRGPHY_DSP_FILTER_FEXT1 0x0900 +#define BRGPHY_DSP_FILTER_FEXT0 0x0800 +#define BRGPHY_DSP_FILTER_NEXT3 0x0700 +#define BRGPHY_DSP_FILTER_NEXT2 0x0600 +#define BRGPHY_DSP_FILTER_NEXT1 0x0500 +#define BRGPHY_DSP_FILTER_NEXT0 0x0400 +#define BRGPHY_DSP_FILTER_ECHO 0x0300 +#define BRGPHY_DSP_FILTER_DFE 0x0200 +#define BRGPHY_DSP_FILTER_FFE 0x0100 + +#define BRGPHY_DSP_CONTROL_ALL_FILTERS 0x1000 + +#define BRGPHY_DSP_SEL_CH_0 0x0000 +#define BRGPHY_DSP_SEL_CH_1 0x2000 +#define BRGPHY_DSP_SEL_CH_2 0x4000 +#define BRGPHY_DSP_SEL_CH_3 0x6000 + +#define BRGPHY_MII_AUXCTL 0x18 /* AUX control */ +#define BRGPHY_AUXCTL_LOW_SQ 0x8000 /* Low squelch */ +#define BRGPHY_AUXCTL_LONG_PKT 0x4000 /* RX long packets */ +#define BRGPHY_AUXCTL_ER_CTL 0x3000 /* Edgerate control */ +#define BRGPHY_AUXCTL_TX_TST 0x0400 /* TX test, always 1 */ +#define BRGPHY_AUXCTL_DIS_PRF 0x0080 /* dis part resp filter */ +#define BRGPHY_AUXCTL_DIAG_MODE 0x0004 /* Diagnostic mode */ + +#define BRGPHY_MII_AUXSTS 0x19 /* AUX status */ +#define BRGPHY_AUXSTS_ACOMP 0x8000 /* Autoneg complete */ +#define BRGPHY_AUXSTS_AN_ACK 0x4000 /* Autoneg complete ack */ +#define BRGPHY_AUXSTS_AN_ACK_D 0x2000 /* Autoneg complete ack detect */ +#define BRGPHY_AUXSTS_AN_NPW 0x1000 /* Autoneg next page wait */ +#define BRGPHY_AUXSTS_AN_RES 0x0700 /* Autoneg HCD */ +#define BRGPHY_AUXSTS_PDF 0x0080 /* Parallel detect. fault */ +#define BRGPHY_AUXSTS_RF 0x0040 /* Remote fault */ +#define BRGPHY_AUXSTS_ANP_R 0x0020 /* Autoneg page received */ +#define BRGPHY_AUXSTS_LP_ANAB 0x0010 /* Link partner autoneg ability */ +#define BRGPHY_AUXSTS_LP_NPAB 0x0008 /* Link partner next page ability */ +#define BRGPHY_AUXSTS_LINK 0x0004 /* Link status */ +#define BRGPHY_AUXSTS_PRR 0x0002 /* Pause resolution-RX */ +#define BRGPHY_AUXSTS_PRT 0x0001 /* Pause resolution-TX */ + +#define BRGPHY_RES_1000FD 0x0700 /* 1000baseT full duplex */ +#define BRGPHY_RES_1000HD 0x0600 /* 1000baseT half duplex */ +#define BRGPHY_RES_100FD 0x0500 /* 100baseT full duplex */ +#define BRGPHY_RES_100T4 0x0400 /* 100baseT4 */ +#define BRGPHY_RES_100HD 0x0300 /* 100baseT half duplex */ +#define BRGPHY_RES_10FD 0x0200 /* 10baseT full duplex */ +#define BRGPHY_RES_10HD 0x0100 /* 10baseT half duplex */ + +#define BRGPHY_MII_ISR 0x1A /* Interrupt status */ +#define BRGPHY_ISR_PSERR 0x4000 /* Pair swap error */ +#define BRGPHY_ISR_MDXI_SC 0x2000 /* MDIX Status Change */ +#define BRGPHY_ISR_HCT 0x1000 /* Counter above 32K */ +#define BRGPHY_ISR_LCT 0x0800 /* All counter below 128 */ +#define BRGPHY_ISR_AN_PR 0x0400 /* Autoneg page received */ +#define BRGPHY_ISR_NO_HDCL 0x0200 /* No HCD Link */ +#define BRGPHY_ISR_NO_HDC 0x0100 /* No HCD */ +#define BRGPHY_ISR_USHDC 0x0080 /* Negotiated Unsupported HCD */ +#define BRGPHY_ISR_SCR_S_ERR 0x0040 /* Scrambler sync error */ +#define BRGPHY_ISR_RRS_CHG 0x0020 /* Remote RX status change */ +#define BRGPHY_ISR_LRS_CHG 0x0010 /* Local RX status change */ +#define BRGPHY_ISR_DUP_CHG 0x0008 /* Duplex mode change */ +#define BRGPHY_ISR_LSP_CHG 0x0004 /* Link speed changed */ +#define BRGPHY_ISR_LNK_CHG 0x0002 /* Link status change */ +#define BRGPHY_ISR_CRCERR 0x0001 /* CRC error */ + +#define BRGPHY_MII_IMR 0x1B /* Interrupt mask */ +#define BRGPHY_IMR_PSERR 0x4000 /* Pair swap error */ +#define BRGPHY_IMR_MDXI_SC 0x2000 /* MDIX Status Change */ +#define BRGPHY_IMR_HCT 0x1000 /* Counter above 32K */ +#define BRGPHY_IMR_LCT 0x0800 /* All counter below 128 */ +#define BRGPHY_IMR_AN_PR 0x0400 /* Autoneg page received */ +#define BRGPHY_IMR_NO_HDCL 0x0200 /* No HCD Link */ +#define BRGPHY_IMR_NO_HDC 0x0100 /* No HCD */ +#define BRGPHY_IMR_USHDC 0x0080 /* Negotiated Unsupported HCD */ +#define BRGPHY_IMR_SCR_S_ERR 0x0040 /* Scrambler sync error */ +#define BRGPHY_IMR_RRS_CHG 0x0020 /* Remote RX status change */ +#define BRGPHY_IMR_LRS_CHG 0x0010 /* Local RX status change */ +#define BRGPHY_IMR_DUP_CHG 0x0008 /* Duplex mode change */ +#define BRGPHY_IMR_LSP_CHG 0x0004 /* Link speed changed */ +#define BRGPHY_IMR_LNK_CHG 0x0002 /* Link status change */ +#define BRGPHY_IMR_CRCERR 0x0001 /* CRC error */ + +/*******************************************************/ +/* Begin: Shared SerDes PHY register definitions */ +/*******************************************************/ + +/* SerDes autoneg is different from copper */ +#define BRGPHY_SERDES_ANAR 0x04 +#define BRGPHY_SERDES_ANAR_FDX 0x0020 +#define BRGPHY_SERDES_ANAR_HDX 0x0040 +#define BRGPHY_SERDES_ANAR_NO_PAUSE (0x0 << 7) +#define BRGPHY_SERDES_ANAR_SYM_PAUSE (0x1 << 7) +#define BRGPHY_SERDES_ANAR_ASYM_PAUSE (0x2 << 7) +#define BRGPHY_SERDES_ANAR_BOTH_PAUSE (0x3 << 7) + +#define BRGPHY_SERDES_ANLPAR 0x05 +#define BRGPHY_SERDES_ANLPAR_FDX 0x0020 +#define BRGPHY_SERDES_ANLPAR_HDX 0x0040 +#define BRGPHY_SERDES_ANLPAR_NO_PAUSE (0x0 << 7) +#define BRGPHY_SERDES_ANLPAR_SYM_PAUSE (0x1 << 7) +#define BRGPHY_SERDES_ANLPAR_ASYM_PAUSE (0x2 << 7) +#define BRGPHY_SERDES_ANLPAR_BOTH_PAUSE (0x3 << 7) + +/*******************************************************/ +/* End: Shared SerDes PHY register definitions */ +/*******************************************************/ + +/*******************************************************/ +/* Begin: PHY register values for the 5706 PHY */ +/*******************************************************/ + +/* + * Shadow register 0x1C, bit 15 is write enable, + * bits 14-10 select function (0x00 to 0x1F). + */ +#define BRGPHY_MII_SHADOW_1C 0x1C +#define BRGPHY_SHADOW_1C_WRITE_EN 0x8000 +#define BRGPHY_SHADOW_1C_SELECT_MASK 0x7C00 + +/* Shadow 0x1C Mode Control Register (select value 0x1F) */ +#define BRGPHY_SHADOW_1C_MODE_CTRL (0x1F << 10) +/* When set, Regs 0-0x0F are 1000X, else 1000T */ +#define BRGPHY_SHADOW_1C_ENA_1000X 0x0001 + +#define BRGPHY_MII_TEST1 0x1E +#define BRGPHY_TEST1_TRIM_EN 0x0010 +#define BRGPHY_TEST1_CRC_EN 0x8000 + +#define BRGPHY_MII_TEST2 0x1F + +/*******************************************************/ +/* End: PHY register values for the 5706 PHY */ +/*******************************************************/ + +/*******************************************************/ +/* Begin: PHY register values for the 5708S SerDes PHY */ +/*******************************************************/ + +/* Autoneg Next Page Transmit 1 Regiser */ +#define BRGPHY_5708S_ANEG_NXT_PG_XMIT1 0x0B +#define BRGPHY_5708S_ANEG_NXT_PG_XMIT1_25G 0x0001 + +/* Use the BLOCK_ADDR register to select the page for registers 0x10 to 0x1E */ +#define BRGPHY_5708S_BLOCK_ADDR 0x1f +#define BRGPHY_5708S_DIG_PG0 0x0000 +#define BRGPHY_5708S_DIG3_PG2 0x0002 +#define BRGPHY_5708S_TX_MISC_PG5 0x0005 + +/* 5708S SerDes "Digital" Registers (page 0) */ +#define BRGPHY_5708S_PG0_1000X_CTL1 0x10 +#define BRGPHY_5708S_PG0_1000X_CTL1_AUTODET_EN 0x0010 +#define BRGPHY_5708S_PG0_1000X_CTL1_FIBER_MODE 0x0001 + +#define BRGPHY_5708S_PG0_1000X_STAT1 0x14 +#define BRGPHY_5708S_PG0_1000X_STAT1_LINK 0x0002 +#define BRGPHY_5708S_PG0_1000X_STAT1_FDX 0x0004 +#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_MASK 0x0018 +#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_10 (0x0 << 3) +#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_100 (0x1 << 3) +#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_1G (0x2 << 3) +#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_25G (0x3 << 3) + + +#define BRGPHY_5708S_PG0_1000X_CTL2 0x11 +#define BRGPHY_5708S_PG0_1000X_CTL2_PAR_DET_EN 0x0001 + +/* 5708S SerDes "Digital 3" Registers (page 2) */ +#define BRGPHY_5708S_PG2_DIGCTL_3_0 0x10 +#define BRGPHY_5708S_PG2_DIGCTL_3_0_USE_IEEE 0x0001 + +/* 5708S SerDes "TX Misc" Registers (page 5) */ +#define BRGPHY_5708S_PG5_2500STATUS1 0x10 +#define BRGPHY_5708S_PG5_TXACTL1 0x15 +#define BRGPHY_5708S_PG5_TXACTL3 0x17 + +/*******************************************************/ +/* End: PHY register values for the 5708S SerDes PHY */ +/*******************************************************/ + +#define BRGPHY_INTRS \ + ~(BRGPHY_IMR_LNK_CHG|BRGPHY_IMR_LSP_CHG|BRGPHY_IMR_DUP_CHG) + +#endif /* _DEV_BRGPHY_MIIREG_H_ */ Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile 2007-11-25 11:29:29 UTC (rev 22991) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile 2007-11-25 11:31:51 UTC (rev 22992) @@ -0,0 +1,14 @@ +SubDir HAIKU_TOP src add-ons kernel drivers network marvell_yukon dev msk ; + +UsePrivateHeaders kernel net ; + +UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ; +UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ; + +SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 EM_FAST_INTR=1 ] ; + +KernelAddon marvell_yukon : + if_msk.c + glue.c + : libfreebsd_network.a + ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c 2007-11-25 11:29:29 UTC (rev 22991) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c 2007-11-25 11:31:51 UTC (rev 22992) @@ -0,0 +1,13 @@ +#include + +HAIKU_FBSD_DRIVER_GLUE(marvell_yukon, mskc, pci) + +NO_HAIKU_CHECK_DISABLE_INTERRUPTS(); +NO_HAIKU_REENABLE_INTERRUPTS(); +NO_HAIKU_FBSD_MII_DRIVER(); + +#ifdef EM_FAST_INTR + HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_FAST_TASKQUEUE); +#else + HAIKU_DRIVER_REQUIREMENTS(0); +#endif Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c 2007-11-25 11:29:29 UTC (rev 22991) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c 2007-11-25 11:31:51 UTC (rev 22992) @@ -0,0 +1,4157 @@ +/****************************************************************************** + * + * Name : sky2.c + * Project: Gigabit Ethernet Driver for FreeBSD 5.x/6.x + * Version: $Revision: 1.23 $ + * Date : $Date: 2005/12/22 09:04:11 $ + * Purpose: Main driver source file + * + *****************************************************************************/ + +/****************************************************************************** + * + * LICENSE: + * Copyright (C) Marvell International Ltd. and/or its affiliates + * + * The computer program files contained in this folder ("Files") + * are provided to you under the BSD-type license terms provided + * below, and any use of such Files and any derivative works + * thereof created by you shall be governed by the following terms + * and conditions: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * - Neither the name of Marvell nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * /LICENSE + * + *****************************************************************************/ + +/*- + * Copyright (c) 1997, 1998, 1999, 2000 + * Bill Paul . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +/*- + * Copyright (c) 2003 Nathan L. Binkert + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Device driver for the Marvell Yukon II Ethernet controller. + * Due to lack of documentation, this driver is based on the code from + * sk(4) and Marvell's myk(4) driver for FreeBSD 5.x. + */ + +#include +__FBSDID("$FreeBSD: src/sys/dev/msk/if_msk.c,v 1.18 2007/07/20 00:25:20 yongari Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +MODULE_DEPEND(msk, pci, 1, 1, 1); +MODULE_DEPEND(msk, ether, 1, 1, 1); +MODULE_DEPEND(msk, miibus, 1, 1, 1); + +/* "device miibus" required. See GENERIC if you get errors here. */ +#include "miibus_if.h" + +/* Tunables. */ +static int msi_disable = 0; +TUNABLE_INT("hw.msk.msi_disable", &msi_disable); +static int legacy_intr = 0; +TUNABLE_INT("hw.msk.legacy_intr", &legacy_intr); + +#define MSK_CSUM_FEATURES (CSUM_TCP | CSUM_UDP) + +/* + * Devices supported by this driver. + */ +static struct msk_product { + uint16_t msk_vendorid; + uint16_t msk_deviceid; + const char *msk_name; +} msk_products[] = { + { VENDORID_SK, DEVICEID_SK_YUKON2, + "SK-9Sxx Gigabit Ethernet" }, + { VENDORID_SK, DEVICEID_SK_YUKON2_EXPR, + "SK-9Exx Gigabit Ethernet"}, + { VENDORID_MARVELL, DEVICEID_MRVL_8021CU, + "Marvell Yukon 88E8021CU Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8021X, + "Marvell Yukon 88E8021 SX/LX Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8022CU, + "Marvell Yukon 88E8022CU Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8022X, + "Marvell Yukon 88E8022 SX/LX Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8061CU, + "Marvell Yukon 88E8061CU Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8061X, + "Marvell Yukon 88E8061 SX/LX Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8062CU, + "Marvell Yukon 88E8062CU Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8062X, + "Marvell Yukon 88E8062 SX/LX Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8035, + "Marvell Yukon 88E8035 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8036, + "Marvell Yukon 88E8036 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8038, + "Marvell Yukon 88E8038 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_4361, + "Marvell Yukon 88E8050 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_4360, + "Marvell Yukon 88E8052 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_4362, + "Marvell Yukon 88E8053 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_4363, + "Marvell Yukon 88E8055 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_4364, + "Marvell Yukon 88E8056 Gigabit Ethernet" }, + { VENDORID_DLINK, DEVICEID_DLINK_DGE550SX, + "D-Link 550SX Gigabit Ethernet" }, + { VENDORID_DLINK, DEVICEID_DLINK_DGE560T, + "D-Link 560T Gigabit Ethernet" } +}; + +static const char *model_name[] = { + "Yukon XL", + "Yukon EC Ultra", + "Yukon Unknown", + "Yukon EC", + "Yukon FE" +}; + +static int mskc_probe(device_t); +static int mskc_attach(device_t); +static int mskc_detach(device_t); +static void mskc_shutdown(device_t); +static int mskc_setup_rambuffer(struct msk_softc *); +static int mskc_suspend(device_t); +static int mskc_resume(device_t); +static void mskc_reset(struct msk_softc *); + +static int msk_probe(device_t); +static int msk_attach(device_t); +static int msk_detach(device_t); + +static void msk_tick(void *); +static void msk_legacy_intr(void *); +static int msk_intr(void *); +static void msk_int_task(void *, int); +static void msk_intr_phy(struct msk_if_softc *); +static void msk_intr_gmac(struct msk_if_softc *); +static __inline void msk_rxput(struct msk_if_softc *); +static int msk_handle_events(struct msk_softc *); +static void msk_handle_hwerr(struct msk_if_softc *, uint32_t); +static void msk_intr_hwerr(struct msk_softc *); +static void msk_rxeof(struct msk_if_softc *, uint32_t, int); +static void msk_jumbo_rxeof(struct msk_if_softc *, uint32_t, int); +static void msk_txeof(struct msk_if_softc *, int); +static struct mbuf *msk_defrag(struct mbuf *, int, int); +static int msk_encap(struct msk_if_softc *, struct mbuf **); +static void msk_tx_task(void *, int); +static void msk_start(struct ifnet *); +static int msk_ioctl(struct ifnet *, u_long, caddr_t); +static void msk_set_prefetch(struct msk_softc *, int, bus_addr_t, uint32_t); +static void msk_set_rambuffer(struct msk_if_softc *); +static void msk_init(void *); +static void msk_init_locked(struct msk_if_softc *); +static void msk_stop(struct msk_if_softc *); +static void msk_watchdog(struct msk_if_softc *); +static int msk_mediachange(struct ifnet *); +static void msk_mediastatus(struct ifnet *, struct ifmediareq *); +static void msk_phy_power(struct msk_softc *, int); +static void msk_dmamap_cb(void *, bus_dma_segment_t *, int, int); +static int msk_status_dma_alloc(struct msk_softc *); +static void msk_status_dma_free(struct msk_softc *); +static int msk_txrx_dma_alloc(struct msk_if_softc *); +static void msk_txrx_dma_free(struct msk_if_softc *); +static void *msk_jalloc(struct msk_if_softc *); +static void msk_jfree(void *, void *); +static int msk_init_rx_ring(struct msk_if_softc *); +static int msk_init_jumbo_rx_ring(struct msk_if_softc *); +static void msk_init_tx_ring(struct msk_if_softc *); +static __inline void msk_discard_rxbuf(struct msk_if_softc *, int); +static __inline void msk_discard_jumbo_rxbuf(struct msk_if_softc *, int); +static int msk_newbuf(struct msk_if_softc *, int); +static int msk_jumbo_newbuf(struct msk_if_softc *, int); + +static int msk_phy_readreg(struct msk_if_softc *, int, int); +static int msk_phy_writereg(struct msk_if_softc *, int, int, int); +static int msk_miibus_readreg(device_t, int, int); +static int msk_miibus_writereg(device_t, int, int, int); +static void msk_miibus_statchg(device_t); +static void msk_link_task(void *, int); + +static void msk_setmulti(struct msk_if_softc *); +static void msk_setvlan(struct msk_if_softc *, struct ifnet *); +static void msk_setpromisc(struct msk_if_softc *); + +static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int); +static int sysctl_hw_msk_proc_limit(SYSCTL_HANDLER_ARGS); + +static device_method_t mskc_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, mskc_probe), + DEVMETHOD(device_attach, mskc_attach), + DEVMETHOD(device_detach, mskc_detach), + DEVMETHOD(device_suspend, mskc_suspend), + DEVMETHOD(device_resume, mskc_resume), + DEVMETHOD(device_shutdown, mskc_shutdown), + + /* bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + + { NULL, NULL } +}; + +static driver_t mskc_driver = { + "mskc", + mskc_methods, + sizeof(struct msk_softc) +}; + +static devclass_t mskc_devclass; + +static device_method_t msk_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, msk_probe), + DEVMETHOD(device_attach, msk_attach), + DEVMETHOD(device_detach, msk_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + /* bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + + /* MII interface */ + DEVMETHOD(miibus_readreg, msk_miibus_readreg), + DEVMETHOD(miibus_writereg, msk_miibus_writereg), + DEVMETHOD(miibus_statchg, msk_miibus_statchg), + + { NULL, NULL } +}; + +static driver_t msk_driver = { + "msk", + msk_methods, + sizeof(struct msk_if_softc) +}; + +static devclass_t msk_devclass; + +DRIVER_MODULE(mskc, pci, mskc_driver, mskc_devclass, 0, 0); +DRIVER_MODULE(msk, mskc, msk_driver, msk_devclass, 0, 0); +DRIVER_MODULE(miibus, msk, miibus_driver, miibus_devclass, 0, 0); + +static struct resource_spec msk_res_spec_io[] = { + { SYS_RES_IOPORT, PCIR_BAR(1), RF_ACTIVE }, + { -1, 0, 0 } +}; + +static struct resource_spec msk_res_spec_mem[] = { + { SYS_RES_MEMORY, PCIR_BAR(0), RF_ACTIVE }, + { -1, 0, 0 } +}; + +static struct resource_spec msk_irq_spec_legacy[] = { + { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE }, + { -1, 0, 0 } +}; + +static struct resource_spec msk_irq_spec_msi[] = { + { SYS_RES_IRQ, 1, RF_ACTIVE }, + { SYS_RES_IRQ, 2, RF_ACTIVE }, + { -1, 0, 0 } +}; + +static int +msk_miibus_readreg(device_t dev, int phy, int reg) +{ + struct msk_if_softc *sc_if; + + sc_if = device_get_softc(dev); + + return (msk_phy_readreg(sc_if, phy, reg)); +} + +static int +msk_phy_readreg(struct msk_if_softc *sc_if, int phy, int reg) +{ + struct msk_softc *sc; + int i, val; + + sc = sc_if->msk_softc; + + GMAC_WRITE_2(sc, sc_if->msk_port, GM_SMI_CTRL, + GM_SMI_CT_PHY_AD(phy) | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD); + + for (i = 0; i < MSK_TIMEOUT; i++) { + DELAY(1); + val = GMAC_READ_2(sc, sc_if->msk_port, GM_SMI_CTRL); + if ((val & GM_SMI_CT_RD_VAL) != 0) { + val = GMAC_READ_2(sc, sc_if->msk_port, GM_SMI_DATA); + break; + } + } + + if (i == MSK_TIMEOUT) { + if_printf(sc_if->msk_ifp, "phy failed to come ready\n"); + val = 0; + } + + return (val); +} + +static int +msk_miibus_writereg(device_t dev, int phy, int reg, int val) +{ + struct msk_if_softc *sc_if; + + sc_if = device_get_softc(dev); + + return (msk_phy_writereg(sc_if, phy, reg, val)); +} + +static int +msk_phy_writereg(struct msk_if_softc *sc_if, int phy, int reg, int val) +{ + struct msk_softc *sc; + int i; + + sc = sc_if->msk_softc; + + GMAC_WRITE_2(sc, sc_if->msk_port, GM_SMI_DATA, val); + GMAC_WRITE_2(sc, sc_if->msk_port, GM_SMI_CTRL, + GM_SMI_CT_PHY_AD(phy) | GM_SMI_CT_REG_AD(reg)); + for (i = 0; i < MSK_TIMEOUT; i++) { + DELAY(1); + if ((GMAC_READ_2(sc, sc_if->msk_port, GM_SMI_CTRL) & + GM_SMI_CT_BUSY) == 0) + break; + } + if (i == MSK_TIMEOUT) + if_printf(sc_if->msk_ifp, "phy write timeout\n"); + + return (0); +} + +static void +msk_miibus_statchg(device_t dev) +{ + struct msk_if_softc *sc_if; + + sc_if = device_get_softc(dev); + taskqueue_enqueue(taskqueue_swi, &sc_if->msk_link_task); +} + +static void +msk_link_task(void *arg, int pending) +{ + struct msk_softc *sc; + struct msk_if_softc *sc_if; + struct mii_data *mii; + struct ifnet *ifp; + uint32_t gmac; + + sc_if = (struct msk_if_softc *)arg; + sc = sc_if->msk_softc; + + MSK_IF_LOCK(sc_if); + + mii = device_get_softc(sc_if->msk_miibus); + ifp = sc_if->msk_ifp; + if (mii == NULL || ifp == NULL) { + MSK_IF_UNLOCK(sc_if); + return; + } + + if (mii->mii_media_status & IFM_ACTIVE) { + if (IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) + sc_if->msk_link = 1; + } else + sc_if->msk_link = 0; + + if (sc_if->msk_link != 0) { + /* Enable Tx FIFO Underrun. */ + CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_MSK), + GM_IS_TX_FF_UR | GM_IS_RX_FF_OR); + /* + * Because mii(4) notify msk(4) that it detected link status + * change, there is no need to enable automatic + * speed/flow-control/duplex updates. + */ + gmac = GM_GPCR_AU_ALL_DIS; + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_1000_SX: + case IFM_1000_T: + gmac |= GM_GPCR_SPEED_1000; + break; + case IFM_100_TX: + gmac |= GM_GPCR_SPEED_100; + break; + case IFM_10_T: + break; + } + + if (((mii->mii_media_active & IFM_GMASK) & IFM_FDX) != 0) + gmac |= GM_GPCR_DUP_FULL; + /* Disable Rx flow control. */ + if (((mii->mii_media_active & IFM_GMASK) & IFM_FLAG0) == 0) + gmac |= GM_GPCR_FC_RX_DIS; + /* Disable Tx flow control. */ + if (((mii->mii_media_active & IFM_GMASK) & IFM_FLAG1) == 0) + gmac |= GM_GPCR_FC_TX_DIS; + gmac |= GM_GPCR_RX_ENA | GM_GPCR_TX_ENA; + GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac); + /* Read again to ensure writing. */ + GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); + + gmac = GMC_PAUSE_ON; + if (((mii->mii_media_active & IFM_GMASK) & + (IFM_FLAG0 | IFM_FLAG1)) == 0) + gmac = GMC_PAUSE_OFF; + /* Diable pause for 10/100 Mbps in half-duplex mode. */ + if ((((mii->mii_media_active & IFM_GMASK) & IFM_FDX) == 0) && + (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX || + IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T)) + gmac = GMC_PAUSE_OFF; + CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), gmac); + + /* Enable PHY interrupt for FIFO underrun/overflow. */ + if (sc->msk_marvell_phy) + msk_phy_writereg(sc_if, PHY_ADDR_MARV, + PHY_MARV_INT_MASK, PHY_M_IS_FIFO_ERROR); + } else { + /* + * Link state changed to down. + * Disable PHY interrupts. + */ + if (sc->msk_marvell_phy) + msk_phy_writereg(sc_if, PHY_ADDR_MARV, + PHY_MARV_INT_MASK, 0); + /* Disable Rx/Tx MAC. */ + gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); + gmac &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); + GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac); + /* Read again to ensure writing. */ + GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); + } + + MSK_IF_UNLOCK(sc_if); +} + +static void +msk_setmulti(struct msk_if_softc *sc_if) +{ + struct msk_softc *sc; + struct ifnet *ifp; + struct ifmultiaddr *ifma; + uint32_t mchash[2]; + uint32_t crc; + uint16_t mode; + + sc = sc_if->msk_softc; + + MSK_IF_LOCK_ASSERT(sc_if); + [... truncated: 6009 lines follow ...] From axeld at mail.berlios.de Sun Nov 25 13:11:37 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 25 Nov 2007 13:11:37 +0100 Subject: [Haiku-commits] r22993 - in haiku/trunk/src/libs/compat/freebsd_network: . compat/net Message-ID: <200711251211.lAPCBavp002581@sheep.berlios.de> Author: axeld Date: 2007-11-25 13:11:36 +0100 (Sun, 25 Nov 2007) New Revision: 22993 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22993&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/Jamfile haiku/trunk/src/libs/compat/freebsd_network/compat/net/ethernet.h Log: Build fix; fbsd_ether.c did not compile anymore (but was not recompiled since the wrong header was included). Modified: haiku/trunk/src/libs/compat/freebsd_network/Jamfile =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/Jamfile 2007-11-25 11:31:51 UTC (rev 22992) +++ haiku/trunk/src/libs/compat/freebsd_network/Jamfile 2007-11-25 12:11:36 UTC (rev 22993) @@ -1,10 +1,10 @@ SubDir HAIKU_TOP src libs compat freebsd_network ; -UseHeaders $(HAIKU_PRIVATE_KERNEL_HEADERS) : true ; -UsePrivateHeaders net ; UseHeaders [ FDirName $(SUBDIR) ] : true ; UseHeaders [ FDirName $(SUBDIR) compat ] : true ; +UsePrivateHeaders net ; +UseHeaders $(HAIKU_PRIVATE_KERNEL_HEADERS) : true ; SubDirCcFlags [ FDefines _KERNEL=1 ] ; Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/net/ethernet.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/net/ethernet.h 2007-11-25 11:31:51 UTC (rev 22992) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/net/ethernet.h 2007-11-25 12:11:36 UTC (rev 22993) @@ -5,9 +5,11 @@ * */ -#ifndef _NET_ETHERNET_H_ -#define _NET_ETHERNET_H_ +#ifndef _FBSD_COMPAT_NET_ETHERNET_H_ +#define _FBSD_COMPAT_NET_ETHERNET_H_ +#include + /* * Somce basic Ethernet constants. */ @@ -399,4 +401,4 @@ #endif /* !_KERNEL */ -#endif /* !_NET_ETHERNET_H_ */ +#endif /* !_FBSD_COMPAT_NET_ETHERNET_H_ */ From oruizdorantes at mail.berlios.de Sun Nov 25 17:48:20 2007 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Sun, 25 Nov 2007 17:48:20 +0100 Subject: [Haiku-commits] r22994 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200711251648.lAPGmKso018964@sheep.berlios.de> Author: oruizdorantes Date: 2007-11-25 17:48:20 +0100 (Sun, 25 Nov 2007) New Revision: 22994 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22994&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c Log: Remove fetched item in the recycle list Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c 2007-11-25 12:11:36 UTC (rev 22993) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c 2007-11-25 16:48:20 UTC (rev 22994) @@ -22,7 +22,6 @@ }; - snet_buffer* snb_create(uint16 size) { @@ -63,14 +62,12 @@ } - inline void snb_reset(snet_buffer* snb) { snb->puttingSize = snb->pullingSize = 0; } - void snb_free(snet_buffer* snb) { @@ -86,7 +83,6 @@ } - inline void* snb_get(snet_buffer* snb) { @@ -94,7 +90,6 @@ return snb->buffer; } - inline uint16 snb_size(snet_buffer* snb) { @@ -102,7 +97,6 @@ return snb->expectedSize; } - inline void* snb_cookie(snet_buffer* snb) { @@ -110,7 +104,6 @@ return snb->cookie; } - inline void snb_set_cookie(snet_buffer* snb, void* cookie) { @@ -118,21 +111,18 @@ snb->cookie = cookie; } - /* Return true if we canot "put" more data in the buffer */ inline bool snb_completed(snet_buffer* snb) { return (snb != NULL && (snb->expectedSize == snb->puttingSize)); } - /* Return true if we cannot pull more more data from the buffer */ inline bool snb_finished(snet_buffer* snb) { return (snb != NULL && (snb->expectedSize == snb->pullingSize)); } - inline bool snb_remaining_to_put(snet_buffer* snb) { return (snb != NULL && (snb->expectedSize - snb->puttingSize)); @@ -144,14 +134,13 @@ return (snb != NULL && (snb->expectedSize - snb->pullingSize)); } - /* ISSUE1: Number of packets in the worst case(we always need a bigger buffer than before) increases, never decreases: SOL1: Delete the smallest when the queue is bigger than X elements SOL2: ? - ISSUE2: If the queue is not gonna be used for long time, Memory c + ISSUE2: If the queue is not gonna be used for long time. Memory c ould be freed SOL1: Provide purge func. @@ -177,7 +166,6 @@ } - void snb_park(struct list* l, snet_buffer* snb) { @@ -189,7 +177,6 @@ } } - snet_buffer* snb_fetch(struct list* l, uint16 size) { @@ -211,5 +198,13 @@ previous = item; } - return snb_attempt_reuse(item, size); + // reusing previous pointer for another proposit + previous = snb_attempt_reuse(item, size); + + /* the resulting reused one is the same as we fetched? => remove it from list*/ + if (item == previous) { + list_remove_item(l, item); + } + + return previous; } From mmu_man at mail.berlios.de Sun Nov 25 18:48:46 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 25 Nov 2007 18:48:46 +0100 Subject: [Haiku-commits] r22995 - haiku/trunk/src/add-ons/media/media-add-ons/opensound Message-ID: <200711251748.lAPHmkMw028205@sheep.berlios.de> Author: mmu_man Date: 2007-11-25 18:48:46 +0100 (Sun, 25 Nov 2007) New Revision: 22995 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22995&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/opensound/OpenSoundDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp Log: gcc4 fix Modified: haiku/trunk/src/add-ons/media/media-add-ons/opensound/OpenSoundDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/opensound/OpenSoundDevice.cpp 2007-11-25 16:48:20 UTC (rev 22994) +++ haiku/trunk/src/add-ons/media/media-add-ons/opensound/OpenSoundDevice.cpp 2007-11-25 17:48:46 UTC (rev 22995) @@ -584,7 +584,7 @@ } OpenSoundDeviceEngine * -OpenSoundDevice::NextFreeEngineAt(int32 i, bool rec=false) +OpenSoundDevice::NextFreeEngineAt(int32 i, bool rec) { // find the first free engine in the rec or play chain OpenSoundDeviceEngine *engine = EngineAt(i); Modified: haiku/trunk/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp 2007-11-25 16:48:20 UTC (rev 22994) +++ haiku/trunk/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp 2007-11-25 17:48:46 UTC (rev 22995) @@ -269,7 +269,7 @@ } -size_t OpenSoundDeviceEngine::GetISpace(audio_buf_info *info=NULL) +size_t OpenSoundDeviceEngine::GetISpace(audio_buf_info *info) { audio_buf_info abinfo; CALLED(); @@ -288,7 +288,7 @@ } -size_t OpenSoundDeviceEngine::GetOSpace(audio_buf_info *info=NULL) +size_t OpenSoundDeviceEngine::GetOSpace(audio_buf_info *info) { audio_buf_info abinfo; //CALLED(); From mmu_man at mail.berlios.de Sun Nov 25 19:15:44 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 25 Nov 2007 19:15:44 +0100 Subject: [Haiku-commits] r22996 - haiku/trunk/build/jam Message-ID: <200711251815.lAPIFiDs029008@sheep.berlios.de> Author: mmu_man Date: 2007-11-25 19:15:43 +0100 (Sun, 25 Nov 2007) New Revision: 22996 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22996&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Add OpenSound media node to the image, as the one included in the opensound zip is built with gcc2 and won't load with gcc4 builds. Hope having both doesn't do nasty things on gcc2 builds. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-25 17:48:46 UTC (rev 22995) +++ haiku/trunk/build/jam/HaikuImage 2007-11-25 18:15:43 UTC (rev 22996) @@ -91,6 +91,7 @@ video_producer_demo.media_addon usb_webcam.media_addon dvb.media_addon + opensound.media_addon #legacy.media_addon ; BEOS_ADD_ONS_MEDIA_PLUGINS = $(GPL_ONLY)ac3_decoder From axeld at pinc-software.de Mon Nov 26 12:04:19 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 26 Nov 2007 12:04:19 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r22994_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/drivers/bluetooth/h2/h2generic?= In-Reply-To: <200711251648.lAPGmKso018964@sheep.berlios.de> Message-ID: <786215321-BeMail@zon> oruizdorantes at BerliOS wrote: > } > > - > inline void BTW there are two blank lines between function according to our coding style - no reason to remove them. Bye, Axel. From axeld at mail.berlios.de Mon Nov 26 13:22:54 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 26 Nov 2007 13:22:54 +0100 Subject: [Haiku-commits] r22997 - haiku/trunk/src/servers/media_addon Message-ID: <200711261222.lAQCMstv006350@sheep.berlios.de> Author: axeld Date: 2007-11-26 13:22:53 +0100 (Mon, 26 Nov 2007) New Revision: 22997 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22997&view=rev Modified: haiku/trunk/src/servers/media_addon/main.cpp Log: * Now checks if the media_server is running in ReadyToRun(), and quits itself if not. This fixes bug #323. * Now uses find_directory() instead of hard-coded add-on paths. * A few more error checks. * Cleanup. Modified: haiku/trunk/src/servers/media_addon/main.cpp =================================================================== --- haiku/trunk/src/servers/media_addon/main.cpp 2007-11-25 18:15:43 UTC (rev 22996) +++ haiku/trunk/src/servers/media_addon/main.cpp 2007-11-26 12:22:53 UTC (rev 22997) @@ -24,45 +24,50 @@ */ #define BUILDING_MEDIA_ADDON 1 + +#include + +#include #include -#include +#include +#include +#include +#include #include #include -#include +#include +#include #include -#include -#include -#include -#include + #include "debug.h" -#include "TMap.h" -#include "ServerInterface.h" #include "DataExchange.h" #include "DormantNodeManager.h" -#include "Notifications.h" +#include "MediaFilePlayer.h" #include "MediaMisc.h" #include "MediaRosterEx.h" #include "MediaSounds.h" +#include "Notifications.h" +#include "ServerInterface.h" #include "SystemTimeSource.h" -#include "MediaFilePlayer.h" +#include "TMap.h" + //#define USER_ADDON_PATH "../add-ons/media" void DumpFlavorInfo(const flavor_info *info); -struct AddOnInfo -{ +struct AddOnInfo { media_addon_id id; bool wants_autostart; int32 flavor_count; List active_flavors; - BMediaAddOn *addon; // if != NULL, need to call _DormantNodeManager->PutAddon(id) + BMediaAddOn *addon; + // if != NULL, need to call _DormantNodeManager->PutAddon(id) }; -class MediaAddonServer : BApplication -{ +class MediaAddonServer : BApplication { public: MediaAddonServer(const char *sig); ~MediaAddonServer(); @@ -74,7 +79,6 @@ void AddOnAdded(const char *path, ino_t file_node); void AddOnRemoved(ino_t file_node); void HandleMessage(int32 code, const void *data, size_t size); - static int32 controlthread(void *arg); void PutAddonIfPossible(AddOnInfo *info); void InstantiatePhysicalInputsAndOutputs(AddOnInfo *info); @@ -83,53 +87,61 @@ void ScanAddOnFlavors(BMediaAddOn *addon); - Map *filemap; - Map *infomap; + port_id ControlPort() const { return fControlPort; } - BMediaRoster *mediaroster; - ino_t DirNodeSystem; - ino_t DirNodeUser; - port_id control_port; - thread_id control_thread; +private: + static int32 _ControlThread(void *arg); + + Map *fFileMap; + Map *fInfoMap; + + BMediaRoster *fMediaRoster; + ino_t fSystemAddOnsNode; + ino_t fUserAddOnsNode; + port_id fControlPort; + thread_id fControlThread; bool fStartup; typedef BApplication inherited; }; -MediaAddonServer::MediaAddonServer(const char *sig) : - BApplication(sig), + +MediaAddonServer::MediaAddonServer(const char *sig) + : BApplication(sig), fStartup(true) { CALLED(); - mediaroster = BMediaRoster::Roster(); - filemap = new Map; - infomap = new Map; - control_port = create_port(64, MEDIA_ADDON_SERVER_PORT_NAME); - control_thread = spawn_thread(controlthread, "media_addon_server control", 12, this); - resume_thread(control_thread); + fMediaRoster = BMediaRoster::Roster(); + fFileMap = new Map; + fInfoMap = new Map; + fControlPort = create_port(64, MEDIA_ADDON_SERVER_PORT_NAME); + fControlThread = spawn_thread(_ControlThread, "media_addon_server control", + B_NORMAL_PRIORITY + 2, this); + resume_thread(fControlThread); } + MediaAddonServer::~MediaAddonServer() { CALLED(); - - delete_port(control_port); + + delete_port(fControlPort); status_t err; - wait_for_thread(control_thread,&err); + wait_for_thread(fControlThread,&err); // unregister all media add-ons media_addon_id *id; - for (filemap->Rewind(); filemap->GetNext(&id); ) + for (fFileMap->Rewind(); fFileMap->GetNext(&id); ) _DormantNodeManager->UnregisterAddon(*id); - - - // XXX unregister system time source - - delete filemap; - delete infomap; + + // TODO: unregister system time source + + delete fFileMap; + delete fInfoMap; } -void + +void MediaAddonServer::HandleMessage(int32 code, const void *data, size_t size) { switch (code) { @@ -138,7 +150,7 @@ const addonserver_instantiate_dormant_node_request *request = static_cast(data); addonserver_instantiate_dormant_node_reply reply; status_t rv; - rv = MediaRosterEx(mediaroster)->InstantiateDormantNode(request->addonid, request->flavorid, request->creator_team, &reply.node); + rv = MediaRosterEx(fMediaRoster)->InstantiateDormantNode(request->addonid, request->flavorid, request->creator_team, &reply.node); request->SendReply(rv, &reply, sizeof(reply)); break; } @@ -162,8 +174,9 @@ } } + int32 -MediaAddonServer::controlthread(void *arg) +MediaAddonServer::_ControlThread(void *arg) { char data[B_MEDIA_MESSAGE_SIZE]; MediaAddonServer *app; @@ -171,15 +184,23 @@ int32 code; app = (MediaAddonServer *)arg; - while ((size = read_port_etc(app->control_port, &code, data, sizeof(data), 0, 0)) > 0) + while ((size = read_port_etc(app->ControlPort(), &code, data, sizeof(data), 0, 0)) > 0) app->HandleMessage(code, data, size); return 0; } -void + +void MediaAddonServer::ReadyToRun() { + if (!be_roster->IsRunning("application/x-vnd.Be.media-server")) { + // the media server is not running, let's quit + fprintf(stderr, "The media_server is not running!\n"); + Quit(); + return; + } + // the control thread is already running at this point, // so we can talk to the media server and also receive // commands for instantiation @@ -188,16 +209,18 @@ // The very first thing to do is to create the system time source, // register it with the server, and make it the default SYSTEM_TIME_SOURCE - BMediaNode *ts = new SystemTimeSource; - status_t result = mediaroster->RegisterNode(ts); + BMediaNode *timeSource = new SystemTimeSource; + status_t result = fMediaRoster->RegisterNode(timeSource); if (result != B_OK) { - fprintf(stderr, "Can't register system time source : %s\n", strerror(result)); + fprintf(stderr, "Can't register system time source : %s\n", + strerror(result)); debugger("Can't register system time source"); } - if (ts->ID() != NODE_SYSTEM_TIMESOURCE_ID) + + if (timeSource->ID() != NODE_SYSTEM_TIMESOURCE_ID) debugger("System time source got wrong node ID"); - media_node node = ts->Node(); - result = MediaRosterEx(mediaroster)->SetNode(SYSTEM_TIME_SOURCE, &node); + media_node node = timeSource->Node(); + result = MediaRosterEx(fMediaRoster)->SetNode(SYSTEM_TIME_SOURCE, &node); if (result != B_OK) debugger("Can't setup system time source as default"); @@ -208,37 +231,43 @@ // any active nodes (flavors) will be unloaded. // load dormant media nodes + BPath path; + find_directory(B_BEOS_ADDONS_DIRECTORY, &path); + path.Append("media"); + node_ref nref; - BEntry e("/boot/beos/system/add-ons/media"); - e.GetNodeRef(&nref); - DirNodeSystem = nref.node; - WatchDir(&e); + BEntry entry(path.Path()); + entry.GetNodeRef(&nref); + fSystemAddOnsNode = nref.node; + WatchDir(&entry); #ifdef USER_ADDON_PATH - BEntry e2(USER_ADDON_PATH); + entry.SetTo(USER_ADDON_PATH); #else - BEntry e2("/boot/home/config/add-ons/media"); + find_directory(B_USER_ADDONS_DIRECTORY, &path); + path.Append("media"); + entry.SetTo(path.Path()); #endif - e2.GetNodeRef(&nref); - DirNodeUser = nref.node; - WatchDir(&e2); - + entry.GetNodeRef(&nref); + fUserAddOnsNode = nref.node; + WatchDir(&entry); + fStartup = false; - + AddOnInfo *info; - - infomap->Rewind(); - while (infomap->GetNext(&info)) + + fInfoMap->Rewind(); + while (fInfoMap->GetNext(&info)) InstantiatePhysicalInputsAndOutputs(info); - infomap->Rewind(); - while (infomap->GetNext(&info)) + fInfoMap->Rewind(); + while (fInfoMap->GetNext(&info)) InstantiateAutostartFlavors(info); - infomap->Rewind(); - while (infomap->GetNext(&info)) + fInfoMap->Rewind(); + while (fInfoMap->GetNext(&info)) PutAddonIfPossible(info); - + server_rescan_defaults_command cmd; SendToServer(SERVER_RESCAN_DEFAULTS, &cmd, sizeof(cmd)); } @@ -248,19 +277,19 @@ MediaAddonServer::QuitRequested() { CALLED(); - + AddOnInfo *info; - infomap->Rewind(); - while(infomap->GetNext(&info)) { + fInfoMap->Rewind(); + while(fInfoMap->GetNext(&info)) { DestroyInstantiatedFlavors(info); PutAddonIfPossible(info); } - + return true; } -void +void MediaAddonServer::ScanAddOnFlavors(BMediaAddOn *addon) { AddOnInfo *info; @@ -270,29 +299,29 @@ port_id port; status_t rv; bool b; - + ASSERT(addon); ASSERT(addon->AddonID() > 0); - - TRACE("MediaAddonServer::ScanAddOnFlavors: id %ld\n",addon->AddonID()); - + + TRACE("MediaAddonServer::ScanAddOnFlavors: id %ld\n", addon->AddonID()); + port = find_port(MEDIA_SERVER_PORT_NAME); if (port <= B_OK) { ERROR("couldn't find media_server port\n"); return; } - + // cache the media_addon_id in a local variable to avoid // calling BMediaAddOn::AddonID() too often addon_id = addon->AddonID(); - + // update the cached flavor count, get oldflavorcount and newflavorcount - b = infomap->Get(addon_id, &info); + b = fInfoMap->Get(addon_id, &info); ASSERT(b); oldflavorcount = info->flavor_count; newflavorcount = addon->CountFlavors(); info->flavor_count = newflavorcount; - + TRACE("%ld old flavors, %ld new flavors\n", oldflavorcount, newflavorcount); // during the first update (i == 0), the server removes old dormant_flavor_infos @@ -303,29 +332,29 @@ ERROR("MediaAddonServer::ScanAddOnFlavors GetFlavorAt failed for index %d!\n", i); continue; } - + #if DEBUG >= 2 DumpFlavorInfo(info); #endif - + dormant_flavor_info dfi; dfi = *info; dfi.node_info.addon = addon_id; dfi.node_info.flavor_id = info->internal_id; strncpy(dfi.node_info.name, info->name, B_MEDIA_NAME_LENGTH - 1); dfi.node_info.name[B_MEDIA_NAME_LENGTH - 1] = 0; - + xfer_server_register_dormant_node *msg; size_t flattensize; size_t msgsize; - + flattensize = dfi.FlattenedSize(); msgsize = flattensize + sizeof(xfer_server_register_dormant_node); msg = (xfer_server_register_dormant_node *) malloc(msgsize); - + // the server should remove previously registered "dormant_flavor_info"s - // during the first update, but after the first iteration, we don't want - // the server to anymore remove old dormant_flavor_infos; + // during the first update, but after the first iteration, we don't + // want the server to anymore remove old dormant_flavor_infos msg->purge_id = (i == 0) ? addon_id : 0; msg->dfi_type = dfi.TypeCode(); @@ -343,10 +372,12 @@ // XXX parameter list is (media_addon_id addonid, int32 newcount, int32 gonecount) // XXX we currently pretend that all old flavors have been removed, this could // XXX probably be done in a smarter way - BPrivate::media::notifications::FlavorsChanged(addon_id, newflavorcount, oldflavorcount); + BPrivate::media::notifications::FlavorsChanged(addon_id, newflavorcount, + oldflavorcount); } -void + +void MediaAddonServer::AddOnAdded(const char *path, ino_t file_node) { TRACE("\n\nMediaAddonServer::AddOnAdded: path %s\n",path); @@ -359,7 +390,7 @@ ERROR("MediaAddonServer::AddOnAdded: failed to register add-on %s\n", path); return; } - + TRACE("MediaAddonServer::AddOnAdded: loading addon %ld now...\n", id); addon = _DormantNodeManager->GetAddon(id); @@ -372,14 +403,14 @@ TRACE("MediaAddonServer::AddOnAdded: loading finished, id %ld\n", id); // put file's inode and addon's id into map - filemap->Insert(file_node, id); - + fFileMap->Insert(file_node, id); + // also create AddOnInfo struct and get a pointer so // we can modify it AddOnInfo tempinfo; - infomap->Insert(id, tempinfo); + fInfoMap->Insert(id, tempinfo); AddOnInfo *info; - infomap->Get(id, &info); + fInfoMap->Get(id, &info); // setup info->id = id; @@ -393,7 +424,7 @@ // need to call BMediaNode::WantsAutoStart() // after the flavors have been scanned info->wants_autostart = addon->WantsAutoStart(); - + if (info->wants_autostart) TRACE("add-on %ld WantsAutoStart!\n", id); @@ -419,71 +450,87 @@ // since it is done by PutAddonIfPossible() } + void MediaAddonServer::DestroyInstantiatedFlavors(AddOnInfo *info) { printf("MediaAddonServer::DestroyInstantiatedFlavors\n"); media_node *node; while (info->active_flavors.GetNext(&node)) { - if ((node->kind & B_TIME_SOURCE) - && (mediaroster->StopTimeSource(*node, 0, true)!=B_OK)) { - printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't stop timesource\n"); + if ((node->kind & B_TIME_SOURCE) != 0 + && (fMediaRoster->StopTimeSource(*node, 0, true) != B_OK)) { + printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't stop " + "timesource\n"); continue; - } - - if(mediaroster->StopNode(*node, 0, true)!=B_OK) { - printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't stop node\n"); + } + + if (fMediaRoster->StopNode(*node, 0, true) != B_OK) { + printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't stop " + "node\n"); continue; } - + if (node->kind & B_BUFFER_CONSUMER) { media_input inputs[16]; int32 count = 0; - if(mediaroster->GetConnectedInputsFor(*node, inputs, 16, &count)!=B_OK) { - printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't get connected inputs\n"); + if (fMediaRoster->GetConnectedInputsFor(*node, inputs, 16, &count) + != B_OK) { + printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't " + "get connected inputs\n"); continue; } - - for(int32 i=0; iNodeIDFor(inputs[i].source.port)) < 0) { - printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't get source node id\n"); + if ((sourceNode = fMediaRoster->NodeIDFor( + inputs[i].source.port)) < 0) { + printf("MediaAddonServer::DestroyInstantiatedFlavors " + "couldn't get source node id\n"); continue; } - - if(mediaroster->Disconnect(sourceNode, inputs[i].source, node->node, inputs[i].destination)!=B_OK) { - printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't disconnect input\n"); + + if (fMediaRoster->Disconnect(sourceNode, inputs[i].source, + node->node, inputs[i].destination) != B_OK) { + printf("MediaAddonServer::DestroyInstantiatedFlavors " + "couldn't disconnect input\n"); continue; } } } - + if (node->kind & B_BUFFER_PRODUCER) { media_output outputs[16]; int32 count = 0; - if(mediaroster->GetConnectedOutputsFor(*node, outputs, 16, &count)!=B_OK) { - printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't get connected outputs\n"); + if (fMediaRoster->GetConnectedOutputsFor(*node, outputs, 16, + &count) != B_OK) { + printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't " + "get connected outputs\n"); continue; } - for(int32 i=0; iNodeIDFor(outputs[i].destination.port)) < 0) { - printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't get destination node id\n"); + if ((destNode = fMediaRoster->NodeIDFor( + outputs[i].destination.port)) < 0) { + printf("MediaAddonServer::DestroyInstantiatedFlavors " + "couldn't get destination node id\n"); continue; } - - if(mediaroster->Disconnect(node->node, outputs[i].source, destNode, outputs[i].destination)!=B_OK) { - printf("MediaAddonServer::DestroyInstantiatedFlavors couldn't disconnect output\n"); + + if (fMediaRoster->Disconnect(node->node, outputs[i].source, + destNode, outputs[i].destination) != B_OK) { + printf("MediaAddonServer::DestroyInstantiatedFlavors " + "couldn't disconnect output\n"); continue; } } } - + info->active_flavors.RemoveCurrent(); } } + void MediaAddonServer::PutAddonIfPossible(AddOnInfo *info) { @@ -493,6 +540,7 @@ } } + void MediaAddonServer::InstantiatePhysicalInputsAndOutputs(AddOnInfo *info) { @@ -500,7 +548,7 @@ int count = info->addon->CountFlavors(); for (int i = 0; i < count; i++) { const flavor_info *flavorinfo; - if (B_OK != info->addon->GetFlavorAt(i, &flavorinfo)) { + if (info->addon->GetFlavorAt(i, &flavorinfo) != B_OK) { ERROR("MediaAddonServer::InstantiatePhysialInputsAndOutputs GetFlavorAt failed for index %d!\n", i); continue; } @@ -514,7 +562,7 @@ strcpy(dni.name, flavorinfo->name); printf("MediaAddonServer::InstantiatePhysialInputsAndOutputs: \"%s\" is a physical input/output\n", flavorinfo->name); - rv = mediaroster->InstantiateDormantNode(dni, &node); + rv = fMediaRoster->InstantiateDormantNode(dni, &node); if (rv != B_OK) { ERROR("MediaAddonServer::InstantiatePhysialInputsAndOutputs Couldn't instantiate node flavor, internal_id %ld, name %s\n", flavorinfo->internal_id, flavorinfo->name); } else { @@ -525,6 +573,7 @@ } } + void MediaAddonServer::InstantiateAutostartFlavors(AddOnInfo *info) { @@ -539,18 +588,19 @@ printf("trying autostart of node %ld, index %ld\n", info->id, index); rv = info->addon->AutoStart(index, &outNode, &outInternalID, &outHasMore); if (rv == B_OK) { - printf("started node %ld\n",index); + printf("started node %ld\n", index); // XXX IncrementAddonFlavorInstancesCount - rv = MediaRosterEx(mediaroster)->RegisterNode(outNode, info->id, outInternalID); + rv = MediaRosterEx(fMediaRoster)->RegisterNode(outNode, info->id, + outInternalID); if (rv != B_OK) { printf("failed to register node %ld\n",index); // XXX DecrementAddonFlavorInstancesCount } - + info->active_flavors.Insert(outNode->Node()); - + if (!outHasMore) return; } else if (rv == B_MEDIA_ADDON_FAILED && outHasMore) { @@ -561,6 +611,7 @@ } } + void MediaAddonServer::AddOnRemoved(ino_t file_node) { @@ -569,64 +620,66 @@ AddOnInfo *info; int32 oldflavorcount; // XXX locking? - - if (!filemap->Get(file_node, &tempid)) { + + if (!fFileMap->Get(file_node, &tempid)) { ERROR("MediaAddonServer::AddOnRemoved: inode %Ld removed, but no media add-on found\n", file_node); return; } id = *tempid; // tempid pointer is invalid after Removing() it from the map - filemap->Remove(file_node); - - if (!infomap->Get(id, &info)) { + fFileMap->Remove(file_node); + + if (!fInfoMap->Get(id, &info)) { ERROR("MediaAddonServer::AddOnRemoved: couldn't get addon info for add-on %ld\n", id); oldflavorcount = 1000; } else { oldflavorcount = info->flavor_count; //same reason as above - + DestroyInstantiatedFlavors(info); PutAddonIfPossible(info); - + if (info->addon) { ERROR("MediaAddonServer::AddOnRemoved: couldn't unload addon %ld since flavors are in use\n", id); } } - - infomap->Remove(id); + fInfoMap->Remove(id); _DormantNodeManager->UnregisterAddon(id); - + BPrivate::media::notifications::FlavorsChanged(id, 0, oldflavorcount); } -void + +void MediaAddonServer::WatchDir(BEntry *dir) { - BEntry e; - BDirectory d(dir); + // send fake notices to trigger add-on loading + BDirectory directory(dir); node_ref nref; entry_ref ref; - while (B_OK == d.GetNextEntry(&e, false)) { - e.GetRef(&ref); - e.GetNodeRef(&nref); + BEntry entry; + while (directory.GetNextEntry(&entry, false) == B_OK) { + if (entry.GetRef(&ref) != B_OK || entry.GetNodeRef(&nref) != B_OK) + continue; + BMessage msg(B_NODE_MONITOR); - msg.AddInt32("opcode",B_ENTRY_CREATED); - msg.AddInt32("device",ref.device); - msg.AddInt64("directory",ref.directory); - msg.AddInt64("node",nref.node); - msg.AddString("name",ref.name); - msg.AddBool("nowait",true); + msg.AddInt32("opcode", B_ENTRY_CREATED); + msg.AddInt32("device", ref.device); + msg.AddInt64("directory", ref.directory); + msg.AddInt64("node", nref.node); + msg.AddString("name", ref.name); + msg.AddBool("nowait", true); MessageReceived(&msg); } - dir->GetNodeRef(&nref); - watch_node(&nref,B_WATCH_DIRECTORY,be_app_messenger); + dir->GetNodeRef(&nref); + watch_node(&nref, B_WATCH_DIRECTORY, be_app_messenger); } -void + +void MediaAddonServer::MessageReceived(BMessage *msg) { - switch (msg->what) - { + switch (msg->what) { case MEDIA_ADDON_SERVER_PLAY_MEDIA: { const char *name, *type; @@ -634,16 +687,15 @@ || (msg->FindString(MEDIA_TYPE_KEY, &type) != B_OK)) { msg->SendReply(B_ERROR); } - + PlayMediaFile(type, name); msg->SendReply(B_OK); // XXX don't know which reply is expected return; } - + case B_NODE_MONITOR: { - switch (msg->FindInt32("opcode")) - { + switch (msg->FindInt32("opcode")) { case B_ENTRY_CREATED: { const char *name; @@ -684,12 +736,12 @@ ino_t to; msg->FindInt64("from directory", &from); msg->FindInt64("to directory", &to); - if (DirNodeSystem == from || DirNodeUser == from) { + if (fSystemAddOnsNode == from || fUserAddOnsNode == from) { msg->ReplaceInt32("opcode",B_ENTRY_REMOVED); msg->AddInt64("directory",from); MessageReceived(msg); } - if (DirNodeSystem == to || DirNodeUser == to) { + if (fSystemAddOnsNode == to || fUserAddOnsNode == to) { msg->ReplaceInt32("opcode",B_ENTRY_CREATED); msg->AddInt64("directory",to); msg->AddBool("nowait",true); @@ -700,20 +752,21 @@ } break; } - default: inherited::MessageReceived(msg); break; + + default: + inherited::MessageReceived(msg); + break; } printf("MediaAddonServer: Unhandled message:\n"); msg->PrintToStream(); } -int main() -{ - new MediaAddonServer(B_MEDIA_ADDON_SERVER_SIGNATURE); - be_app->Run(); - return 0; -} -void DumpFlavorInfo(const flavor_info *info) +// #pragma mark - + + +void +DumpFlavorInfo(const flavor_info *info) { printf(" name = %s\n",info->name); printf(" info = %s\n",info->info); @@ -737,3 +790,13 @@ printf(" in_format_count = %ld\n",info->in_format_count); printf(" out_format_count = %ld\n",info->out_format_count); } + + +int +main() +{ + new MediaAddonServer(B_MEDIA_ADDON_SERVER_SIGNATURE); + be_app->Run(); + return 0; +} + From superstippi at gmx.de Mon Nov 26 13:46:52 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 26 Nov 2007 13:46:52 +0100 Subject: [Haiku-commits] r22997 - haiku/trunk/src/servers/media_addon In-Reply-To: <200711261222.lAQCMstv006350@sheep.berlios.de> References: <200711261222.lAQCMstv006350@sheep.berlios.de> Message-ID: <20071126134652.19813.2@stippis2.1196071146.fake> > -int main() > -{ > - new MediaAddonServer(B_MEDIA_ADDON_SERVER_SIGNATURE); > - be_app->Run(); > - return 0; > -} > +int > +main() > +{ > + new MediaAddonServer(B_MEDIA_ADDON_SERVER_SIGNATURE); > + be_app->Run(); > + return 0; > +} Will the MediaAddonServer destructor ever be called if one is "leaking" it like that? Or is there something else going on here? Best regards, -Stephan From axeld at mail.berlios.de Mon Nov 26 14:38:33 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 26 Nov 2007 14:38:33 +0100 Subject: [Haiku-commits] r22998 - haiku/trunk/src/system/kernel/cache Message-ID: <200711261338.lAQDcXIV011131@sheep.berlios.de> Author: axeld Date: 2007-11-26 14:38:32 +0100 (Mon, 26 Nov 2007) New Revision: 22998 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22998&view=rev Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp Log: read_from_file() and write_to_file() did not take the pageOffset into account. Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-11-26 12:22:53 UTC (rev 22997) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-11-26 13:38:32 UTC (rev 22998) @@ -281,6 +281,9 @@ int32 pageOffset, addr_t buffer, size_t bufferSize, size_t lastReservedPages, size_t reservePages) { + TRACE(("read_from_file(offset = %Ld, pageOffset = %ld, buffer = %#lx, " + "bufferSize = %lu\n", offset, pageOffset, buffer, bufferSize)); + iovec vec; vec.iov_base = (void *)buffer; vec.iov_len = bufferSize; @@ -289,8 +292,8 @@ mutex_unlock(&ref->cache->lock); vm_page_unreserve_pages(lastReservedPages); - status_t status = vfs_read_pages(ref->vnode, cookie, offset, &vec, 1, - &bufferSize, false); + status_t status = vfs_read_pages(ref->vnode, cookie, offset + pageOffset, + &vec, 1, &bufferSize, false); if (status == B_OK) reserve_pages(ref, reservePages, false); @@ -462,8 +465,8 @@ mutex_unlock(&ref->cache->lock); vm_page_unreserve_pages(lastReservedPages); - status_t status = vfs_write_pages(ref->vnode, cookie, offset, &vec, 1, - &bufferSize, false); + status_t status = vfs_write_pages(ref->vnode, cookie, offset + pageOffset, + &vec, 1, &bufferSize, false); if (status == B_OK) reserve_pages(ref, reservePages, true); From marcusoverhagen at arcor.de Mon Nov 26 15:15:56 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Mon, 26 Nov 2007 15:15:56 +0100 (CET) Subject: [Haiku-commits] r22997 - haiku/trunk/src/servers/media_addon In-Reply-To: <20071126134652.19813.2@stippis2.1196071146.fake> References: <20071126134652.19813.2@stippis2.1196071146.fake> <200711261222.lAQCMstv006350@sheep.berlios.de> Message-ID: <3102124.1196086556348.JavaMail.ngmail@webmail10> Stephan Assmus wrote: > > +main() > > +{ > > + new MediaAddonServer(B_MEDIA_ADDON_SERVER_SIGNATURE); > > + be_app->Run(); > > + return 0; > > +} > > Will the MediaAddonServer destructor ever be called if one is "leaking" it > like that? Or is there something else going on here? I don't think it will be called. Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From axeld at mail.berlios.de Mon Nov 26 15:29:56 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 26 Nov 2007 15:29:56 +0100 Subject: [Haiku-commits] r22999 - haiku/trunk/src/servers/media_addon Message-ID: <200711261429.lAQETu3x013643@sheep.berlios.de> Author: axeld Date: 2007-11-26 15:29:55 +0100 (Mon, 26 Nov 2007) New Revision: 22999 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22999&view=rev Modified: haiku/trunk/src/servers/media_addon/main.cpp Log: The MediaAddonServer destructor was never called, thanks Stippi! Modified: haiku/trunk/src/servers/media_addon/main.cpp =================================================================== --- haiku/trunk/src/servers/media_addon/main.cpp 2007-11-26 13:38:32 UTC (rev 22998) +++ haiku/trunk/src/servers/media_addon/main.cpp 2007-11-26 14:29:55 UTC (rev 22999) @@ -797,6 +797,7 @@ { new MediaAddonServer(B_MEDIA_ADDON_SERVER_SIGNATURE); be_app->Run(); + delete be_app; return 0; } From axeld at mail.berlios.de Mon Nov 26 17:02:10 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 26 Nov 2007 17:02:10 +0100 Subject: [Haiku-commits] r23000 - haiku/trunk/src/tools/fs_shell Message-ID: <200711261602.lAQG2AST020499@sheep.berlios.de> Author: axeld Date: 2007-11-26 17:02:10 +0100 (Mon, 26 Nov 2007) New Revision: 23000 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23000&view=rev Modified: haiku/trunk/src/tools/fs_shell/file_cache.cpp Log: The fs_shell cache implementation had the same problem as our real cache until r22998 - but since this was the only implementation, its consequences were much more likely. Modified: haiku/trunk/src/tools/fs_shell/file_cache.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/file_cache.cpp 2007-11-26 14:29:55 UTC (rev 22999) +++ haiku/trunk/src/tools/fs_shell/file_cache.cpp 2007-11-26 16:02:10 UTC (rev 23000) @@ -89,8 +89,8 @@ mutex_unlock(&ref->lock); - fssh_status_t status = vfs_read_pages(ref->node, cookie, offset, &vec, 1, - &bufferSize, false); + fssh_status_t status = vfs_read_pages(ref->node, cookie, + offset + pageOffset, &vec, 1, &bufferSize, false); mutex_lock(&ref->lock); @@ -108,8 +108,8 @@ mutex_unlock(&ref->lock); - fssh_status_t status = vfs_write_pages(ref->node, cookie, offset, &vec, 1, - &bufferSize, false); + fssh_status_t status = vfs_write_pages(ref->node, cookie, + offset + pageOffset, &vec, 1, &bufferSize, false); mutex_lock(&ref->lock); From revol at free.fr Mon Nov 26 18:38:59 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Mon, 26 Nov 2007 18:38:59 +0100 CET Subject: [Haiku-commits] r23000 - haiku/trunk/src/tools/fs_shell In-Reply-To: <200711261602.lAQG2AST020499@sheep.berlios.de> Message-ID: <11020099539-BeMail@laptop> > Author: axeld > Date: 2007-11-26 17:02:10 +0100 (Mon, 26 Nov 2007) > New Revision: 23000 Hey! You get a cookie box ! :) Fran?ois. From axeld at mail.berlios.de Mon Nov 26 22:47:22 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 26 Nov 2007 22:47:22 +0100 Subject: [Haiku-commits] r23001 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711262147.lAQLlMaE029726@sheep.berlios.de> Author: axeld Date: 2007-11-26 22:47:22 +0100 (Mon, 26 Nov 2007) New Revision: 23001 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23001&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/bus.c Log: Fixed setting up an interrupt using the new filter method: INTR_FAST doesn't have to be set in this case. Modified: haiku/trunk/src/libs/compat/freebsd_network/bus.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-11-26 16:02:10 UTC (rev 23000) +++ haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-11-26 21:47:22 UTC (rev 23001) @@ -296,18 +296,15 @@ intr->arg = arg; intr->irq = res->r_bushandle; intr->flags = flags; + intr->sem = -1; + intr->thread = -1; - if (flags & INTR_FAST) { - intr->sem = -1; - intr->thread = -1; - - if (filter != NULL) { - status = install_io_interrupt_handler(intr->irq, - (interrupt_handler)intr->filter, intr->arg, 0); - } else { - status = install_io_interrupt_handler(intr->irq, - intr_fast_wrapper, intr, 0); - } + if (filter != NULL) { + status = install_io_interrupt_handler(intr->irq, + (interrupt_handler)intr->filter, intr->arg, 0); + } else if (flags & INTR_FAST) { + status = install_io_interrupt_handler(intr->irq, + intr_fast_wrapper, intr, 0); } else { snprintf(semName, sizeof(semName), "%s intr", dev->dev_name); From ingo_weinhold at gmx.de Mon Nov 26 23:43:16 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 26 Nov 2007 23:43:16 +0100 Subject: [Haiku-commits] r23000 - haiku/trunk/src/tools/fs_shell In-Reply-To: <11020099539-BeMail@laptop> References: <11020099539-BeMail@laptop> Message-ID: <20071126234316.1592.1@knochen-vm.nameserver> On 2007-11-26 at 18:38:59 [+0100], Fran?ois Revol wrote: > > Author: axeld > > Date: 2007-11-26 17:02:10 +0100 (Mon, 26 Nov 2007) > > > New Revision: 23000 > > Hey! > You get a cookie box ! :) ... or maybe an Illuminati tattoo? ;-) CU, Ingo From bonefish at mail.berlios.de Tue Nov 27 00:26:00 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 27 Nov 2007 00:26:00 +0100 Subject: [Haiku-commits] r23002 - in haiku/trunk: build/jam src/tests/system/libroot/posix/posixtestsuite src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_getspecific src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_setspecific Message-ID: <200711262326.lAQNQ0xZ002207@sheep.berlios.de> Author: bonefish Date: 2007-11-27 00:25:59 +0100 (Tue, 27 Nov 2007) New Revision: 23002 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23002&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_getspecific/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_getspecific/3-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-2.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/3-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/1-2.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_setspecific/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_setspecific/1-2.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh Log: Patch by Vasilis Kaoutsis: * Added pthreads posix test suite tests to run script and image. * Improved output for said tests. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/build/jam/HaikuImage 2007-11-26 23:25:59 UTC (rev 23002) @@ -446,6 +446,17 @@ AddFilesToHaikuImage home posixtestsuite conformance interfaces sigset : sigset_1-1 sigset_2-1 sigset_3-1 sigset_4-1 sigset_5-1 sigset_6-1 sigset_7-1 sigset_8-1 sigset_9-1 sigset_10-1 ; + + # add pthreads tests + AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_getspecific + : pthread_getspecific_1-1 pthread_getspecific_3-1 ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_key_create + : pthread_key_create_1-1 pthread_key_create_1-2 pthread_key_create_2-1 + pthread_key_create_3-1 ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_key_delete + : pthread_key_delete_1-1 pthread_key_delete_1-2 pthread_key_delete_2-1 ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_setspecific + : pthread_setspecific_1-1 pthread_setspecific_1-2 ; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_getspecific/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_getspecific/1-1.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_getspecific/1-1.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -37,13 +37,13 @@ { if(pthread_key_create(&keys[i], NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_getspecific_1-1 Error: pthread_key_create() failed\n"); return PTS_UNRESOLVED; } else { if(pthread_setspecific(keys[i], (void *)(long)(i + KEY_VALUE)) != 0) { - printf("Error: pthread_setspecific() failed\n"); + printf("pthread_getspecific_1-1 Error: pthread_setspecific() failed\n"); return PTS_UNRESOLVED; } @@ -55,18 +55,18 @@ rc = pthread_getspecific(keys[i]); if(rc != (void *)(long)(i + KEY_VALUE)) { - printf("Test FAILED: Did not return correct value of thread-specific key, expected %d, but got %ld\n", (i + KEY_VALUE), (long)rc); + printf("pthread_getspecific_1-1 Test FAILED: Did not return correct value of thread-specific key, expected %d, but got %ld\n", (i + KEY_VALUE), (long)rc); return PTS_FAIL; } else { if(pthread_key_delete(keys[i]) != 0) { - printf("Error: pthread_key_delete() failed\n"); + printf("pthread_getspecific_1-1 Error: pthread_key_delete() failed\n"); return PTS_UNRESOLVED; } } } - printf("Test PASSED\n"); + printf("pthread_getspecific_1-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_getspecific/3-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_getspecific/3-1.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_getspecific/3-1.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -30,23 +30,23 @@ if(pthread_key_create(&key, NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_getspecific_3-1 Error: pthread_key_create() failed\n"); return PTS_UNRESOLVED; } rc = pthread_getspecific(key); if(rc != NULL) { - printf("Test FAILED: Did not return correct value, expected NULL, but got %ld\n", (long)rc); + printf("pthread_getspecific_3-1 Test FAILED: Did not return correct value, expected NULL, but got %ld\n", (long)rc); return PTS_FAIL; } if(pthread_key_delete(key) != 0) { - printf("Error: pthread_key_delete() failed\n"); + printf("pthread_getspecific_3-1 Error: pthread_key_delete() failed\n"); return PTS_UNRESOLVED; } - printf("Test PASSED\n"); + printf("pthread_getspecific_3-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-1.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-1.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -40,13 +40,13 @@ { if(pthread_key_create(&keys[i], NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_key_create_1-1 Error: pthread_key_create() failed\n"); return PTS_UNRESOLVED; } else { if(pthread_setspecific(keys[i], (void *)(long)(i + KEY_VALUE)) != 0) { - printf("Error: pthread_setspecific() failed\n"); + printf("pthread_key_create_1-1 Error: pthread_setspecific() failed\n"); return PTS_UNRESOLVED; } @@ -58,18 +58,18 @@ rc = pthread_getspecific(keys[i]); if(rc != (void *)(long)(i + KEY_VALUE)) { - printf("Test FAILED: Did not return correct value of thread-specific key, expected %ld, but got %ld\n", (long)(i + KEY_VALUE), (long)rc); + printf("pthread_key_create_1-1 Test FAILED: Did not return correct value of thread-specific key, expected %ld, but got %ld\n", (long)(i + KEY_VALUE), (long)rc); return PTS_FAIL; } else { if(pthread_key_delete(keys[i]) != 0) { - printf("Error: pthread_key_delete() failed\n"); + printf("pthread_key_create_1-1 Error: pthread_key_delete() failed\n"); return PTS_UNRESOLVED; } } } - printf("Test PASSED\n"); + printf("pthread_key_create_1-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-2.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-2.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-2.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -36,7 +36,7 @@ /* Set the key to KEY_VALUE */ if(pthread_setspecific(keys[i], (void *)(KEY_VALUE)) != 0) { - printf("Error: pthread_setspecific() failed\n"); + printf("pthread_key_create_1-2 Error: pthread_setspecific() failed\n"); pthread_exit((void*)PTS_FAIL); } @@ -53,7 +53,7 @@ { if(pthread_key_create(&keys[i], NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_key_create_1-2 Error: pthread_key_create() failed\n"); return PTS_UNRESOLVED; } } @@ -65,24 +65,24 @@ /* Create a thread */ if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { - perror("Error creating thread\n"); + perror("pthread_key_create_1-2 Error creating thread\n"); return PTS_UNRESOLVED; } /* Wait for thread to end */ if(pthread_join(new_th, &value_ptr) != 0) { - perror("Error in pthread_join\n"); + perror("pthread_key_create_1-2 Error in pthread_join\n"); return PTS_UNRESOLVED; } if(value_ptr == (void*) PTS_FAIL) { - printf("Test FAILED: Could not use a certain key value to set for many keys\n"); + printf("pthread_key_create_1-2: Test FAILED: Could not use a certain key value to set for many keys\n"); return PTS_FAIL; } } - printf("Test PASSED\n"); + printf("pthread_key_create_1-2: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/2-1.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/2-1.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -33,13 +33,13 @@ rc = pthread_getspecific(key); if(rc != NULL) { - printf("Test FAILED\n"); + printf("pthread_key_create_2-1 Test FAILED\n"); return PTS_FAIL; } if(pthread_key_create(&key, NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_key_create_2-1 pthread_key_create_2-1 Error: pthread_key_create() failed\n"); return PTS_UNRESOLVED; } else { @@ -48,12 +48,12 @@ rc = pthread_getspecific(key); if(rc != NULL) { - printf("Test FAILED\n"); + printf("pthread_key_create_2-1 Test FAILED\n"); return PTS_FAIL; } } - printf("Test PASSED\n"); + printf("pthread_key_create_2-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/3-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/3-1.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/3-1.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -44,7 +44,7 @@ /* Set the value of the key to a value */ if(pthread_setspecific(key, (void *)(KEY_VALUE)) != 0) { - printf("Error: pthread_setspecific() failed\n"); + printf("pthread_key_create_3-1 Error: pthread_setspecific() failed\n"); pthread_exit((void*) PTS_UNRESOLVED); } @@ -62,31 +62,31 @@ /* Create a key with a destructor function */ if(pthread_key_create(&key, dest_func) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_key_create_3-1 Error: pthread_key_create() failed\n"); pthread_exit((void*) PTS_UNRESOLVED); } /* Create a thread */ if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { - perror("Error creating thread\n"); + perror("pthread_key_create_3-1 Error creating thread\n"); return PTS_UNRESOLVED; } /* Wait for the thread's return */ if(pthread_join(new_th, NULL) != 0) { - perror("Error in pthread_join()\n"); + perror("pthread_key_create_3-1 Error in pthread_join()\n"); return PTS_UNRESOLVED; } /* Check if the destructor was called */ if(dest_cnt == 0) { - printf("Test FAILED: Destructor not called\n"); + printf("pthread_key_create_3-1 Test FAILED: Destructor not called\n"); return PTS_FAIL; } - printf("Test PASSED\n"); + printf("pthread_key_create_3-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/1-1.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/1-1.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -39,18 +39,18 @@ { if(pthread_key_create(&keys[i], NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_key_delete_1-1 Error: pthread_key_create() failed\n"); return PTS_UNRESOLVED; } if(pthread_key_delete(keys[i]) != 0) { - printf("Test FAILED\n"); + printf("pthread_key_delete_1-1 Test FAILED\n"); return PTS_FAIL; } } - printf("Test PASSED\n"); + printf("pthread_key_delete_1-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/1-2.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/1-2.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/1-2.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -40,23 +40,23 @@ { if(pthread_key_create(&keys[i], NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_key_delete_1-2 Error: pthread_key_create() failed\n"); return PTS_UNRESOLVED; } if(pthread_setspecific(keys[i], (void*)(long)(KEY_VALUE + i)) != 0) { - printf("Error: pthread_setspecific failed\n"); + printf("pthread_key_delete_1-2 Error: pthread_setspecific failed\n"); return PTS_UNRESOLVED; } if(pthread_key_delete(keys[i]) != 0) { - printf("Test FAILED\n"); + printf("pthread_key_delete_1-2 Test FAILED\n"); return PTS_FAIL; } } - printf("Test PASSED\n"); + printf("pthread_key_delete_1-2: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/2-1.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_delete/2-1.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -47,7 +47,7 @@ /* Set the value of the key to a value */ if(pthread_setspecific(key, (void *)(KEY_VALUE)) != 0) { - printf("Error: pthread_setspecific() failed\n"); + printf("pthread_key_delete_2-1 Error: pthread_setspecific() failed\n"); pthread_exit((void*) PTS_UNRESOLVED); } @@ -65,21 +65,21 @@ /* Create a key with a destructor function */ if(pthread_key_create(&key, dest_func) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_key_delete_2-1 Error: pthread_key_create() failed\n"); pthread_exit((void*) PTS_UNRESOLVED); } /* Create a thread */ if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { - perror("Error creating thread\n"); + perror("pthread_key_delete_2-1 Error creating thread\n"); return PTS_UNRESOLVED; } /* Wait for the thread's return */ if(pthread_join(new_th, NULL) != 0) { - perror("Error in pthread_join()\n"); + perror("pthread_key_delete_2-1 Error in pthread_join()\n"); return PTS_UNRESOLVED; } @@ -89,15 +89,15 @@ { if(dest_cnt == 0) { - printf("Error calling the key destructor function\n"); + printf("pthread_key_delete_2-1 Error calling the key destructor function\n"); return PTS_UNRESOLVED; } else { - printf("Test FAILED: pthread_key_delete failed to be called from the destructor function\n"); + printf("pthread_key_delete_2-1 Test FAILED: pthread_key_delete failed to be called from the destructor function\n"); return PTS_FAIL; } } - printf("Test PASSED\n"); + printf("pthread_key_delete_2-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_setspecific/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_setspecific/1-1.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_setspecific/1-1.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -38,13 +38,13 @@ { if(pthread_key_create(&keys[i], NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_setspecific_1-1 Error: pthread_key_create() failed\n"); return PTS_UNRESOLVED; } else { if(pthread_setspecific(keys[i], (void *)(long)(i + KEY_VALUE)) != 0) { - printf("Test FAILED: Could not set the value of the key to %d\n", (i + KEY_VALUE)); + printf("pthread_setspecific_1-1 Test FAILED: Could not set the value of the key to %d\n", (i + KEY_VALUE)); return PTS_FAIL; } @@ -56,18 +56,18 @@ rc = pthread_getspecific(keys[i]); if(rc != (void *)(long)(i + KEY_VALUE)) { - printf("Test FAILED: Did not return correct value of thread-specific key, expected %ld, but got %ld\n", (long)(i + KEY_VALUE), (long)rc); + printf("pthread_setspecific_1-1 Test FAILED: Did not return correct value of thread-specific key, expected %ld, but got %ld\n", (long)(i + KEY_VALUE), (long)rc); return PTS_FAIL; } else { if(pthread_key_delete(keys[i]) != 0) { - printf("Error: pthread_key_delete() failed\n"); + printf("pthread_setspecific_1-1 Error: pthread_key_delete() failed\n"); return PTS_UNRESOLVED; } } } - printf("Test PASSED\n"); + printf("pthread_setspecific_1-1: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_setspecific/1-2.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_setspecific/1-2.c 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_setspecific/1-2.c 2007-11-26 23:25:59 UTC (rev 23002) @@ -40,7 +40,7 @@ * that we bind for the main thread) */ if(pthread_setspecific(key, (void *)(KEY_VALUE_2)) != 0) { - printf("Test FAILED: Could not set the value of the key to %d\n", (KEY_VALUE_2)); + printf("pthread_setspecific_1-2 Test FAILED: Could not set the value of the key to %d\n", (KEY_VALUE_2)); pthread_exit((void*)PTS_FAIL); return NULL; } @@ -60,21 +60,21 @@ /* Create the key */ if(pthread_key_create(&key, NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); + printf("pthread_setspecific_1-2 Error: pthread_key_create() failed\n"); return PTS_UNRESOLVED; } /* Bind a value for this main thread */ if(pthread_setspecific(key, (void *)(KEY_VALUE_1)) != 0) { - printf("Test FAILED: Could not set the value of the key to %d\n", (KEY_VALUE_1)); + printf("pthread_setspecific_1-2 Test FAILED: Could not set the value of the key to %d\n", (KEY_VALUE_1)); return PTS_FAIL; } /* Create another thread. This thread will also bind a value to the key */ if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { - printf("Error: in pthread_create()\n"); + printf("pthread_setspecific_1-2 Error: in pthread_create()\n"); return PTS_UNRESOLVED; } @@ -88,16 +88,16 @@ * thread, they should be different. */ if(rc1 != (void *)(KEY_VALUE_1)) { - printf("Test FAILED: Incorrect value bound to key, expected %d, got %ld\n", KEY_VALUE_1, (long)rc1); + printf("pthread_setspecific_1-2 Test FAILED: Incorrect value bound to key, expected %d, got %ld\n", KEY_VALUE_1, (long)rc1); return PTS_FAIL; } if(rc2 != (void *)(KEY_VALUE_2)) { - printf("Test FAILED: Incorrect value bound to key, expected %d, got %ld\n", KEY_VALUE_2, (long)rc2); + printf("pthread_setspecific_1-2 Test FAILED: Incorrect value bound to key, expected %d, got %ld\n", KEY_VALUE_2, (long)rc2); return PTS_FAIL; } - printf("Test PASSED\n"); + printf("pthread_setspecific_1-2: Test PASSED\n"); return PTS_PASS; } Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh 2007-11-26 21:47:22 UTC (rev 23001) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh 2007-11-26 23:25:59 UTC (rev 23002) @@ -30,7 +30,8 @@ conformance/interfaces/difftime/difftime_1-1 echo "" echo "fork()" - conformance/interfaces/fork/fork_3-1 +# conformance/interfaces/fork/fork_3-1 + echo "fork_3-1: FIXME : test sometimes fails, see bug #1639" conformance/interfaces/fork/fork_4-1 conformance/interfaces/fork/fork_6-1 conformance/interfaces/fork/fork_8-1 @@ -46,6 +47,32 @@ } +threads_tests() +{ + echo "pthread_getspecific()" + conformance/interfaces/pthread_getspecific/pthread_getspecific_1-1 + conformance/interfaces/pthread_getspecific/pthread_getspecific_3-1 + echo "" + echo "pthread_key_create()" + conformance/interfaces/pthread_key_create/pthread_key_create_1-1 +# conformance/interfaces/pthread_key_create/pthread_key_create_1-2 + echo "pthread_key_create_1-2: FIXME: test fails, see bug #1644" +# conformance/interfaces/pthread_key_create/pthread_key_create_2-1 + echo "pthread_key_create_2-1: FIXME: test invokes the debugger, see bug #1646" + conformance/interfaces/pthread_key_create/pthread_key_create_3-1 + echo "" + echo "pthread_key_delete()" + conformance/interfaces/pthread_key_delete/pthread_key_delete_1-1 + conformance/interfaces/pthread_key_delete/pthread_key_delete_1-2 +# conformance/interfaces/pthread_key_delete/pthread_key_delete_2-1 + echo "pthread_key_delete_2-1: FIXME: test blocks, see bug #1642" + echo "" + echo "pthread_setspecific()" + conformance/interfaces/pthread_setspecific/pthread_setspecific_1-1 + conformance/interfaces/pthread_setspecific/pthread_setspecific_1-2 +} + + signals_tests() { echo "kill()" @@ -112,6 +139,7 @@ standard_tests asynchronous_input_output_tests signals_tests + threads_tests } @@ -135,7 +163,7 @@ #TODO sem* ;; THR) echo "Executing threads tests" - #TODO pthread_* + threads_tests ;; TMR) echo "Executing timers and clocks tests" #TODO time* *time clock* nanosleep @@ -155,4 +183,4 @@ esac -echo "**** Tests Complete ****" +echo "**** Tests Completed ****" From axeld at mail.berlios.de Tue Nov 27 13:59:35 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 27 Nov 2007 13:59:35 +0100 Subject: [Haiku-commits] r23003 - in haiku/trunk: headers/private/kernel/boot src/system/boot/platform/bios_ia32 src/system/kernel/debug Message-ID: <200711271259.lARCxZwJ010902@sheep.berlios.de> Author: axeld Date: 2007-11-27 13:59:34 +0100 (Tue, 27 Nov 2007) New Revision: 23003 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23003&view=rev Modified: haiku/trunk/headers/private/kernel/boot/kernel_args.h haiku/trunk/src/system/boot/platform/bios_ia32/debug.c haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp haiku/trunk/src/system/boot/platform/bios_ia32/serial.cpp haiku/trunk/src/system/boot/platform/bios_ia32/serial.h haiku/trunk/src/system/boot/platform/bios_ia32/start.c haiku/trunk/src/system/kernel/debug/debug.c Log: * The boot loader (bios_ia32 only) now duplicates everything that goes to the serial output, and puts it into the new kernel_args::debug_output field. * syslog_init() will now check if there is anything in kernel_args::debug_output and will put that into the syslog buffer. * dump_block() now also prints an offset. * Fixed warning in mmu.cpp. Modified: haiku/trunk/headers/private/kernel/boot/kernel_args.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/kernel_args.h 2007-11-26 23:25:59 UTC (rev 23002) +++ haiku/trunk/headers/private/kernel/boot/kernel_args.h 2007-11-27 12:59:34 UTC (rev 23003) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -70,6 +70,9 @@ addr_range physical_buffer; } frame_buffer; + void *debug_output; + uint32 debug_size; + platform_kernel_args platform_args; arch_kernel_args arch_args; } kernel_args; Modified: haiku/trunk/src/system/boot/platform/bios_ia32/debug.c =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/debug.c 2007-11-26 23:25:59 UTC (rev 23002) +++ haiku/trunk/src/system/boot/platform/bios_ia32/debug.c 2007-11-27 12:59:34 UTC (rev 23003) @@ -1,5 +1,5 @@ /* - * Copyright 2004, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -12,9 +12,8 @@ #include -/** This works only after console_init() was called. - */ - +/*! This works only after console_init() was called. +*/ void panic(const char *format, ...) { Modified: haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp 2007-11-26 23:25:59 UTC (rev 23002) +++ haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp 2007-11-27 12:59:34 UTC (rev 23003) @@ -393,7 +393,7 @@ if (address < KERNEL_BASE || address + size >= KERNEL_BASE + kMaxKernelSize) { panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n", - address, size); + (void *)address, size); } // unmap all pages within the range Modified: haiku/trunk/src/system/boot/platform/bios_ia32/serial.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/serial.cpp 2007-11-26 23:25:59 UTC (rev 23002) +++ haiku/trunk/src/system/boot/platform/bios_ia32/serial.cpp 2007-11-27 12:59:34 UTC (rev 23003) @@ -1,5 +1,5 @@ /* - * Copyright 2004, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -34,7 +34,10 @@ static int32 sSerialEnabled = 0; static uint16 sSerialBasePort = 0x3f8; +static char sBuffer[4096]; +static uint32 sBufferPosition; + static void serial_putc(char c) { @@ -52,6 +55,11 @@ if (sSerialEnabled <= 0) return; + if (sBufferPosition + size < sizeof(sBuffer)) { + memcpy(sBuffer + sBufferPosition, string, size); + sBufferPosition += size; + } + while (size-- != 0) { char c = string[0]; @@ -85,6 +93,20 @@ extern "C" void +serial_cleanup(void) +{ + if (sSerialEnabled <= 0) + return; + + gKernelArgs.debug_output = kernel_args_malloc(sBufferPosition); + if (gKernelArgs.debug_output != NULL) { + memcpy(gKernelArgs.debug_output, sBuffer, sBufferPosition); + gKernelArgs.debug_size = sBufferPosition; + } +} + + +extern "C" void serial_init(void) { // copy the base ports of the optional 4 serial ports to the kernel args Modified: haiku/trunk/src/system/boot/platform/bios_ia32/serial.h =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/serial.h 2007-11-26 23:25:59 UTC (rev 23002) +++ haiku/trunk/src/system/boot/platform/bios_ia32/serial.h 2007-11-27 12:59:34 UTC (rev 23003) @@ -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-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ #ifndef SERIAL_H #define SERIAL_H @@ -14,6 +14,7 @@ #endif extern void serial_init(void); +extern void serial_cleanup(void); extern void serial_puts(const char *string, size_t size); Modified: haiku/trunk/src/system/boot/platform/bios_ia32/start.c =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/start.c 2007-11-26 23:25:59 UTC (rev 23002) +++ haiku/trunk/src/system/boot/platform/bios_ia32/start.c 2007-11-27 12:59:34 UTC (rev 23003) @@ -75,6 +75,7 @@ // or I don't see something important... addr_t stackTop = gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size; + serial_cleanup(); mmu_init_for_kernel(); smp_boot_other_cpus(); Modified: haiku/trunk/src/system/kernel/debug/debug.c =================================================================== --- haiku/trunk/src/system/kernel/debug/debug.c 2007-11-26 23:25:59 UTC (rev 23002) +++ haiku/trunk/src/system/kernel/debug/debug.c 2007-11-27 12:59:34 UTC (rev 23003) @@ -6,7 +6,7 @@ * Distributed under the terms of the NewOS License. */ -/* This file contains the debugger */ +/*! This file contains the debugger and debug output facilities */ #include "blue_screen.h" #include "gdb.h" @@ -602,7 +602,7 @@ static status_t -syslog_init(void) +syslog_init(struct kernel_args *args) { status_t status; @@ -628,6 +628,9 @@ sSyslogMessage->ident[0] = '\0'; //strcpy(sSyslogMessage->ident, "KERNEL"); + if (args->debug_output != NULL) + syslog_write(args->debug_output, args->debug_size); + return B_OK; err3: @@ -748,7 +751,7 @@ if (sDebugScreenEnabled) blue_screen_enter(true); - syslog_init(); + syslog_init(args); return arch_debug_init(args); } @@ -1101,7 +1104,7 @@ for (i = 0; i < size;) { int start = i; - dprintf(prefix); + dprintf("%s%04x ", prefix, i); for (; i < start + DUMPED_BLOCK_SIZE; i++) { if (!(i % 4)) dprintf(" "); From bonefish at mail.berlios.de Tue Nov 27 16:27:53 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 27 Nov 2007 16:27:53 +0100 Subject: [Haiku-commits] r23004 - haiku/trunk/src/system/libroot/posix/pthread Message-ID: <200711271527.lARFRrT7021547@sheep.berlios.de> Author: bonefish Date: 2007-11-27 16:27:52 +0100 (Tue, 27 Nov 2007) New Revision: 23004 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23004&view=rev Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread.c Log: Correctly return errors. Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread.c 2007-11-27 12:59:34 UTC (rev 23003) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread.c 2007-11-27 15:27:52 UTC (rev 23004) @@ -83,9 +83,10 @@ int pthread_join(pthread_t thread, void **value_ptr) { - wait_for_thread(thread, (status_t *)value_ptr); - /* the thread could be joinable and gone */ - return B_OK; + status_t error = wait_for_thread(thread, (status_t *)value_ptr); + if (error == B_BAD_THREAD_ID) + return ESRCH; + return error; } From bonefish at mail.berlios.de Tue Nov 27 16:29:47 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 27 Nov 2007 16:29:47 +0100 Subject: [Haiku-commits] r23005 - haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create Message-ID: <200711271529.lARFTlBS021768@sheep.berlios.de> Author: bonefish Date: 2007-11-27 16:29:47 +0100 (Tue, 27 Nov 2007) New Revision: 23005 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23005&view=rev Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-2.c Log: The pthread_*() functions don't set errno, but return the error code directly. Hence perror() doesn't print anything useful. Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-2.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-2.c 2007-11-27 15:27:52 UTC (rev 23004) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/1-2.c 2007-11-27 15:29:47 UTC (rev 23005) @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "posixtest.h" @@ -47,13 +48,15 @@ { pthread_t new_th; void *value_ptr; + int error; /* Create a key */ for(i = 0;i Author: axeld Date: 2007-11-27 17:33:19 +0100 (Tue, 27 Nov 2007) New Revision: 23006 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23006&view=rev Modified: haiku/trunk/headers/private/kernel/boot/kernel_args.h haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp haiku/trunk/src/system/kernel/debug/frame_buffer_console.cpp Log: * The boot loader now remembers the bytes per row as told by the graphics card, and passes that information on to the kernel. This should fix wrong bytes per row with certain resolutions and graphics cards. * The boot loader now recognizes 15 bit modes that are advertised as 16 bit modes. This should fix wrong colors in 16 bit modes on some cards. * Reenabled setting MTRR for VESA mode - don't remember why I disabled it, but it works fine on my test machines. Modified: haiku/trunk/headers/private/kernel/boot/kernel_args.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/kernel_args.h 2007-11-27 15:29:47 UTC (rev 23005) +++ haiku/trunk/headers/private/kernel/boot/kernel_args.h 2007-11-27 16:33:19 UTC (rev 23006) @@ -63,11 +63,12 @@ struct driver_settings_file *driver_settings; struct { + addr_range physical_buffer; + uint32 bytes_per_row; + uint16 width; + uint16 height; + uint8 depth; bool enabled; - int32 width; - int32 height; - int32 depth; - addr_range physical_buffer; } frame_buffer; void *debug_output; Modified: haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp 2007-11-27 15:29:47 UTC (rev 23005) +++ haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp 2007-11-27 16:33:19 UTC (rev 23006) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -37,7 +37,8 @@ struct video_mode { list_link link; uint16 mode; - int32 width, height, bits_per_pixel; + uint16 width, height, bits_per_pixel; + uint32 bytes_per_row; }; static vbe_info_block sInfo; @@ -319,11 +320,11 @@ if (mode == 0xffff) break; - TRACE((" %lx: ", mode)); + TRACE((" %x: ", mode)); struct vbe_mode_info modeInfo; if (vesa_get_mode_info(mode, &modeInfo) == B_OK) { - TRACE(("%ld x %ld x %ld (a = %ld, mem = %ld, phy = %lx, p = %ld, b = %ld)\n", + TRACE(("%u x %u x %u (a = %d, mem = %d, phy = %lx, p = %d, b = %d)\n", modeInfo.width, modeInfo.height, modeInfo.bits_per_pixel, modeInfo.attributes, modeInfo.memory_model, modeInfo.physical_base, modeInfo.num_planes, modeInfo.num_banks)); @@ -343,9 +344,16 @@ continue; videoMode->mode = mode; + videoMode->bytes_per_row = modeInfo.bytes_per_row; videoMode->width = modeInfo.width; videoMode->height = modeInfo.height; videoMode->bits_per_pixel = modeInfo.bits_per_pixel; + if (modeInfo.bits_per_pixel == 16 + && modeInfo.red_mask_size + modeInfo.green_mask_size + + modeInfo.blue_mask_size == 15) { + // this is really a 15-bit mode + videoMode->bits_per_pixel = 15; + } if (standardMode == NULL) standardMode = videoMode; @@ -501,7 +509,8 @@ video_mode *mode = NULL; while ((mode = (video_mode *)list_get_next_item(&sModeList, mode)) != NULL) { char label[64]; - sprintf(label, "%ldx%ld %ld bit", mode->width, mode->height, mode->bits_per_pixel); + sprintf(label, "%ux%u %u bit", mode->width, mode->height, + mode->bits_per_pixel); menu->AddItem(item = new(nothrow) MenuItem(label)); item->SetData(mode); @@ -542,16 +551,19 @@ blit32(const uint8 *data, uint16 width, uint16 height, const uint8 *palette, uint16 left, uint16 top) { - uint32 *start = (uint32 *)sFrameBuffer + gKernelArgs.frame_buffer.width * top + left; + uint32 *start = (uint32 *)(sFrameBuffer + + gKernelArgs.frame_buffer.bytes_per_row * top + 4 * left); for (int32 y = 0; y < height; y++) { for (int32 x = 0; x < width; x++) { uint16 color = data[y * width + x] * 3; - start[x] = (palette[color + 0] << 16) | (palette[color + 1] << 8) | (palette[color + 2]); + start[x] = (palette[color + 0] << 16) | (palette[color + 1] << 8) + | (palette[color + 2]); } - start += gKernelArgs.frame_buffer.width; + start = (uint32 *)((addr_t)start + + gKernelArgs.frame_buffer.bytes_per_row); } } @@ -560,7 +572,8 @@ blit24(const uint8 *data, uint16 width, uint16 height, const uint8 *palette, uint16 left, uint16 top) { - uint8 *start = (uint8 *)sFrameBuffer + gKernelArgs.frame_buffer.width * 3 * top + 3 * left; + uint8 *start = (uint8 *)sFrameBuffer + + gKernelArgs.frame_buffer.bytes_per_row * top + 3 * left; for (int32 y = 0; y < height; y++) { for (int32 x = 0; x < width; x++) { @@ -572,7 +585,7 @@ start[index + 2] = palette[color + 0]; } - start += gKernelArgs.frame_buffer.width * 3; + start = start + gKernelArgs.frame_buffer.bytes_per_row; } } @@ -581,17 +594,20 @@ blit16(const uint8 *data, uint16 width, uint16 height, const uint8 *palette, uint16 left, uint16 top) { - uint16 *start = (uint16 *)sFrameBuffer + gKernelArgs.frame_buffer.width * top + left; + uint16 *start = (uint16 *)(sFrameBuffer + + gKernelArgs.frame_buffer.bytes_per_row * top + 2 * left); for (int32 y = 0; y < height; y++) { for (int32 x = 0; x < width; x++) { uint16 color = data[y * width + x] * 3; - start[x] = ((palette[color + 0] >> 3) << 11) | ((palette[color + 1] >> 2) << 5) + start[x] = ((palette[color + 0] >> 3) << 11) + | ((palette[color + 1] >> 2) << 5) | ((palette[color + 2] >> 3)); } - start += gKernelArgs.frame_buffer.width; + start = (uint16 *)((addr_t)start + + gKernelArgs.frame_buffer.bytes_per_row); } } @@ -600,17 +616,20 @@ blit15(const uint8 *data, uint16 width, uint16 height, const uint8 *palette, uint16 left, uint16 top) { - uint16 *start = (uint16 *)sFrameBuffer + gKernelArgs.frame_buffer.width * top + left; + uint16 *start = (uint16 *)(sFrameBuffer + + gKernelArgs.frame_buffer.bytes_per_row * top + 2 * left); for (int32 y = 0; y < height; y++) { for (int32 x = 0; x < width; x++) { uint16 color = data[y * width + x] * 3; - start[x] = ((palette[color + 0] >> 3) << 10) | ((palette[color + 1] >> 3) << 5) + start[x] = ((palette[color + 0] >> 3) << 10) + | ((palette[color + 1] >> 3) << 5) | ((palette[color + 2] >> 3)); } - start += gKernelArgs.frame_buffer.width; + start = (uint16 *)((addr_t)start + + gKernelArgs.frame_buffer.bytes_per_row); } } @@ -622,10 +641,11 @@ if (vesa_set_palette((const uint8 *)kPalette, 0, 256) != B_OK) dprintf("set palette failed!\n"); - addr_t start = sFrameBuffer + gKernelArgs.frame_buffer.width * top + left; + addr_t start = sFrameBuffer + gKernelArgs.frame_buffer.bytes_per_row * top + + left; for (int32 i = 0; i < height; i++) { - memcpy((void *)(start + gKernelArgs.frame_buffer.width * i), + memcpy((void *)(start + gKernelArgs.frame_buffer.bytes_per_row * i), &data[i * width], width); } } @@ -713,7 +733,6 @@ addr_t lastBase = gKernelArgs.frame_buffer.physical_buffer.start; size_t lastSize = gKernelArgs.frame_buffer.physical_buffer.size; - int32 bytesPerPixel = 1; if (sVesaCompatible && sMode != NULL) { if (!sModeChosen) @@ -726,13 +745,12 @@ if (vesa_get_mode_info(sMode->mode, &modeInfo) != B_OK) goto fallback; - bytesPerPixel = (modeInfo.bits_per_pixel + 7) / 8; - gKernelArgs.frame_buffer.width = modeInfo.width; gKernelArgs.frame_buffer.height = modeInfo.height; + gKernelArgs.frame_buffer.bytes_per_row = modeInfo.bytes_per_row; gKernelArgs.frame_buffer.depth = modeInfo.bits_per_pixel; - gKernelArgs.frame_buffer.physical_buffer.size = gKernelArgs.frame_buffer.width - * gKernelArgs.frame_buffer.height * bytesPerPixel; + gKernelArgs.frame_buffer.physical_buffer.size = modeInfo.bytes_per_row + * gKernelArgs.frame_buffer.height; gKernelArgs.frame_buffer.physical_buffer.start = modeInfo.physical_base; } else { fallback: @@ -741,13 +759,14 @@ gKernelArgs.frame_buffer.width = 640; gKernelArgs.frame_buffer.height = 480; + gKernelArgs.frame_buffer.bytes_per_row = 640 / 2; gKernelArgs.frame_buffer.depth = 4; gKernelArgs.frame_buffer.physical_buffer.size = gKernelArgs.frame_buffer.width * gKernelArgs.frame_buffer.height / 2; gKernelArgs.frame_buffer.physical_buffer.start = 0xa0000; } - gKernelArgs.frame_buffer.enabled = 1; + gKernelArgs.frame_buffer.enabled = true; // If the new frame buffer is either larger than the old one or located at // a different address, we need to remap it, so we first have to throw @@ -760,8 +779,9 @@ } if (lastBase == 0) { // the graphics memory has not been mapped yet! - sFrameBuffer = mmu_map_physical_memory(gKernelArgs.frame_buffer.physical_buffer.start, - gKernelArgs.frame_buffer.physical_buffer.size, kDefaultPageFlags); + sFrameBuffer = mmu_map_physical_memory( + gKernelArgs.frame_buffer.physical_buffer.start, + gKernelArgs.frame_buffer.physical_buffer.size, kDefaultPageFlags); } // clear the video memory Modified: haiku/trunk/src/system/kernel/debug/frame_buffer_console.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/frame_buffer_console.cpp 2007-11-27 15:29:47 UTC (rev 23005) +++ haiku/trunk/src/system/kernel/debug/frame_buffer_console.cpp 2007-11-27 16:33:19 UTC (rev 23006) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -222,7 +222,8 @@ static void -console_fill_glyph(int32 x, int32 y, int32 width, int32 height, uint8 glyph, uint8 attr) +console_fill_glyph(int32 x, int32 y, int32 width, int32 height, uint8 glyph, + uint8 attr) { if (x >= sConsole.columns || y >= sConsole.rows || !frame_buffer_console_available()) @@ -245,7 +246,8 @@ static void -console_blit(int32 srcx, int32 srcy, int32 width, int32 height, int32 destx, int32 desty) +console_blit(int32 srcx, int32 srcy, int32 width, int32 height, int32 destx, + int32 desty) { if (!frame_buffer_console_available()) return; @@ -266,8 +268,10 @@ } for (int32 y = 0; y < height; y++) { - memmove((void *)(sConsole.frame_buffer + (desty + y) * sConsole.bytes_per_row + destx), - (void *)(sConsole.frame_buffer + (srcy + y) * sConsole.bytes_per_row + srcx), width); + memmove((void *)(sConsole.frame_buffer + (desty + y) + * sConsole.bytes_per_row + destx), + (void *)(sConsole.frame_buffer + (srcy + y) * sConsole.bytes_per_row + + srcx), width); } } @@ -281,7 +285,8 @@ switch (sConsole.bytes_per_pixel) { case 1: if (sConsole.depth >= 8) { - memset((void *)sConsole.frame_buffer, sPalette8[background_color(attr)], + memset((void *)sConsole.frame_buffer, + sPalette8[background_color(attr)], sConsole.height * sConsole.bytes_per_row); } else { // special case for VGA mode @@ -394,33 +399,22 @@ if (sConsole.area < B_OK) return sConsole.area; - int32 bytesPerRow = args->frame_buffer.width; - switch (args->frame_buffer.depth) { - case 1: - case 4: - // special VGA mode (will always be treated as monochrome) - bytesPerRow /= 8; - break; - case 15: - case 16: - bytesPerRow *= 2; - break; - case 24: - bytesPerRow *= 3; - break; - case 32: - bytesPerRow *= 4; - break; + if (args->frame_buffer.depth == 4) { + // VGA mode will be treated as monochrome + args->frame_buffer.bytes_per_row /= 8; } - frame_buffer_update((addr_t)frameBuffer, args->frame_buffer.width, args->frame_buffer.height, - args->frame_buffer.depth, bytesPerRow); + frame_buffer_update((addr_t)frameBuffer, args->frame_buffer.width, + args->frame_buffer.height, args->frame_buffer.depth, + args->frame_buffer.bytes_per_row); + sBootInfo.frame_buffer = (addr_t)frameBuffer; sBootInfo.width = args->frame_buffer.width; sBootInfo.height = args->frame_buffer.height; sBootInfo.depth = args->frame_buffer.depth; - sBootInfo.bytes_per_row = bytesPerRow; - add_boot_item(FRAME_BUFFER_BOOT_INFO, &sBootInfo, sizeof(frame_buffer_boot_info)); + sBootInfo.bytes_per_row = args->frame_buffer.bytes_per_row; + add_boot_item(FRAME_BUFFER_BOOT_INFO, &sBootInfo, + sizeof(frame_buffer_boot_info)); return B_OK; } @@ -432,13 +426,13 @@ mutex_init(&sConsole.lock, "console_lock"); // TODO: enable MTRR in VESA mode! -// if (sConsole.frame_buffer == NULL) + if (sConsole.frame_buffer == NULL) return B_OK; // try to set frame buffer memory to write combined -// return vm_set_area_memory_type(sConsole.area, -// args->frame_buffer.physical_buffer.start, B_MTR_WC); + return vm_set_area_memory_type(sConsole.area, + args->frame_buffer.physical_buffer.start, B_MTR_WC); } From axeld at mail.berlios.de Tue Nov 27 17:38:20 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 27 Nov 2007 17:38:20 +0100 Subject: [Haiku-commits] r23007 - in haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000: . dev/em Message-ID: <200711271638.lARGcK2u028515@sheep.berlios.de> Author: axeld Date: 2007-11-27 17:38:20 +0100 (Tue, 27 Nov 2007) New Revision: 23007 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23007&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/glue.c Log: * Renamed old ipro1000 driver to beos_ipro1000, as it's still valuable for BeOS R5 and later (should be moved somewhere else, though). * Renamed FreeBSD's Intel PRO 1000 driver (known as "em" in BSD) to ipro1000 which also puts it on the image, instead of the old one. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/Jamfile 2007-11-27 16:33:19 UTC (rev 23006) +++ haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/Jamfile 2007-11-27 16:38:20 UTC (rev 23007) @@ -8,7 +8,7 @@ # For ether_driver.h UsePrivateHeaders net ; -KernelAddon ipro1000 : +KernelAddon beos_ipro1000 : driver.c device.c if_compat.c @@ -20,33 +20,20 @@ util.c ; -# Package haiku-ipro1000-cvs : -# ipro1000 : -# boot home config add-ons kernel drivers bin ; -# Package haiku-ipro1000-cvs : -# ipro1000 : -# boot home config add-ons kernel drivers dev net ; -# Package haiku-ipro1000-cvs : -# ipro1000.settings : -# boot home config settings kernel drivers sample ; - -Package haiku-networkingkit-cvs : - ipro1000 : +Package haiku-networkingkit-cvs : beos_ipro1000 : boot home config add-ons kernel drivers bin ; -PackageDriverSymLink haiku-networkingkit-cvs : net ipro1000 ; -Package haiku-networkingkit-cvs : - ipro1000.settings : +PackageDriverSymLink haiku-networkingkit-cvs : net beos_ipro1000 ; +Package haiku-networkingkit-cvs : ipro1000.settings : boot home config settings kernel drivers sample ; - # Installation HaikuInstall install-networking : /boot/home/config/add-ons/kernel/drivers/bin : - ipro1000 + beos_ipro1000 ; HaikuInstallRelSymLink install-networking : /boot/home/config/add-ons/kernel/drivers/dev/net : - ipro1000 : + beos_ipro1000 : installed-symlink ; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/Jamfile 2007-11-27 16:33:19 UTC (rev 23006) +++ haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/Jamfile 2007-11-27 16:38:20 UTC (rev 23007) @@ -7,7 +7,7 @@ SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 EM_FAST_INTR=1 ] ; -KernelAddon e1000 : +KernelAddon ipro1000 : e1000_80003es2lan.c e1000_82540.c e1000_82541.c Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/glue.c 2007-11-27 16:33:19 UTC (rev 23006) +++ haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/dev/em/glue.c 2007-11-27 16:38:20 UTC (rev 23007) @@ -1,6 +1,6 @@ #include -HAIKU_FBSD_DRIVER_GLUE(e1000, em, pci) +HAIKU_FBSD_DRIVER_GLUE(ipro1000, em, pci) NO_HAIKU_CHECK_DISABLE_INTERRUPTS(); NO_HAIKU_REENABLE_INTERRUPTS(); From mmu_man at mail.berlios.de Tue Nov 27 23:32:31 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Tue, 27 Nov 2007 23:32:31 +0100 Subject: [Haiku-commits] r23008 - haiku/trunk/src/apps/3dmov Message-ID: <200711272232.lARMWV6w013017@sheep.berlios.de> Author: mmu_man Date: 2007-11-27 23:32:31 +0100 (Tue, 27 Nov 2007) New Revision: 23008 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23008&view=rev Modified: haiku/trunk/src/apps/3dmov/GLMovView.cpp Log: Fix build Modified: haiku/trunk/src/apps/3dmov/GLMovView.cpp =================================================================== --- haiku/trunk/src/apps/3dmov/GLMovView.cpp 2007-11-27 16:38:20 UTC (rev 23007) +++ haiku/trunk/src/apps/3dmov/GLMovView.cpp 2007-11-27 22:32:31 UTC (rev 23008) @@ -24,3 +24,31 @@ { } + + +void +GLMovView::MouseDown(BPoint where) +{ + +} + + +void +GLMovView::MouseUp(BPoint where) +{ + +} + + +void +GLMovView::MouseMoved(BPoint where, uint32 code, const BMessage *a_message) +{ + +} + + +void +GLMovView::FileDropped(BPoint where, BMediaFile *file) +{ + +} From bonefish at mail.berlios.de Wed Nov 28 01:07:33 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 28 Nov 2007 01:07:33 +0100 Subject: [Haiku-commits] r23009 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200711280007.lAS07X9s004752@sheep.berlios.de> Author: bonefish Date: 2007-11-28 01:07:32 +0100 (Wed, 28 Nov 2007) New Revision: 23009 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23009&view=rev Modified: haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/src/system/kernel/team.cpp haiku/trunk/src/system/kernel/thread.cpp Log: Added a list of death_entry's to the teams structure. It stores the exit status of (non-main) threads of a team. Fixes bug #1644. Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2007-11-27 22:32:31 UTC (rev 23008) +++ haiku/trunk/headers/private/kernel/thread_types.h 2007-11-28 00:07:32 UTC (rev 23009) @@ -94,7 +94,9 @@ }; #define MAX_DEAD_CHILDREN 32 - // this is a soft limit for the number of dead entries in a team + // this is a soft limit for the number of child death entries in a team +#define MAX_DEAD_THREADS 32 + // this is a soft limit for the number of thread death entries in a team typedef struct team_dead_children team_dead_children; typedef struct team_job_control_children team_job_control_children; @@ -155,6 +157,8 @@ int pending_signals; void *io_context; sem_id death_sem; // semaphore to wait on for dying threads + struct list dead_threads; + int dead_threads_count; team_dead_children *dead_children; team_job_control_children *stopped_children; Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2007-11-27 22:32:31 UTC (rev 23008) +++ haiku/trunk/src/system/kernel/team.cpp 2007-11-28 00:07:32 UTC (rev 23009) @@ -567,6 +567,10 @@ team->dead_threads_kernel_time = 0; team->dead_threads_user_time = 0; + // dead threads + list_init(&team->dead_threads); + team->dead_threads_count = 0; + // dead children team->dead_children = new(nothrow) team_dead_children; if (team->dead_children == NULL) @@ -636,6 +640,11 @@ team->dead_children->condition_variable.Unpublish(); + while (death_entry* threadDeathEntry = (death_entry*)list_remove_head_item( + &team->dead_threads)) { + free(threadDeathEntry); + } + while (job_control_entry* entry = team->dead_children->entries.RemoveHead()) delete entry; Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2007-11-27 22:32:31 UTC (rev 23008) +++ haiku/trunk/src/system/kernel/thread.cpp 2007-11-28 00:07:32 UTC (rev 23009) @@ -1215,11 +1215,14 @@ } struct job_control_entry *death = NULL; + struct death_entry* threadDeathEntry = NULL; + if (team != team_get_kernel_team()) { if (team->main_thread == thread) { // this was the main thread in this team, so we will delete that as well deleteTeam = true; - } + } else + threadDeathEntry = (death_entry*)malloc(sizeof(death_entry)); // remove this thread from the current team and add it to the kernel // put the thread into the kernel team until it dies @@ -1272,8 +1275,30 @@ RELEASE_THREAD_LOCK(); team_remove_team(team, &freeGroup); - } else + } else { + // The thread is not the main thread. We store a thread death + // entry for it, unless someone is already waiting it. + if (threadDeathEntry != NULL + && list_is_empty(&thread->exit.waiters)) { + threadDeathEntry->thread = thread->id; + threadDeathEntry->status = thread->exit.status; + threadDeathEntry->reason = thread->exit.reason; + threadDeathEntry->signal = thread->exit.signal; + + // add entry -- remove and old one, if we hit the limit + list_add_item(&team->dead_threads, threadDeathEntry); + team->dead_threads_count++; + threadDeathEntry = NULL; + + if (team->dead_threads_count > MAX_DEAD_THREADS) { + threadDeathEntry = (death_entry*)list_remove_head_item( + &team->dead_threads); + team->dead_threads_count--; + } + } + RELEASE_THREAD_LOCK(); + } RELEASE_TEAM_LOCK(); @@ -1284,6 +1309,9 @@ TRACE(("thread_exit: thread %ld now a kernel thread!\n", thread->id)); } + if (threadDeathEntry != NULL) + free(threadDeathEntry); + // delete the team if we're its main thread if (deleteTeam) { team_delete_process_group(freeGroup); @@ -1640,6 +1668,8 @@ list_add_link_to_head(&thread->exit.waiters, &death); } + death_entry* threadDeathEntry = NULL; + RELEASE_THREAD_LOCK(); if (thread == NULL) { @@ -1647,16 +1677,32 @@ // find its death entry in our team GRAB_TEAM_LOCK(); + struct team* team = thread_get_current_thread()->team; + + // check the child death entries first (i.e. main threads of child + // teams) bool deleteEntry; - freeDeath = team_get_death_entry(thread_get_current_thread()->team, id, - &deleteEntry); + freeDeath = team_get_death_entry(team, id, &deleteEntry); if (freeDeath != NULL) { death.status = freeDeath->status; if (!deleteEntry) freeDeath = NULL; - } else - status = B_BAD_THREAD_ID; + } else { + // check the thread death entries of the team (non-main threads) + while ((threadDeathEntry = (death_entry*)list_get_next_item( + &team->dead_threads, threadDeathEntry)) != NULL) { + if (threadDeathEntry->thread == id) { + list_remove_item(&team->dead_threads, threadDeathEntry); + team->dead_threads_count--; + death.status = threadDeathEntry->status; + break; + } + } + if (threadDeathEntry == NULL) + status = B_BAD_THREAD_ID; + } + RELEASE_TEAM_LOCK(); } @@ -1668,6 +1714,7 @@ *_returnCode = death.status; delete freeDeath; + free(threadDeathEntry); return B_OK; } From bonefish at mail.berlios.de Wed Nov 28 01:14:42 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 28 Nov 2007 01:14:42 +0100 Subject: [Haiku-commits] r23010 - haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create Message-ID: <200711280014.lAS0Eghh010042@sheep.berlios.de> Author: bonefish Date: 2007-11-28 01:14:41 +0100 (Wed, 28 Nov 2007) New Revision: 23010 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23010&view=rev Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/2-1.c Log: The behavior of pthread_getspecific() when called with an invalid key is undefined as per Open Group Base Specs. Commented out the code block. It doesn't do what the preceding comment suggests anyway. In fact the whole test doesn't quite do what the comment in the header promises. Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/2-1.c 2007-11-28 00:07:32 UTC (rev 23009) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_key_create/2-1.c 2007-11-28 00:14:41 UTC (rev 23010) @@ -30,12 +30,12 @@ void* rc; /* Verify that the value associated with "key" in a new thread is NULL */ - rc = pthread_getspecific(key); - if(rc != NULL) - { - printf("pthread_key_create_2-1 Test FAILED\n"); - return PTS_FAIL; - } +// rc = pthread_getspecific(key); +// if(rc != NULL) +// { +// printf("pthread_key_create_2-1 Test FAILED\n"); +// return PTS_FAIL; +// } if(pthread_key_create(&key, NULL) != 0) { From axeld at mail.berlios.de Wed Nov 28 12:56:13 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 28 Nov 2007 12:56:13 +0100 Subject: [Haiku-commits] r23011 - haiku/trunk/src/system/kernel Message-ID: <200711281156.lASBuDMT004789@sheep.berlios.de> Author: axeld Date: 2007-11-28 12:56:06 +0100 (Wed, 28 Nov 2007) New Revision: 23011 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23011&view=rev Modified: haiku/trunk/src/system/kernel/image.c Log: * Made the debugger command "team_images" a bit more useful: it now accepts a team ID argument, instead of only being able to dump the images of the current team. * The debugger commands are now now also built-in without the DEBUG flag set (for now). * _get_next_image_info() now also supports the B_SYSTEM_TEAM constant. * Minor cleanup. Modified: haiku/trunk/src/system/kernel/image.c =================================================================== --- haiku/trunk/src/system/kernel/image.c 2007-11-28 00:14:41 UTC (rev 23010) +++ haiku/trunk/src/system/kernel/image.c 2007-11-28 11:56:06 UTC (rev 23011) @@ -1,9 +1,9 @@ /* - * Copyright 2003-2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ -/* User Runtime Loader support in the kernel */ +/*! User Runtime Loader support in the kernel */ #include @@ -28,6 +28,7 @@ # define TRACE(x) ; #endif +#define ADD_DEBUGGER_COMMANDS struct image { struct image *next; @@ -40,9 +41,8 @@ static mutex sImageMutex; -/** Registers an image with the specified team. - */ - +/*! Registers an image with the specified team. +*/ image_id register_image(struct team *team, image_info *_info, size_t size) { @@ -67,9 +67,8 @@ } -/** Unregisters an image from the specified team. - */ - +/*! Unregisters an image from the specified team. +*/ status_t unregister_image(struct team *team, image_id id) { @@ -99,10 +98,9 @@ } -/** Counts the registered images from the specified team. - * The team lock must be hold when you call this function. - */ - +/*! Counts the registered images from the specified team. + The team lock must be hold when you call this function. +*/ int32 count_images(struct team *team) { @@ -117,11 +115,10 @@ } -/** Removes all images from the specified team. Must only be called - * with the team lock hold or a team that has already been removed - * from the list (in thread_exit()). - */ - +/*! Removes all images from the specified team. Must only be called + with the team lock hold or a team that has already been removed + from the list (in thread_exit()). +*/ status_t remove_images(struct team *team) { @@ -136,11 +133,10 @@ } -/** Unlike in BeOS, this function only returns images that belong to the - * current team. - * ToDo: we might want to rethink that one day... - */ - +/*! Unlike in BeOS, this function only returns images that belong to the + current team. + TODO: we might want to rethink that one day... +*/ status_t _get_image_info(image_id id, image_info *info, size_t size) { @@ -178,8 +174,11 @@ if (teamID == B_CURRENT_TEAM) team = thread_get_current_thread()->team; + else if (teamID == B_SYSTEM_TEAM) + team = team_get_kernel_team(); else team = team_get_team_struct_locked(teamID); + if (team) { struct image *image = NULL; int32 count = 0; @@ -205,13 +204,23 @@ } -#ifdef DEBUG +#ifdef ADD_DEBUGGER_COMMANDS static int dump_images_list(int argc, char **argv) { - struct team *team = thread_get_current_thread()->team; struct image *image = NULL; + struct team *team; + if (argc > 1) { + team_id id = strtol(argv[1], NULL, 0); + team = team_get_team_struct_locked(id); + if (team == NULL) { + kprintf("No team with ID %ld found\n", id); + return 1; + } + } else + team = thread_get_current_thread()->team; + kprintf("Registered images of team 0x%lx\n", team->id); kprintf(" ID text size data size name\n"); @@ -261,7 +270,7 @@ status_t image_init(void) { -#ifdef DEBUG +#ifdef ADD_DEBUGGER_COMMANDS add_debugger_command("team_images", &dump_images_list, "Dump all registered images from the current team"); #endif From axeld at mail.berlios.de Wed Nov 28 17:50:49 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 28 Nov 2007 17:50:49 +0100 Subject: [Haiku-commits] r23012 - in haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev: . mii msk Message-ID: <200711281650.lASGonSZ001470@sheep.berlios.de> Author: axeld Date: 2007-11-28 17:50:48 +0100 (Wed, 28 Nov 2007) New Revision: 23012 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23012&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy_subr.c Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c Log: Added fallback MII to the marvell_yukon driver. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/Jamfile 2007-11-28 11:56:06 UTC (rev 23011) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/Jamfile 2007-11-28 16:50:48 UTC (rev 23012) @@ -1,4 +1,4 @@ SubDir HAIKU_TOP src add-ons kernel drivers network marvell_yukon dev ; -#SubInclude HAIKU_TOP src add-ons kernel drivers network marvell_yukon dev mii ; +SubInclude HAIKU_TOP src add-ons kernel drivers network marvell_yukon dev mii ; SubInclude HAIKU_TOP src add-ons kernel drivers network marvell_yukon dev msk ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile 2007-11-28 11:56:06 UTC (rev 23011) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile 2007-11-28 16:50:48 UTC (rev 23012) @@ -0,0 +1,15 @@ +SubDir HAIKU_TOP src add-ons kernel drivers network marvell_yukon dev mii ; + +UsePrivateHeaders kernel net ; + +UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ; +UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ; + +SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ; + +KernelStaticLibrary marvell_yukon_mii.a + : + ukphy.c + ukphy_subr.c + ; + Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c 2007-11-28 11:56:06 UTC (rev 23011) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c 2007-11-28 16:50:48 UTC (rev 23012) @@ -0,0 +1,232 @@ +/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ + +/*- + * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center, and by Frank van der Linden. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*- + * Copyright (c) 1997 Manuel Bouyer. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Manuel Bouyer. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.17 2005/01/06 01:42:56 imp Exp $"); + +/* + * driver for generic unknown PHYs + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "miibus_if.h" + +static int ukphy_probe(device_t); +static int ukphy_attach(device_t); + +static device_method_t ukphy_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, ukphy_probe), + DEVMETHOD(device_attach, ukphy_attach), + DEVMETHOD(device_detach, mii_phy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + { 0, 0 } +}; + +static devclass_t ukphy_devclass; + +static driver_t ukphy_driver = { + "ukphy", + ukphy_methods, + sizeof(struct mii_softc) +}; + +DRIVER_MODULE(ukphy, miibus, ukphy_driver, ukphy_devclass, 0, 0); + +static int ukphy_service(struct mii_softc *, struct mii_data *, int); + +static int +ukphy_probe(dev) + device_t dev; +{ + + /* + * We know something is here, so always match at a low priority. + */ + device_set_desc(dev, "Generic IEEE 802.3u media interface"); + return (-100); +} + +static int +ukphy_attach(dev) + device_t dev; +{ + struct mii_softc *sc; + struct mii_attach_args *ma; + struct mii_data *mii; + +static int ppp; +if (ppp++ > 0) + panic("oops"); + sc = device_get_softc(dev); + ma = device_get_ivars(dev); + sc->mii_dev = device_get_parent(dev); + mii = device_get_softc(sc->mii_dev); +device_printf(dev, "insert into %p\n", mii); +device_printf(sc->mii_dev, "this is the parent\n"); + LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); + + if (bootverbose) + device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n", + MII_OUI(ma->mii_id1, ma->mii_id2), + MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2)); + + sc->mii_inst = mii->mii_instance; + sc->mii_phy = ma->mii_phyno; + sc->mii_service = ukphy_service; + sc->mii_pdata = mii; + + mii->mii_instance++; + + sc->mii_flags |= MIIF_NOISOLATE; + + mii_phy_reset(sc); + + sc->mii_capabilities = + PHY_READ(sc, MII_BMSR) & ma->mii_capmask; + if (sc->mii_capabilities & BMSR_EXTSTAT) + sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); + device_printf(dev, " "); + mii_phy_add_media(sc); + printf("\n"); + + MIIBUS_MEDIAINIT(sc->mii_dev); + mii_phy_setmedia(sc); + + return(0); +} + +static int +ukphy_service(sc, mii, cmd) + struct mii_softc *sc; + struct mii_data *mii; + int cmd; +{ + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; + int reg; + + switch (cmd) { + case MII_POLLSTAT: + /* + * If we're not polling our PHY instance, just return. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) + return (0); + break; + + case MII_MEDIACHG: + /* + * If the media indicates a different PHY instance, + * isolate ourselves. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) { + reg = PHY_READ(sc, MII_BMCR); + PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); + return (0); + } + + /* + * If the interface is not up, don't do anything. + */ + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + break; + + mii_phy_setmedia(sc); + break; + + case MII_TICK: + /* + * If we're not currently selected, just return. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) + return (0); + if (mii_phy_tick(sc) == EJUSTRETURN) + return (0); + break; + } + + /* Update the media status. */ + ukphy_status(sc); + + /* Callback if something changed. */ + mii_phy_update(sc, cmd); + return (0); +} Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy_subr.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy_subr.c 2007-11-28 11:56:06 UTC (rev 23011) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy_subr.c 2007-11-28 16:50:48 UTC (rev 23012) @@ -0,0 +1,129 @@ +/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center, and by Frank van der Linden. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy_subr.c,v 1.8.8.1 2006/07/19 04:40:26 yongari Exp $"); + +/* + * Subroutines shared by the ukphy driver and other PHY drivers. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "miibus_if.h" + +/* + * Media status subroutine. If a PHY driver does media detection simply + * by decoding the NWay autonegotiation, use this routine. + */ +void +ukphy_status(struct mii_softc *phy) +{ + struct mii_data *mii = phy->mii_pdata; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; + int bmsr, bmcr, anlpar, gtcr, gtsr; + + mii->mii_media_status = IFM_AVALID; + mii->mii_media_active = IFM_ETHER; + + bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); + if (bmsr & BMSR_LINK) + mii->mii_media_status |= IFM_ACTIVE; + + bmcr = PHY_READ(phy, MII_BMCR); + if (bmcr & BMCR_ISO) { + mii->mii_media_active |= IFM_NONE; + mii->mii_media_status = 0; + return; + } + + if (bmcr & BMCR_LOOP) + mii->mii_media_active |= IFM_LOOP; + + if (bmcr & BMCR_AUTOEN) { + /* + * NWay autonegotiation takes the highest-order common + * bit of the ANAR and ANLPAR (i.e. best media advertised + * both by us and our link partner). + */ + if ((bmsr & BMSR_ACOMP) == 0) { + /* Erg, still trying, I guess... */ + mii->mii_media_active |= IFM_NONE; + return; + } + + anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); + if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && + (phy->mii_extcapabilities & + (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { + gtcr = PHY_READ(phy, MII_100T2CR); + gtsr = PHY_READ(phy, MII_100T2SR); + } else + gtcr = gtsr = 0; + + if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) + mii->mii_media_active |= IFM_1000_T|IFM_FDX; + else if ((gtcr & GTCR_ADV_1000THDX) && + (gtsr & GTSR_LP_1000THDX)) + mii->mii_media_active |= IFM_1000_T; + else if (anlpar & ANLPAR_T4) + mii->mii_media_active |= IFM_100_T4; + else if (anlpar & ANLPAR_TX_FD) + mii->mii_media_active |= IFM_100_TX|IFM_FDX; + else if (anlpar & ANLPAR_TX) + mii->mii_media_active |= IFM_100_TX; + else if (anlpar & ANLPAR_10_FD) + mii->mii_media_active |= IFM_10_T|IFM_FDX; + else if (anlpar & ANLPAR_10) + mii->mii_media_active |= IFM_10_T; + else + mii->mii_media_active |= IFM_NONE; + } else + mii->mii_media_active = ife->ifm_media; +} Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile 2007-11-28 11:56:06 UTC (rev 23011) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile 2007-11-28 16:50:48 UTC (rev 23012) @@ -10,5 +10,5 @@ KernelAddon marvell_yukon : if_msk.c glue.c - : libfreebsd_network.a + : libfreebsd_network.a marvell_yukon_mii.a ; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c 2007-11-28 11:56:06 UTC (rev 23011) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c 2007-11-28 16:50:48 UTC (rev 23012) @@ -1,10 +1,30 @@ +/* + * Copyright 2007, Hugo Santos. All Rights Reserved. + * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ + + #include + HAIKU_FBSD_DRIVER_GLUE(marvell_yukon, mskc, pci) +extern driver_t *DRIVER_MODULE_NAME(ukphy, miibus); + + +driver_t * +__haiku_select_miibus_driver(device_t dev) +{ + driver_t *drivers[] = { + DRIVER_MODULE_NAME(ukphy, miibus) + }; + + return __haiku_probe_miibus(dev, drivers, 1); +} + NO_HAIKU_CHECK_DISABLE_INTERRUPTS(); NO_HAIKU_REENABLE_INTERRUPTS(); -NO_HAIKU_FBSD_MII_DRIVER(); #ifdef EM_FAST_INTR HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_FAST_TASKQUEUE); From axeld at mail.berlios.de Wed Nov 28 17:59:36 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 28 Nov 2007 17:59:36 +0100 Subject: [Haiku-commits] r23013 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711281659.lASGxaNV001884@sheep.berlios.de> Author: axeld Date: 2007-11-28 17:59:35 +0100 (Wed, 28 Nov 2007) New Revision: 23013 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23013&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c Log: * device_add_child() now also works for sub-drivers, needed by the marvell_yukon driver. * The device path is currently inherited from its parent which might be revised later on (nameunit is not y Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-28 16:50:48 UTC (rev 23012) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-28 16:59:35 UTC (rev 23013) @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -344,10 +345,7 @@ { list_init_etc(&dev->children, offsetof(struct device, link)); - if (driver == NULL) - return dev; - - if (device_set_driver(dev, driver) < 0) + if (driver != NULL && device_set_driver(dev, driver) < 0) return NULL; return dev; @@ -369,6 +367,7 @@ for (i = 0; method == NULL && driver->methods[i].name != NULL; i++) { device_method_t *mth = &driver->methods[i]; + if (strcmp(mth->name, "device_probe") == 0) dev->methods.probe = (void *)mth->method; else if (strcmp(mth->name, "device_attach") == 0) @@ -432,6 +431,24 @@ } +static image_id +find_own_image() +{ + int32 cookie = 0; + image_info info; + while (get_next_image_info(B_SYSTEM_TEAM, &cookie, &info) == B_OK) { + if (((uint32)info.text <= (uint32)find_own_image + && (uint32)info.text + (uint32)info.text_size + > (uint32)find_own_image)) { + // found our own image + return info.id; + } + } + + return B_ENTRY_NOT_FOUND; +} + + device_t device_add_child(device_t dev, const char *name, int order) { @@ -440,13 +457,27 @@ if (name != NULL) { if (strcmp(name, "miibus") == 0) child = new_device(&miibus_driver); + else { + // find matching driver structure + driver_t **driver; + char symbol[128]; + + snprintf(symbol, sizeof(symbol), "__fbsd_%s%s", name, dev->driver->name); + if (get_image_symbol(find_own_image(), symbol, B_SYMBOL_TYPE_DATA, + (void **)&driver) == B_OK) + child = new_device(*driver); + + // inherit the device name of our parent + name = dev->dev_name; + } } else child = new_device(NULL); if (child == NULL) return NULL; - snprintf(child->dev_name, sizeof(child->dev_name), "%s", name); + if (name != NULL) + strlcpy(child->dev_name, name, sizeof(child->dev_name)); child->parent = dev; list_add_item(&dev->children, child); From axeld at mail.berlios.de Wed Nov 28 18:00:33 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 28 Nov 2007 18:00:33 +0100 Subject: [Haiku-commits] r23014 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711281700.lASH0X6A002056@sheep.berlios.de> Author: axeld Date: 2007-11-28 18:00:33 +0100 (Wed, 28 Nov 2007) New Revision: 23014 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23014&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/device.c haiku/trunk/src/libs/compat/freebsd_network/if.c Log: The compatibility layer was calling if_init() too early, I've now moved it to the compat_open() function. Modified: haiku/trunk/src/libs/compat/freebsd_network/device.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-28 16:59:35 UTC (rev 23013) +++ haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-28 17:00:33 UTC (rev 23014) @@ -133,6 +133,8 @@ ifp->if_flags |= IFF_UP; ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); + + ifp->if_init(ifp->if_softc); } *cookie = device; Modified: haiku/trunk/src/libs/compat/freebsd_network/if.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/if.c 2007-11-28 16:59:35 UTC (rev 23013) +++ haiku/trunk/src/libs/compat/freebsd_network/if.c 2007-11-28 17:00:33 UTC (rev 23014) @@ -306,8 +306,6 @@ // once all drivers are cleaned up. if (macAddress != IFP2ENADDR(ifp)) memcpy(IFP2ENADDR(ifp), macAddress, ETHER_ADDR_LEN); - - ifp->if_init(ifp->if_softc); } From stippi at mail.berlios.de Wed Nov 28 19:38:35 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 28 Nov 2007 19:38:35 +0100 Subject: [Haiku-commits] r23015 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200711281838.lASIcZCF026129@sheep.berlios.de> Author: stippi Date: 2007-11-28 19:38:34 +0100 (Wed, 28 Nov 2007) New Revision: 23015 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23015&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp Log: * I don't know what's going on, but with this change, I can boot Haiku again on my P35 with JMircon controller. I still have the "pci fixup" disabled though. Without this change, I could boot until the blue desktop background with cursor, but all the apps were in frozen state and would not display on screen (F12 worked and showed Tracker and so on as running teams, but I could not even move the mouse) Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-11-28 17:00:33 UTC (rev 23014) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-11-28 18:38:34 UTC (rev 23015) @@ -339,10 +339,11 @@ void -AHCIController::GetRestrictions(uchar targetID, bool *isATAPI, bool *noAutoSense, uint32 *maxBlocks) +AHCIController::GetRestrictions(uchar targetID, bool *isATAPI, + bool *noAutoSense, uint32 *maxBlocks) { if (!fPort[targetID]) return; - return fPort[targetID]->ScsiGetRestrictions(isATAPI, noAutoSense, maxBlocks); + fPort[targetID]->ScsiGetRestrictions(isATAPI, noAutoSense, maxBlocks); } From revol at free.fr Wed Nov 28 21:51:08 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 28 Nov 2007 21:51:08 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r23015_-_haiku/trunk/src/add-ons?= =?windows-1252?q?/kernel/busses/scsi/ahci?= In-Reply-To: <200711281838.lASIcZCF026129@sheep.berlios.de> Message-ID: <1135787008-BeMail@laptop> > * I don't know what's going on, but with this change, I can boot > Haiku again > on my P35 with JMircon controller. I still have the "pci fixup" > disabled > though. Without this change, I could boot until the blue desktop > background > with cursor, but all the apps were in frozen state and would not > display > on screen (F12 worked and showed Tracker and so on as running > teams, but > I could not even move the mouse) > Weirdo, except from the return (but returning void is a noop, semantically at least) it's only cosmetic... Sure you made a full build ? Now maybe there is a side effect of how gcc handles void return types... Maybe using return there forces the opcodes into a specific order in which the value of the return value register is preserved from the callee as if it was returning something, and not using return puts opcodes into a different order where it does something... but then it means the caller use the return value where it shouldn't. Either it's using a different prototype, or gcc is screwed :D Fran?ois. From superstippi at gmx.de Wed Nov 28 22:30:30 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Wed, 28 Nov 2007 22:30:30 +0100 Subject: [Haiku-commits] r23015 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci In-Reply-To: <1135787008-BeMail@laptop> References: <1135787008-BeMail@laptop> Message-ID: <20071128223030.643.1@stippis2.1196284559.fake> Fran?ois Revol wrote (2007-11-28, 21:51:08 [+0100]): > > * I don't know what's going on, but with this change, I can boot > > Haiku again > > on my P35 with JMircon controller. I still have the "pci fixup" > > disabled > > though. Without this change, I could boot until the blue desktop > > background > > with cursor, but all the apps were in frozen state and would not > > display > > on screen (F12 worked and showed Tracker and so on as running > > teams, but > > I could not even move the mouse) > > > > Weirdo, except from the return (but returning void is a noop, > semantically at least) it's only cosmetic... > Sure you made a full build ? > > Now maybe there is a side effect of how gcc handles void return types... > Maybe using return there forces the opcodes into a specific order in > which the value of the return value register is preserved from the callee > as if it was returning something, and not using return puts opcodes into > a different order where it does something... but then it means the caller > use the return value where it shouldn't. Either it's using a different > prototype, or gcc is screwed :D I am doing a GCC 2.95.3 build under Dano. I triple checked that this was the cause. Without the return I can boot (tried several times), and with the return, I can not (also checked several times). And I do have a fairly clean build, I deleted the beos folder from my Haiku partition and all my object files only a couple days ago. In the last week or two, I reverted the AHCI driver to an older revision to be able to boot, today I tried to track down all the changes between that revision and the current one. Most changes seemed harmless and I then I finally found the cause. And I tracked down why I can't boot with the pci_fixup code in place. Appearantly, I have both an Intel (0x2921) and a JMicron (0x2363) SATA chip on my motherboard. The JMicron one is being used (I think), the BIOS only mentions that one. With the fixup code for Intel in place, I get a "no boot patitions found" KDL early on. The JMicron is reported twice by Dano's listdev, one time as "Mass Storage Controller (IDE) [1|1|85]" and once as "Mass Storage Controller (Unknown) [1|6|1]". And then there is another Intel chip too "Mass Storage Controller (IDE) [1|1|85]" with device id 0x2926. The 0x2921 is reported as "Mass Storage Controller (IDE) [1|1|8a]". Best regards, -Stephan From axeld at pinc-software.de Wed Nov 28 22:53:25 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Wed, 28 Nov 2007 22:53:25 +0100 CET Subject: [Haiku-commits] r23015 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci In-Reply-To: <20071128223030.643.1@stippis2.1196284559.fake> Message-ID: <23210355296-BeMail@zon> Stephan Assmus wrote: > I am doing a GCC 2.95.3 build under Dano. I triple checked that this > was > the cause. Without the return I can boot (tried several times), and > with > the return, I can not (also checked several times). And I do have a > fairly > clean build, I deleted the beos folder from my Haiku partition and > all my > object files only a couple days ago. In the last week or two, I > reverted > the AHCI driver to an older revision to be able to boot, today I > tried to > track down all the changes between that revision and the current one. > Most > changes seemed harmless and I then I finally found the cause. It would be interesting to compare the assembly output of both versions. Bye, Axel. From axeld at mail.berlios.de Wed Nov 28 23:13:49 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 28 Nov 2007 23:13:49 +0100 Subject: [Haiku-commits] r23016 - in haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev: mii msk Message-ID: <200711282213.lASMDn3w005409@sheep.berlios.de> Author: axeld Date: 2007-11-28 23:13:48 +0100 (Wed, 28 Nov 2007) New Revision: 23016 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23016&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phy.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phyreg.h haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/miidevs.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c Log: Added e1000phy code to marvell_yukon driver. The driver is still not functional, though - it's a bit more complex, and needs a better compatibility layer. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile 2007-11-28 18:38:34 UTC (rev 23015) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile 2007-11-28 22:13:48 UTC (rev 23016) @@ -9,6 +9,7 @@ KernelStaticLibrary marvell_yukon_mii.a : + e1000phy.c ukphy.c ukphy_subr.c ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phy.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phy.c 2007-11-28 18:38:34 UTC (rev 23015) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phy.c 2007-11-28 22:13:48 UTC (rev 23016) @@ -0,0 +1,513 @@ +/*- + * Principal Author: Parag Patel + * Copyright (c) 2001 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Additonal Copyright (c) 2001 by Traakan Software under same licence. + * Secondary Author: Matthew Jacob + */ + +#include +__FBSDID("$FreeBSD: src/sys/dev/mii/e1000phy.c,v 1.18 2006/12/11 11:09:48 yongari Exp $"); + +/* + * driver for the Marvell 88E1000 series external 1000/100/10-BT PHY. + */ + +/* + * Support added for the Marvell 88E1011 (Alaska) 1000/100/10baseTX and + * 1000baseSX PHY. + * Nathan Binkert + * Jung-uk Kim + */ + +#include +#include +#include +#include +#include +#include + + +#include +#include + +#include +#include +#include "miidevs.h" + +#include + +#include "miibus_if.h" + +static int e1000phy_probe(device_t); +static int e1000phy_attach(device_t); + +struct e1000phy_softc { + struct mii_softc mii_sc; + int mii_model; +}; + +static device_method_t e1000phy_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, e1000phy_probe), + DEVMETHOD(device_attach, e1000phy_attach), + DEVMETHOD(device_detach, mii_phy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + { 0, 0 } +}; + +static devclass_t e1000phy_devclass; +static driver_t e1000phy_driver = { + "e1000phy", + e1000phy_methods, + sizeof(struct e1000phy_softc) +}; + +DRIVER_MODULE(e1000phy, miibus, e1000phy_driver, e1000phy_devclass, 0, 0); + +static int e1000phy_service(struct mii_softc *, struct mii_data *, int); +static void e1000phy_status(struct mii_softc *); +static void e1000phy_reset(struct mii_softc *); +static int e1000phy_mii_phy_auto(struct e1000phy_softc *); + +static const struct mii_phydesc e1000phys[] = { + MII_PHY_DESC(MARVELL, E1000), + MII_PHY_DESC(MARVELL, E1011), + MII_PHY_DESC(MARVELL, E1000_3), + MII_PHY_DESC(MARVELL, E1000S), + MII_PHY_DESC(MARVELL, E1000_5), + MII_PHY_DESC(MARVELL, E1000_6), + MII_PHY_DESC(MARVELL, E3082), + MII_PHY_DESC(MARVELL, E1112), + MII_PHY_DESC(MARVELL, E1149), + MII_PHY_DESC(MARVELL, E1111), + MII_PHY_DESC(MARVELL, E1116), + MII_PHY_DESC(MARVELL, E1118), + MII_PHY_DESC(xxMARVELL, E1000), + MII_PHY_DESC(xxMARVELL, E1011), + MII_PHY_DESC(xxMARVELL, E1000_3), + MII_PHY_DESC(xxMARVELL, E1000_5), + MII_PHY_DESC(xxMARVELL, E1111), + MII_PHY_END +}; + +static int +e1000phy_probe(device_t dev) +{ + + return (mii_phy_dev_probe(dev, e1000phys, BUS_PROBE_DEFAULT)); +} + +static int +e1000phy_attach(device_t dev) +{ + struct e1000phy_softc *esc; + struct mii_softc *sc; + struct mii_attach_args *ma; + struct mii_data *mii; + int fast_ether; + + esc = device_get_softc(dev); + sc = &esc->mii_sc; + ma = device_get_ivars(dev); + sc->mii_dev = device_get_parent(dev); + mii = device_get_softc(sc->mii_dev); + LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); + + sc->mii_inst = mii->mii_instance; + sc->mii_phy = ma->mii_phyno; + sc->mii_service = e1000phy_service; + sc->mii_pdata = mii; + sc->mii_anegticks = MII_ANEGTICKS_GIGE; + mii->mii_instance++; + + fast_ether = 0; + esc->mii_model = MII_MODEL(ma->mii_id2); + switch (esc->mii_model) { + case MII_MODEL_MARVELL_E1011: + case MII_MODEL_MARVELL_E1112: + if (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK) + sc->mii_flags |= MIIF_HAVEFIBER; + break; + case MII_MODEL_MARVELL_E3082: + /* 88E3082 10/100 Fast Ethernet PHY. */ + sc->mii_anegticks = MII_ANEGTICKS; + fast_ether = 1; + break; + } + + e1000phy_reset(sc); + + device_printf(dev, " "); + +#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), + E1000_CR_ISOLATE); + if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst), + E1000_CR_SPEED_10); + printf("10baseT, "); + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX, sc->mii_inst), + E1000_CR_SPEED_10 | E1000_CR_FULL_DUPLEX); + printf("10baseT-FDX, "); + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, sc->mii_inst), + E1000_CR_SPEED_100); + printf("100baseTX, "); + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_FDX, sc->mii_inst), + E1000_CR_SPEED_100 | E1000_CR_FULL_DUPLEX); + printf("100baseTX-FDX, "); + if (fast_ether == 0) { + /* + * 1000BT-simplex not supported; driver must ignore + * this entry, but it must be present in order to + * manually set full-duplex. + */ + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, 0, + sc->mii_inst), E1000_CR_SPEED_1000); + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, IFM_FDX, + sc->mii_inst), + E1000_CR_SPEED_1000 | E1000_CR_FULL_DUPLEX); + printf("1000baseTX-FDX, "); + } + } else { + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, IFM_FDX, sc->mii_inst), + E1000_CR_SPEED_1000 | E1000_CR_FULL_DUPLEX); + printf("1000baseSX-FDX, "); + } + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst), 0); + printf("auto\n"); +#undef ADD + + MIIBUS_MEDIAINIT(sc->mii_dev); + return (0); +} + +static void +e1000phy_reset(struct mii_softc *sc) +{ + struct e1000phy_softc *esc; + uint16_t reg; + + esc = (struct e1000phy_softc *)sc; + reg = PHY_READ(sc, E1000_SCR); + if ((sc->mii_flags & MIIF_HAVEFIBER) != 0) { + reg &= ~E1000_SCR_AUTO_X_MODE; + PHY_WRITE(sc, E1000_SCR, reg); + if (esc->mii_model == MII_MODEL_MARVELL_E1112) { + /* Select 1000BASE-X only mode. */ + PHY_WRITE(sc, E1000_EADR, 2); + reg = PHY_READ(sc, E1000_SCR); + reg &= ~E1000_SCR_MODE_MASK; + reg |= E1000_SCR_MODE_1000BX; + PHY_WRITE(sc, E1000_SCR, reg); + PHY_WRITE(sc, E1000_EADR, 1); + } + } else { + switch (esc->mii_model) { + case MII_MODEL_MARVELL_E1111: + case MII_MODEL_MARVELL_E1112: + case MII_MODEL_MARVELL_E1116: + case MII_MODEL_MARVELL_E1118: + case MII_MODEL_MARVELL_E1149: + /* Disable energy detect mode. */ + reg &= ~E1000_SCR_EN_DETECT_MASK; + reg |= E1000_SCR_AUTO_X_MODE; + break; + case MII_MODEL_MARVELL_E3082: + reg |= (E1000_SCR_AUTO_X_MODE >> 1); + break; + default: + reg &= ~E1000_SCR_AUTO_X_MODE; + break; + } + /* Enable CRS on TX. */ + reg |= E1000_SCR_ASSERT_CRS_ON_TX; + /* Auto correction for reversed cable polarity. */ + reg &= ~E1000_SCR_POLARITY_REVERSAL; + PHY_WRITE(sc, E1000_SCR, reg); + } + + switch (MII_MODEL(esc->mii_model)) { + case MII_MODEL_MARVELL_E3082: + case MII_MODEL_MARVELL_E1112: + case MII_MODEL_MARVELL_E1116: + case MII_MODEL_MARVELL_E1118: + case MII_MODEL_MARVELL_E1149: + break; + default: + /* Force TX_CLK to 25MHz clock. */ + reg = PHY_READ(sc, E1000_ESCR); + reg |= E1000_ESCR_TX_CLK_25; + PHY_WRITE(sc, E1000_ESCR, reg); + break; + } + + /* Reset the PHY so all changes take effect. */ + reg = PHY_READ(sc, E1000_CR); + reg |= E1000_CR_RESET; + PHY_WRITE(sc, E1000_CR, reg); +} + +static int +e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) +{ + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; + struct e1000phy_softc *esc = (struct e1000phy_softc *)sc; + uint16_t speed, gig; + int reg; + + switch (cmd) { + case MII_POLLSTAT: + /* + * If we're not polling our PHY instance, just return. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) + return (0); + break; + + case MII_MEDIACHG: + /* + * If the media indicates a different PHY instance, + * isolate ourselves. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) { + reg = PHY_READ(sc, E1000_CR); + PHY_WRITE(sc, E1000_CR, reg | E1000_CR_ISOLATE); + return (0); + } + + /* + * If the interface is not up, don't do anything. + */ + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + break; + + if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) { + e1000phy_mii_phy_auto(esc); + break; + } + + speed = 0; + switch (IFM_SUBTYPE(ife->ifm_media)) { + case IFM_1000_T: + if (esc->mii_model == MII_MODEL_MARVELL_E3082) + return (EINVAL); + speed = E1000_CR_SPEED_1000; + break; + case IFM_1000_SX: + if (esc->mii_model == MII_MODEL_MARVELL_E3082) + return (EINVAL); + speed = E1000_CR_SPEED_1000; + break; + case IFM_100_TX: + speed = E1000_CR_SPEED_100; + break; + case IFM_10_T: + speed = E1000_CR_SPEED_10; + break; + case IFM_NONE: + reg = PHY_READ(sc, E1000_CR); + PHY_WRITE(sc, E1000_CR, + reg | E1000_CR_ISOLATE | E1000_CR_POWER_DOWN); + goto done; + default: + return (EINVAL); + } + + if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) { + speed |= E1000_CR_FULL_DUPLEX; + gig = E1000_1GCR_1000T_FD; + } else + gig = E1000_1GCR_1000T; + + reg = PHY_READ(sc, E1000_CR); + reg &= ~E1000_CR_AUTO_NEG_ENABLE; + PHY_WRITE(sc, E1000_CR, reg | E1000_CR_RESET); + + /* + * When setting the link manually, one side must + * be the master and the other the slave. However + * ifmedia doesn't give us a good way to specify + * this, so we fake it by using one of the LINK + * flags. If LINK0 is set, we program the PHY to + * be a master, otherwise it's a slave. + */ + if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T || + (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_SX)) { + if ((mii->mii_ifp->if_flags & IFF_LINK0)) + PHY_WRITE(sc, E1000_1GCR, gig | + E1000_1GCR_MS_ENABLE | E1000_1GCR_MS_VALUE); + else + PHY_WRITE(sc, E1000_1GCR, gig | + E1000_1GCR_MS_ENABLE); + } else { + if (esc->mii_model != MII_MODEL_MARVELL_E3082) + PHY_WRITE(sc, E1000_1GCR, 0); + } + PHY_WRITE(sc, E1000_AR, E1000_AR_SELECTOR_FIELD); + PHY_WRITE(sc, E1000_CR, speed | E1000_CR_RESET); +done: + break; + case MII_TICK: + /* + * If we're not currently selected, just return. + */ + if (IFM_INST(ife->ifm_media) != sc->mii_inst) + return (0); + + /* + * Is the interface even up? + */ + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + return (0); + + /* + * Only used for autonegotiation. + */ + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; + + /* + * check for link. + * Read the status register twice; BMSR_LINK is latch-low. + */ + reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); + if (reg & BMSR_LINK) { + sc->mii_ticks = 0; + break; + } + + /* Announce link loss right after it happens. */ + if (sc->mii_ticks <= sc->mii_anegticks) + return (0); + + sc->mii_ticks = 0; + e1000phy_reset(sc); + e1000phy_mii_phy_auto(esc); + break; + } + + /* Update the media status. */ + e1000phy_status(sc); + + /* Callback if something changed. */ + mii_phy_update(sc, cmd); + return (0); +} + +static void +e1000phy_status(struct mii_softc *sc) +{ + struct mii_data *mii = sc->mii_pdata; + int bmsr, bmcr, esr, gsr, ssr, isr, ar, lpar; + + mii->mii_media_status = IFM_AVALID; + mii->mii_media_active = IFM_ETHER; + + bmsr = PHY_READ(sc, E1000_SR) | PHY_READ(sc, E1000_SR); + esr = PHY_READ(sc, E1000_ESR); + bmcr = PHY_READ(sc, E1000_CR); + ssr = PHY_READ(sc, E1000_SSR); + isr = PHY_READ(sc, E1000_ISR); + ar = PHY_READ(sc, E1000_AR); + lpar = PHY_READ(sc, E1000_LPAR); + + if (bmsr & E1000_SR_LINK_STATUS) + mii->mii_media_status |= IFM_ACTIVE; + + if (bmcr & E1000_CR_LOOPBACK) + mii->mii_media_active |= IFM_LOOP; + + if ((((bmcr & E1000_CR_AUTO_NEG_ENABLE) != 0) && + ((bmsr & E1000_SR_AUTO_NEG_COMPLETE) == 0)) || + ((ssr & E1000_SSR_LINK) == 0) || + ((ssr & E1000_SSR_SPD_DPLX_RESOLVED) == 0)) { + /* Erg, still trying, I guess... */ + mii->mii_media_active |= IFM_NONE; + return; + } + + if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { + if (ssr & E1000_SSR_1000MBS) + mii->mii_media_active |= IFM_1000_T; + else if (ssr & E1000_SSR_100MBS) + mii->mii_media_active |= IFM_100_TX; + else + mii->mii_media_active |= IFM_10_T; + } else { + if (ssr & E1000_SSR_1000MBS) + mii->mii_media_active |= IFM_1000_SX; + } + + if (ssr & E1000_SSR_DUPLEX) + mii->mii_media_active |= IFM_FDX; + else + mii->mii_media_active |= IFM_HDX; + + if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { + /* FLAG0==rx-flow-control FLAG1==tx-flow-control */ + if ((ar & E1000_AR_PAUSE) && (lpar & E1000_LPAR_PAUSE)) { + mii->mii_media_active |= IFM_FLAG0 | IFM_FLAG1; + } else if (!(ar & E1000_AR_PAUSE) && (ar & E1000_AR_ASM_DIR) && + (lpar & E1000_LPAR_PAUSE) && (lpar & E1000_LPAR_ASM_DIR)) { + mii->mii_media_active |= IFM_FLAG1; + } else if ((ar & E1000_AR_PAUSE) && (ar & E1000_AR_ASM_DIR) && + !(lpar & E1000_LPAR_PAUSE) && (lpar & E1000_LPAR_ASM_DIR)) { + mii->mii_media_active |= IFM_FLAG0; + } + } + + /* FLAG2 : local PHY resolved to MASTER */ + if ((IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T) || + (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_SX)) { + PHY_READ(sc, E1000_1GSR); + gsr = PHY_READ(sc, E1000_1GSR); + if ((gsr & E1000_1GSR_MS_CONFIG_RES) != 0) + mii->mii_media_active |= IFM_FLAG2; + } +} + +static int +e1000phy_mii_phy_auto(struct e1000phy_softc *esc) +{ + struct mii_softc *sc; + + sc = &esc->mii_sc; + if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) + PHY_WRITE(sc, E1000_AR, E1000_AR_10T | E1000_AR_10T_FD | + E1000_AR_100TX | E1000_AR_100TX_FD | + E1000_AR_PAUSE | E1000_AR_ASM_DIR); + else + PHY_WRITE(sc, E1000_AR, E1000_FA_1000X_FD | E1000_FA_1000X | + E1000_FA_SYM_PAUSE | E1000_FA_ASYM_PAUSE); + if (esc->mii_model != MII_MODEL_MARVELL_E3082) + PHY_WRITE(sc, E1000_1GCR, + E1000_1GCR_1000T_FD | E1000_1GCR_1000T); + PHY_WRITE(sc, E1000_CR, + E1000_CR_AUTO_NEG_ENABLE | E1000_CR_RESTART_AUTO_NEG); + + return (EJUSTRETURN); +} Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phyreg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phyreg.h 2007-11-28 18:38:34 UTC (rev 23015) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phyreg.h 2007-11-28 22:13:48 UTC (rev 23016) @@ -0,0 +1,324 @@ +/* $FreeBSD: src/sys/dev/mii/e1000phyreg.h,v 1.4 2006/12/11 10:43:32 yongari Exp $ */ +/*- + * Principal Author: Parag Patel + * Copyright (c) 2001 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Additonal Copyright (c) 2001 by Traakan Software under same licence. + * Secondary Author: Matthew Jacob + */ + +/*- + * Derived by information released by Intel under the following license: + * + * Copyright (c) 1999 - 2001, Intel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * Marvell E1000 PHY registers + */ + +#define E1000_MAX_REG_ADDRESS 0x1F + +#define E1000_CR 0x00 /* control register */ +#define E1000_CR_SPEED_SELECT_MSB 0x0040 +#define E1000_CR_COLL_TEST_ENABLE 0x0080 +#define E1000_CR_FULL_DUPLEX 0x0100 +#define E1000_CR_RESTART_AUTO_NEG 0x0200 +#define E1000_CR_ISOLATE 0x0400 +#define E1000_CR_POWER_DOWN 0x0800 +#define E1000_CR_AUTO_NEG_ENABLE 0x1000 +#define E1000_CR_SPEED_SELECT_LSB 0x2000 +#define E1000_CR_LOOPBACK 0x4000 +#define E1000_CR_RESET 0x8000 + +#define E1000_CR_SPEED_1000 0x0040 +#define E1000_CR_SPEED_100 0x2000 +#define E1000_CR_SPEED_10 0x0000 + +#define E1000_SR 0x01 /* status register */ +#define E1000_SR_EXTENDED 0x0001 +#define E1000_SR_JABBER_DETECT 0x0002 +#define E1000_SR_LINK_STATUS 0x0004 +#define E1000_SR_AUTO_NEG 0x0008 +#define E1000_SR_REMOTE_FAULT 0x0010 +#define E1000_SR_AUTO_NEG_COMPLETE 0x0020 +#define E1000_SR_PREAMBLE_SUPPRESS 0x0040 +#define E1000_SR_EXTENDED_STATUS 0x0100 +#define E1000_SR_100T2 0x0200 +#define E1000_SR_100T2_FD 0x0400 +#define E1000_SR_10T 0x0800 +#define E1000_SR_10T_FD 0x1000 +#define E1000_SR_100TX 0x2000 +#define E1000_SR_100TX_FD 0x4000 +#define E1000_SR_100T4 0x8000 + +#define E1000_ID1 0x02 /* ID register 1 */ +#define E1000_ID2 0x03 /* ID register 2 */ +#define E1000_ID_88E1000 0x01410C50 +#define E1000_ID_88E1000S 0x01410C40 +#define E1000_ID_88E1011 0x01410C20 +#define E1000_ID_MASK 0xFFFFFFF0 + +#define E1000_AR 0x04 /* autonegotiation advertise reg */ +#define E1000_AR_SELECTOR_FIELD 0x0001 +#define E1000_AR_10T 0x0020 +#define E1000_AR_10T_FD 0x0040 +#define E1000_AR_100TX 0x0080 +#define E1000_AR_100TX_FD 0x0100 +#define E1000_AR_100T4 0x0200 +#define E1000_AR_PAUSE 0x0400 +#define E1000_AR_ASM_DIR 0x0800 +#define E1000_AR_REMOTE_FAULT 0x2000 +#define E1000_AR_NEXT_PAGE 0x8000 +#define E1000_AR_SPEED_MASK 0x01E0 + +/* Autonegotiation register bits for fiber cards (Alaska Only!) */ +#define E1000_FA_1000X_FD 0x0020 +#define E1000_FA_1000X 0x0040 +#define E1000_FA_SYM_PAUSE 0x0080 +#define E1000_FA_ASYM_PAUSE 0x0100 +#define E1000_FA_FAULT1 0x1000 +#define E1000_FA_FAULT2 0x2000 +#define E1000_FA_NEXT_PAGE 0x8000 + +#define E1000_LPAR 0x05 /* autoneg link partner abilities reg */ +#define E1000_LPAR_SELECTOR_FIELD 0x0001 +#define E1000_LPAR_10T 0x0020 +#define E1000_LPAR_10T_FD 0x0040 +#define E1000_LPAR_100TX 0x0080 +#define E1000_LPAR_100TX_FD 0x0100 +#define E1000_LPAR_100T4 0x0200 +#define E1000_LPAR_PAUSE 0x0400 +#define E1000_LPAR_ASM_DIR 0x0800 +#define E1000_LPAR_REMOTE_FAULT 0x2000 +#define E1000_LPAR_ACKNOWLEDGE 0x4000 +#define E1000_LPAR_NEXT_PAGE 0x8000 + +/* autoneg link partner ability register bits for fiber cards (Alaska Only!) */ +#define E1000_FPAR_1000X_FD 0x0020 +#define E1000_FPAR_1000X 0x0040 +#define E1000_FPAR_SYM_PAUSE 0x0080 +#define E1000_FPAR_ASYM_PAUSE 0x0100 +#define E1000_FPAR_FAULT1 0x1000 +#define E1000_FPAR_FAULT2 0x2000 +#define E1000_FPAR_ACK 0x4000 +#define E1000_FPAR_NEXT_PAGE 0x8000 + +#define E1000_ER 0x06 /* autoneg expansion reg */ +#define E1000_ER_LP_NWAY 0x0001 +#define E1000_ER_PAGE_RXD 0x0002 +#define E1000_ER_NEXT_PAGE 0x0004 +#define E1000_ER_LP_NEXT_PAGE 0x0008 +#define E1000_ER_PAR_DETECT_FAULT 0x0100 + +#define E1000_NPTX 0x07 /* autoneg next page TX */ +#define E1000_NPTX_MSG_CODE_FIELD 0x0001 +#define E1000_NPTX_TOGGLE 0x0800 +#define E1000_NPTX_ACKNOWLDGE2 0x1000 +#define E1000_NPTX_MSG_PAGE 0x2000 +#define E1000_NPTX_NEXT_PAGE 0x8000 + +#define E1000_RNPR 0x08 /* autoneg link-partner (?) next page */ +#define E1000_RNPR_MSG_CODE_FIELD 0x0001 +#define E1000_RNPR_TOGGLE 0x0800 +#define E1000_RNPR_ACKNOWLDGE2 0x1000 +#define E1000_RNPR_MSG_PAGE 0x2000 +#define E1000_RNPR_ACKNOWLDGE 0x4000 +#define E1000_RNPR_NEXT_PAGE 0x8000 + +#define E1000_1GCR 0x09 /* 1000T (1G) control reg */ +#define E1000_1GCR_ASYM_PAUSE 0x0080 +#define E1000_1GCR_1000T 0x0100 +#define E1000_1GCR_1000T_FD 0x0200 +#define E1000_1GCR_REPEATER_DTE 0x0400 +#define E1000_1GCR_MS_VALUE 0x0800 +#define E1000_1GCR_MS_ENABLE 0x1000 +#define E1000_1GCR_TEST_MODE_NORMAL 0x0000 +#define E1000_1GCR_TEST_MODE_1 0x2000 +#define E1000_1GCR_TEST_MODE_2 0x4000 +#define E1000_1GCR_TEST_MODE_3 0x6000 +#define E1000_1GCR_TEST_MODE_4 0x8000 +#define E1000_1GCR_SPEED_MASK 0x0300 + +#define E1000_1GSR 0x0A /* 1000T (1G) status reg */ +#define E1000_1GSR_IDLE_ERROR_CNT 0x0000 +#define E1000_1GSR_ASYM_PAUSE_DIR 0x0100 +#define E1000_1GSR_LP 0x0400 +#define E1000_1GSR_LP_FD 0x0800 +#define E1000_1GSR_REMOTE_RX_STATUS 0x1000 +#define E1000_1GSR_LOCAL_RX_STATUS 0x2000 +#define E1000_1GSR_MS_CONFIG_RES 0x4000 +#define E1000_1GSR_MS_CONFIG_FAULT 0x8000 + +#define E1000_ESR 0x0F /* IEEE extended status reg */ +#define E1000_ESR_1000T 0x1000 +#define E1000_ESR_1000T_FD 0x2000 +#define E1000_ESR_1000X 0x4000 +#define E1000_ESR_1000X_FD 0x8000 + +#define E1000_TX_POLARITY_MASK 0x0100 +#define E1000_TX_NORMAL_POLARITY 0 + +#define E1000_AUTO_POLARITY_DISABLE 0x0010 + +#define E1000_SCR 0x10 /* special control register */ +#define E1000_SCR_JABBER_DISABLE 0x0001 +#define E1000_SCR_POLARITY_REVERSAL 0x0002 +#define E1000_SCR_SQE_TEST 0x0004 +#define E1000_SCR_INT_FIFO_DISABLE 0x0008 +#define E1000_SCR_CLK125_DISABLE 0x0010 +#define E1000_SCR_MDI_MANUAL_MODE 0x0000 +#define E1000_SCR_MDIX_MANUAL_MODE 0x0020 +#define E1000_SCR_AUTO_X_1000T 0x0040 +#define E1000_SCR_AUTO_X_MODE 0x0060 +#define E1000_SCR_10BT_EXT_ENABLE 0x0080 +#define E1000_SCR_MII_5BIT_ENABLE 0x0100 +#define E1000_SCR_SCRAMBLER_DISABLE 0x0200 +#define E1000_SCR_FORCE_LINK_GOOD 0x0400 +#define E1000_SCR_ASSERT_CRS_ON_TX 0x0800 +#define E1000_SCR_RX_FIFO_DEPTH_6 0x0000 +#define E1000_SCR_RX_FIFO_DEPTH_8 0x1000 +#define E1000_SCR_RX_FIFO_DEPTH_10 0x2000 +#define E1000_SCR_RX_FIFO_DEPTH_12 0x3000 +#define E1000_SCR_TX_FIFO_DEPTH_6 0x0000 +#define E1000_SCR_TX_FIFO_DEPTH_8 0x4000 +#define E1000_SCR_TX_FIFO_DEPTH_10 0x8000 +#define E1000_SCR_TX_FIFO_DEPTH_12 0xC000 + +#define E1000_SCR_EN_DETECT_MASK 0x0300 + +/* 88E1112 page 2 */ +#define E1000_SCR_MODE_MASK 0x0380 +#define E1000_SCR_MODE_AUTO 0x0180 +#define E1000_SCR_MODE_COPPER 0x0280 +#define E1000_SCR_MODE_1000BX 0x0380 + +#define E1000_SSR 0x11 /* special status register */ +#define E1000_SSR_JABBER 0x0001 +#define E1000_SSR_REV_POLARITY 0x0002 +#define E1000_SSR_MDIX 0x0020 +#define E1000_SSR_LINK 0x0400 +#define E1000_SSR_SPD_DPLX_RESOLVED 0x0800 +#define E1000_SSR_PAGE_RCVD 0x1000 +#define E1000_SSR_DUPLEX 0x2000 +#define E1000_SSR_SPEED 0xC000 +#define E1000_SSR_10MBS 0x0000 +#define E1000_SSR_100MBS 0x4000 +#define E1000_SSR_1000MBS 0x8000 + +#define E1000_IER 0x12 /* interrupt enable reg */ +#define E1000_IER_JABBER 0x0001 +#define E1000_IER_POLARITY_CHANGE 0x0002 +#define E1000_IER_MDIX_CHANGE 0x0040 +#define E1000_IER_FIFO_OVER_UNDERUN 0x0080 +#define E1000_IER_FALSE_CARRIER 0x0100 +#define E1000_IER_SYMBOL_ERROR 0x0200 +#define E1000_IER_LINK_STAT_CHANGE 0x0400 +#define E1000_IER_AUTO_NEG_COMPLETE 0x0800 +#define E1000_IER_PAGE_RECEIVED 0x1000 +#define E1000_IER_DUPLEX_CHANGED 0x2000 +#define E1000_IER_SPEED_CHANGED 0x4000 +#define E1000_IER_AUTO_NEG_ERR 0x8000 + +#define E1000_ISR 0x13 /* interrupt status reg */ +#define E1000_ISR_JABBER 0x0001 +#define E1000_ISR_POLARITY_CHANGE 0x0002 +#define E1000_ISR_MDIX_CHANGE 0x0040 +#define E1000_ISR_FIFO_OVER_UNDERUN 0x0080 +#define E1000_ISR_FALSE_CARRIER 0x0100 +#define E1000_ISR_SYMBOL_ERROR 0x0200 +#define E1000_ISR_LINK_STAT_CHANGE 0x0400 +#define E1000_ISR_AUTO_NEG_COMPLETE 0x0800 +#define E1000_ISR_PAGE_RECEIVED 0x1000 +#define E1000_ISR_DUPLEX_CHANGED 0x2000 +#define E1000_ISR_SPEED_CHANGED 0x4000 +#define E1000_ISR_AUTO_NEG_ERR 0x8000 + +#define E1000_ESCR 0x14 /* extended special control reg */ +#define E1000_ESCR_FIBER_LOOPBACK 0x4000 +#define E1000_ESCR_DOWN_NO_IDLE 0x8000 +#define E1000_ESCR_TX_CLK_2_5 0x0060 +#define E1000_ESCR_TX_CLK_25 0x0070 +#define E1000_ESCR_TX_CLK_0 0x0000 + +#define E1000_RECR 0x15 /* RX error counter reg */ + +#define E1000_EADR 0x16 /* extended address reg */ + +#define E1000_LCR 0x18 /* LED control reg */ +#define E1000_LCR_LED_TX 0x0001 +#define E1000_LCR_LED_RX 0x0002 +#define E1000_LCR_LED_DUPLEX 0x0004 +#define E1000_LCR_LINK 0x0008 +#define E1000_LCR_BLINK_42MS 0x0000 +#define E1000_LCR_BLINK_84MS 0x0100 +#define E1000_LCR_BLINK_170MS 0x0200 +#define E1000_LCR_BLINK_340MS 0x0300 +#define E1000_LCR_BLINK_670MS 0x0400 +#define E1000_LCR_PULSE_OFF 0x0000 +#define E1000_LCR_PULSE_21_42MS 0x1000 +#define E1000_LCR_PULSE_42_84MS 0x2000 +#define E1000_LCR_PULSE_84_170MS 0x3000 +#define E1000_LCR_PULSE_170_340MS 0x4000 +#define E1000_LCR_PULSE_340_670MS 0x5000 +#define E1000_LCR_PULSE_670_13S 0x6000 +#define E1000_LCR_PULSE_13_26S 0x7000 + +/* The following register is found only on the 88E1011 Alaska PHY */ +#define E1000_ESSR 0x1B /* Extended PHY specific sts */ +#define E1000_ESSR_FIBER_LINK 0x2000 +#define E1000_ESSR_GMII_COPPER 0x000f +#define E1000_ESSR_GMII_FIBER 0x0007 +#define E1000_ESSR_TBI_COPPER 0x000d +#define E1000_ESSR_TBI_FIBER 0x0005 Added: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/miidevs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/miidevs.h 2007-11-28 18:38:34 UTC (rev 23015) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/miidevs.h 2007-11-28 22:13:48 UTC (rev 23016) @@ -0,0 +1,40 @@ +#define MII_OUI_MARVELL 0x005043 +#define MII_OUI_xxMARVELL 0x000ac2 + +#define MII_MODEL_MARVELL_E1000 0x0000 +#define MII_MODEL_MARVELL_E1011 0x0002 +#define MII_MODEL_MARVELL_E1000_3 0x0003 +#define MII_MODEL_MARVELL_E1000S 0x0004 +#define MII_MODEL_MARVELL_E1000_5 0x0005 +#define MII_MODEL_MARVELL_E1000_6 0x0006 +#define MII_MODEL_MARVELL_E3082 0x0008 +#define MII_MODEL_MARVELL_E1112 0x0009 +#define MII_MODEL_MARVELL_E1149 0x000b +#define MII_MODEL_MARVELL_E1111 0x000c +#define MII_MODEL_MARVELL_E1116 0x0021 +#define MII_MODEL_MARVELL_E1118 0x0022 + +#define MII_MODEL_xxMARVELL_E1000 0x0005 +#define MII_MODEL_xxMARVELL_E1011 0x0002 +#define MII_MODEL_xxMARVELL_E1000_3 0x0003 +#define MII_MODEL_xxMARVELL_E1000_5 0x0005 +#define MII_MODEL_xxMARVELL_E1111 0x000c + +#define MII_STR_MARVELL_E1000 "Marvell 88E1000 Gigabit PHY" +#define MII_STR_MARVELL_E1011 "Marvell 88E1011 Gigabit PHY" +#define MII_STR_MARVELL_E1000_3 "Marvell 88E1000 Gigabit PHY" +#define MII_STR_MARVELL_E1000S "Marvell 88E1000S Gigabit PHY" +#define MII_STR_MARVELL_E1000_5 "Marvell 88E1000 Gigabit PHY" +#define MII_STR_MARVELL_E1000_6 "Marvell 88E1000 Gigabit PHY" +#define MII_STR_MARVELL_E3082 "Marvell 88E3082 10/100 Fast Ethernet PHY" +#define MII_STR_MARVELL_E1112 "Marvell 88E1112 Gigabit PHY" +#define MII_STR_MARVELL_E1149 "Marvell 88E1149 Gigabit PHY" +#define MII_STR_MARVELL_E1111 "Marvell 88E1111 Gigabit PHY" +#define MII_STR_MARVELL_E1116 "Marvell 88E1116 Gigabit PHY" +#define MII_STR_MARVELL_E1118 "Marvell 88E1118 Gigabit PHY" + +#define MII_STR_xxMARVELL_E1000 "Marvell 88E1000 Gigabit PHY" +#define MII_STR_xxMARVELL_E1011 "Marvell 88E1011 Gigabit PHY" +#define MII_STR_xxMARVELL_E1000_3 "Marvell 88E1000 Gigabit PHY" +#define MII_STR_xxMARVELL_E1000_5 "Marvell 88E1000 Gigabit PHY" +#define MII_STR_xxMARVELL_E1111 "Marvell 88E1111 Gigabit PHY" Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c 2007-11-28 18:38:34 UTC (rev 23015) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c 2007-11-28 22:13:48 UTC (rev 23016) @@ -10,6 +10,7 @@ HAIKU_FBSD_DRIVER_GLUE(marvell_yukon, mskc, pci) +extern driver_t *DRIVER_MODULE_NAME(e1000phy, miibus); extern driver_t *DRIVER_MODULE_NAME(ukphy, miibus); @@ -17,10 +18,11 @@ __haiku_select_miibus_driver(device_t dev) { driver_t *drivers[] = { + DRIVER_MODULE_NAME(e1000phy, miibus), DRIVER_MODULE_NAME(ukphy, miibus) }; - return __haiku_probe_miibus(dev, drivers, 1); + return __haiku_probe_miibus(dev, drivers, 2); } NO_HAIKU_CHECK_DISABLE_INTERRUPTS(); From axeld at mail.berlios.de Wed Nov 28 23:16:55 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 28 Nov 2007 23:16:55 +0100 Subject: [Haiku-commits] r23017 - in haiku/trunk/src/libs/compat/freebsd_network: . compat/dev/mii Message-ID: <200711282216.lASMGtpd005595@sheep.berlios.de> Author: axeld Date: 2007-11-28 23:16:55 +0100 (Wed, 28 Nov 2007) New Revision: 23017 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23017&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/dev/mii/miivar.h haiku/trunk/src/libs/compat/freebsd_network/fbsd_mii_physubr.c Log: Some additions from FreeBSD 7 code. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/dev/mii/miivar.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/dev/mii/miivar.h 2007-11-28 22:13:48 UTC (rev 23016) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/dev/mii/miivar.h 2007-11-28 22:16:55 UTC (rev 23017) @@ -165,6 +165,9 @@ u_int32_t mpd_model; /* the PHY's model */ const char *mpd_name; /* the PHY's name */ }; +#define MII_PHY_DESC(a, b) { MII_OUI_ ## a, MII_MODEL_ ## a ## _ ## b, \ + MII_STR_ ## a ## _ ## b } +#define MII_PHY_END { 0, 0, NULL } /* * An array of these structures map MII media types to BMCR/ANAR settings. @@ -243,6 +246,7 @@ int mii_phy_tick(struct mii_softc *); const struct mii_phydesc * mii_phy_match(const struct mii_attach_args *ma, const struct mii_phydesc *mpd); +int mii_phy_dev_probe(device_t dev, const struct mii_phydesc *mpd, int mrv); void ukphy_status(struct mii_softc *); #endif /* _KERNEL */ Modified: haiku/trunk/src/libs/compat/freebsd_network/fbsd_mii_physubr.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/fbsd_mii_physubr.c 2007-11-28 22:13:48 UTC (rev 23016) +++ haiku/trunk/src/libs/compat/freebsd_network/fbsd_mii_physubr.c 2007-11-28 22:16:55 UTC (rev 23017) @@ -542,3 +542,16 @@ } return (NULL); } + +int +mii_phy_dev_probe(device_t dev, const struct mii_phydesc *mpd, int mrv) +{ + + mpd = mii_phy_match(device_get_ivars(dev), mpd); + if (mpd != NULL) { + device_set_desc(dev, mpd->mpd_name); + return (mrv); + } + + return (ENXIO); +} From jackburton at mail.berlios.de Wed Nov 28 23:19:25 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 28 Nov 2007 23:19:25 +0100 Subject: [Haiku-commits] r23018 - haiku/trunk/src/kits/interface Message-ID: <200711282219.lASMJPOk005893@sheep.berlios.de> Author: jackburton Date: 2007-11-28 23:19:24 +0100 (Wed, 28 Nov 2007) New Revision: 23018 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23018&view=rev Modified: haiku/trunk/src/kits/interface/Menu.cpp Log: Only enlarge the menus if there's a submenu symbol (regression). Fixes bug #1647. Modified: haiku/trunk/src/kits/interface/Menu.cpp =================================================================== --- haiku/trunk/src/kits/interface/Menu.cpp 2007-11-28 22:16:55 UTC (rev 23017) +++ haiku/trunk/src/kits/interface/Menu.cpp 2007-11-28 22:19:24 UTC (rev 23018) @@ -1735,7 +1735,8 @@ item->fBounds.bottom = item->fBounds.top + height + fPad.top + fPad.bottom; - width += item->Frame().Height(); + if (item->fSubmenu != NULL) + width += item->Frame().Height(); frame.right = max_c(frame.right, width + fPad.left + fPad.right); frame.bottom = item->fBounds.bottom; From marcusoverhagen at arcor.de Wed Nov 28 22:16:28 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Wed, 28 Nov 2007 22:16:28 +0100 (CET) Subject: [Haiku-commits] r23015 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci In-Reply-To: <200711281838.lASIcZCF026129@sheep.berlios.de> References: <200711281838.lASIcZCF026129@sheep.berlios.de> Message-ID: <215378.1196284588273.JavaMail.ngmail@webmail11> Hi, I' had one strange problem when using gcc 4, that was randomly freezing applications. Which compiler are you using? Is the problem reproduceable, will reverting to 23014 make it appear again? If yes, can you please submit a bugreport and include the ahci_controller.o object files? Thanks Marcus ----- Original Nachricht ---- Von: stippi at BerliOS An: haiku-commits at lists.berlios.de Datum: 28.11.2007 19:38 Betreff: [Haiku-commits] r23015 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci > Author: stippi > Date: 2007-11-28 19:38:34 +0100 (Wed, 28 Nov 2007) > New Revision: 23015 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23015&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp > Log: > * I don't know what's going on, but with this change, I can boot Haiku > again > on my P35 with JMircon controller. I still have the "pci fixup" disabled > though. Without this change, I could boot until the blue desktop > background > with cursor, but all the apps were in frozen state and would not display > on screen (F12 worked and showed Tracker and so on as running teams, but > I could not even move the mouse) > > > Modified: > haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp > =================================================================== > --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp > 2007-11-28 17:00:33 UTC (rev 23014) > +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp > 2007-11-28 18:38:34 UTC (rev 23015) > @@ -339,10 +339,11 @@ > > > void > -AHCIController::GetRestrictions(uchar targetID, bool *isATAPI, bool > *noAutoSense, uint32 *maxBlocks) > +AHCIController::GetRestrictions(uchar targetID, bool *isATAPI, > + bool *noAutoSense, uint32 *maxBlocks) > { > if (!fPort[targetID]) > return; > > - return fPort[targetID]->ScsiGetRestrictions(isATAPI, noAutoSense, > maxBlocks); > + fPort[targetID]->ScsiGetRestrictions(isATAPI, noAutoSense, maxBlocks); > } > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From superstippi at gmx.de Thu Nov 29 09:47:32 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 29 Nov 2007 09:47:32 +0100 Subject: [Haiku-commits] r23015 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci In-Reply-To: <215378.1196284588273.JavaMail.ngmail@webmail11> References: <200711281838.lASIcZCF026129@sheep.berlios.de> <215378.1196284588273.JavaMail.ngmail@webmail11> Message-ID: <20071129094732.639.1@stippis2.1196325838.fake> Hi, strangest thing... I tried to provide you guys with two different object files. So I put the "return" back in. Guess what... the object files are identical. And even stranger - I can boot Haiku now with the "return" as well. I swear I tried several times yesterday to make sure this was the change that fixed it. I have not changed anything else btw, and have not seen the "freeze after blue desktop" bug again. :-\ Best regards, -Stephan From axeld at mail.berlios.de Thu Nov 29 19:56:06 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 29 Nov 2007 19:56:06 +0100 Subject: [Haiku-commits] r23019 - in haiku/trunk/src: add-ons/kernel/drivers/network/3com/dev/mii add-ons/kernel/drivers/network/3com/pci add-ons/kernel/drivers/network/marvell_yukon/dev/mii add-ons/kernel/drivers/network/marvell_yukon/dev/msk add-ons/kernel/drivers/network/rtl8139/pci add-ons/kernel/drivers/network/via_rhine/dev/mii add-ons/kernel/drivers/network/via_rhine/pci libs/compat/freebsd_network libs/compat/freebsd_network/compat/net libs/compat/freebsd_network/compat/sys Message-ID: <200711291856.lATIu6SQ014216@sheep.berlios.de> Author: axeld Date: 2007-11-29 19:56:03 +0100 (Thu, 29 Nov 2007) New Revision: 23019 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23019&view=rev Added: haiku/trunk/src/libs/compat/freebsd_network/driver.c haiku/trunk/src/libs/compat/freebsd_network/pci.c Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/ukphy.c haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/ukphy.c haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/pci/glue.c haiku/trunk/src/libs/compat/freebsd_network/Jamfile haiku/trunk/src/libs/compat/freebsd_network/bus.c haiku/trunk/src/libs/compat/freebsd_network/compat.c haiku/trunk/src/libs/compat/freebsd_network/compat/net/if_var.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/bus.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h haiku/trunk/src/libs/compat/freebsd_network/device.c haiku/trunk/src/libs/compat/freebsd_network/device.h haiku/trunk/src/libs/compat/freebsd_network/fbsd_mii.c haiku/trunk/src/libs/compat/freebsd_network/if.c Log: Completely renovated the FreeBSD compatibility layer: * Removed NETDEV() and DEVNET() macros and functionality. * The exported devices are now attached to ifnet objects only, therefore, the ifnet object now has the receive queue, and everything else a device could need. * There is now a root device where everything else is attached, it currently only holds the pci_info structure, so it's more or less a PCI child. * This simplified the device handling a bit everywhere. * We now attach drivers already in init_driver() - this is needed as drivers may publish more than one interface when being attached. * Implemented device_delete_child(), device_attach() (which bus_generic_attach() now uses), device_is_attached(), and device_is_alive(). * Therefore, if_initname() does now the actual job of registering the devices. * On open, if_init() is called which comes pretty close to what our open() is supposed to do. * Updated ukphy.c to the one from FreeBSD 7 where used (we should probably move that into the compat layer, anyway). * The MII driver array must now be NULL terminated; therefore you don't need to specify the count anymore. * Moved PCI code from compat.c to bus.c. * Moved the driver code from device.c to driver.c. * Removed superfluous init_compat_layer() function. * Fixed a few bugs, a few things weren't brought down correctly. * The rtl8139 interrupt routine now checks if it really was the cause of the interrupt - this code is not tested, either, it may not work (which would then require a work-around like I did for the 3com driver). * The HAIKU_PROTECT_INTR_REGISTER in the rtl8139 driver was pretty much useless which is why I removed it. * Probably introduced a lot of new bugs, though - I haven't tested this code at all yet. It will probably just crash :-) Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/ukphy.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/ukphy.c 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/ukphy.c 2007-11-29 18:56:03 UTC (rev 23019) @@ -67,7 +67,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.17 2005/01/06 01:42:56 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.20 2007/01/20 00:52:29 marius Exp $"); /* * driver for generic unknown PHYs @@ -114,34 +114,27 @@ static int ukphy_service(struct mii_softc *, struct mii_data *, int); static int -ukphy_probe(dev) - device_t dev; +ukphy_probe(device_t dev) { /* * We know something is here, so always match at a low priority. */ device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (-100); + return (BUS_PROBE_GENERIC); } static int -ukphy_attach(dev) - device_t dev; +ukphy_attach(device_t dev) { struct mii_softc *sc; struct mii_attach_args *ma; struct mii_data *mii; -static int ppp; -if (ppp++ > 0) - panic("oops"); sc = device_get_softc(dev); ma = device_get_ivars(dev); sc->mii_dev = device_get_parent(dev); mii = device_get_softc(sc->mii_dev); -device_printf(dev, "insert into %p\n", mii); -device_printf(sc->mii_dev, "this is the parent\n"); LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); if (bootverbose) @@ -156,8 +149,6 @@ mii->mii_instance++; - sc->mii_flags |= MIIF_NOISOLATE; - mii_phy_reset(sc); sc->mii_capabilities = @@ -171,14 +162,11 @@ MIIBUS_MEDIAINIT(sc->mii_dev); mii_phy_setmedia(sc); - return(0); + return (0); } static int -ukphy_service(sc, mii, cmd) - struct mii_softc *sc; - struct mii_data *mii; - int cmd; +ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c 2007-11-29 18:56:03 UTC (rev 23019) @@ -23,10 +23,11 @@ driver_t *drivers[] = { DRIVER_MODULE_NAME(bmtphy, miibus), DRIVER_MODULE_NAME(xlphy, miibus), - DRIVER_MODULE_NAME(ukphy, miibus) + DRIVER_MODULE_NAME(ukphy, miibus), + NULL }; - return __haiku_probe_miibus(dev, drivers, 3); + return __haiku_probe_miibus(dev, drivers); } Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c 2007-11-29 18:56:03 UTC (rev 23019) @@ -67,7 +67,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.17 2005/01/06 01:42:56 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.20 2007/01/20 00:52:29 marius Exp $"); /* * driver for generic unknown PHYs @@ -114,34 +114,27 @@ static int ukphy_service(struct mii_softc *, struct mii_data *, int); static int -ukphy_probe(dev) - device_t dev; +ukphy_probe(device_t dev) { /* * We know something is here, so always match at a low priority. */ device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (-100); + return (BUS_PROBE_GENERIC); } static int -ukphy_attach(dev) - device_t dev; +ukphy_attach(device_t dev) { struct mii_softc *sc; struct mii_attach_args *ma; struct mii_data *mii; -static int ppp; -if (ppp++ > 0) - panic("oops"); sc = device_get_softc(dev); ma = device_get_ivars(dev); sc->mii_dev = device_get_parent(dev); mii = device_get_softc(sc->mii_dev); -device_printf(dev, "insert into %p\n", mii); -device_printf(sc->mii_dev, "this is the parent\n"); LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); if (bootverbose) @@ -156,8 +149,6 @@ mii->mii_instance++; - sc->mii_flags |= MIIF_NOISOLATE; - mii_phy_reset(sc); sc->mii_capabilities = @@ -171,14 +162,11 @@ MIIBUS_MEDIAINIT(sc->mii_dev); mii_phy_setmedia(sc); - return(0); + return (0); } static int -ukphy_service(sc, mii, cmd) - struct mii_softc *sc; - struct mii_data *mii; - int cmd; +ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c 2007-11-29 18:56:03 UTC (rev 23019) @@ -19,10 +19,11 @@ { driver_t *drivers[] = { DRIVER_MODULE_NAME(e1000phy, miibus), - DRIVER_MODULE_NAME(ukphy, miibus) + DRIVER_MODULE_NAME(ukphy, miibus), + NULL }; - return __haiku_probe_miibus(dev, drivers, 2); + return __haiku_probe_miibus(dev, drivers); } NO_HAIKU_CHECK_DISABLE_INTERRUPTS(); Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/pci/glue.c 2007-11-29 18:56:03 UTC (rev 23019) @@ -6,21 +6,33 @@ HAIKU_FBSD_MII_DRIVER(rlphy); HAIKU_DRIVER_REQUIREMENTS(0); + int -HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev) { +HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev) +{ struct rl_softc *sc = device_get_softc(dev); + uint16_t status; - HAIKU_PROTECT_INTR_REGISTER(CSR_WRITE_2(sc, RL_IMR, 0)); + status = CSR_READ_2(sc, RL_ISR); + if (status == 0xffff) + return 0; + if (status != 0 && (status & RL_INTRS) == 0) { + CSR_WRITE_2(sc, RL_ISR, status); + return 0; + } + if ((status & RL_INTRS) == 0) + return 0; - /* we don't read the status register, so we just assume it was for us. */ + CSR_WRITE_2(sc, RL_IMR, 0); return 1; } + void HAIKU_REENABLE_INTERRUPTS(device_t dev) { struct rl_softc *sc = device_get_softc(dev); RL_LOCK(sc); - HAIKU_PROTECT_INTR_REGISTER(CSR_WRITE_2(sc, RL_IMR, RL_INTRS)); + CSR_WRITE_2(sc, RL_IMR, RL_INTRS); RL_UNLOCK(sc); } Modified: haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/ukphy.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/ukphy.c 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/ukphy.c 2007-11-29 18:56:03 UTC (rev 23019) @@ -67,7 +67,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.17 2005/01/06 01:42:56 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.20 2007/01/20 00:52:29 marius Exp $"); /* * driver for generic unknown PHYs @@ -114,20 +114,18 @@ static int ukphy_service(struct mii_softc *, struct mii_data *, int); static int -ukphy_probe(dev) - device_t dev; +ukphy_probe(device_t dev) { /* * We know something is here, so always match at a low priority. */ device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (-100); + return (BUS_PROBE_GENERIC); } static int -ukphy_attach(dev) - device_t dev; +ukphy_attach(device_t dev) { struct mii_softc *sc; struct mii_attach_args *ma; @@ -151,8 +149,6 @@ mii->mii_instance++; - sc->mii_flags |= MIIF_NOISOLATE; - mii_phy_reset(sc); sc->mii_capabilities = @@ -166,14 +162,11 @@ MIIBUS_MEDIAINIT(sc->mii_dev); mii_phy_setmedia(sc); - return(0); + return (0); } static int -ukphy_service(sc, mii, cmd) - struct mii_softc *sc; - struct mii_data *mii; - int cmd; +ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/pci/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/pci/glue.c 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/pci/glue.c 2007-11-29 18:56:03 UTC (rev 23019) @@ -20,9 +20,10 @@ { driver_t *drivers[] = { DRIVER_MODULE_NAME(ciphy, miibus), - DRIVER_MODULE_NAME(ukphy, miibus) + DRIVER_MODULE_NAME(ukphy, miibus), + NULL }; - return __haiku_probe_miibus(dev, drivers, 2); + return __haiku_probe_miibus(dev, drivers); } Modified: haiku/trunk/src/libs/compat/freebsd_network/Jamfile =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/Jamfile 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/libs/compat/freebsd_network/Jamfile 2007-11-29 18:56:03 UTC (rev 23019) @@ -13,6 +13,7 @@ callout.c compat.c device.c + driver.c fbsd_busdma_x86.c fbsd_ether.c fbsd_if_media.c @@ -23,5 +24,6 @@ mbuf.c mii.c mutex.c + pci.c taskqueue.c ; Modified: haiku/trunk/src/libs/compat/freebsd_network/bus.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-11-29 18:56:03 UTC (rev 23019) @@ -11,6 +11,7 @@ #include +#include #include #include #include @@ -24,6 +25,14 @@ # define TRACE_BUS_SPACE_RW(x) #endif +//#define DEBUG_PCI +#ifdef DEBUG_PCI +# define TRACE_PCI(dev, format, args...) device_printf(dev, format , ##args) +#else +# define TRACE_PCI(dev, format, args...) do { } while (0) +#endif + + #define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1)) // TODO: x86 specific! @@ -306,7 +315,7 @@ status = install_io_interrupt_handler(intr->irq, intr_fast_wrapper, intr, 0); } else { - snprintf(semName, sizeof(semName), "%s intr", dev->dev_name); + snprintf(semName, sizeof(semName), "%s intr", dev->device_name); intr->sem = create_sem(0, semName); if (intr->sem < B_OK) { @@ -314,7 +323,7 @@ return B_NO_MEMORY; } - snprintf(semName, sizeof(semName), "%s intr handler", dev->dev_name); + snprintf(semName, sizeof(semName), "%s intr handler", dev->device_name); intr->thread = spawn_kernel_thread(intr_handler, semName, B_REAL_TIME_DISPLAY_PRIORITY, intr); @@ -450,3 +459,184 @@ BUS_SPACE_WRITE(1, uint8_t, out8) BUS_SPACE_WRITE(2, uint16_t, out16) BUS_SPACE_WRITE(4, uint32_t, out32) + + +// #pragma mark - PCI functions + + +uint32_t +pci_read_config(device_t dev, int offset, int size) +{ + pci_info *info = &((struct root_device_softc *)dev->root->softc)->pci_info; + + uint32_t value = gPci->read_pci_config(info->bus, info->device, + info->function, offset, size); + TRACE_PCI(dev, "pci_read_config(%i, %i) = 0x%x\n", offset, size, value); + return value; +} + + +void +pci_write_config(device_t dev, int offset, uint32_t value, int size) +{ + pci_info *info = &((struct root_device_softc *)dev->root->softc)->pci_info; + + TRACE_PCI(dev, "pci_write_config(%i, 0x%x, %i)\n", offset, value, size); + + gPci->write_pci_config(info->bus, info->device, info->function, offset, + size, value); +} + + +uint16_t +pci_get_vendor(device_t dev) +{ + return pci_read_config(dev, PCI_vendor_id, 2); +} + + +uint16_t +pci_get_device(device_t dev) +{ + return pci_read_config(dev, PCI_device_id, 2); +} + + +uint16_t +pci_get_subvendor(device_t dev) +{ + return pci_read_config(dev, PCI_subsystem_vendor_id, 2); +} + + +uint16_t +pci_get_subdevice(device_t dev) +{ + return pci_read_config(dev, PCI_subsystem_id, 2); +} + + +uint8_t +pci_get_revid(device_t dev) +{ + return pci_read_config(dev, PCI_revision, 1); +} + + +static void +pci_set_command_bit(device_t dev, uint16_t bit) +{ + uint16_t command = pci_read_config(dev, PCI_command, 2); + pci_write_config(dev, PCI_command, command | bit, 2); +} + + +int +pci_enable_busmaster(device_t dev) +{ + pci_set_command_bit(dev, PCI_command_master); + return 0; +} + + +int +pci_enable_io(device_t dev, int space) +{ + /* adapted from FreeBSD's pci_enable_io_method */ + int bit = 0; + + switch (space) { + case SYS_RES_IOPORT: + bit = PCI_command_io; + break; + case SYS_RES_MEMORY: + bit = PCI_command_memory; + break; + default: + return EINVAL; + } + + pci_set_command_bit(dev, bit); + if (pci_read_config(dev, PCI_command, 2) & bit) + return 0; + + device_printf(dev, "pci_enable_io(%d) failed.\n", space); + + return ENXIO; +} + + +int +pci_find_extcap(device_t child, int capability, int *_capabilityRegister) +{ + uint8 capabilityPointer; + uint8 headerType; + uint16 status; + + status = pci_read_config(child, PCIR_STATUS, 2); + if ((status & PCIM_STATUS_CAPPRESENT) == 0) + return ENXIO; + + headerType = pci_read_config(child, PCI_header_type, 1); + switch (headerType & PCIM_HDRTYPE) { + case 0: + case 1: + capabilityPointer = PCIR_CAP_PTR; + break; + case 2: + capabilityPointer = PCIR_CAP_PTR_2; + break; + default: + return ENXIO; + } + capabilityPointer = pci_read_config(child, capabilityPointer, 1); + + while (capabilityPointer != 0) { + if (pci_read_config(child, capabilityPointer + PCICAP_ID, 1) + == capability) { + if (_capabilityRegister != NULL) + *_capabilityRegister = capabilityPointer; + return 0; + } + capabilityPointer = pci_read_config(child, + capabilityPointer + PCICAP_NEXTPTR, 1); + } + + return ENOENT; +} + + +int +pci_msi_count(device_t dev) +{ + return 0; +} + + +int +pci_alloc_msi(device_t dev, int *count) +{ + return ENODEV; +} + + +int +pci_release_msi(device_t dev) +{ + return ENODEV; +} + + +int +pci_msix_count(device_t dev) +{ + return 0; +} + + +int +pci_alloc_msix(device_t dev, int *count) +{ + return ENODEV; +} + Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/net/if_var.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/net/if_var.h 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/net/if_var.h 2007-11-29 18:56:03 UTC (rev 23019) @@ -186,8 +186,14 @@ struct mtx if_addr_mtx; /* mutex to protect address lists */ /* Haiku additions */ - struct sockaddr_dl if_lladdr; - struct device *if_dev; + struct sockaddr_dl if_lladdr; + char device_name[128]; + struct device *root_device; + struct ifqueue receive_queue; + sem_id receive_sem; + sem_id link_state_sem; + int32 open_count; + int32 flags; }; typedef void if_init_f_t(void *); Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/bus.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/bus.h 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/bus.h 2007-11-29 18:56:03 UTC (rev 23019) @@ -88,6 +88,13 @@ #define FILTER_HANDLED B_HANDLED_INTERRUPT #define FILTER_SCHEDULE_THREAD B_INVOKE_SCHEDULER +/* Note that we reversed the original order, so whenever actual (negative) + numbers are used in a driver, we have to change it. */ +#define BUS_PROBE_SPECIFIC 0 +#define BUS_PROBE_LOW_PRIORITY 10 +#define BUS_PROBE_DEFAULT 20 +#define BUS_PROBE_GENERIC 100 + int bus_generic_detach(device_t dev); int bus_generic_suspend(device_t dev); int bus_generic_resume(device_t dev); @@ -136,6 +143,7 @@ device_t device_add_child(device_t dev, const char *name, int unit); int device_delete_child(device_t dev, device_t child); int device_is_attached(device_t dev); +int device_attach(device_t dev); int bus_generic_print_child(device_t dev, device_t child); void bus_generic_driver_added(device_t dev, driver_t *driver); int bus_generic_attach(device_t dev); Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2007-11-29 18:56:03 UTC (rev 23019) @@ -41,19 +41,16 @@ size_t softc_size; } driver_t; -#define BUS_PROBE_LOW_PRIORITY 10 -#define BUS_PROBE_DEFAULT 20 - #define DRIVER_MODULE_NAME(name, busname) \ - __fbsd_##name##busname + __fbsd_ ## name ## _ ## busname -status_t _fbsd_init_hardware(driver_t *); -status_t _fbsd_init_driver(driver_t *); -void _fbsd_uninit_driver(driver_t *); +status_t _fbsd_init_hardware(driver_t *driver); +status_t _fbsd_init_driver(driver_t *driver); +void _fbsd_uninit_driver(driver_t *driver); -extern const char gDriverName[]; +extern const char *gDriverName; driver_t *__haiku_select_miibus_driver(device_t dev); -driver_t *__haiku_probe_miibus(device_t dev, driver_t *drivers[], int count); +driver_t *__haiku_probe_miibus(device_t dev, driver_t *drivers[]); /* we define the driver methods with HAIKU_FBSD_DRIVER_GLUE to * force the rest of the stuff to be linked back with the driver. @@ -61,10 +58,10 @@ * the final binary, gcc 4.x rightfuly doesn't. */ #define HAIKU_FBSD_DRIVER_GLUE(publicname, name, busname) \ - extern const char *gDevNameList[]; \ + extern const char *gDeviceNameList[]; \ extern device_hooks gDeviceHooks; \ extern driver_t *DRIVER_MODULE_NAME(name, busname); \ - const char gDriverName[] = #publicname; \ + const char *gDriverName = #publicname; \ int32 api_version = B_CUR_DRIVER_API_VERSION; \ status_t init_hardware() \ { \ @@ -77,14 +74,14 @@ void uninit_driver() \ { _fbsd_uninit_driver(DRIVER_MODULE_NAME(name, busname)); } \ const char **publish_devices() \ - { return gDevNameList; } \ + { return gDeviceNameList; } \ device_hooks *find_device(const char *name) \ { return &gDeviceHooks; } -#define HAIKU_FBSD_RETURN_MII_DRIVER(drivers, count) \ +#define HAIKU_FBSD_RETURN_MII_DRIVER(drivers) \ driver_t *__haiku_select_miibus_driver(device_t dev) \ { \ - return __haiku_probe_miibus(dev, drivers, count); \ + return __haiku_probe_miibus(dev, drivers); \ } #define HAIKU_FBSD_MII_DRIVER(name) \ @@ -92,13 +89,14 @@ driver_t *__haiku_select_miibus_driver(device_t dev) \ { \ driver_t *drivers[] = { \ - DRIVER_MODULE_NAME(name, miibus) \ + DRIVER_MODULE_NAME(name, miibus), \ + NULL \ }; \ - return __haiku_probe_miibus(dev, drivers, 1); \ + return __haiku_probe_miibus(dev, drivers); \ } #define NO_HAIKU_FBSD_MII_DRIVER() \ - HAIKU_FBSD_RETURN_MII_DRIVER(NULL, 0) + HAIKU_FBSD_RETURN_MII_DRIVER(NULL) extern spinlock __haiku_intr_spinlock; extern int __haiku_disable_interrupts(device_t dev); Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-28 22:19:24 UTC (rev 23018) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-29 18:56:03 UTC (rev 23019) @@ -14,204 +14,88 @@ #include #include -#include -#include +#include #include #include -//#define DEBUG_PCI -#ifdef DEBUG_PCI -# define TRACE_PCI(dev, format, args...) device_printf(dev, format , ##args) -#else -# define TRACE_PCI(dev, format, args...) do { } while (0) -#endif - spinlock __haiku_intr_spinlock; struct net_stack_module_info *gStack; pci_module_info *gPci; +static struct list sRootDevices; +static int sNextUnit; -// #pragma mark - PCI +// #pragma mark - private functions -uint32_t -pci_read_config(device_t dev, int offset, int size) -{ - uint32_t value = gPci->read_pci_config(NETDEV(dev)->pci_info.bus, - NETDEV(dev)->pci_info.device, NETDEV(dev)->pci_info.function, - offset, size); - TRACE_PCI(dev, "pci_read_config(%i, %i) = 0x%x\n", offset, size, value); - return value; -} - -void -pci_write_config(device_t dev, int offset, uint32_t value, int size) +static device_t +init_device(device_t device, driver_t *driver) { - TRACE_PCI(dev, "pci_write_config(%i, 0x%x, %i)\n", offset, value, size); + list_init_etc(&device->children, offsetof(struct device, link)); + device->unit = sNextUnit++; - gPci->write_pci_config(NETDEV(dev)->pci_info.bus, - NETDEV(dev)->pci_info.device, NETDEV(dev)->pci_info.function, - offset, size, value); -} + if (driver != NULL && device_set_driver(device, driver) < 0) + return NULL; - -uint16_t -pci_get_vendor(device_t dev) -{ - return pci_read_config(dev, PCI_vendor_id, 2); + return device; } -uint16_t -pci_get_device(device_t dev) +static device_t +new_device(driver_t *driver) { - return pci_read_config(dev, PCI_device_id, 2); -} + device_t dev = malloc(sizeof(struct device)); + if (dev == NULL) + return NULL; + memset(dev, 0, sizeof(struct device)); -uint16_t -pci_get_subvendor(device_t dev) -{ - return pci_read_config(dev, PCI_subsystem_vendor_id, 2); -} - - -uint16_t -pci_get_subdevice(device_t dev) -{ - return pci_read_config(dev, PCI_subsystem_id, 2); -} - - -uint8_t -pci_get_revid(device_t dev) -{ - return pci_read_config(dev, PCI_revision, 1); -} - - -static void -pci_set_command_bit(device_t dev, uint16_t bit) -{ - uint16_t command = pci_read_config(dev, PCI_command, 2); - pci_write_config(dev, PCI_command, command | bit, 2); -} - - -int -pci_enable_busmaster(device_t dev) -{ - pci_set_command_bit(dev, PCI_command_master); - return 0; -} - - -int -pci_enable_io(device_t dev, int space) -{ - /* adapted from FreeBSD's pci_enable_io_method */ - int bit = 0; - - switch (space) { - case SYS_RES_IOPORT: - bit = PCI_command_io; - break; - case SYS_RES_MEMORY: - bit = PCI_command_memory; - break; - default: - return EINVAL; + if (init_device(dev, driver) == NULL) { + free(dev); + return NULL; } - pci_set_command_bit(dev, bit); - if (pci_read_config(dev, PCI_command, 2) & bit) - return 0; - - device_printf(dev, "pci_enable_io(%d) failed.\n", space); - - return ENXIO; + return dev; } -int -pci_find_extcap(device_t child, int capability, int *_capabilityRegister) +static image_id +find_own_image() { - uint8 capabilityPointer; - uint8 headerType; - uint16 status; - - status = pci_read_config(child, PCIR_STATUS, 2); - if ((status & PCIM_STATUS_CAPPRESENT) == 0) - return ENXIO; - - headerType = pci_read_config(child, PCI_header_type, 1); - switch (headerType & PCIM_HDRTYPE) { - case 0: - case 1: - capabilityPointer = PCIR_CAP_PTR; - break; - case 2: - capabilityPointer = PCIR_CAP_PTR_2; - break; - default: - return ENXIO; - } - capabilityPointer = pci_read_config(child, capabilityPointer, 1); - - while (capabilityPointer != 0) { - if (pci_read_config(child, capabilityPointer + PCICAP_ID, 1) - == capability) { - if (_capabilityRegister != NULL) - *_capabilityRegister = capabilityPointer; - return 0; + int32 cookie = 0; + image_info info; + while (get_next_image_info(B_SYSTEM_TEAM, &cookie, &info) == B_OK) { + if (((uint32)info.text <= (uint32)find_own_image + && (uint32)info.text + (uint32)info.text_size + > (uint32)find_own_image)) { + // found our own image + return info.id; } - capabilityPointer = pci_read_config(child, - capabilityPointer + PCICAP_NEXTPTR, 1); } - return ENOENT; + return B_ENTRY_NOT_FOUND; } -int -pci_msi_count(device_t dev) +static device_method_signature_t +resolve_method(driver_t *driver, const char *name) { - return 0; -} + device_method_signature_t method = NULL; + int i; + for (i = 0; method == NULL && driver->methods[i].name != NULL; i++) { + if (strcmp(driver->methods[i].name, name) == 0) + method = driver->methods[i].method; + } -int -pci_alloc_msi(device_t dev, int *count) -{ - return ENODEV; + return method; } -int -pci_release_msi(device_t dev) -{ - return ENODEV; -} - - -int -pci_msix_count(device_t dev) -{ - return 0; -} - - -int -pci_alloc_msix(device_t dev, int *count) -{ - return ENODEV; -} - - // #pragma mark - Device @@ -251,7 +135,7 @@ va_list vl; va_start(vl, format); - driver_vprintf_etc(dev->dev_name, format, vl); + driver_vprintf_etc(dev->device_name, format, vl); va_end(vl); return 0; } @@ -300,22 +184,13 @@ } -void -device_sprintf_name(device_t dev, const char *format, ...) -{ - va_list vl; - va_start(vl, format); - vsnprintf(dev->dev_name, sizeof(dev->dev_name), format, vl); - va_end(vl); -} - - const char * device_get_name(device_t dev) { - if (dev) - return dev->dev_name; - return NULL; + if (dev == NULL) + return NULL; + + return dev->device_name; } @@ -340,18 +215,6 @@ } -device_t -init_device(device_t dev, driver_t *driver) -{ - list_init_etc(&dev->children, offsetof(struct device, link)); - - if (driver != NULL && device_set_driver(dev, driver) < 0) - return NULL; - - return dev; -} - [... truncated: 1550 lines follow ...] From axeld at mail.berlios.de Thu Nov 29 20:12:20 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 29 Nov 2007 20:12:20 +0100 Subject: [Haiku-commits] r23020 - haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp Message-ID: <200711291912.lATJCKAH015353@sheep.berlios.de> Author: axeld Date: 2007-11-29 20:12:20 +0100 (Thu, 29 Nov 2007) New Revision: 23020 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23020&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxp.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpvar.h Log: * Updated the driver to the FreeBSD 7 version. * Made it compile - not yet tested (but I do have the hardware). Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/glue.c 2007-11-29 18:56:03 UTC (rev 23019) +++ haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/glue.c 2007-11-29 19:12:20 UTC (rev 23020) @@ -1,3 +1,38 @@ +/* + * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ + + #include +#include +#include "if_fxpreg.h" +#include "if_fxpvar.h" + + HAIKU_FBSD_DRIVER_GLUE(ipro100, fxp, pci) + + +int +__haiku_disable_interrupts(device_t dev) +{ + struct fxp_softc *sc = device_get_softc(dev); + + // TODO: check interrupt status! + CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE); + return 1; +} + + +void +__haiku_reenable_interrupts(device_t dev) +{ + struct fxp_softc *sc = device_get_softc(dev); + + CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, 0); +} + + +HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_SWI_TASKQUEUE); +NO_HAIKU_FBSD_MII_DRIVER(); Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxp.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxp.c 2007-11-29 18:56:03 UTC (rev 23019) +++ haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxp.c 2007-11-29 19:12:20 UTC (rev 23020) @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/fxp/if_fxp.c,v 1.240.2.10.2.1 2006/11/20 16:21:12 rink Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/fxp/if_fxp.c,v 1.266 2007/05/30 03:46:04 kevlo Exp $"); /* * Intel EtherExpress Pro/100B PCI Fast Ethernet driver @@ -62,7 +62,6 @@ #include #include -#include /* for DELAY */ #include #include @@ -179,6 +178,7 @@ { 0x1065, -1, "Intel 82562ET/EZ/GT/GZ PRO/100 VE Ethernet" }, { 0x1068, -1, "Intel 82801FBM (ICH6-M) Pro/100 VE Ethernet" }, { 0x1069, -1, "Intel 82562EM/EX/GX Pro/100 Ethernet" }, + { 0x1091, -1, "Intel 82562GX Pro/100 Ethernet" }, { 0x1092, -1, "Intel Pro/100 VE Network Connection" }, { 0x1093, -1, "Intel Pro/100 VM Network Connection" }, { 0x1094, -1, "Intel Pro/100 946GZ (ICH7) Network Connection" }, @@ -229,7 +229,7 @@ static void fxp_release(struct fxp_softc *sc); static int fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t data); -static void fxp_watchdog(struct ifnet *ifp); +static void fxp_watchdog(struct fxp_softc *sc); static int fxp_add_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp); static int fxp_mc_addrs(struct fxp_softc *sc); @@ -249,7 +249,7 @@ static int fxp_serial_ifmedia_upd(struct ifnet *ifp); static void fxp_serial_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); -static volatile int fxp_miibus_readreg(device_t dev, int phy, int reg); +static int fxp_miibus_readreg(device_t dev, int phy, int reg); static void fxp_miibus_writereg(device_t dev, int phy, int reg, int value); static void fxp_load_ucode(struct fxp_softc *sc); @@ -291,6 +291,18 @@ DRIVER_MODULE(fxp, cardbus, fxp_driver, fxp_devclass, 0, 0); DRIVER_MODULE(miibus, fxp, miibus_driver, miibus_devclass, 0, 0); +static struct resource_spec fxp_res_spec_mem[] = { + { SYS_RES_MEMORY, FXP_PCI_MMBA, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE }, + { -1, 0 } +}; + +static struct resource_spec fxp_res_spec_io[] = { + { SYS_RES_IOPORT, FXP_PCI_IOBA, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE }, + { -1, 0 } +}; + /* * Wait for the previous command to be accepted (but not necessarily * completed). @@ -390,7 +402,7 @@ uint32_t val; uint16_t data, myea[ETHER_ADDR_LEN / 2]; u_char eaddr[ETHER_ADDR_LEN]; - int i, rid, m1, m2, prefer_iomap; + int i, prefer_iomap; int error; error = 0; @@ -420,51 +432,34 @@ * We default to memory mapping. Then we accept an override from the * command line. Then we check to see which one is enabled. */ - m1 = PCIM_CMD_MEMEN; - m2 = PCIM_CMD_PORTEN; prefer_iomap = 0; - if (resource_int_value(device_get_name(dev), device_get_unit(dev), - "prefer_iomap", &prefer_iomap) == 0 && prefer_iomap != 0) { - m1 = PCIM_CMD_PORTEN; - m2 = PCIM_CMD_MEMEN; - } + resource_int_value(device_get_name(dev), device_get_unit(dev), + "prefer_iomap", &prefer_iomap); + if (prefer_iomap) + sc->fxp_spec = fxp_res_spec_io; + else + sc->fxp_spec = fxp_res_spec_mem; - sc->rtp = (m1 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT; - sc->rgd = (m1 == PCIM_CMD_MEMEN)? FXP_PCI_MMBA : FXP_PCI_IOBA; - sc->mem = bus_alloc_resource_any(dev, sc->rtp, &sc->rgd, RF_ACTIVE); - if (sc->mem == NULL) { - sc->rtp = - (m2 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT; - sc->rgd = (m2 == PCIM_CMD_MEMEN)? FXP_PCI_MMBA : FXP_PCI_IOBA; - sc->mem = bus_alloc_resource_any(dev, sc->rtp, &sc->rgd, - RF_ACTIVE); + error = bus_alloc_resources(dev, sc->fxp_spec, sc->fxp_res); + if (error) { + if (sc->fxp_spec == fxp_res_spec_mem) + sc->fxp_spec = fxp_res_spec_io; + else + sc->fxp_spec = fxp_res_spec_mem; + error = bus_alloc_resources(dev, sc->fxp_spec, sc->fxp_res); } - - if (!sc->mem) { + if (error) { + device_printf(dev, "could not allocate resources\n"); error = ENXIO; goto fail; - } + } + if (bootverbose) { device_printf(dev, "using %s space register mapping\n", - sc->rtp == SYS_RES_MEMORY? "memory" : "I/O"); + sc->fxp_spec == fxp_res_spec_mem ? "memory" : "I/O"); } - sc->sc_st = rman_get_bustag(sc->mem); - sc->sc_sh = rman_get_bushandle(sc->mem); - /* - * Allocate our interrupt. - */ - rid = 0; - sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); - if (sc->irq == NULL) { - device_printf(dev, "could not map interrupt\n"); - error = ENXIO; - goto fail; - } - - /* * Reset to a stable state. */ CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SELECTIVE_RESET); @@ -618,19 +613,19 @@ sc->maxtxseg = FXP_NTXSEG; if (sc->flags & FXP_FLAG_EXT_RFA) sc->maxtxseg--; - error = bus_dma_tag_create(NULL, 2, 0, BUS_SPACE_MAXADDR_32BIT, - BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES * sc->maxtxseg, - sc->maxtxseg, MCLBYTES, 0, busdma_lock_mutex, &Giant, - &sc->fxp_mtag); + error = bus_dma_tag_create(bus_get_dma_tag(dev), 2, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + MCLBYTES * sc->maxtxseg, sc->maxtxseg, MCLBYTES, 0, + busdma_lock_mutex, &Giant, &sc->fxp_mtag); if (error) { device_printf(dev, "could not allocate dma tag\n"); goto fail; } - error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT, - BUS_SPACE_MAXADDR, NULL, NULL, sizeof(struct fxp_stats), 1, - sizeof(struct fxp_stats), 0, busdma_lock_mutex, &Giant, - &sc->fxp_stag); + error = bus_dma_tag_create(bus_get_dma_tag(dev), 4, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + sizeof(struct fxp_stats), 1, sizeof(struct fxp_stats), 0, + busdma_lock_mutex, &Giant, &sc->fxp_stag); if (error) { device_printf(dev, "could not allocate dma tag\n"); goto fail; @@ -647,9 +642,10 @@ goto fail; } - error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT, - BUS_SPACE_MAXADDR, NULL, NULL, FXP_TXCB_SZ, 1, - FXP_TXCB_SZ, 0, busdma_lock_mutex, &Giant, &sc->cbl_tag); + error = bus_dma_tag_create(bus_get_dma_tag(dev), 4, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + FXP_TXCB_SZ, 1, FXP_TXCB_SZ, 0, + busdma_lock_mutex, &Giant, &sc->cbl_tag); if (error) { device_printf(dev, "could not allocate dma tag\n"); goto fail; @@ -668,10 +664,10 @@ goto fail; } - error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT, - BUS_SPACE_MAXADDR, NULL, NULL, sizeof(struct fxp_cb_mcs), 1, - sizeof(struct fxp_cb_mcs), 0, busdma_lock_mutex, &Giant, - &sc->mcs_tag); + error = bus_dma_tag_create(bus_get_dma_tag(dev), 4, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + sizeof(struct fxp_cb_mcs), 1, sizeof(struct fxp_cb_mcs), 0, + busdma_lock_mutex, &Giant, &sc->mcs_tag); if (error) { device_printf(dev, "could not allocate dma tag\n"); goto fail; @@ -772,7 +768,6 @@ ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = fxp_ioctl; ifp->if_start = fxp_start; - ifp->if_watchdog = fxp_watchdog; ifp->if_capabilities = ifp->if_capenable = 0; @@ -813,8 +808,8 @@ /* * Hook our interrupt after all initialization is complete. */ - error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE, - fxp_intr, sc, &sc->ih); + error = bus_setup_intr(dev, sc->fxp_res[1], INTR_TYPE_NET | INTR_MPSAFE, + NULL, fxp_intr, sc, &sc->ih); if (error) { device_printf(dev, "could not setup irq\n"); ether_ifdetach(sc->ifp); @@ -858,10 +853,7 @@ bus_dmamap_unload(sc->mcs_tag, sc->mcs_map); bus_dmamem_free(sc->mcs_tag, sc->mcsp, sc->mcs_map); } - if (sc->irq) - bus_release_resource(sc->dev, SYS_RES_IRQ, 0, sc->irq); - if (sc->mem) - bus_release_resource(sc->dev, sc->rtp, sc->rgd, sc->mem); + bus_release_resources(sc->dev, sc->fxp_spec, sc->fxp_res); if (sc->fxp_mtag) { for (i = 0; i < FXP_NRFABUFS; i++) { rxp = &sc->fxp_desc.rx_list[i]; @@ -930,7 +922,7 @@ * Unhook interrupt before dropping lock. This is to prevent * races with fxp_intr(). */ - bus_teardown_intr(sc->dev, sc->irq, sc->ih); + bus_teardown_intr(sc->dev, sc->fxp_res[1], sc->ih); sc->ih = NULL; /* Release our allocated resources. */ @@ -1417,7 +1409,7 @@ * Set a 5 second timer just in case we don't hear * from the card again. */ - ifp->if_timer = 5; + sc->watchdog_timer = 5; } txp->tx_cb->tx_threshold = tx_threshold; @@ -1598,7 +1590,7 @@ if (statack & (FXP_SCB_STATACK_CXTNO | FXP_SCB_STATACK_CNA)) { fxp_txeof(sc); - ifp->if_timer = 0; + sc->watchdog_timer = 0; if (sc->tx_queued == 0) { if (sc->need_mcsetup) fxp_mc_setup(sc); @@ -1826,6 +1818,11 @@ mii_tick(device_get_softc(sc->miibus)); /* + * Check that chip hasn't hung. + */ + fxp_watchdog(sc); + + /* * Schedule another timeout one second from now. */ callout_reset(&sc->stat_ch, hz, fxp_tick, sc); @@ -1843,7 +1840,7 @@ int i; ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - ifp->if_timer = 0; + sc->watchdog_timer = 0; /* * Cancel stats updater. @@ -1885,16 +1882,18 @@ * card has wedged for some reason. */ static void -fxp_watchdog(struct ifnet *ifp) +fxp_watchdog(struct fxp_softc *sc) { - struct fxp_softc *sc = ifp->if_softc; - FXP_LOCK(sc); + FXP_LOCK_ASSERT(sc, MA_OWNED); + + if (sc->watchdog_timer == 0 || --sc->watchdog_timer) + return; + device_printf(sc->dev, "device timeout\n"); - ifp->if_oerrors++; + sc->ifp->if_oerrors++; fxp_init_body(sc); - FXP_UNLOCK(sc); } /* @@ -2099,8 +2098,7 @@ cb_ias->cb_status = 0; cb_ias->cb_command = htole16(FXP_CB_COMMAND_IAS | FXP_CB_COMMAND_EL); cb_ias->link_addr = 0xffffffff; - bcopy(IFP2ENADDR(sc->ifp), cb_ias->macaddr, - sizeof(IFP2ENADDR(sc->ifp))); + bcopy(IF_LLADDR(sc->ifp), cb_ias->macaddr, ETHER_ADDR_LEN); /* * Start the IAS (Individual Address Setup) command/DMA. @@ -2205,6 +2203,11 @@ mii = device_get_softc(sc->miibus); FXP_LOCK(sc); + if (mii->mii_instance) { + struct mii_softc *miisc; + LIST_FOREACH(miisc, &mii->mii_phys, mii_list) + mii_phy_reset(miisc); + } mii_mediachg(mii); FXP_UNLOCK(sc); return (0); @@ -2225,7 +2228,8 @@ ifmr->ifm_active = mii->mii_media_active; ifmr->ifm_status = mii->mii_media_status; - if (ifmr->ifm_status & IFM_10_T && sc->flags & FXP_FLAG_CU_RESUME_BUG) + if (IFM_SUBTYPE(ifmr->ifm_active) == IFM_10_T && + sc->flags & FXP_FLAG_CU_RESUME_BUG) sc->cu_resume_bug = 1; else sc->cu_resume_bug = 0; @@ -2319,7 +2323,7 @@ return (0); } -static volatile int +static int fxp_miibus_readreg(device_t dev, int phy, int reg) { struct fxp_softc *sc = device_get_softc(dev); @@ -2515,7 +2519,6 @@ fxp_mc_setup(struct fxp_softc *sc) { struct fxp_cb_mcs *mcsp = sc->mcsp; - struct ifnet *ifp = sc->ifp; struct fxp_tx *txp; int count; @@ -2562,7 +2565,7 @@ * Set a 5 second timer just in case we don't hear from the * card again. */ - ifp->if_timer = 5; + sc->watchdog_timer = 5; return; } @@ -2604,7 +2607,7 @@ CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->mcs_addr); fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_START); - ifp->if_timer = 2; + sc->watchdog_timer = 2; return; } Modified: haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpvar.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpvar.h 2007-11-29 18:56:03 UTC (rev 23019) +++ haiku/trunk/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpvar.h 2007-11-29 19:12:20 UTC (rev 23020) @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/fxp/if_fxpvar.h,v 1.37.2.1 2005/08/26 14:35:45 jhb Exp $ + * $FreeBSD: src/sys/dev/fxp/if_fxpvar.h,v 1.40 2006/11/30 14:58:01 glebius Exp $ */ /* @@ -142,14 +142,10 @@ */ struct fxp_softc { struct ifnet *ifp; /* per-interface network data */ - struct resource *mem; /* resource descriptor for registers */ - int rtp; /* register resource type */ - int rgd; /* register descriptor in use */ - struct resource *irq; /* resource descriptor for interrupt */ + struct resource *fxp_res[2]; /* I/O and IRQ resources */ + struct resource_spec *fxp_spec; /* the resource spec we used */ void *ih; /* interrupt handler cookie */ struct mtx sc_mtx; - bus_space_tag_t sc_st; /* bus space tag */ - bus_space_handle_t sc_sh; /* bus space handle */ bus_dma_tag_t fxp_mtag; /* bus DMA tag for mbufs */ bus_dma_tag_t fxp_stag; /* bus DMA tag for stats */ bus_dmamap_t fxp_smap; /* bus DMA map for stats */ @@ -166,6 +162,7 @@ uint32_t stats_addr; /* DMA address of the stats structure */ int rx_idle_secs; /* # of seconds RX has been idle */ struct callout stat_ch; /* stat callout */ + int watchdog_timer; /* seconds until chip reset */ struct fxp_cb_mcs *mcsp; /* Pointer to mcast setup descriptor */ uint32_t mcs_addr; /* DMA address of the multicast cmd */ struct ifmedia sc_media; /* media information */ @@ -198,15 +195,9 @@ #define FXP_FLAG_SAVE_BAD 0x0800 /* save bad pkts: bad size, CRC, etc */ /* Macros to ease CSR access. */ -#define CSR_READ_1(sc, reg) \ - bus_space_read_1((sc)->sc_st, (sc)->sc_sh, (reg)) -#define CSR_READ_2(sc, reg) \ - bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (reg)) -#define CSR_READ_4(sc, reg) \ - bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg)) -#define CSR_WRITE_1(sc, reg, val) \ - bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val)) -#define CSR_WRITE_2(sc, reg, val) \ - bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val)) -#define CSR_WRITE_4(sc, reg, val) \ - bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val)) +#define CSR_READ_1(sc, reg) bus_read_1(sc->fxp_res[0], reg) +#define CSR_READ_2(sc, reg) bus_read_2(sc->fxp_res[0], reg) +#define CSR_READ_4(sc, reg) bus_read_4(sc->fxp_res[0], reg) +#define CSR_WRITE_1(sc, reg, val) bus_write_1(sc->fxp_res[0], reg, val) +#define CSR_WRITE_2(sc, reg, val) bus_write_2(sc->fxp_res[0], reg, val) +#define CSR_WRITE_4(sc, reg, val) bus_write_4(sc->fxp_res[0], reg, val) From korli at mail.berlios.de Thu Nov 29 21:10:31 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 29 Nov 2007 21:10:31 +0100 Subject: [Haiku-commits] r23021 - haiku/trunk/build/jam Message-ID: <200711292010.lATKAVTq018684@sheep.berlios.de> Author: korli Date: 2007-11-29 21:10:31 +0100 (Thu, 29 Nov 2007) New Revision: 23021 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23021&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: ipro1000 doesn't build on ppc Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-11-29 19:12:20 UTC (rev 23020) +++ haiku/trunk/build/jam/HaikuImage 2007-11-29 20:10:31 UTC (rev 23021) @@ -116,7 +116,7 @@ $(X86_ONLY)s3savage $(X86_ONLY)via vesa #$(X86_ONLY)vmware ; BEOS_ADD_ONS_DRIVERS_MIDI = emuxki ; -BEOS_ADD_ONS_DRIVERS_NET = $(X86_ONLY)3com etherpci ipro1000 $(X86_ONLY)rtl8139 rtl8169 sis900 +BEOS_ADD_ONS_DRIVERS_NET = $(X86_ONLY)3com etherpci $(X86_ONLY)ipro1000 $(X86_ONLY)rtl8139 rtl8169 sis900 $(X86_ONLY)via_rhine wb840 net_stack #vlance $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; From mmu_man at mail.berlios.de Thu Nov 29 22:48:35 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 29 Nov 2007 22:48:35 +0100 Subject: [Haiku-commits] r23022 - haiku/trunk/src/bin Message-ID: <200711292148.lATLmYwj026348@sheep.berlios.de> Author: mmu_man Date: 2007-11-29 22:48:33 +0100 (Thu, 29 Nov 2007) New Revision: 23022 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23022&view=rev Added: haiku/trunk/src/bin/WindowShade.cpp Modified: haiku/trunk/src/bin/Jamfile Log: A WindowShade mockup, not yet functionnal. Modified: haiku/trunk/src/bin/Jamfile =================================================================== --- haiku/trunk/src/bin/Jamfile 2007-11-29 20:10:31 UTC (rev 23021) +++ haiku/trunk/src/bin/Jamfile 2007-11-29 21:48:33 UTC (rev 23022) @@ -101,6 +101,7 @@ setversion.cpp urlwrapper.cpp version.cpp + WindowShade.cpp # yes.cpp : be : $(haiku-utils_rsrc) ; Added: haiku/trunk/src/bin/WindowShade.cpp =================================================================== --- haiku/trunk/src/bin/WindowShade.cpp 2007-11-29 20:10:31 UTC (rev 23021) +++ haiku/trunk/src/bin/WindowShade.cpp 2007-11-29 21:48:33 UTC (rev 23022) @@ -0,0 +1,110 @@ +/* + * Copyright 2007, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol, revol at free.fr + * Axel D?rfler, axeld at pinc-software.de + */ + + +#include +#include + +#include +#include +#include + + +static int sColorWhich = -1; +static struct option const kLongOptions[] = { + {"activetab", required_argument, &sColorWhich, B_WINDOW_TAB_COLOR}, + {"frame", required_argument, &sColorWhich, B_WINDOW_INACTIVE_TAB_COLOR}, //XXX:?? + {"activeborder", required_argument, &sColorWhich, -1}, //XXX:?? + {"inactiveborder", required_argument, &sColorWhich, -1}, //XXX:?? + {"activetitle", required_argument, &sColorWhich, B_WINDOW_TEXT_COLOR}, + {"inactivetitle", required_argument, &sColorWhich, B_WINDOW_INACTIVE_TEXT_COLOR}, + {"sum", required_argument, 0, 's'}, + {"refresh", no_argument, 0, 'r'}, + {"help", no_argument, 0, 'h'}, + {NULL} +}; + +extern const char *__progname; +static const char *sProgramName = __progname; + + +void +usage(void) +{ + printf("%s [-sum md5sum] [colID colspec] [-refresh]\n", sProgramName); + printf("Tweak the default window decorator colors.\n"); + printf("\t-sum deprecated option, kept for compatibility\n"); + printf("\t-refresh refresh the entire display (force update)\n"); + printf("\tcolID can be:\n"); + printf("\t-activetab\n"); + printf("\t-frame\n"); + printf("\t-activeborder\n"); + printf("\t-inactiveborder\n"); + printf("\t-activetitle\n"); + printf("\t-inactivetitle\n"); + printf("\tcolspec is a 6 digit hexadecimal color number. \n" + "\t\t\t(rrggbb, html format)\n"); +} + + +static int +UpdateUIColor(color_which which, const char *str) +{ + rgb_color color; + unsigned int r, g, b; + if (which < 0) + return -1; + // parse + if (!str || !str[0]) + return -1; + if (str[0] == '#') + str++; + if (sscanf(str, "%02x%02x%02x", &r, &g, &b) < 3) + return -1; + color.red = r; + color.green = g; + color.blue = b; + color.alpha = 255; + //printf("setting %d to {%d, %d, %d, %d}\n", which, r, g, b, 255); + set_ui_color(which, color); + return B_OK; +} + +int +main(int argc, char **argv) +{ + BApplication app("application/x-vnd.Haiku-WindowShade"); + int c; + + // parse command line parameters + + while ((c = getopt_long_only(argc, argv, "h", kLongOptions, NULL)) != -1) { + switch (c) { + case 0: + UpdateUIColor((color_which)sColorWhich, optarg); + break; + case 'h': + usage(); + return 0; + default: + usage(); + return 1; + + case 'r': + // TODO: refresh (but shouldn't be needed) + break; + case 's': + // IGNORED, for compatibility with original app + break; + } + sColorWhich = -1; + } + + return 0; +} From mmu_man at mail.berlios.de Fri Nov 30 02:18:24 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 30 Nov 2007 02:18:24 +0100 Subject: [Haiku-commits] r23023 - haiku/trunk/src/bin Message-ID: <200711300118.lAU1IOkB023655@sheep.berlios.de> Author: mmu_man Date: 2007-11-30 02:18:23 +0100 (Fri, 30 Nov 2007) New Revision: 23023 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23023&view=rev Modified: haiku/trunk/src/bin/WindowShade.cpp Log: Test code to set other ui_colors... Modified: haiku/trunk/src/bin/WindowShade.cpp =================================================================== --- haiku/trunk/src/bin/WindowShade.cpp 2007-11-29 21:48:33 UTC (rev 23022) +++ haiku/trunk/src/bin/WindowShade.cpp 2007-11-30 01:18:23 UTC (rev 23023) @@ -24,6 +24,41 @@ {"inactiveborder", required_argument, &sColorWhich, -1}, //XXX:?? {"activetitle", required_argument, &sColorWhich, B_WINDOW_TEXT_COLOR}, {"inactivetitle", required_argument, &sColorWhich, B_WINDOW_INACTIVE_TEXT_COLOR}, + //temporary stuff + // grep ' B_.*_COLOR' headers/os/interface/InterfaceDefs.h | awk '{ print "I(" substr(tolower($1),3) ", " $1 ")," }' +#define I(l,v) \ + { #l, required_argument, &sColorWhich, v }, \ + { #v, required_argument, &sColorWhich, v } + +I(panel_background_color, B_PANEL_BACKGROUND_COLOR), +I(panel_text_color, B_PANEL_TEXT_COLOR), +I(document_background_color, B_DOCUMENT_BACKGROUND_COLOR), +I(document_text_color, B_DOCUMENT_TEXT_COLOR), +I(control_background_color, B_CONTROL_BACKGROUND_COLOR), +I(control_text_color, B_CONTROL_TEXT_COLOR), +I(control_border_color, B_CONTROL_BORDER_COLOR), +I(control_highlight_color, B_CONTROL_HIGHLIGHT_COLOR), +I(navigation_base_color, B_NAVIGATION_BASE_COLOR), +I(navigation_pulse_color, B_NAVIGATION_PULSE_COLOR), +I(shine_color, B_SHINE_COLOR), +I(shadow_color, B_SHADOW_COLOR), +I(menu_background_color, B_MENU_BACKGROUND_COLOR), +I(menu_selected_background_color, B_MENU_SELECTED_BACKGROUND_COLOR), +I(menu_item_text_color, B_MENU_ITEM_TEXT_COLOR), +I(menu_selected_item_text_color, B_MENU_SELECTED_ITEM_TEXT_COLOR), +I(menu_selected_border_color, B_MENU_SELECTED_BORDER_COLOR), +I(tooltip_background_color, B_TOOLTIP_BACKGROUND_COLOR), +I(tooltip_text_color, B_TOOLTIP_TEXT_COLOR), +I(success_color, B_SUCCESS_COLOR), +I(failure_color, B_FAILURE_COLOR), +I(keyboard_navigation_color, B_KEYBOARD_NAVIGATION_COLOR), +I(menu_selection_background_color, B_MENU_SELECTION_BACKGROUND_COLOR), +I(desktop_color, B_DESKTOP_COLOR), +I(window_tab_color, B_WINDOW_TAB_COLOR), +I(window_text_color, B_WINDOW_TEXT_COLOR), +I(window_inactive_tab_color, B_WINDOW_INACTIVE_TAB_COLOR), +I(window_inactive_text_color, B_WINDOW_INACTIVE_TEXT_COLOR), + {"sum", required_argument, 0, 's'}, {"refresh", no_argument, 0, 'r'}, {"help", no_argument, 0, 'h'}, From mmu_man at mail.berlios.de Fri Nov 30 02:21:20 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 30 Nov 2007 02:21:20 +0100 Subject: [Haiku-commits] r23024 - haiku/trunk/src/servers/app Message-ID: <200711300121.lAU1LJ6S024141@sheep.berlios.de> Author: mmu_man Date: 2007-11-30 02:21:19 +0100 (Fri, 30 Nov 2007) New Revision: 23024 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23024&view=rev Modified: haiku/trunk/src/servers/app/DesktopSettings.cpp haiku/trunk/src/servers/app/DesktopSettings.h haiku/trunk/src/servers/app/DesktopSettingsPrivate.h haiku/trunk/src/servers/app/ServerApp.cpp Log: Propagate set_ui_color() up to the DesktopSettingsPrivate class. Still needs code to save the values. Also needs a way to access them from Decorator::UIColor(), but the DesktopSettings passed to the ctor can't be cached. Modified: haiku/trunk/src/servers/app/DesktopSettings.cpp =================================================================== --- haiku/trunk/src/servers/app/DesktopSettings.cpp 2007-11-30 01:18:23 UTC (rev 23023) +++ haiku/trunk/src/servers/app/DesktopSettings.cpp 2007-11-30 01:21:19 UTC (rev 23024) @@ -478,6 +478,29 @@ } +void +DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color) +{ + // + int32 index = color_which_to_index(which); + if (index < 0 || index >= kNumColors) + return; + fShared.colors[index] = color; + Save(kAppearanceSettings); +} + + +rgb_color +DesktopSettingsPrivate::UIColor(color_which which) const +{ + static const rgb_color invalidColor = {0, 0, 0, 0}; + int32 index = color_which_to_index(which); + if (index < 0 || index >= kNumColors) + return invalidColor; + return fShared.colors[index]; +} + + // #pragma mark - read access @@ -563,6 +586,13 @@ } +rgb_color +DesktopSettings::UIColor(color_which which) const +{ + return fSettings->UIColor(which); +} + + // #pragma mark - write access @@ -633,3 +663,11 @@ fSettings->SetShowAllDraggers(show); } + +void +LockedDesktopSettings::SetUIColor(color_which which, const rgb_color color) +{ + fSettings->SetUIColor(which, color); +} + + Modified: haiku/trunk/src/servers/app/DesktopSettings.h =================================================================== --- haiku/trunk/src/servers/app/DesktopSettings.h 2007-11-30 01:18:23 UTC (rev 23023) +++ haiku/trunk/src/servers/app/DesktopSettings.h 2007-11-30 01:21:19 UTC (rev 23024) @@ -50,6 +50,8 @@ int32 WorkspacesCount() const; const BMessage* WorkspacesMessage(int32 index) const; + rgb_color UIColor(color_which which) const; + protected: DesktopSettingsPrivate* fSettings; }; @@ -70,6 +72,8 @@ void SetShowAllDraggers(bool show); + void SetUIColor(color_which which, const rgb_color color); + private: Desktop* fDesktop; }; Modified: haiku/trunk/src/servers/app/DesktopSettingsPrivate.h =================================================================== --- haiku/trunk/src/servers/app/DesktopSettingsPrivate.h 2007-11-30 01:18:23 UTC (rev 23023) +++ haiku/trunk/src/servers/app/DesktopSettingsPrivate.h 2007-11-30 01:21:19 UTC (rev 23024) @@ -52,6 +52,8 @@ void SetWorkspacesMessage(int32 index, BMessage& message); const BMessage* WorkspacesMessage(int32 index) const; + void SetUIColor(color_which which, const rgb_color color); + rgb_color UIColor(color_which which) const; private: void _SetDefaults(); status_t _Load(); Modified: haiku/trunk/src/servers/app/ServerApp.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerApp.cpp 2007-11-30 01:18:23 UTC (rev 23023) +++ haiku/trunk/src/servers/app/ServerApp.cpp 2007-11-30 01:21:19 UTC (rev 23024) @@ -2274,6 +2274,26 @@ break; } + case AS_SET_UI_COLOR: + { + STRACE(("ServerApp %s: Set UI Color\n", Signature())); + // Attached Data: + // 1) color_which which + // 2) rgb_color color + color_which which; + rgb_color color; + + link.Read(&which); + if (link.Read(&color) == B_OK) { + LockedDesktopSettings settings(fDesktop); + settings.SetUIColor(which, color); + } + + fLink.StartMessage(B_OK); + fLink.Flush(); + break; + } + case AS_GET_ACCELERANT_INFO: { STRACE(("ServerApp %s: get accelerant info\n", Signature())); From axeld at pinc-software.de Fri Nov 30 10:30:44 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 30 Nov 2007 10:30:44 +0100 CET Subject: [Haiku-commits] r23022 - haiku/trunk/src/bin In-Reply-To: <200711292148.lATLmYwj026348@sheep.berlios.de> Message-ID: <1768568463-BeMail@zon> mmu_man at BerliOS wrote: > Log: > A WindowShade mockup, not yet functionnal. Hm, we already have the (non-functional) Appearance app around, do we really need another (non-functional) app to do the same thing? :-) If you want to have the (not-working) functionality available on the command line, I think it would make more sense to add a command line mode to Appearance rather than adding a new app. Bye, Axel. From axeld at mail.berlios.de Fri Nov 30 10:40:54 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 30 Nov 2007 10:40:54 +0100 Subject: [Haiku-commits] r23025 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711300940.lAU9esb0001300@sheep.berlios.de> Author: axeld Date: 2007-11-30 10:40:52 +0100 (Fri, 30 Nov 2007) New Revision: 23025 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23025&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/driver.c Log: Since device_add_child() needs the name of the parent driver, the root device needs a driver_t object, too. Modified: haiku/trunk/src/libs/compat/freebsd_network/driver.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/driver.c 2007-11-30 01:21:19 UTC (rev 23024) +++ haiku/trunk/src/libs/compat/freebsd_network/driver.c 2007-11-30 09:40:52 UTC (rev 23025) @@ -42,6 +42,11 @@ static status_t init_root_device(driver_t *driver, device_t *_root, device_t *_child) { + static driver_t sRootDriver = { + "pci", + NULL, + sizeof(struct root_device_softc) + }; device_t child; device_t root = device_add_child(NULL, NULL, 0); @@ -54,6 +59,8 @@ return B_NO_MEMORY; } + root->driver = &sRootDriver; + child = device_add_child(root, driver->name, 0); if (child == NULL) { device_delete_child(NULL, root); From revol at free.fr Fri Nov 30 10:59:02 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 30 Nov 2007 10:59:02 +0100 CET Subject: [Haiku-commits] r23022 - haiku/trunk/src/bin In-Reply-To: <1768568463-BeMail@zon> Message-ID: <753699427-BeMail@laptop> > mmu_man at BerliOS wrote: > > Log: > > A WindowShade mockup, not yet functionnal. > > Hm, we already have the (non-functional) Appearance app around, do we > really need another (non-functional) app to do the same thing? :-) > If you want to have the (not-working) functionality available on the > command line, I think it would make more sense to add a command line > mode to Appearance rather than adding a new app. That was for binary compatibility with the few R5 apps using it. The code can probably be added to Appearance's ArgsReceived and symlinked. That was mainly to prepare for a bigger fish :p Fran?ois. From revol at free.fr Fri Nov 30 10:59:47 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 30 Nov 2007 10:59:47 +0100 CET Subject: [Haiku-commits] r23025 - haiku/trunk/src/libs/compat/freebsd_network In-Reply-To: <200711300940.lAU9esb0001300@sheep.berlios.de> Message-ID: <798705720-BeMail@laptop> > Author: axeld > Date: 2007-11-30 10:40:52 +0100 (Fri, 30 Nov 2007) > New Revision: 23025 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23025&view=rev > > Modified: > haiku/trunk/src/libs/compat/freebsd_network/driver.c > Log: > Since device_add_child() needs the name of the parent driver, the > root > device needs a driver_t object, too. Ahh, suppose I can add back net drivers to the image now :) Fran?ois. From axeld at mail.berlios.de Fri Nov 30 13:28:52 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 30 Nov 2007 13:28:52 +0100 Subject: [Haiku-commits] r23026 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200711301228.lAUCSqho005653@sheep.berlios.de> Author: axeld Date: 2007-11-30 13:28:51 +0100 (Fri, 30 Nov 2007) New Revision: 23026 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23026&view=rev Removed: haiku/trunk/src/libs/compat/freebsd_network/pci.c Modified: haiku/trunk/src/libs/compat/freebsd_network/Jamfile haiku/trunk/src/libs/compat/freebsd_network/callout.c haiku/trunk/src/libs/compat/freebsd_network/compat.c haiku/trunk/src/libs/compat/freebsd_network/device.c haiku/trunk/src/libs/compat/freebsd_network/driver.c haiku/trunk/src/libs/compat/freebsd_network/if.c Log: * compat_open() still needs to get the stack module, as the callout functionality needs it. * callout_init_mtx() now initializes the timer manually, since the stack might not have been loaded yet (since a device is now attached in init_driver()). * Minor other fixes; the FreeBSD compatibility layer should now be functional again. * Accidently put pci.c into the repository, but that was never meant to happen. Modified: haiku/trunk/src/libs/compat/freebsd_network/Jamfile =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/Jamfile 2007-11-30 09:40:52 UTC (rev 23025) +++ haiku/trunk/src/libs/compat/freebsd_network/Jamfile 2007-11-30 12:28:51 UTC (rev 23026) @@ -24,6 +24,5 @@ mbuf.c mii.c mutex.c - pci.c taskqueue.c ; Modified: haiku/trunk/src/libs/compat/freebsd_network/callout.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/callout.c 2007-11-30 09:40:52 UTC (rev 23025) +++ haiku/trunk/src/libs/compat/freebsd_network/callout.c 2007-11-30 12:28:51 UTC (rev 23026) @@ -1,9 +1,6 @@ /* * Copyright 2007, Hugo Santos. All Rights Reserved. * Distributed under the terms of the MIT License. - * - * Authors: - * Hugo Santos, hugosantos at gmail.com */ #include "device.h" @@ -33,7 +30,11 @@ void callout_init_mtx(struct callout *c, struct mtx *mtx, int flags) { - gStack->init_timer(&c->c_timer, handle_callout, c); + // we must manually initialize the timer, since the networking + // stack might not be loaded yet + c->c_timer.hook = handle_callout; + c->c_timer.data = c; + c->c_timer.due = 0; c->c_arg = NULL; c->c_func = NULL; Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-30 09:40:52 UTC (rev 23025) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-30 12:28:51 UTC (rev 23026) @@ -279,7 +279,7 @@ driver_t **driver; char symbol[128]; - snprintf(symbol, sizeof(symbol), "__fbsd_%s%s", name, + snprintf(symbol, sizeof(symbol), "__fbsd_%s_%s", name, parent->driver->name); if (get_image_symbol(find_own_image(), symbol, B_SYMBOL_TYPE_DATA, (void **)&driver) == B_OK) @@ -479,11 +479,11 @@ void * _kernel_malloc(size_t size, int flags) { - // our kernel malloc() is insufficent, must handle M_WAIT + // our kernel malloc() is insufficient, must handle M_WAIT void *ptr = malloc(size); if (ptr == NULL) - return ptr; + return NULL; if (flags & M_ZERO) memset(ptr, 0, size); @@ -518,8 +518,8 @@ if (flags & M_ZERO) memset(addr, 0, size); - driver_printf("(%s) addr = %p, area = %ld, size = %lu\n", - name, addr, area, size); + //driver_printf("(%s) addr = %p, area = %ld, size = %lu\n", + // name, addr, area, size); return addr; } Modified: haiku/trunk/src/libs/compat/freebsd_network/device.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-30 09:40:52 UTC (rev 23025) +++ haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-11-30 12:28:51 UTC (rev 23026) @@ -36,11 +36,16 @@ if (gDeviceNameList[i] == NULL) return B_ERROR; + if (get_module(NET_STACK_MODULE_NAME, (module_info **)&gStack) != B_OK) + return B_ERROR; + ifp = gDevices[i]; if_printf(ifp, "compat_open(0x%lx)\n", flags); - if (!atomic_test_and_set(&ifp->open_count, 1, 0)) + if (atomic_or(&ifp->open_count, 1)) { + put_module(NET_STACK_MODULE_NAME); return B_BUSY; + } ifp->if_flags &= ~IFF_UP; ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); @@ -83,6 +88,7 @@ /* TODO: empty out the send queue */ atomic_and(&ifp->open_count, 0); + put_module(NET_STACK_MODULE_NAME); return B_OK; } Modified: haiku/trunk/src/libs/compat/freebsd_network/driver.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/driver.c 2007-11-30 09:40:52 UTC (rev 23025) +++ haiku/trunk/src/libs/compat/freebsd_network/driver.c 2007-11-30 12:28:51 UTC (rev 23026) @@ -60,6 +60,7 @@ } root->driver = &sRootDriver; + root->root = root; child = device_add_child(root, driver->name, 0); if (child == NULL) { @@ -138,8 +139,8 @@ status_t _fbsd_init_driver(driver_t *driver) { - int i, found = 0; status_t status; + int i = 0; dprintf("%s: init_driver(%p)\n", gDriverName, driver); @@ -163,8 +164,6 @@ goto err3; } - i = 0; - while (gDeviceCount < MAX_DEVICES) { device_t root, device; bool found = false; @@ -180,10 +179,11 @@ if (device->methods.probe(device) < 0) continue; - if (device_attach(device) == 0) { + if (device_attach(device) == 0) found = true; - break; - } + + i++; + break; } if (!found) { @@ -192,10 +192,10 @@ } } - if (gDeviceCount > 0) { - TRACE(("%s, ... %d cards.\n", gDriverName, found)); + if (gDeviceCount > 0) return B_OK; - } else if (status == B_OK) + + if (status == B_OK) status = B_ERROR; if (HAIKU_DRIVER_REQUIRES(FBSD_TASKQUEUES)) @@ -217,7 +217,7 @@ TRACE(("%s: uninit_driver(%p)\n", gDriverName, driver)); - for (i = 0; gDeviceNameList[i] != NULL; i++) { + for (i = 0; i < gDeviceCount; i++) { device_delete_child(NULL, gDevices[i]->root_device); } Modified: haiku/trunk/src/libs/compat/freebsd_network/if.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/if.c 2007-11-30 09:40:52 UTC (rev 23025) +++ haiku/trunk/src/libs/compat/freebsd_network/if.c 2007-11-30 12:28:51 UTC (rev 23026) @@ -48,6 +48,7 @@ } ifp->link_state_sem = -1; + ifp->open_count = 0; ifp->flags = 0; ifq_init(&ifp->receive_queue, semName); Deleted: haiku/trunk/src/libs/compat/freebsd_network/pci.c From axeld at mail.berlios.de Fri Nov 30 13:31:33 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 30 Nov 2007 13:31:33 +0100 Subject: [Haiku-commits] r23027 - haiku/trunk/build/jam Message-ID: <200711301231.lAUCVXAC006024@sheep.berlios.de> Author: axeld Date: 2007-11-30 13:31:33 +0100 (Fri, 30 Nov 2007) New Revision: 23027 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23027&view=rev Modified: haiku/trunk/build/jam/NetBootArchive Log: Added marvell_yukon driver, and marked all FreeBSD drivers to be compiled for x86 only (for now, that should be easily fixable). Modified: haiku/trunk/build/jam/NetBootArchive =================================================================== --- haiku/trunk/build/jam/NetBootArchive 2007-11-30 12:28:51 UTC (rev 23026) +++ haiku/trunk/build/jam/NetBootArchive 2007-11-30 12:31:33 UTC (rev 23027) @@ -19,8 +19,9 @@ ipv4_datagram ; BEOS_NETWORK_PROTOCOLS = ipv4 tcp udp icmp ; -BEOS_ADD_ONS_DRIVERS_NET = 3com etherpci ipro1000 rtl8139 rtl8169 sis900 - via_rhine wb840 net_stack vlance +BEOS_ADD_ONS_DRIVERS_NET = $(X86_ONLY)3com etherpci $(X86_ONLY)ipro1000 + $(X86_ONLY)rtl8139 rtl8169 sis900 + $(X86_ONLY)marvell_yukon $(X86_ONLY)via_rhine wb840 net_stack vlance $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)isa ide scsi From axeld at pinc-software.de Fri Nov 30 14:29:48 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 30 Nov 2007 14:29:48 +0100 CET Subject: [Haiku-commits] r23025 - haiku/trunk/src/libs/compat/freebsd_network In-Reply-To: <798705720-BeMail@laptop> Message-ID: <16112252079-BeMail@zon> "Fran?ois Revol" wrote: > > Log: > > Since device_add_child() needs the name of the parent driver, the > > root device needs a driver_t object, too. > Ahh, suppose I can add back net drivers to the image now :) Indeed; I just didn't have the time to check my changes yesterday, sorry. Bye, Axel. From axeld at pinc-software.de Fri Nov 30 14:30:52 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 30 Nov 2007 14:30:52 +0100 CET Subject: [Haiku-commits] r23022 - haiku/trunk/src/bin In-Reply-To: <753699427-BeMail@laptop> Message-ID: <16176532990-BeMail@zon> "Fran?ois Revol" wrote: > > mmu_man at BerliOS wrote: > > > Log: > > > A WindowShade mockup, not yet functionnal. > > Hm, we already have the (non-functional) Appearance app around, do > > we > > really need another (non-functional) app to do the same thing? :-) > > If you want to have the (not-working) functionality available on > > the > > command line, I think it would make more sense to add a command > > line > > mode to Appearance rather than adding a new app. > That was for binary compatibility with the few R5 apps using it. > The code can probably be added to Appearance's ArgsReceived and > symlinked. There is no WindowShade app on any of my BeOS installations, so there is no reason for any backwards compatibility either. > That was mainly to prepare for a bigger fish :p OMG, what might that be? :-0 Bye, Axel. From revol at free.fr Fri Nov 30 14:59:31 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 30 Nov 2007 14:59:31 +0100 CET Subject: [Haiku-commits] r23025 - haiku/trunk/src/libs/compat/freebsd_network In-Reply-To: <16112252079-BeMail@zon> Message-ID: <918475479-BeMail@laptop> > "Fran?ois Revol" wrote: > > > Log: > > > Since device_add_child() needs the name of the parent driver, the > > > root device needs a driver_t object, too. > > Ahh, suppose I can add back net drivers to the image now :) > > Indeed; I just didn't have the time to check my changes yesterday, > sorry. Working again now, thx. Fran?ois. From axeld at mail.berlios.de Fri Nov 30 15:10:53 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 30 Nov 2007 15:10:53 +0100 Subject: [Haiku-commits] r23028 - haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp Message-ID: <200711301410.lAUEArPi020684@sheep.berlios.de> Author: axeld Date: 2007-11-30 15:10:52 +0100 (Fri, 30 Nov 2007) New Revision: 23028 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23028&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp Log: * We now cache the local hardware address in the protocol object. This allows us to not have to look it up in arp_send_data(), and also to have more than one uninitialized interface around (ie. set to INADDR_ANY), and still have the ARP layer act correctly. * arp_update_entry() now allows entries that link to INADDR_ANY to be updated at will. This fixes trying to bring more than one uninitialized interface up. * Some cleanup. Modified: haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp 2007-11-30 12:31:33 UTC (rev 23027) +++ haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp 2007-11-30 14:10:52 UTC (rev 23028) @@ -81,8 +81,8 @@ static int Compare(void *_entry, const void *_key); static uint32 Hash(void *_entry, const void *_key, uint32 range); static arp_entry *Lookup(in_addr_t protocolAddress); - static arp_entry *Add(in_addr_t protocolAddress, sockaddr_dl *hardwareAddress, - uint32 flags); + static arp_entry *Add(in_addr_t protocolAddress, + sockaddr_dl *hardwareAddress, uint32 flags); ~arp_entry(); @@ -105,6 +105,7 @@ #define ARP_REQUEST_TIMEOUT 1000000LL // 1 second struct arp_protocol : net_datalink_protocol { + sockaddr_dl hardware_address; }; @@ -251,6 +252,9 @@ static void ipv4_to_ether_multicast(sockaddr_dl *destination, const sockaddr_in *source) { + // TODO: this is ethernet specific, and doesn't belong here + // (should be moved to the ethernet_frame module) + // RFC 1112 - Host extensions for IP multicasting // // ``An IP host group address is mapped to an Ethernet multicast @@ -292,14 +296,16 @@ arp_entry *entry = arp_entry::Lookup(protocolAddress); if (entry != NULL) { // We disallow updating of entries that had been resolved before, - // but to a different address. + // but to a different address (only for those that belong to a + // specific address - redefining INADDR_ANY is always allowed). // Right now, you have to manually purge the ARP entries (or wait some // time) to let us switch to the new address. - if (entry->hardware_address.sdl_alen != 0 + if (protocolAddress != INADDR_ANY + && entry->hardware_address.sdl_alen != 0 && memcmp(LLADDR(&entry->hardware_address), LLADDR(hardwareAddress), ETHER_ADDRESS_LENGTH)) { - dprintf("ARP host %08lx updated with different hardware address %02x:%02x:%02x:%02x:%02x:%02x.\n", - protocolAddress, + dprintf("ARP host %08x updated with different hardware address " + "%02x:%02x:%02x:%02x:%02x:%02x.\n", protocolAddress, hardwareAddress->sdl_data[0], hardwareAddress->sdl_data[1], hardwareAddress->sdl_data[2], hardwareAddress->sdl_data[3], hardwareAddress->sdl_data[4], hardwareAddress->sdl_data[5]); @@ -338,7 +344,7 @@ static status_t -arp_update_local(net_datalink_protocol *protocol) +arp_update_local(arp_protocol *protocol) { net_interface *interface = protocol->interface; in_addr_t inetAddress; @@ -359,6 +365,9 @@ address.sdl_alen = interface->device->address.length; memcpy(LLADDR(&address), interface->device->address.data, address.sdl_alen); + memcpy(&protocol->hardware_address, &address, sizeof(sockaddr_dl)); + // cache the address in our protocol + arp_entry *entry; status_t status = arp_update_entry(inetAddress, &address, ARP_FLAG_LOCAL | ARP_FLAG_PERMANENT, &entry); @@ -375,14 +384,16 @@ BenaphoreLocker locker(sCacheLock); if (!sIgnoreReplies) { - arp_update_entry(header.protocol_sender, (sockaddr_dl *)buffer->source, 0); + arp_update_entry(header.protocol_sender, + (sockaddr_dl *)buffer->source, 0); // remember the address of the sender as we might need it later } // check if this request is for us arp_entry *entry = arp_entry::Lookup(header.protocol_target); - if (entry == NULL || (entry->flags & (ARP_FLAG_LOCAL | ARP_FLAG_PUBLISH)) == 0) { + if (entry == NULL + || (entry->flags & (ARP_FLAG_LOCAL | ARP_FLAG_PUBLISH)) == 0) { // We're not the one to answer this request // TODO: instead of letting the other's request time-out, can we reply // failure somehow? @@ -397,7 +408,8 @@ memcpy(header.hardware_target, header.hardware_sender, ETHER_ADDRESS_LENGTH); header.protocol_target = header.protocol_sender; - memcpy(header.hardware_sender, LLADDR(&entry->hardware_address), ETHER_ADDRESS_LENGTH); + memcpy(header.hardware_sender, LLADDR(&entry->hardware_address), + ETHER_ADDRESS_LENGTH); header.protocol_sender = entry->protocol_address; // exchange source and destination address @@ -409,7 +421,8 @@ buffer->flags = 0; // make sure this won't be a broadcast message - return entry->protocol->next->module->send_data(entry->protocol->next, buffer); + return entry->protocol->next->module->send_data(entry->protocol->next, + buffer); } @@ -465,7 +478,8 @@ case ARP_OPCODE_REQUEST: TRACE((" got ARP request\n")); if (handle_arp_request(buffer, header) == B_OK) { - // the function will take care of the buffer if everything went well + // the function will take care of the buffer if everything + // went well return B_OK; } break; @@ -496,8 +510,9 @@ break; case ARP_STATE_REQUEST_FAILED: - // requesting the ARP entry failed, we keep it around for a while, though, - // so that we won't try to request the same address again too soon. + // Requesting the ARP entry failed, we keep it around for a while, + // though, so that we won't try to request the same address again + // too soon. TRACE((" requesting ARP entry %p failed!\n", entry)); entry->timer_state = ARP_STATE_REMOVE_FAILED; entry->MarkFailed(); @@ -514,9 +529,10 @@ benaphore_unlock(&sCacheLock); delete entry; + break; - break; default: + { if (entry->timer_state > ARP_STATE_LAST_REQUEST) break; @@ -547,6 +563,8 @@ entry->timer_state++; sStackModule->set_timer(&entry->timer, ARP_REQUEST_TIMEOUT); + break; + } } } @@ -558,7 +576,8 @@ note that the lock will be interrupted here if everything goes well. */ static status_t -arp_start_resolve(net_datalink_protocol *protocol, in_addr_t address, arp_entry **_entry) +arp_start_resolve(net_datalink_protocol *protocol, in_addr_t address, + arp_entry **_entry) { // create an unresolved ARP entry as a placeholder arp_entry *entry = arp_entry::Add(address, NULL, 0); @@ -602,7 +621,8 @@ // prepare source and target addresses - struct sockaddr_dl &source = *(struct sockaddr_dl *)entry->request_buffer->source; + struct sockaddr_dl &source = *(struct sockaddr_dl *) + entry->request_buffer->source; source.sdl_len = sizeof(sockaddr_dl); source.sdl_family = AF_DLI; source.sdl_index = device->index; @@ -626,8 +646,8 @@ static status_t -arp_control(const char *subsystem, uint32 function, - void *buffer, size_t bufferSize) +arp_control(const char *subsystem, uint32 function, void *buffer, + size_t bufferSize) { struct arp_control control; if (bufferSize != sizeof(struct arp_control)) @@ -639,6 +659,7 @@ switch (function) { case ARP_SET_ENTRY: + { sockaddr_dl hardwareAddress; hardwareAddress.sdl_len = sizeof(sockaddr_dl); @@ -648,10 +669,13 @@ hardwareAddress.sdl_e_type = ETHER_TYPE_IP; hardwareAddress.sdl_nlen = hardwareAddress.sdl_slen = 0; hardwareAddress.sdl_alen = ETHER_ADDRESS_LENGTH; - memcpy(hardwareAddress.sdl_data, control.ethernet_address, ETHER_ADDRESS_LENGTH); + memcpy(hardwareAddress.sdl_data, control.ethernet_address, + ETHER_ADDRESS_LENGTH); return arp_update_entry(control.address, &hardwareAddress, - control.flags & (ARP_FLAG_PUBLISH | ARP_FLAG_PERMANENT | ARP_FLAG_REJECT)); + control.flags & (ARP_FLAG_PUBLISH | ARP_FLAG_PERMANENT + | ARP_FLAG_REJECT)); + } case ARP_GET_ENTRY: { @@ -763,7 +787,8 @@ status_t -arp_init_protocol(struct net_interface *interface, net_datalink_protocol **_protocol) +arp_init_protocol(struct net_interface *interface, + net_datalink_protocol **_protocol) { // We currently only support a single family and type! if (interface->domain->family != AF_INET @@ -780,6 +805,7 @@ if (protocol == NULL) return B_NO_MEMORY; + memset(&protocol->hardware_address, 0, sizeof(sockaddr_dl)); *_protocol = protocol; return B_OK; } @@ -797,23 +823,17 @@ status_t -arp_send_data(net_datalink_protocol *protocol, - net_buffer *buffer) +arp_send_data(net_datalink_protocol *_protocol, net_buffer *buffer) { + arp_protocol *protocol = (arp_protocol *)_protocol; { BenaphoreLocker locker(sCacheLock); - // Lookup source (us) - // TODO: this could be cached - the lookup isn't really needed at all + // Set buffer target and destination address - arp_entry *entry = arp_entry::Lookup( - ((struct sockaddr_in *)buffer->source)->sin_addr.s_addr); - if (entry == NULL) - return B_ERROR; + memcpy(buffer->source, &protocol->hardware_address, + protocol->hardware_address.sdl_len); - memcpy(buffer->source, &entry->hardware_address, - entry->hardware_address.sdl_len); - if (buffer->flags & MSG_MCAST) { sockaddr_dl multicastDestination; ipv4_to_ether_multicast(&multicastDestination, @@ -822,7 +842,7 @@ sizeof(multicastDestination)); } else if ((buffer->flags & MSG_BCAST) == 0) { // Lookup destination (we may need to wait for this) - entry = arp_entry::Lookup( + arp_entry *entry = arp_entry::Lookup( ((struct sockaddr_in *)buffer->destination)->sin_addr.s_addr); if (entry == NULL) { status_t status = arp_start_resolve(protocol, @@ -891,16 +911,19 @@ status_t -arp_control(net_datalink_protocol *protocol, - int32 op, void *argument, size_t length) +arp_control(net_datalink_protocol *_protocol, int32 op, void *argument, + size_t length) { + arp_protocol *protocol = (arp_protocol *)_protocol; + if (op == SIOCSIFADDR && (protocol->interface->flags & IFF_UP) != 0) { // The interface may get a new address, so we need to update our // local entries. bool hasOldAddress = false; in_addr_t oldAddress = 0; if (protocol->interface->address != NULL) { - oldAddress = ((sockaddr_in *)protocol->interface->address)->sin_addr.s_addr; + oldAddress = ((sockaddr_in *) + protocol->interface->address)->sin_addr.s_addr; hasOldAddress = true; } @@ -911,7 +934,8 @@ arp_update_local(protocol); - if (oldAddress == ((sockaddr_in *)protocol->interface->address)->sin_addr.s_addr + if (oldAddress == ((sockaddr_in *) + protocol->interface->address)->sin_addr.s_addr || !hasOldAddress) return B_OK; From revol at free.fr Fri Nov 30 15:13:04 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 30 Nov 2007 15:13:04 +0100 CET Subject: [Haiku-commits] r23022 - haiku/trunk/src/bin In-Reply-To: <16176532990-BeMail@zon> Message-ID: <1731917308-BeMail@laptop> > > That was for binary compatibility with the few R5 apps using it. > > The code can probably be added to Appearance's ArgsReceived and > > symlinked. > > There is no WindowShade app on any of my BeOS installations, so there > is no reason for any backwards compatibility either. On mine neither (but it didn't work on Dano), but there are a few apps on bebits using it. I know it's a toy but it's a bit funky like sliding tabs... > > That was mainly to prepare for a bigger fish :p > > OMG, what might that be? :-0 I'm digging out the theme engine I wrote long ago, which was used in Zeta (but I wrote it before working there). It's just lacking these changes to be usable there, only needs a gui. It's probably not a good idea to put it in by default, but it'd be a nice 3rd party for those liking ugly themes (Citrus anyone ? ;) Btw, to support changing colors of decors it will need to access the DesktopSettings obj when drawing, in UIColor()... but the one passed on ctor doesn't live long enough (on stack). As I didn't dig much app_server I'm wondering if I can switch it to cache the Desktop object instead, if it lives long enough, to instanciate a DesktopSettings when needed. It will also need some more colors, maybe we could allocate some color ids specifically for Decors ? B_WINDOW_DECOR_EXTRA_1_COLOR, ... that'd be color specific but would allow them to be saved in settings and changeable. Btw2, what's the guidelines for trunk/3rdparty/ ? I could put the theme engine there maybe. (or make the first Haiku-only shareware ? :P) Fran?ois. From bonefish at mail.berlios.de Fri Nov 30 15:21:17 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 30 Nov 2007 15:21:17 +0100 Subject: [Haiku-commits] r23029 - haiku/trunk/src/tests/system/libroot/posix/posixtestsuite Message-ID: <200711301421.lAUELHDW023780@sheep.berlios.de> Author: bonefish Date: 2007-11-30 15:21:17 +0100 (Fri, 30 Nov 2007) New Revision: 23029 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23029&view=rev Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh Log: Uncommented the pthread_key_create() tests. Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh 2007-11-30 14:10:52 UTC (rev 23028) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh 2007-11-30 14:21:17 UTC (rev 23029) @@ -55,10 +55,8 @@ echo "" echo "pthread_key_create()" conformance/interfaces/pthread_key_create/pthread_key_create_1-1 -# conformance/interfaces/pthread_key_create/pthread_key_create_1-2 - echo "pthread_key_create_1-2: FIXME: test fails, see bug #1644" -# conformance/interfaces/pthread_key_create/pthread_key_create_2-1 - echo "pthread_key_create_2-1: FIXME: test invokes the debugger, see bug #1646" + conformance/interfaces/pthread_key_create/pthread_key_create_1-2 + conformance/interfaces/pthread_key_create/pthread_key_create_2-1 conformance/interfaces/pthread_key_create/pthread_key_create_3-1 echo "" echo "pthread_key_delete()" From bonefish at mail.berlios.de Fri Nov 30 15:23:46 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 30 Nov 2007 15:23:46 +0100 Subject: [Haiku-commits] r23030 - haiku/trunk/src/build/libroot Message-ID: <200711301423.lAUENk8D024019@sheep.berlios.de> Author: bonefish Date: 2007-11-30 15:23:46 +0100 (Fri, 30 Nov 2007) New Revision: 23030 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23030&view=rev Modified: haiku/trunk/src/build/libroot/fs_attr_generic.cpp Log: * Removed the BUILDING_FS_SHELL guarded code. It was needed for the old FS shell only. * Accessing attributes of symlinks was broken. Modified: haiku/trunk/src/build/libroot/fs_attr_generic.cpp =================================================================== --- haiku/trunk/src/build/libroot/fs_attr_generic.cpp 2007-11-30 14:21:17 UTC (rev 23029) +++ haiku/trunk/src/build/libroot/fs_attr_generic.cpp 2007-11-30 14:23:46 UTC (rev 23030) @@ -1,13 +1,6 @@ -#ifdef BUILDING_FS_SHELL -# include "compat.h" -# define B_OK 0 -# define B_BAD_VALUE EINVAL -# define B_FILE_ERROR EBADF -#else -# include -# include -#endif +#include +#include #include #include @@ -30,6 +23,7 @@ static const char *sAttributeDirBasePath = HAIKU_BUILD_ATTRIBUTES_DIR; + // init_attribute_dir_base_dir static status_t init_attribute_dir_base_dir() @@ -195,23 +189,7 @@ return B_OK; } -// get_attribute_path -static status_t -get_attribute_path(int fd, const char *attribute, string &attrPath, - string &typePath) -{ - // stat the file to get a NodeRef - struct stat st; - if (fstat(fd, &st) < 0) - return errno; - NodeRef ref(st); - return get_attribute_path(ref, NULL, fd, attribute, attrPath, typePath); -} - - -#ifndef BUILDING_FS_SHELL - // get_attribute_path_virtual_fd static status_t get_attribute_path_virtual_fd(int fd, const char *attribute, string &attrPath, @@ -234,9 +212,32 @@ (pathValid ? -1 : fd), attribute, attrPath, typePath); } -#endif // ! BUILDING_FS_SHELL +// get_attribute_path +static status_t +get_attribute_path(int fd, const char *attribute, string &attrPath, + string &typePath) +{ + if (get_descriptor(fd)) { + // This is a virtual file descriptor -- we have a special function + // for handling it. + return get_attribute_path_virtual_fd(fd, attribute, attrPath, + typePath); + } else { + // This is a real (i.e. system) file descriptor -- fstat() it and + // build the path. + // stat the file to get a NodeRef + struct stat st; + if (fstat(fd, &st) < 0) + return errno; + NodeRef ref(st); + + return get_attribute_path(ref, NULL, fd, attribute, attrPath, typePath); + } +} + + // # pragma mark - Public API @@ -257,15 +258,6 @@ { struct stat st; -#ifdef BUILDING_FS_SHELL - - if (fstat(fd, &st) < 0) - return NULL; - - return open_attr_dir(NodeRef(st), NULL, fd); - -#else - status_t error = _kern_read_stat(fd, NULL, false, &st, sizeof(struct stat)); if (error != B_OK) { @@ -281,8 +273,6 @@ // get the attribute path return open_attr_dir(NodeRef(st), (pathValid ? path.c_str() : NULL), (pathValid ? -1 : fd)); - -#endif } // fs_close_attr_dir @@ -513,8 +503,6 @@ // #pragma mark - Private Syscalls -#ifndef BUILDING_FS_SHELL - // _kern_open_attr_dir int _kern_open_attr_dir(int fd, const char *path) @@ -610,5 +598,3 @@ return B_OK; } - -#endif // ! BUILDING_FS_SHELL From ingo_weinhold at gmx.de Fri Nov 30 16:17:52 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 30 Nov 2007 16:17:52 +0100 Subject: [Haiku-commits] r23022 - haiku/trunk/src/bin In-Reply-To: <1731917308-BeMail@laptop> References: <1731917308-BeMail@laptop> Message-ID: <20071130161752.1745.1@knochen-vm.nameserver> On 2007-11-30 at 15:13:04 [+0100], Fran?ois Revol wrote: > > > That was for binary compatibility with the few R5 apps using it. > > > The code can probably be added to Appearance's ArgsReceived and > > > symlinked. > > > > There is no WindowShade app on any of my BeOS installations, so there > > is no reason for any backwards compatibility either. > > On mine neither (but it didn't work on Dano), but there are a few apps > on bebits using it. > I know it's a toy but it's a bit funky like sliding tabs... > > > > That was mainly to prepare for a bigger fish :p > > > > OMG, what might that be? :-0 > > I'm digging out the theme engine I wrote long ago, which was used in > Zeta (but I wrote it before working there). It's just lacking these > changes to be usable there, only needs a gui. > It's probably not a good idea to put it in by default, but it'd be a > nice 3rd party for those liking ugly themes (Citrus anyone ? ;) To be honest, I'm not sure, if I'd like to see theming on Haiku at all. [...] > Btw2, > what's the guidelines for trunk/3rdparty/ ? Not sure. Marcus created it. Currently it has the feel of stuff that comes from third parties and is somehow Haiku-related, but not needed for Haiku or building it. I'd probably prefer it to live under data/ ATM. CU, Ingo From axeld at mail.berlios.de Fri Nov 30 19:39:57 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 30 Nov 2007 19:39:57 +0100 Subject: [Haiku-commits] r23031 - haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci Message-ID: <200711301839.lAUIdvpM027780@sheep.berlios.de> Author: axeld Date: 2007-11-30 19:39:56 +0100 (Fri, 30 Nov 2007) New Revision: 23031 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23031&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c Log: Accidently removed our changes when updating to the FreeBSD 7 version of the driver. Ingo, this is your chance to remind me of the vendor branch : Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c 2007-11-30 14:23:46 UTC (rev 23030) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c 2007-11-30 18:39:56 UTC (rev 23031) @@ -2286,10 +2286,15 @@ } #endif + #ifndef __HAIKU__ while ((status = CSR_READ_2(sc, XL_STATUS)) & XL_INTRS && status != 0xFFFF) { CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ACK|(status & XL_INTRS)); +#else + status = atomic_and((int32 *)&sc->xl_intr_status, 0); + if ((status & XL_INTRS) != 0 && status != 0xFFFF) { +#endif if (status & XL_STAT_UP_COMPLETE) { int curpkts; From axeld at mail.berlios.de Fri Nov 30 19:50:42 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 30 Nov 2007 19:50:42 +0100 Subject: [Haiku-commits] r23032 - in haiku/trunk/src/libs/compat/freebsd_network: . compat/sys Message-ID: <200711301850.lAUIogpx001176@sheep.berlios.de> Author: axeld Date: 2007-11-30 19:50:40 +0100 (Fri, 30 Nov 2007) New Revision: 23032 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23032&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/bus.c haiku/trunk/src/libs/compat/freebsd_network/compat.c haiku/trunk/src/libs/compat/freebsd_network/compat/sys/bus.h Log: Implemented device_detach(), and bus_generic_detach() - both are needed by the updated mii code on destruction. Modified: haiku/trunk/src/libs/compat/freebsd_network/bus.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-11-30 18:39:56 UTC (rev 23031) +++ haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-11-30 18:50:40 UTC (rev 23032) @@ -379,14 +379,6 @@ int -bus_generic_detach(device_t dev) -{ - UNIMPLEMENTED(); - return B_ERROR; -} - - -int bus_generic_suspend(device_t dev) { UNIMPLEMENTED(); Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/bus.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/bus.h 2007-11-30 18:39:56 UTC (rev 23031) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/bus.h 2007-11-30 18:50:40 UTC (rev 23032) @@ -144,6 +144,7 @@ int device_delete_child(device_t dev, device_t child); int device_is_attached(device_t dev); int device_attach(device_t dev); +int device_detach(device_t dev); int bus_generic_print_child(device_t dev, device_t child); void bus_generic_driver_added(device_t dev, driver_t *driver); int bus_generic_attach(device_t dev); Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-30 18:39:56 UTC (rev 23031) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-11-30 18:50:40 UTC (rev 23032) @@ -329,8 +329,10 @@ if ((atomic_and(&parent->flags, ~DEVICE_ATTACHED) & DEVICE_ATTACHED) != 0 && parent->methods.detach != NULL) { int status = parent->methods.detach(parent); - if (status != 0) + if (status != 0) { + atomic_or(&parent->flags, DEVICE_ATTACHED); return status; + } } if (parent->flags & DEVICE_DESC_ALLOCED) @@ -366,6 +368,24 @@ int +device_detach(device_t device) +{ + if (device->driver == NULL) + return B_ERROR; + + if ((atomic_and(&device->flags, ~DEVICE_ATTACHED) & DEVICE_ATTACHED) != 0) { + int result = device->methods.detach(device); + if (result != 0) { + atomic_or(&device->flags, DEVICE_ATTACHED); + return result; + } + } + + return 0; +} + + +int bus_generic_attach(device_t dev) { device_t child = NULL; @@ -394,6 +414,26 @@ } +int +bus_generic_detach(device_t device) +{ + device_t child = NULL; + + if ((device->flags & DEVICE_ATTACHED) == 0) + return B_ERROR; + + while (true) { + child = list_get_next_item(&device->children, child); + if (child == NULL) + break; + + device_detach(child); + } + + return 0; +} + + // #pragma mark - Misc, Malloc From oruizdorantes at mail.berlios.de Fri Nov 30 20:51:44 2007 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 30 Nov 2007 20:51:44 +0100 Subject: [Haiku-commits] r23033 - haiku/trunk/headers/os/bluetooth Message-ID: <200711301951.lAUJpioG004132@sheep.berlios.de> Author: oruizdorantes Date: 2007-11-30 20:51:44 +0100 (Fri, 30 Nov 2007) New Revision: 23033 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23033&view=rev Modified: haiku/trunk/headers/os/bluetooth/bdaddrUtils.h haiku/trunk/headers/os/bluetooth/bluetooth.h Log: Wrong method name Modified: haiku/trunk/headers/os/bluetooth/bdaddrUtils.h =================================================================== --- haiku/trunk/headers/os/bluetooth/bdaddrUtils.h 2007-11-30 18:50:40 UTC (rev 23032) +++ haiku/trunk/headers/os/bluetooth/bdaddrUtils.h 2007-11-30 19:51:44 UTC (rev 23033) @@ -1,11 +1,10 @@ /* - * Copyright 2007 Haiku. - * Distributed under the terms of the MIT License. + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * - * Authors: - * Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * All rights reserved. Distributed under the terms of the MIT License. + * */ - + #ifndef _BDADDR_UTILS_H #define _BDADDR_UTILS_H @@ -16,7 +15,7 @@ class bdaddrUtils { public: - static inline bdaddr_t MullAddress() + static inline bdaddr_t NullAddress() { return ((bdaddr_t) {{0, 0, 0, 0, 0, 0}}); Modified: haiku/trunk/headers/os/bluetooth/bluetooth.h =================================================================== --- haiku/trunk/headers/os/bluetooth/bluetooth.h 2007-11-30 18:50:40 UTC (rev 23032) +++ haiku/trunk/headers/os/bluetooth/bluetooth.h 2007-11-30 19:51:44 UTC (rev 23033) @@ -1,9 +1,8 @@ /* - * Copyright 2007 Haiku. - * Distributed under the terms of the MIT License. + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * - * Authors: - * Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * All rights reserved. Distributed under the terms of the MIT License. + * */ #ifndef _BLUETOOTH_H From oruizdorantes at mail.berlios.de Fri Nov 30 20:59:31 2007 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 30 Nov 2007 20:59:31 +0100 Subject: [Haiku-commits] r23034 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200711301959.lAUJxVwN004529@sheep.berlios.de> Author: oruizdorantes Date: 2007-11-30 20:59:29 +0100 (Fri, 30 Nov 2007) New Revision: 23034 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23034&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.h Log: Remaining part of the USB-BT driver. Events are commands are tested and working. ACLcode is untested and needs review. Lacks some general headers to be able to compile it, as I am still considering making some org. changes. Commiting for possible reviews or suggestions. Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h 2007-11-30 19:51:44 UTC (rev 23033) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h 2007-11-30 19:59:29 UTC (rev 23034) @@ -0,0 +1,33 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _H2CFG_H_ +#define _H2CFG_H_ + +/* TODO: move exclusive header for drivers*/ +#define BT_DRIVER_SUPPORTS_CMD 1 +#define BT_DRIVER_SUPPORTS_EVT 1 +#define BT_DRIVER_SUPPORTS_ESCO 0 +#define BT_DRIVER_SUPPORTS_SCO 0 +#define BT_DRIVER_SUPPORTS_ACL 0 + +#define BT_DRIVER_RXCOVERAGE (BT_DRIVER_SUPPORTS_EVT+BT_DRIVER_SUPPORTS_ACL+BT_DRIVER_SUPPORTS_SCO+BT_DRIVER_SUPPORTS_ESCO) +#define BT_DRIVER_TXCOVERAGE (BT_DRIVER_SUPPORTS_CMD+BT_DRIVER_SUPPORTS_ACL+BT_DRIVER_SUPPORTS_SCO+BT_DRIVER_SUPPORTS_ESCO) + +#if BT_DRIVER_RXCOVERAGE<1 || BT_DRIVER_TXCOVERAGE<1 +#error incomplete Bluetooth driver Commands and Events should be implemented +#endif + + +//////////////////////////////////// + +#define BT_SURVIVE_WITHOUT_HCI +#define BT_SURVIVE_WITHOUT_NET_BUFFERS +//#define BT_IOCTLS_PASS_SIZE + + +#endif Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2007-11-30 19:51:44 UTC (rev 23033) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2007-11-30 19:59:29 UTC (rev 23034) @@ -0,0 +1,824 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include "snet_buffer.h" + +#include +#include + +#define BT_DEBUG_THIS_MODULE +#include + +#include "h2generic.h" +#include "h2transactions.h" +#include "h2util.h" + +#include "h2cfg.h" + +int32 api_version = B_CUR_DRIVER_API_VERSION; + +/* Modules */ +static char* usb_name = B_USB_MODULE_NAME; +static char* hci_name = B_BT_HCI_MODULE_NAME; + +usb_module_info *usb = NULL; +bt_hci_module_info *hci = NULL; +struct net_buffer_module_info *nb = NULL; + +/* Driver Global data */ +static char *publish_names[MAX_BT_GENERIC_USB_DEVICES]; + +int32 dev_count = 0; /* number of connected devices */ +static bt_usb_dev* bt_usb_devices[MAX_BT_GENERIC_USB_DEVICES]; +sem_id dev_table_sem = -1; /* sem to synchronize access to device table */ + +usb_support_descriptor supported_devices[] = +{ + /* Generic Bluetooth USB device */ + /* Class, SubClass, and Protocol codes that describe a Bluetooth device */ + { UDCLASS_WIRELESS, UDSUBCLASS_RF, UDPROTO_BLUETOOTH , 0 , 0 }, + + /* Generic devices */ + /* Broadcom BCM2035 */ + { 0, 0, 0, 0x0a5c, 0x200a }, + { 0, 0, 0, 0x0a5c, 0x2009 }, + + /* Devices taken from the linux Driver */ + /* AVM BlueFRITZ! USB v2.0 */ + { 0, 0, 0, 0x057c , 0x3800 }, + /* Bluetooth Ultraport Module from IBM */ + { 0, 0, 0, 0x04bf , 0x030a }, + /* ALPS Modules with non-standard id */ + { 0, 0, 0, 0x044e , 0x3001 }, + { 0, 0, 0, 0x044e , 0x3002 }, + /* Ericsson with non-standard id */ + { 0, 0, 0, 0x0bdb , 0x1002 } +}; + +/* add a device to the list of connected devices */ +static bt_usb_dev* +spawn_device(const usb_device* usb_dev) +{ + int32 i; + status_t err = B_OK; + bt_usb_dev* new_bt_dev = NULL; + + flowf("add_device()\n"); + + /* 16 usb dongles... u are unsane */ + if (dev_count >= MAX_BT_GENERIC_USB_DEVICES) { + flowf("device table full\n"); + goto exit; + } + + /* try the allocation */ + new_bt_dev = (bt_usb_dev*)malloc(sizeof(bt_usb_dev)); + if ( new_bt_dev == NULL ) { + flowf("no memoery allocating\n"); + goto exit; + } + memset(new_bt_dev, 0, sizeof(bt_usb_dev) ); + + /* We will need this sem for some flow control */ + new_bt_dev->cmd_complete = create_sem(1, ID "cmd_complete"); + if (new_bt_dev->cmd_complete < 0) { + err = new_bt_dev->cmd_complete; + goto bail0; + } + + /* and this for something else */ + new_bt_dev->lock = create_sem(1, ID "lock"); + if (new_bt_dev->lock < 0) { + err = new_bt_dev->lock; + goto bail1; + } + + /* find a free slot and fill out the name */ + acquire_sem(dev_table_sem); + for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { + if (bt_usb_devices[i] == NULL) { + bt_usb_devices[i] = new_bt_dev; + sprintf(new_bt_dev->name, "%s/%ld", DEVICE_PATH, i); + new_bt_dev->num = i; + debugf("added device %p %ld %s\n", bt_usb_devices[i] ,new_bt_dev->num,new_bt_dev->name); + break; + } + } + release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); + + /* In the case we cannot us */ + if (bt_usb_devices[i] != new_bt_dev) { + flowf("Device could not be added\n"); + goto bail2; + } + + new_bt_dev->dev = usb_dev; + /* TODO am i actually gonna use this? */ + new_bt_dev->open_count = 0; + + dev_count++; + return new_bt_dev; + +bail2: + delete_sem(new_bt_dev->lock); +bail1: + delete_sem(new_bt_dev->cmd_complete); +bail0: + free(new_bt_dev); +exit: + return new_bt_dev; +} + + +/* remove a device from the list of connected devices */ +static void +kill_device(bt_usb_dev* dev) +{ + uint16 i; + debugf("remove_device(%p)\n", dev); + + delete_sem(dev->lock); + delete_sem(dev->cmd_complete); + + free(dev); + dev_count--; +} + + +bt_usb_dev* +fetch_device(bt_usb_dev* dev, hci_id hid) +{ + int i; + + debugf("(%p)\n", dev); + + acquire_sem(dev_table_sem); + if (dev != NULL) + for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { + /* somehow the device is still around */ + if (bt_usb_devices[i] == dev) { + release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); + return bt_usb_devices[i]; + } + } + else + for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { + /* somehow the device is still around */ + if (bt_usb_devices[i] != NULL && bt_usb_devices[i]->hdev == hid) { + release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); + return bt_usb_devices[i]; + } + } + + + release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); + + return NULL; +} + +#if 0 +#pragma mark - +#endif + +static bt_hci_transport bt_usb_hooks = +{ + NULL, + NULL, + NULL, + NULL, + H2, + "H2 Bluetooth Device" +}; + +/* called by USB Manager when device is added to the USB */ +static status_t +device_added(const usb_device* dev, void** cookie) +{ + const usb_interface_info* interface; + const usb_device_descriptor* desc; + const usb_configuration_info* config; + const usb_interface_info* uif; + const usb_endpoint_info* ep; + + status_t err = B_ERROR; + bt_usb_dev* new_bt_dev = spawn_device(dev); + int e, i; + + debugf("device_added(%ld, %p)\n", dev, new_bt_dev); + + if (new_bt_dev == NULL) { + flowf("Couldn't allocate device record.\n"); + err = ENOMEM; + goto bail_no_mem; + } + + /* we only have 1 configuration number 0 */ + config = usb->get_nth_configuration(dev, 0); + //dump_usb_configuration_info(config); + if (config == NULL) { + flowf("couldn't get default config.\n"); + err = B_ERROR; + goto bail; + } + + debugf("found %ld alt interfaces.\n", config->interface->alt_count); + + /* set first interface */ + interface = &config->interface->alt[0]; + err = usb->set_alt_interface(new_bt_dev->dev, interface); + + if (err != B_OK) { + debugf("set_alt_interface() returned %ld.\n", err); + goto bail; + } + + /* call set_configuration() only after calling set_alt_interface()*/ + err = usb->set_configuration(dev, config); + if (err != B_OK) { + debugf("set_configuration() returned %ld.\n", err); + goto bail; + } + + /* Place to find out whats our concrete device and set up some special info to our driver */ + /* TODO: if this code increases too much reconsider this implementation*/ + desc = usb->get_device_descriptor(dev); + if ( desc->vendor_id == 0x0a5c && desc->product_id == 0x200a && desc->product_id == 0x2009) { + // Tecom Device VENDOR_ID 0x0a5c PRODUCT_ID 0x2035 + new_bt_dev->driver_info = BT_WILL_NEED_A_RESET | BT_SCO_NOT_WORKING; + } + /* + else if ( desc->vendor_id == YOUR_VENDOR_HERE && desc->product_id == YOUR_PRODUCT_HERE ) { + YOUR_SPECIAL_FLAGS_HERE + } + */ + + if (new_bt_dev->driver_info & BT_IGNORE_THIS_DEVICE){ + err = ENODEV; + goto bail; + } + + // security check + if (config->interface->active->descr->interface_number > 0){ + debugf("Strange condition happened %d\n", config->interface->active->descr->interface_number); + err = B_ERROR; + goto bail; + } + + debugf("Found %ld interfaces. Expected 3\n", config->interface_count); + /* Find endpoints that we need */ + uif = config->interface->active; + for (e = 0; e < uif->descr->num_endpoints; e++) { + + ep = &uif->endpoint[e]; + switch (ep->descr->attributes & USB_ENDPOINT_ATTR_MASK) + { + case USB_ENDPOINT_ATTR_INTERRUPT: + if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) + { + new_bt_dev->intr_in_ep = ep; + new_bt_dev->max_packet_size_intr_in = ep->descr->max_packet_size; + flowf("INT in\n"); + } else + { + ; + flowf("INT out\n"); + } + break; + + case USB_ENDPOINT_ATTR_BULK: + if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) + { + new_bt_dev->bulk_in_ep = ep; + new_bt_dev->max_packet_size_bulk_in = ep->descr->max_packet_size;; + flowf("BULK int\n"); + } else + { + new_bt_dev->bulk_out_ep = ep; + new_bt_dev->max_packet_size_bulk_out = ep->descr->max_packet_size;; + flowf("BULK out\n"); + } + break; + } + } + + if (!new_bt_dev->bulk_in_ep || !new_bt_dev->bulk_out_ep || !new_bt_dev->intr_in_ep) { + flowf("Minimal # endpoints for BT not found\n"); + goto bail; + } + + // Look into the devices suported to understand this + if (new_bt_dev->driver_info & BT_DIGIANSWER) + new_bt_dev->ctrl_req = USB_TYPE_VENDOR; + else + new_bt_dev->ctrl_req = USB_TYPE_CLASS; + + new_bt_dev->connected = true; + + /* set the cookie that will be passed to other USB + hook functions (currently device_removed() is the only other) */ + *cookie = new_bt_dev; + debugf("Ok %p\n",bt_usb_devices[0]); + return B_OK; + +bail: + kill_device(new_bt_dev); +bail_no_mem: + *cookie = NULL; +done: + return err; +} + + +/* called by USB Manager when device is removed from the USB */ +static status_t +device_removed(void* cookie) +{ + int32 i; + void* item; + bt_usb_dev* bdev = (bt_usb_dev*) fetch_device(cookie, 0); + + debugf("device_removed(%p)\n", bdev); + + if (bdev == NULL) { + flowf("Weird condition...\n"); + return B_ERROR; + } + // TODO: Consider some other place + // TX + for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) { + if (i = BT_COMMAND) + while ((item = list_remove_head_item(&bdev->nbuffersTx[i])) != NULL) { + snb_free(item); + } + else + while ((item = list_remove_head_item(&bdev->nbuffersTx[i])) != NULL) { + nb_destroy(item); + } + + } + // RX + for (i = 0; i < BT_DRIVER_RXCOVERAGE; i++) { + nb_destroy(bdev->nbufferRx[i]); + } + snb_free(bdev->eventRx); + + purge_room(&bdev->eventRoom); + purge_room(&bdev->aclRoom); + // TODO: Consider some other place + + if (hci != NULL) + hci->UnregisterDriver(bdev->hdev); + + bdev->connected = false; + + /* TODO: maybe we still need this struct for close and free hooks */ + kill_device(bdev); + + return B_OK; +} + + +static usb_notify_hooks notify_hooks = +{ + &device_added, + &device_removed +}; + +#if 0 +#pragma mark - +#endif + +/* implements the POSIX open() */ +static status_t +device_open(const char *name, uint32 flags, void **cookie) +{ + status_t err = ENODEV; + bt_usb_dev* bdev = NULL; + hci_id hdev; + int i; + + flowf("device_open()\n"); + + acquire_sem(dev_table_sem); + for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { + if (bt_usb_devices[i] && !strcmp(name, bt_usb_devices[i]->name)) { + bdev = bt_usb_devices[i]; + break; + } + } + release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); + + if (bdev == NULL) { + flowf("Device not found in the open list!"); + *cookie = NULL; + return B_ERROR; + } + + acquire_sem(bdev->lock); + // Set HCI_RUNNING + if ( TEST_AND_SET(&bdev->state, RUNNING) ) { + flowf("dev already running! - reOpened device!\n"); + return B_ERROR; + } + + // TX structures + for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) { + list_init(&bdev->nbuffersTx[i]); + bdev->nbuffersPendingTx[i] = 0; + } + + // RX structures + bdev->eventRx = NULL; + for (i = 0; i < BT_DRIVER_RXCOVERAGE; i++) { + bdev->nbufferRx[i] = NULL; + } + + + // dumping the USB frames + init_room(&bdev->eventRoom); + init_room(&bdev->aclRoom); + //Init_room(new_bt_dev->scoRoom); + + list_init(&bdev->snetBufferRecycleTrash); + + // Allocate set and register the HCI device + if (hci != NULL) { + // TODO: Fill the transport descriptor + hci->RegisterDriver(&bt_usb_hooks, &hdev, (void*)bdev); + + if ( err != B_OK ) + { + flowf("Impossible to register a hci device.\n"); + hdev = bdev->num; /* XXX: Lets try to go on*/ + } + } + else { + hdev = bdev->num; + } + bdev->hdev = hdev; + + // H: set the special flags + + // EVENTS + err = submit_rx_event(bdev); + if (err != B_OK) + goto unrun; +#if BT_DRIVER_SUPPORTS_ACL + // ACL + for (i = 0; i < MAX_ACL_IN_WINDOW; i++) { + err = submit_rx_acl(bdev); + if (err != B_OK && i == 0 ) + goto unrun; + } +#endif + +#if BT_DRIVER_SUPPORTS_SCO + // TODO: SCO / eSCO +#endif + + *cookie = bdev; + release_sem(bdev->lock); + + return B_OK; + +unrun: + CLEAR_BIT(bdev->state, RUNNING); // Set the flaq in the HCI world + flowf("Queuing failed device stops running\n"); + + return err; +} + + +/* called when a client calls POSIX close() on the driver, but I/O + ** requests may still be pending */ +static status_t +device_close(void *cookie) +{ + bt_usb_dev* bdev = (bt_usb_dev*)cookie; + + if (bdev == NULL) + panic("bad cookie"); + + debugf("device_close() called on %s\n", DEVICE_PATH, bdev->hdev ); + + + if (!TEST_AND_CLEAR(&bdev->state, RUNNING) ) { + flowf("Device wasnt running!!!\n"); + } + + flowf("Stopping device and cancelling queues...\n"); + + if ( bdev->intr_in_ep != NULL ) { + usb->cancel_queued_transfers(bdev->intr_in_ep->handle); + + } else { + flowf("Cancelling impossible EVENTS\n"); + } + + if (bdev->bulk_in_ep!=NULL) { + usb->cancel_queued_transfers(bdev->bulk_in_ep->handle); + } else { + flowf("Cancelling impossible ACL in\n"); + } + + if (bdev->bulk_out_ep!=NULL) { + usb->cancel_queued_transfers(bdev->bulk_out_ep->handle); + } else { + flowf("Cancelling impossible ACL out\n"); + } + + // TODO: Kill if its not connected? + + return B_OK; +} + + +/* called after device_close(), when all pending I/O requests have + * returned */ +static status_t +device_free (void *cookie) +{ + status_t err = B_OK; + bt_usb_dev* dev = (bt_usb_dev*)cookie; + + debugf("device_free() called on \"%s %ld\"\n",DEVICE_PATH, dev->num); + + + if (--dev->open_count == 0) { + + /* GotoLowPower */ + // interesting ..... + } + else { + /* The last client has closed, and the device is no longer + connected, so remove it from the list. */ + + } + + // TODO: Kill if its not connected? + + return err; +} + + +/* implements the POSIX ioctl() */ +static status_t +device_control(void *cookie, uint32 msg, void *params, size_t size) +{ + status_t err = B_ERROR; + bt_usb_dev* dev = (bt_usb_dev*)cookie; + snet_buffer* snbuf; + TOUCH(size); + + debugf("ioctl() opcode %ld size %ld.\n", msg, size); + + if (dev == NULL) { + flowf("Bad cookie\n"); + return B_BAD_VALUE; + } + + if (params == NULL) { + flowf("Invalid pointer control\n"); + return B_BAD_VALUE; + } + + acquire_sem(dev->lock); + + switch (msg) { + case ISSUE_BT_COMMAND: +#ifdef BT_IOCTLS_PASS_SIZE + if (size == 0) { + flowf("Invalid size control\n"); + err = B_BAD_VALUE; + break; + } +#else + size = (*((size_t*)params)); + ((size_t*)params)++; +#endif + + // TODO: Reuse from some TXcompleted queue + snbuf = snb_create(size); + snb_put(snbuf, params, size); + + err = send_command(dev->hdev, snbuf); + + break; + + case ISSUE_STATICS: + memcpy(params, &dev->stat, sizeof(bt_hci_statistics)); + err = B_OK; + break; + + default: + debugf("Invalid opcode %ld.\n", msg); + err = B_DEV_INVALID_IOCTL; + break; + } + + release_sem(dev->lock); + return err; +} + + +/* implements the POSIX read() */ +static status_t +device_read(void *cookie, off_t pos, void *buf, size_t *count) +{ + debugf("Reading... pos = %ld || count = %ld\n", pos, *count); + + *count = 0; + return B_OK; +} + + +/* implements the POSIX write() */ +static status_t +device_write(void *cookie, off_t pos, const void *buf, size_t *count) +{ + flowf("device_write()\n"); + + return B_ERROR; +} + +#if 0 +#pragma mark - +#endif + +/* called each time the driver is loaded by the kernel */ +status_t +init_driver(void) +{ + int j; + flowf("init_driver()\n"); + + // HCI MODULE INITS + if (get_module(hci_name,(module_info**)&hci) != B_OK) { + debugf("cannot get module \"%s\"\n", hci_name); +#ifndef BT_SURVIVE_WITHOUT_HCI + return B_ERROR; +#endif + } + debugf("hci module at %p\n", hci); + + // USB MODULE INITS + if (get_module(usb_name,(module_info**)&usb) != B_OK) { + debugf("cannot get module \"%s\"\n", usb_name); + goto err_release; + } + debugf("usb module at %p\n", usb); + + + if (get_module(NET_BUFFER_MODULE_NAME,(module_info**)&nb) != B_OK) { + debugf("cannot get module \"%s\"\n", NET_BUFFER_MODULE_NAME); +#ifndef BT_SURVIVE_WITHOUT_NET_BUFFERS + goto err_release; +#endif + } + debugf("nb module at %p\n", nb); + + // GENERAL INITS + dev_table_sem = create_sem(1, ID "dev_table_lock"); + if (dev_table_sem < 0) { + goto err; + } + + for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) { + bt_usb_devices[j] = NULL; + } + + /* After here device_added and publish devices hooks are called + be carefull USB devs */ + usb->register_driver(DEVICE_NAME, supported_devices, 1, NULL); + usb->install_notify(DEVICE_NAME, ¬ify_hooks); + + return B_OK; + +err: // Releasing + put_module(usb_name); +err_release: + put_module(hci_name); + return B_ERROR; +} + + +/* called just before the kernel unloads the driver */ +void +uninit_driver(void) +{ + int32 j; + + flowf("uninit_driver()\n"); + + for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) { + + if (publish_names[j] != NULL) + free(publish_names[j]); + + if (bt_usb_devices[j] != NULL) { + // if (connected_dev != NULL) { + // debugf("Device %p still exists.\n", connected_dev); + // } + kill_device(bt_usb_devices[j]); + bt_usb_devices[j] = NULL; + } + + } + + usb->uninstall_notify(DEVICE_NAME); + usb->register_driver(DEVICE_NAME, supported_devices, 1, NULL); + + /* Releasing modules */ + put_module(usb_name); + put_module(hci_name); + // TODO: netbuffers + + delete_sem(dev_table_sem); +} + + +const char** +publish_devices(void) +{ + int32 j; + int32 i = 0; + + char* str; + + flowf("publish_devices()\n"); + + for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) { + if (publish_names[j]) { + free(publish_names[j]); + publish_names[j] = NULL; + } + } + + acquire_sem(dev_table_sem); + for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) + { + if (bt_usb_devices[j] != NULL && bt_usb_devices[j]->connected) + { + str = strdup(bt_usb_devices[j]->name); + if (str) { + publish_names[i++] = str; + debugf("publishing %s\n", bt_usb_devices[j]->name); + } + } + } + release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); + + publish_names[i] = NULL; + debugf("published %ld devices\n", i); + +// TODO: this method might make better memory use +// dev_names = (char**)malloc(sizeof (char*) * (dev_count+1)); +// if (dev_names) { +// for (i = 0; i < MAX_NUM_DEVS; i++) { +// if ((dev != NULL) && +// (dev_names[i] = (char*)malloc(strlen(DEVICE_PATH)+2/* num + \n */))) { +// sprintf(dev_names[i], "%s%ld", DEVICE_PATH, dev->num); +// debugf("publishing \"%s\"\n", dev_names[i]); +// } +// } + + return (const char**)publish_names; +} + + +static device_hooks hooks = { + device_open, + device_close, + device_free, + device_control, + device_read, + device_write, + NULL, + NULL, + NULL, + NULL +}; + + +device_hooks* +find_device(const char* name) +{ + debugf("find_device(%s)\n", name); + + return &hooks; +} Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h 2007-11-30 19:51:44 UTC (rev 23033) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h 2007-11-30 19:59:29 UTC (rev 23034) @@ -0,0 +1,107 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _H2GENERIC_H_ +#define _H2GENERIC_H_ + +#include +#include + +#include +#include + +#include + +#include "h2cfg.h" +#include "snet_buffer.h" + +/* USB definitions for the generic device*/ +#define UDCLASS_WIRELESS 0xe0 +#define UDSUBCLASS_RF 0x01 +#define UDPROTO_BLUETOOTH 0x01 + +#define TRANSPORT_NAME "h2" +#define DEVICE_NAME "generic" +#define DEVICE_PATH "bus/bluetooth/" TRANSPORT_NAME "/" DEVICE_NAME + +#define ID DEVICE_NAME ": " /* prefix for debug messages */ + +#define USB_TYPE_CLASS (0x01 << 5) /// Check if it is in some other header +#define USB_TYPE_VENDOR (0x02 << 5) + + +// Expecting nobody is gonna have 16 USB-BT dongles connected in their system +#define MAX_BT_GENERIC_USB_DEVICES 16 + +extern usb_module_info *usb; +extern bt_hci_module_info *hci; +extern struct net_buffer_module_info *nb; + +#define MAX_COMMAND_WINDOW 1 +#define MAX_ACL_OUT_WINDOW 4 +#define MAX_ACL_IN_WINDOW 1 + +#define MAX_NUM_QUEUED_PACKETS 1 +#define NUM_BUFFERS 1 + +typedef struct bt_usb_dev bt_usb_dev; + +struct bt_usb_dev { + const usb_device* dev; /* opaque handle */ + hci_id hdev; /* HCI device id*/ + + char name[B_OS_NAME_LENGTH]; + bool connected; /* is the device plugged into the USB? */ + int32 open_count; /* number of clients of the device */ + int32 num; /* instance number of the device */ + + sem_id lock; /* synchronize access to the device */ + sem_id cmd_complete; /* To synchronize completitions */ + + size_t actual_len; /* length of data returned by command */ + status_t cmd_status; /* result of command */ + + uint8 ctrl_req; + uint8 driver_info; + uint32 state; + + bt_hci_statistics stat; + + const usb_endpoint_info *bulk_in_ep; + uint16 max_packet_size_bulk_in; + const usb_endpoint_info *bulk_out_ep; + uint16 max_packet_size_bulk_out; + const usb_endpoint_info *intr_in_ep; + uint16 max_packet_size_intr_in; + +#ifdef BLUETOOTH_SUPPORTS_SCO + const usb_endpoint_info *iso_in_ep; + const usb_endpoint_info *iso_out_ep; +#endif + + /* This so called rooms, are for dumping the USB RX frames + and try to reuse the allocations. see util submodule */ + struct list eventRoom; + struct list aclRoom; + + // Tx buffers: net_buffers for BT_ACL and snet_buffers for BT_COMMAND + // in the same array + struct list nbuffersTx[BT_DRIVER_TXCOVERAGE]; + uint32 nbuffersPendingTx[BT_DRIVER_TXCOVERAGE]; + + // Rx buffer + net_buffer* nbufferRx[BT_DRIVER_RXCOVERAGE]; /* Wasting 1 pointer for BT_EVENT */ + snet_buffer* eventRx; /* <- which we hold here */ + + // for who ever needs preallocated buffers + struct list snetBufferRecycleTrash; + +}; + +bt_usb_dev* fetch_device(bt_usb_dev* dev, hci_id hid); + +#endif Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2007-11-30 19:51:44 UTC (rev 23033) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2007-11-30 19:59:29 UTC (rev 23034) @@ -0,0 +1,402 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#include "h2generic.h" +#include "h2transactions.h" +#include "h2upper.h" +#include "h2util.h" + +#include [... truncated: 847 lines follow ...] From revol at free.fr Fri Nov 30 21:00:28 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 30 Nov 2007 21:00:28 +0100 CET Subject: [Haiku-commits] r23022 - haiku/trunk/src/bin In-Reply-To: <20071130161752.1745.1@knochen-vm.nameserver> Message-ID: <542624725-BeMail@laptop> > > I'm digging out the theme engine I wrote long ago, which was used > > in > > Zeta (but I wrote it before working there). It's just lacking these > > changes to be usable there, only needs a gui. > > It's probably not a good idea to put it in by default, but it'd be > > a > > nice 3rd party for those liking ugly themes (Citrus anyone ? ;) > > To be honest, I'm not sure, if I'd like to see theming on Haiku at > all. I know, but some people will definitely want/do/rant about it, so it's better if done by "us", so it's standardized and kept clean. We could even add some points to the distro guidelines about that, like keep the default theme or something. Then the user is free to change it but at least he won't be lost when checking our own documentation. > > what's the guidelines for trunk/3rdparty/ ? > > Not sure. Marcus created it. Currently it has the feel of stuff that > comes > from third parties and is somehow Haiku-related, but not needed for > Haiku Yeah that'd need some discussion. > or building it. I'd probably prefer it to live under data/ ATM. The haiku.vmx should probably go to build/ actually IMO. But data would be fine too. Fran?ois. From marcusoverhagen at arcor.de Fri Nov 30 21:37:52 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Fri, 30 Nov 2007 21:37:52 +0100 (CET) Subject: [Haiku-commits] r23022 - haiku/trunk/src/bin In-Reply-To: <542624725-BeMail@laptop> References: <542624725-BeMail@laptop> Message-ID: <21977076.1196455072857.JavaMail.ngmail@webmail11> > > > what's the guidelines for trunk/3rdparty/ ? > > > > Not sure. Marcus created it. Currently it has the feel of stuff that comes > > from third parties and is somehow Haiku-related, but not needed for Haiku > It was meant for that purpose, for example to include binary-only third party drivers, tools and applications that might be useful to be installed on the haiku image. we could put for example a firefox.zip there that is know to work with haiku and already compiled, so it just needs to be unzipped onto the haiku image. > Yeah that'd need some discussion. > > > or building it. I'd probably prefer it to live under data/ ATM. > > The haiku.vmx should probably go to build/ actually IMO. But data would be fine too. The haiku.vmx file doesn't really fit into build, and isn't any data needed by haiku. I think the 3rdparty folder is a good place for it, as haiku is independant. Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From ingo_weinhold at gmx.de Fri Nov 30 22:47:28 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 30 Nov 2007 22:47:28 +0100 Subject: [Haiku-commits] r23031 - haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci In-Reply-To: <200711301839.lAUIdvpM027780@sheep.berlios.de> References: <200711301839.lAUIdvpM027780@sheep.berlios.de> Message-ID: <20071130224728.361.1@knochen-vm.nameserver> On 2007-11-30 at 19:39:57 [+0100], axeld at BerliOS wrote: > Author: axeld > Date: 2007-11-30 19:39:56 +0100 (Fri, 30 Nov 2007) > New Revision: 23031 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23031&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c > Log: > Accidently removed our changes when updating to the FreeBSD 7 version of > the driver. > Ingo, this is your chance to remind me of the vendor branch : You already realized it all by yourself. Very good progress! :-P CU, Ingo