From owner-svn-soc-all@FreeBSD.ORG Sun Jul 14 06:52:29 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 31B63CE8 for ; Sun, 14 Jul 2013 06:52:29 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 22FE4793 for ; Sun, 14 Jul 2013 06:52:29 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6E6qSJd036546 for ; Sun, 14 Jul 2013 06:52:28 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6E6qSTn036540 for svn-soc-all@FreeBSD.org; Sun, 14 Jul 2013 06:52:28 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 14 Jul 2013 06:52:28 GMT Message-Id: <201307140652.r6E6qSTn036540@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254775 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jul 2013 06:52:29 -0000 Author: zcore Date: Sun Jul 14 06:52:28 2013 New Revision: 254775 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254775 Log: fix block_if two bugs 1. add missing pthread_mutex_unlock() after pthread_cond_wait() 2. add missing pthread_cond_signal() before pthread_join() Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.c Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/block_if.c Sun Jul 14 04:42:35 2013 (r254774) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.c Sun Jul 14 06:52:28 2013 (r254775) @@ -159,14 +159,13 @@ pthread_mutex_lock(&bc->bc_mtx); } pthread_cond_wait(&bc->bc_cond, &bc->bc_mtx); + pthread_mutex_unlock(&bc->bc_mtx); /* * Check ctxt status here to see if exit requested */ - if (bc->bc_closing) { - pthread_mutex_unlock(&bc->bc_mtx); + if (bc->bc_closing) pthread_exit(NULL); - } } /* Not reached */ @@ -247,7 +246,7 @@ pthread_create(&bc->bc_btid, NULL, blockif_thr, bc); - snprintf(tname, sizeof(tname), "%s blk-%s", vmname, ident); + snprintf(tname, sizeof(tname), "%s blk-%s", vmname, ident); pthread_set_name_np(bc->bc_btid, tname); return (bc); @@ -321,6 +320,7 @@ * Stop the block i/o thread */ bc->bc_closing = 1; + pthread_cond_signal(&bc->bc_cond); pthread_join(bc->bc_btid, &jval); /* XXX Cancel queued i/o's ??? */ From owner-svn-soc-all@FreeBSD.ORG Sun Jul 14 10:28:36 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 99B9A692 for ; Sun, 14 Jul 2013 10:28:36 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 8B4FDC4D for ; Sun, 14 Jul 2013 10:28:36 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6EASauD002983 for ; Sun, 14 Jul 2013 10:28:36 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6EASa1H002981 for svn-soc-all@FreeBSD.org; Sun, 14 Jul 2013 10:28:36 GMT (envelope-from dpl@FreeBSD.org) Date: Sun, 14 Jul 2013 10:28:36 GMT Message-Id: <201307141028.r6EASa1H002981@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254777 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jul 2013 10:28:36 -0000 Author: dpl Date: Sun Jul 14 10:28:36 2013 New Revision: 254777 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254777 Log: Changed to use file opener functions. Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/main.c Sun Jul 14 07:58:10 2013 (r254776) +++ soc2013/dpl/head/contrib/xz/src/xz/main.c Sun Jul 14 10:28:36 2013 (r254777) @@ -207,10 +207,14 @@ if (opt_mode != MODE_LIST) signals_init(); + // Separate opening the files from list_file() and coder_run() + // We have to limit both functions with Capsicum. + file_pair * (*open)(const char **filename, int files) = opt_mode == MODE_LIST + ? &io_list_open : &io_coder_open; + // coder_run() handles compression, decompression, and testing. // list_file() is for --list. - // We have to limit both functions with Capsicum. - void (*run)(const char *filename) = opt_mode == MODE_LIST + void (*run)(const file_pair *pairs, int files) = opt_mode == MODE_LIST ? &list_file : &coder_run; // Process the files given on the command line. Note that if no names @@ -245,12 +249,12 @@ // handling the special case of stdin. args.arg_names[i] = (char *)stdin_filename; files++; - -/* // Do the actual compression/decompression.*/ -/* run(args.arg_names[i]);*/ } } + file_pair pairs[files] = open(args.arg_names, files); + cap_init(); + run(pairs, files); // If --files or --files0 was used, process the filenames from the // given file or stdin. Note that here we don't consider "-" to From owner-svn-soc-all@FreeBSD.ORG Sun Jul 14 10:29:56 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0D6976AB for ; Sun, 14 Jul 2013 10:29:56 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id DA1F4C54 for ; Sun, 14 Jul 2013 10:29:55 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6EATtHY003479 for ; Sun, 14 Jul 2013 10:29:55 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6EATtqh003477 for svn-soc-all@FreeBSD.org; Sun, 14 Jul 2013 10:29:55 GMT (envelope-from dpl@FreeBSD.org) Date: Sun, 14 Jul 2013 10:29:55 GMT Message-Id: <201307141029.r6EATtqh003477@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254778 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jul 2013 10:29:56 -0000 Author: dpl Date: Sun Jul 14 10:29:55 2013 New Revision: 254778 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254778 Log: Changed to work on all the files, that are opened before. Modified: soc2013/dpl/head/contrib/xz/src/xz/list.c Modified: soc2013/dpl/head/contrib/xz/src/xz/list.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/list.c Sun Jul 14 10:28:36 2013 (r254777) +++ soc2013/dpl/head/contrib/xz/src/xz/list.c Sun Jul 14 10:29:55 2013 (r254778) @@ -1057,57 +1057,45 @@ extern void -list_file(const char *filename) +list_file(file_pair pairs[], int files) { int i; - - if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO) - message_fatal(_("--list works only on .xz files " - "(--format=xz or --format=auto)")); - - for ( i = 0; i < files; i++) { - - message_filename(filename); - - if (filename == stdin_filename) { - message_error(_("--list does not support reading from " - "standard input")); - continue; - } + xz_file_info xfi = XZ_FILE_INFO_INIT; // Unset opt_stdout so that io_open_src() won't accept special files. // Set opt_force so that io_open_src() will follow symlinks. opt_stdout = false; opt_force = true; - file_pair *pair = io_open_src(filename); - if (pair == NULL) - continue; - xz_file_info xfi = XZ_FILE_INFO_INIT; - if (!parse_indexes(&xfi, pair)) { - bool fail; - - // We have three main modes: - // - --robot, which has submodes if --verbose is specified - // once or twice - // - Normal --list without --verbose - // - --list with one or two --verbose - if (opt_robot) - fail = print_info_robot(&xfi, pair); - else if (message_verbosity_get() <= V_WARNING) - fail = print_info_basic(&xfi, pair); - else - fail = print_info_adv(&xfi, pair); - - // Update the totals that are displayed after all - // the individual files have been listed. Don't count - // broken files. - if (!fail) - update_totals(&xfi); - - lzma_index_end(xfi.idx, NULL); + for (i = 0; i < files; i++) { + if (pairs[i] == NULL) + continue; + + if (!parse_indexes(&xfi, pairs[i])) { + bool fail; + + // We have three main modes: + // - --robot, which has submodes if --verbose is specified + // once or twice + // - Normal --list without --verbose + // - --list with one or two --verbose + if (opt_robot) + fail = print_info_robot(&xfi, pairs[i]); + else if (message_verbosity_get() <= V_WARNING) + fail = print_info_basic(&xfi, pairs[i]); + else + fail = print_info_adv(&xfi, pairs[i]); + + // Update the totals that are displayed after all + // the individual files have been listed. Don't count + // broken files. + if (!fail) + update_totals(&xfi); + + lzma_index_end(xfi.idx, NULL); + } + + io_close(pairs[i], false); } - - io_close(pair, false); return; } From owner-svn-soc-all@FreeBSD.ORG Sun Jul 14 10:31:55 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 33F7B6DE for ; Sun, 14 Jul 2013 10:31:55 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 252DCC68 for ; Sun, 14 Jul 2013 10:31:55 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6EAVt3T038289 for ; Sun, 14 Jul 2013 10:31:55 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6EAVt1H038284 for svn-soc-all@FreeBSD.org; Sun, 14 Jul 2013 10:31:55 GMT (envelope-from dpl@FreeBSD.org) Date: Sun, 14 Jul 2013 10:31:55 GMT Message-Id: <201307141031.r6EAVt1H038284@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254779 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jul 2013 10:31:55 -0000 Author: dpl Date: Sun Jul 14 10:31:54 2013 New Revision: 254779 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254779 Log: Open all the files before working with them, and limit them in the process. We call cap_init() before working with any file. Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c soc2013/dpl/head/contrib/xz/src/xz/coder.h soc2013/dpl/head/contrib/xz/src/xz/file_io.c soc2013/dpl/head/contrib/xz/src/xz/file_io.h Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.c Sun Jul 14 10:29:55 2013 (r254778) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.c Sun Jul 14 10:31:54 2013 (r254779) @@ -609,59 +609,52 @@ extern void -coder_run(const char *filename) +coder_run(file_pair pairs[], int files) { - // Set and possibly print the filename for the progress message. - message_filename(filename); + int i; - // Try to open the input file. - file_pair *pair = io_open_src(filename); - if (pair == NULL) - return; - - // Assume that something goes wrong. - bool success = false; - - // Read the first chunk of input data. This is needed to detect - // the input file type (for now, only for decompression). - strm.next_in = in_buf.u8; - strm.avail_in = io_read(pair, &in_buf, IO_BUFFER_SIZE); - - if (strm.avail_in != SIZE_MAX) { - // Initialize the coder. This will detect the file format - // and, in decompression or testing mode, check the memory - // usage of the first Block too. This way we don't try to - // open the destination file if we see that coding wouldn't - // work at all anyway. This also avoids deleting the old - // "target" file if --force was used. - const enum coder_init_ret init_ret = coder_init(pair); - - if (init_ret != CODER_INIT_ERROR && !user_abort) { - // Don't open the destination file when --test - // is used. - if (opt_mode == MODE_TEST || !io_open_dest(pair)) { + for( i=0; i < files; i++) { + // Set and possibly print the filename for the progress message. + message_filename(pairs[i].src_name); + + // Assume that something goes wrong. + bool success = false; + + // Read the first chunk of input data. This is needed to detect + // the input file type (for now, only for decompression). + strm.next_in = in_buf.u8; + strm.avail_in = io_read(&pairs[i], &in_buf, IO_BUFFER_SIZE); + + if (strm.avail_in != SIZE_MAX) { + // Initialize the coder. This will detect the file format + // and, in decompression or testing mode, check the memory + // usage of the first Block too. This way we don't try to + // open the destination file if we see that coding wouldn't + // work at all anyway. This also avoids deleting the old + // "target" file if --force was used. + const enum coder_init_ret init_ret = coder_init(&pairs[i]); + + if (init_ret != CODER_INIT_ERROR && !user_abort) { // Initialize the progress indicator. const uint64_t in_size - = pair->src_st.st_size <= 0 - ? 0 : pair->src_st.st_size; + = pairs[i].src_st.st_size <= 0 + ? 0 : pairs[i].src_st.st_size; message_progress_start(&strm, in_size); // Do the actual coding or passthru. if (init_ret == CODER_INIT_NORMAL) - success = coder_normal(pair); + success = coder_normal(&pairs[i]); else - success = coder_passthru(pair); + success = coder_passthru(&pairs[i]); message_progress_end(success); } } + + // Close the file pair. It needs to know if coding was successful to + // know if the source or target file should be unlinked. + io_close(&pairs[i], success); } - // Close the file pair. It needs to know if coding was successful to - // know if the source or target file should be unlinked. - io_close(pair, success); - return; - - } Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.h Sun Jul 14 10:29:55 2013 (r254778) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.h Sun Jul 14 10:31:54 2013 (r254779) @@ -58,4 +58,4 @@ extern void coder_set_compression_settings(void); /// Compress or decompress the given file -extern void coder_run(const char *filename); +extern void coder_run(file_pair *pairs[], int files); Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Sun Jul 14 10:29:55 2013 (r254778) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Sun Jul 14 10:31:54 2013 (r254779) @@ -527,6 +527,15 @@ .dest_pending_sparse = 0, }; +/* pair = (file_pair *)malloc(sizeof(file_pair);*/ +/* pair.src_name = src_name;*/ +/* pair.dest_name = NULL;*/ +/* pair.src_fd = -1;*/ +/* pair.dest_fd = -1;*/ +/* pair.src_eof = false;*/ +/* pair.dest_try_sparse = false;*/ +/* pair.dest_pending_sparse = 0;*/ + // Block the signals, for which we have a custom signal handler, so // that we don't need to worry about EINTR. signals_block(); @@ -956,10 +965,58 @@ return io_write_buf(pair, buf->u8, size); } -extern file_pair -io_open_files(char *filenames[], int files) +extern file_pair ** +io_list_open(char *filename[], int files) { - return; + int i; + file_pair *pairs[files]; + + //Open files a la list_file() + if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO) + message_fatal(_("--list works only on .xz files " + "(--format=xz or --format=auto)")); + + for ( i = 0; i < files; i++) { + message_filename(filename[i]); + + if (filename[i] == stdin_filename) { + message_error(_("--list does not support reading from " + "standard input")); + continue; + } + + // Unset opt_stdout so that io_open_src() won't accept special files. + // Set opt_force so that io_open_src() will follow symlinks. + opt_stdout = false; + opt_force = true; + pairs[i] = io_open_src(filename[i]); +#if defined(CAPSICUM) + limitfd(pairs[i]); +#endif + } + return pairs; +} + +extern file_pair ** +io_coder_open(char *filename[], int files) +{ + int i; + file_pair *pairs[files]; + + for ( i = 0; i < files; i++) { + // Set and possibly print the filename for the progress message. + message_filename(filename[i]); + + // Try to open the input file. + pairs[i] = io_open_src(filename[i]); + if( opt_mode != MODE_TEST ) + io_open_dest(pairs[i]); +#if defined(CAPSICUM) + limitfd(pairs[i]); +#endif + } + + return pairs; } #if defined(CAPSICUM) Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.h Sun Jul 14 10:29:55 2013 (r254778) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.h Sun Jul 14 10:31:54 2013 (r254779) @@ -28,42 +28,6 @@ } io_buf; -typedef struct { - /// Name of the source filename (as given on the command line) or - /// pointer to static "(stdin)" when reading from standard input. - const char *src_name; - - /// Destination filename converted from src_name or pointer to static - /// "(stdout)" when writing to standard output. - char *dest_name; - - /// File descriptor of the source file - int src_fd; - - /// File descriptor of the target file - int dest_fd; - - /// True once end of the source file has been detected. - bool src_eof; - - /// If true, we look for long chunks of zeros and try to create - /// a sparse file. - bool dest_try_sparse; - - /// This is used only if dest_try_sparse is true. This holds the - /// number of zero bytes we haven't written out, because we plan - /// to make that byte range a sparse chunk. - off_t dest_pending_sparse; - - /// Stat of the source file. - struct stat src_st; - - /// Stat of the destination file. - struct stat dest_st; - -} file_pair; - - /// \brief Initialize the I/O module extern void io_init(void); @@ -129,14 +93,21 @@ extern bool io_write(file_pair *pair, const io_buf *buf, size_t size); -/// \brief Open all the files as needed. +/// \brief Open all the files as needed in lit_file(). /// /// \param filenames Array containing all the filenames to be open. /// \param files Number of files to open. /// /// \return Returns an array of file_pairs. -extern file_pair io_open_files(char *filenames[], int files); +extern file_pair ** io_list_open(char *filenames[], int files); +/// \brief Open all the files as needed in coder_run(). +/// +/// \param filenames Array containing all the filenames to be open. +/// \param files Number of files to open. +/// +/// \return Returns an array of file_pairs. +extern file_pair ** io_coder_open(char *filenames[], int files); #if defined(CAPSICUM) /// \brief Limits fd using FreeBSD's Capsicum framework. From owner-svn-soc-all@FreeBSD.ORG Mon Jul 15 13:47:07 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B0BF2DBE for ; Mon, 15 Jul 2013 13:47:07 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A1F60BA1 for ; Mon, 15 Jul 2013 13:47:07 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6FDl7YH000959 for ; Mon, 15 Jul 2013 13:47:07 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6FDl78N000956 for svn-soc-all@FreeBSD.org; Mon, 15 Jul 2013 13:47:07 GMT (envelope-from def@FreeBSD.org) Date: Mon, 15 Jul 2013 13:47:07 GMT Message-Id: <201307151347.r6FDl78N000956@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254804 - in soc2013/def/crashdump-head/sys: kern sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jul 2013 13:47:07 -0000 Author: def Date: Mon Jul 15 13:47:07 2013 New Revision: 254804 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254804 Log: Encrypt a crash dump with a constant AES key and make it suitable for savecore - the first version. Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/conf.h Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Mon Jul 15 12:18:36 2013 (r254803) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Mon Jul 15 13:47:07 2013 (r254804) @@ -867,6 +867,8 @@ dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, off_t offset, size_t length) { + size_t resid; + int error; if (length != 0 && (offset < di->mediaoffset || offset - di->mediaoffset + length > di->mediasize)) { @@ -876,7 +878,49 @@ (uintmax_t)length, (intmax_t)di->mediasize); return (ENOSPC); } - return (di->dumper(di->priv, virtual, physical, offset, length)); + + /* Write kernel dump headers. */ + if (di->offset == 0 || offset == di->kdhoffset) { + di->offset = offset + length; + return (di->dumper(di->priv, virtual, physical, offset, length)); + } + + /* The last dump_write call in the current crash. */ + if (virtual == NULL && physical == 0 && offset == 0 && length == 0) { + xts_block_encrypt(&xts_alg_aes, di->tweak_ctx, di->data_ctx, + di->offset, di->tweak, di->buf_used, + di->buf, di->buf); + return (di->dumper(di->priv, di->buf, physical, di->offset, di->buf_used)); + } + + offset = di->offset; + + while (length + di->buf_used >= di->blocksize) { + resid = qmin(length, di->blocksize - di->buf_used); + memcpy(di->buf + di->buf_used, virtual, resid); + di->buf_used += resid; + xts_block_encrypt(&xts_alg_aes, di->tweak_ctx, di->data_ctx, + offset, di->tweak, di->blocksize, + di->buf, di->buf); + error = (di->dumper(di->priv, di->buf, physical, offset, di->buf_used)); + + if (error) + return (error); + + virtual = (void *)((char *)virtual + resid); + offset += resid; + length -= resid; + di->buf_used = 0; + di->offset = offset; + } + + /* We still have less than blocksize of data to dump. */ + if (length > 0) { + memcpy(di->buf + di->buf_used, virtual, length); + di->buf_used += length; + } + + return (0); } void @@ -888,6 +932,9 @@ di->tweak = kerneldumptweak; di->tweak_ctx = &dumper_tweak_ctx; di->data_ctx = &dumper_data_ctx; + di->buf_used = 0; + di->offset = 0; + di->kdhoffset = 0; rijndael_set_key(di->tweak_ctx, di->key, KERNELDUMP_KEY_SIZE << 3); rijndael_set_key(di->data_ctx, di->key, KERNELDUMP_KEY_SIZE << 3); } @@ -914,4 +961,6 @@ kdh->tweaksize = KERNELDUMP_TWEAK_SIZE; strncpy(kdh->tweak, dumper.tweak, kdh->tweaksize); kdh->parity = kerneldump_parity(kdh); + + dumper.kdhoffset = dumper.mediaoffset + dumper.mediasize - sizeof(*kdh); } Modified: soc2013/def/crashdump-head/sys/sys/conf.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/conf.h Mon Jul 15 12:18:36 2013 (r254803) +++ soc2013/def/crashdump-head/sys/sys/conf.h Mon Jul 15 13:47:07 2013 (r254804) @@ -333,8 +333,12 @@ off_t mediasize; /* Space available in bytes. */ char *key; /* Key information. */ char *tweak; /* Tweak. */ - void *tweak_ctx; - void *data_ctx; + void *tweak_ctx; /* Tweak context. */ + void *data_ctx; /* Data context. */ + uint8_t buf[512]; /* Raw data buffer. */ + u_int buf_used; /* Number of bytes used in the buffer. */ + off_t offset; /* Last used offset in a dump_write call. */ + off_t kdhoffset; /* Offset of the second kernel dump header. */ }; int set_dumper(struct dumperinfo *, const char *_devname); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 04:06:46 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 45FAAB16 for ; Tue, 16 Jul 2013 04:06:46 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 35C1ECDE for ; Tue, 16 Jul 2013 04:06:46 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6G46j2w033298 for ; Tue, 16 Jul 2013 04:06:45 GMT (envelope-from syuu@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6G46jCt033290 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 04:06:45 GMT (envelope-from syuu@FreeBSD.org) Date: Tue, 16 Jul 2013 04:06:45 GMT Message-Id: <201307160406.r6G46jCt033290@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to syuu@FreeBSD.org using -f From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254820 - soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 04:06:46 -0000 Author: syuu Date: Tue Jul 16 04:06:45 2013 New Revision: 254820 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254820 Log: pci_uhci_softc, debuglog output to /tmp/bhyveusb.log, use legacy intr instead of msi, usb rev version fix, uhci_reset segv fix, readable read/write debug message Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Tue Jul 16 03:12:31 2013 (r254819) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Tue Jul 16 04:06:45 2013 (r254820) @@ -43,14 +43,6 @@ #define PCI_VENDOR_ID_INTEL 0x8086 #define PCI_DEVICE_ID_INTEL_82801I_UHCI6 0x2939 -/* - * Per-device softc - */ -struct pci_uhci_softc { - struct pci_devinst *sc_pi; - pthread_mutex_t sc_mtx; -}; - struct PCIDevice { uint8_t *config; }; @@ -62,93 +54,95 @@ typedef struct PCIDeviceClass PCIDeviceClass; typedef struct MemoryRegion MemoryRegion; +FILE *usblog; + #define trace_usb_uhci_queue_add(token) \ - fprintf(stderr, "%s:%d trace_usb_uhci_queue_add token=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_queue_add token=%x\n", \ __func__, __LINE__, token) #define trace_usb_uhci_queue_del(token, reason) \ - fprintf(stderr, "%s:%d trace_usb_uhci_queue_del token=%x reason=%s\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_queue_del token=%x reason=%s\n", \ __func__, __LINE__, token, reason) #define trace_usb_uhci_packet_add(token, td_addr) \ - fprintf(stderr, "%s:%d trace_usb_uhci_packet_add token=%x td_addr=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_packet_add token=%x td_addr=%x\n", \ __func__, __LINE__, token, td_addr) #define trace_usb_uhci_packet_del(token, td_addr) \ - fprintf(stderr, "%s:%d trace_usb_uhci_packet_del token=%x td_addr=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_packet_del token=%x td_addr=%x\n", \ __func__, __LINE__, token, td_addr) #define trace_usb_uhci_packet_cancel(token, td_addr, done) \ - fprintf(stderr, "%s:%d trace_usb_uhci_packet_cancel token=%x td_addr=%x done=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_packet_cancel token=%x td_addr=%x done=%x\n", \ __func__, __LINE__, token, td_addr, done) #define trace_usb_uhci_packet_link_async(token, td_addr) \ - fprintf(stderr, "%s:%d trace_usb_uhci_packet_link_async token=%x td_addr=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_packet_link_async token=%x td_addr=%x\n", \ __func__, __LINE__, token, td_addr) #define trace_usb_uhci_packet_unlink_async(token, td_addr) \ - fprintf(stderr, "%s:%d trace_usb_uhci_packet_unlink_async token=%x td_addr=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_packet_unlink_async token=%x td_addr=%x\n", \ __func__, __LINE__, token, td_addr) #define trace_usb_uhci_reset() \ - fprintf(stderr, "%s:%d trace_usb_uhci_reset\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_reset\n", \ __func__, __LINE__) #define trace_usb_uhci_mmio_writew(addr, val) \ - fprintf(stderr, "%s:%d trace_usb_uhci_mmio_writew addr=%lx val=%lx\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_mmio_writew addr=%lx val=%lx\n", \ __func__, __LINE__, addr, val) #define trace_usb_uhci_mmio_readw(addr, val) \ - fprintf(stderr, "%s:%d trace_usb_uhci_mmio_readw addr=%lx val=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_mmio_readw addr=%lx val=%x\n", \ __func__, __LINE__, addr, val) #define trace_usb_uhci_schedule_start() \ - fprintf(stderr, "%s:%d trace_usb_uhci_schedule_start\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_schedule_start\n", \ __func__, __LINE__) #define trace_usb_uhci_packet_complete_stall(token, td_addr) \ - fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_stall token=%x td_addr=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_packet_complete_stall token=%x td_addr=%x\n", \ __func__, __LINE__, token, td_addr) #define trace_usb_uhci_packet_complete_babble(token, td_addr) \ - fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_babble token=%x td_addr=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_packet_complete_babble token=%x td_addr=%x\n", \ __func__, __LINE__, token, td_addr) #define trace_usb_uhci_packet_complete_error(token, td_addr) \ - fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_error token=%x td_addr=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_packet_complete_error token=%x td_addr=%x\n", \ __func__, __LINE__, token, td_addr) #define trace_usb_uhci_packet_complete_shortxfer(token, td_addr) \ - fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_shortxfer token=%x td_addr=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_packet_complete_shortxfer token=%x td_addr=%x\n", \ __func__, __LINE__, token, td_addr) #define trace_usb_uhci_packet_complete_success(token, td_addr) \ - fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_success token=%x td_addr=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_packet_complete_success token=%x td_addr=%x\n", \ __func__, __LINE__, token, td_addr) #define trace_usb_uhci_td_queue(link, ctrl, token) \ - fprintf(stderr, "%s:%d trace_usb_uhci_td_queue link=%x ctrl=%x token=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_td_queue link=%x ctrl=%x token=%x\n", \ __func__, __LINE__, link, ctrl, token) #define trace_usb_uhci_frame_stop_bandwidth() \ - fprintf(stderr, "%s:%d trace_usb_uhci_frame_stop_bandwidth\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_frame_stop_bandwidth\n", \ __func__, __LINE__) #define trace_usb_uhci_qh_load(link) \ - fprintf(stderr, "%s:%d trace_usb_uhci_qh_load link=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_qh_load link=%x\n", \ __func__, __LINE__, link) #define trace_usb_uhci_frame_loop_stop_idle() \ - fprintf(stderr, "%s:%d trace_usb_uhci_frame_loop_stop_idle\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_frame_loop_stop_idle\n", \ __func__, __LINE__) #define trace_usb_uhci_frame_loop_continue() \ - fprintf(stderr, "%s:%d trace_usb_uhci_frame_loop_continue\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_frame_loop_continue\n", \ __func__, __LINE__) #define trace_usb_uhci_td_load(qh, link, ctrl, token) \ - fprintf(stderr, "%s:%d trace_usb_uhci_td_load qh=%x link=%x ctrl=%x token=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_td_load qh=%x link=%x ctrl=%x token=%x\n", \ __func__, __LINE__, qh, link, ctrl, token) #define trace_usb_uhci_td_nextqh(qh, link) \ - fprintf(stderr, "%s:%d trace_usb_uhci_td_nextqh qh=%x link=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_td_nextqh qh=%x link=%x\n", \ __func__, __LINE__, qh, link) #define trace_usb_uhci_td_async(qh, link) \ - fprintf(stderr, "%s:%d trace_usb_uhci_td_async qh=%x link=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_td_async qh=%x link=%x\n", \ __func__, __LINE__, qh, link) #define trace_usb_uhci_td_complete(qh, link) \ - fprintf(stderr, "%s:%d trace_usb_uhci_td_complete qh=%x link=%x\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_td_complete qh=%x link=%x\n", \ __func__, __LINE__, qh, link) #define trace_usb_uhci_schedule_stop() \ - fprintf(stderr, "%s:%d trace_usb_uhci_schedule_stop\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_schedule_stop\n", \ __func__, __LINE__) #define trace_usb_uhci_frame_start(num) \ - fprintf(stderr, "%s:%d trace_usb_uhci_frame_start num=%d\n", \ + fprintf(usblog, "%s:%d trace_usb_uhci_frame_start num=%d\n", \ __func__, __LINE__, num) //#define DEBUG //#define DEBUG_DUMP_DATA #define PCI_USBREV 0x60 /* USB protocol revision */ -#define PCI_USB_REV_1_1 0x11 +#define PCI_USB_REV_1_0 0x10 #define UHCI_CMD_FGR (1 << 4) #define UHCI_CMD_EGSM (1 << 3) @@ -257,6 +251,7 @@ } UHCIPort; struct UHCIState { + struct pci_uhci_softc *sc; PCIDevice dev; MemoryRegion io_bar; USBBus bus; /* Note unused when we're a companion controller */ @@ -301,8 +296,18 @@ uint32_t el_link; } UHCI_QH; +/* + * Per-device softc + */ +struct pci_uhci_softc { + struct pci_devinst *sc_pi; + struct UHCIState sc_st; + pthread_mutex_t sc_mtx; +}; + static void uhci_async_cancel(UHCIAsync *async); static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td); +static void uhci_process_frame(UHCIState *s); static inline int32_t uhci_queue_token(UHCI_TD *td) { @@ -341,7 +346,7 @@ async = QTAILQ_FIRST(&queue->asyncs); uhci_async_cancel(async); } - usb_device_ep_stopped(queue->ep->dev, queue->ep); +// usb_device_ep_stopped(queue->ep->dev, queue->ep); trace_usb_uhci_queue_del(queue->token, reason); QTAILQ_REMOVE(&s->queues, queue, next); @@ -494,21 +499,23 @@ level = 0; } // qemu_set_irq(s->dev.irq[s->irq_pin], level); + if (level) + pci_lintr_assert(s->sc->sc_pi); + else + pci_lintr_deassert(s->sc->sc_pi); } static void uhci_reset(void *opaque) { UHCIState *s = opaque; - uint8_t *pci_conf; int i; UHCIPort *port; + struct pci_uhci_softc *sc = s->sc; trace_usb_uhci_reset(); - pci_conf = s->dev.config; - - pci_conf[0x6a] = 0x01; /* usb clock */ - pci_conf[0x6b] = 0x00; + pci_set_cfgdata8(sc->sc_pi, 0x6a, 0x01); /* XXX: use macro */ + pci_set_cfgdata8(sc->sc_pi, 0x6b, 0x00); s->cmd = 0; s->status = 0; s->status2 = 0; @@ -587,10 +594,11 @@ { UHCIState *s = opaque; - trace_usb_uhci_mmio_writew(addr, val); +// trace_usb_uhci_mmio_writew(addr, val); switch(addr) { case 0x00: + fprintf(usblog, "%s USBCMD val:%lx\n", __func__, val); if ((val & UHCI_CMD_RS) && !(s->cmd & UHCI_CMD_RS)) { /* start frame processing */ trace_usb_uhci_schedule_start(); @@ -620,6 +628,7 @@ s->cmd = val; break; case 0x02: + fprintf(usblog, "%s USBSTS val:%lx\n", __func__, val); s->status &= ~val; /* XXX: the chip spec is not coherent, so we add a hidden register to distinguish between IOC and SPD */ @@ -628,22 +637,27 @@ uhci_update_irq(s); break; case 0x04: + fprintf(usblog, "%s USBINTR val:%lx\n", __func__, val); s->intr = val; uhci_update_irq(s); break; case 0x06: + fprintf(usblog, "%s FRNUM val:%lx\n", __func__, val); if (s->status & UHCI_STS_HCHALTED) s->frnum = val & 0x7ff; break; case 0x08: + fprintf(usblog, "%s FRBASEADD(lo) val:%lx\n", __func__, val); s->fl_base_addr &= 0xffff0000; s->fl_base_addr |= val & ~0xfff; break; case 0x0a: + fprintf(usblog, "%s FRBASEADD(hi) val:%lx\n", __func__, val); s->fl_base_addr &= 0x0000ffff; s->fl_base_addr |= (val << 16); break; case 0x0c: + fprintf(usblog, "%s SOFMOD val:%lx\n", __func__, val); s->sof_timing = val & 0xff; break; case 0x10 ... 0x1f: @@ -653,6 +667,7 @@ int n; n = (addr >> 1) & 7; + fprintf(usblog, "%s PORTSC%d val:%lx\n", __func__, n, val); if (n >= NB_PORTS) return; port = &s->ports[n]; @@ -685,24 +700,31 @@ switch(addr) { case 0x00: val = s->cmd; + fprintf(usblog, "%s USBCMD val:%x\n", __func__, val); break; case 0x02: val = s->status; + fprintf(usblog, "%s USBSTS val:%x\n", __func__, val); break; case 0x04: val = s->intr; + fprintf(usblog, "%s USBINTR val:%x\n", __func__, val); break; case 0x06: val = s->frnum; + fprintf(usblog, "%s FRNUM val:%x\n", __func__, val); break; case 0x08: val = s->fl_base_addr & 0xffff; + fprintf(usblog, "%s FRBASEADD(lo) val:%x\n", __func__, val); break; case 0x0a: val = (s->fl_base_addr >> 16) & 0xffff; + fprintf(usblog, "%s FRBASEADD(hi) val:%x\n", __func__, val); break; case 0x0c: val = s->sof_timing; + fprintf(usblog, "%s SOFMOD val:%x\n", __func__, val); break; case 0x10 ... 0x1f: { @@ -713,6 +735,7 @@ goto read_default; port = &s->ports[n]; val = port->ctrl; + fprintf(usblog, "%s PORTSC%d val:%x\n", __func__, n, val); } break; default: @@ -721,7 +744,7 @@ break; } - trace_usb_uhci_mmio_readw(addr, val); +// trace_usb_uhci_mmio_readw(addr, val); return val; } @@ -1060,6 +1083,7 @@ /* Force processing of this packet *now*, needed for migration */ s->completions_only = true; // qemu_bh_schedule(s->bh); + uhci_process_frame(s); } static int is_valid(uint32_t link) @@ -1542,7 +1566,7 @@ struct pci_uhci_softc *sc = pi->pi_arg; pthread_mutex_lock(&sc->sc_mtx); - printf("%s baridx:%d offset:%lx size:%d value:%lx\n", __func__, baridx, offset, size, value); + uhci_port_write(&sc->sc_st, offset, value, size); pthread_mutex_unlock(&sc->sc_mtx); } @@ -1555,7 +1579,7 @@ uint64_t value; pthread_mutex_lock(&sc->sc_mtx); - printf("%s baridx:%d offset:%lx size:%d\n", __func__, baridx, offset, size); + value = uhci_port_read(&sc->sc_st, offset, size); pthread_mutex_unlock(&sc->sc_mtx); return (value); @@ -1566,8 +1590,13 @@ { struct pci_uhci_softc *sc; + usblog = fopen("/tmp/bhyveusb.log", "w"); + if (!usblog) { + perror("fopen"); + exit(1); + } sc = malloc(sizeof(struct pci_uhci_softc)); - memset(sc, 0, sizeof(struct pci_uhci_softc)); + memset(sc, 0, sizeof(*sc)); pi->pi_arg = sc; sc->sc_pi = pi; @@ -1578,10 +1607,19 @@ pci_set_cfgdata16(pi, PCIR_DEVICE, PCI_DEVICE_ID_INTEL_82801I_UHCI6); pci_set_cfgdata16(pi, PCIR_VENDOR, PCI_VENDOR_ID_INTEL); pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_SERIALBUS); - pci_set_cfgdata8(pi, PCI_USBREV, PCI_USB_REV_1_1); - - /* MSI support */ - pci_emul_add_msicap(pi, 1); + pci_set_cfgdata8(pi, PCI_USBREV, PCI_USB_REV_1_0); + + if (!pci_is_legacy(pi)) { + fprintf(stderr, "hcd-uhci works only in legacy mode\n"); + } else { + pci_lintr_request(pi, 9); + } + + memset(&sc->sc_st, 0, sizeof(sc->sc_st)); + sc->sc_st.num_ports_vmstate = NB_PORTS; + QTAILQ_INIT(&sc->sc_st.queues); + sc->sc_st.sc = sc; + uhci_reset(&sc->sc_st); pci_emul_alloc_bar(pi, 4, PCIBAR_IO, 0x20); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 06:15:34 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E68B512E for ; Tue, 16 Jul 2013 06:15:33 +0000 (UTC) (envelope-from oleksandr@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id D7AC2B1 for ; Tue, 16 Jul 2013 06:15:33 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6G6FXDo018624 for ; Tue, 16 Jul 2013 06:15:33 GMT (envelope-from oleksandr@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6G6FXfM018616 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 06:15:33 GMT (envelope-from oleksandr@FreeBSD.org) Date: Tue, 16 Jul 2013 06:15:33 GMT Message-Id: <201307160615.r6G6FXfM018616@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to oleksandr@FreeBSD.org using -f From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254822 - soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 06:15:34 -0000 Author: oleksandr Date: Tue Jul 16 06:15:33 2013 New Revision: 254822 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254822 Log: Add vboxvfs_mnt struct, correct vfsops.c function and code style fix Modified: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk Modified: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk ============================================================================== --- soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk Tue Jul 16 04:39:44 2013 (r254821) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk Tue Jul 16 06:15:33 2013 (r254822) @@ -9,3 +9,434 @@ include $(PATH_SUB_CURRENT)/drm/Makefile.kmk # +--- src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk ++++ src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk +@@ -38,7 +38,7 @@ vboxvfs_LIBS = \ + $(VBOX_LIB_VBGL_R0) \ + $(VBOX_LIB_IPRT_GUEST_R0) + vboxvfs_DEPS = \ +- $$(vboxvfs_0_OUTDIR)/vnode_if.h \ ++# $$(vboxvfs_0_OUTDIR)/vnode_if.h \ + $$(vboxvfs_0_OUTDIR)/vnode_if_newproto.h \ + $$(vboxvfs_0_OUTDIR)/vnode_if_typedef.h + vboxvfs_CLEAN += $(vboxvfs_DEPS) +--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h ++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h +@@ -23,6 +23,7 @@ + + #define MAX_HOST_NAME 256 + #define MAX_NLS_NAME 32 ++#define VFSTOVBOXFS(mp) ((struct vboxvfs_mnt *)((mp)->mnt_data)) + + struct vboxvfs_mount_info { + char name[MAX_HOST_NAME]; +@@ -35,10 +36,26 @@ struct vboxvfs_mount_info { + #ifdef _KERNEL + + #include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h" +-#include +-#include ++/*#include ++#include */ ++ ++struct vboxvfs_mnt ++{ ++ VBSFMAP map; ++ int im_flags; ++ struct mount *im_mountp; ++ struct g_consumer *im_cp; ++ struct bufobj *im_bo; ++ struct cdev *im_dev; ++ struct vnode *im_devvp; ++ off_t size; ++ int bsize; ++ int bshift; ++ int bmask; ++ int use_devvp; ++}; + +-struct vboxvfsmount { ++struct vboxvfs_mount { + uid_t uid; + gid_t gid; + mode_t file_mode; +--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c ++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c +@@ -51,208 +51,239 @@ static vfs_statfs_t vboxvfs_statfs; + static vfs_unmount_t vboxvfs_unmount; + + static struct vfsops vboxvfs_vfsops = { +- .vfs_init = vboxvfs_init, +- .vfs_cmount = vboxvfs_cmount, +- .vfs_mount = vboxvfs_mount, +- .vfs_quotactl = vboxvfs_quotactl, +- .vfs_root = vboxvfs_root, +- .vfs_statfs = vboxvfs_statfs, +- .vfs_sync = vfs_stdsync, +- .vfs_uninit = vboxvfs_uninit, +- .vfs_unmount = vboxvfs_unmount, ++ .vfs_init = vboxvfs_init, ++ .vfs_cmount = vboxvfs_cmount, ++ .vfs_mount = vboxvfs_mount, ++ .vfs_quotactl = vboxvfs_quotactl, ++ .vfs_root = vboxvfs_root, ++ .vfs_statfs = vboxvfs_statfs, ++ .vfs_sync = vfs_stdsync, ++ .vfs_uninit = vboxvfs_uninit, ++ .vfs_unmount = vboxvfs_unmount, + }; + + + VFS_SET(vboxvfs_vfsops, vboxvfs, VFCF_NETWORK); + MODULE_DEPEND(vboxvfs, vboxguest, 1, 1, 1); + +-static int vboxvfs_cmount(struct mntarg *ma, void * data, int flags, struct thread *td) ++static int vboxvfs_cmount(struct mntarg *ma, void *data, uint64_t flags) + { +- struct vboxvfs_mount_info args; +- int rc = 0; ++ struct vboxvfs_mount_info args; ++ int rc = 0; + +- printf("%s: Enter\n", __FUNCTION__); ++ printf("%s: Enter\n", __FUNCTION__); + +- rc = copyin(data, &args, sizeof(struct vboxvfs_mount_info)); +- if (rc) +- return rc; ++ rc = copyin(data, &args, sizeof(struct vboxvfs_mount_info)); ++ if (rc) ++ return (rc); + +- ma = mount_argf(ma, "uid", "%d", args.uid); +- ma = mount_argf(ma, "gid", "%d", args.gid); +- ma = mount_arg(ma, "from", args.name, -1); ++ ma = mount_argf(ma, "uid", "%d", args.uid); ++ ma = mount_argf(ma, "gid", "%d", args.gid); ++ ma = mount_arg(ma, "from", args.name, -1); + +- rc = kernel_mount(ma, flags); ++ rc = kernel_mount(ma, flags); + +- printf("%s: Leave rc=%d\n", __FUNCTION__, rc); ++ printf("%s: Leave rc=%d\n", __FUNCTION__, rc); + +- return rc; +-} ++ return (rc); ++}; + + static const char *vboxvfs_opts[] = { +- "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL ++ "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL + }; + +-static int vboxvfs_mount(struct mount *mp, struct thread *td) ++static int vboxvfs_mount(struct mount *mp) + { +- int rc; +- char *pszShare; +- int cbShare, cbOption; +- int uid = 0, gid = 0; +- struct sf_glob_info *pShFlGlobalInfo; +- SHFLSTRING *pShFlShareName = NULL; +- int cbShFlShareName; ++ int rc; ++ char *pszShare; ++ int cbShare, cbOption; ++ int uid = 0, gid = 0; ++ struct sf_glob_info *pShFlGlobalInfo; ++ SHFLSTRING *pShFlShareName = NULL; ++ int cbShFlShareName; + +- printf("%s: Enter\n", __FUNCTION__); ++ printf("%s: Enter\n", __FUNCTION__); + +- if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS)) +- return EOPNOTSUPP; ++ if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS)) ++ return (EOPNOTSUPP); + +- if (vfs_filteropt(mp->mnt_optnew, vboxvfs_opts)) +- { +- vfs_mount_error(mp, "%s", "Invalid option"); +- return EINVAL; +- } ++ if (vfs_filteropt(mp->mnt_optnew, vboxvfs_opts)) ++ { ++ vfs_mount_error(mp, "%s", "Invalid option"); ++ return (EINVAL); ++ } + +- rc = vfs_getopt(mp->mnt_optnew, "from", (void **)&pszShare, &cbShare); +- if (rc || pszShare[cbShare-1] != '\0' || cbShare > 0xfffe) +- return EINVAL; ++ rc = vfs_getopt(mp->mnt_optnew, "from", (void **)&pszShare, &cbShare); ++ if (rc || pszShare[cbShare-1] != '\0' || cbShare > 0xfffe) ++ return (EINVAL); + +- rc = vfs_getopt(mp->mnt_optnew, "gid", (void **)&gid, &cbOption); +- if ((rc != ENOENT) && (rc || cbOption != sizeof(gid))) +- return EINVAL; ++ rc = vfs_getopt(mp->mnt_optnew, "gid", (void **)&gid, &cbOption); ++ if ((rc != ENOENT) && (rc || cbOption != sizeof(gid))) ++ return EINVAL; + +- rc = vfs_getopt(mp->mnt_optnew, "uid", (void **)&uid, &cbOption); +- if ((rc != ENOENT) && (rc || cbOption != sizeof(uid))) +- return EINVAL; ++ rc = vfs_getopt(mp->mnt_optnew, "uid", (void **)&uid, &cbOption); ++ if ((rc != ENOENT) && (rc || cbOption != sizeof(uid))) ++ return EINVAL; + +- pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info)); +- if (!pShFlGlobalInfo) +- return ENOMEM; ++ pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info)); ++ if (!pShFlGlobalInfo) ++ return ENOMEM; + +- cbShFlShareName = offsetof (SHFLSTRING, String.utf8) + cbShare + 1; +- pShFlShareName = RTMemAllocZ(cbShFlShareName); +- if (!pShFlShareName) +- return VERR_NO_MEMORY; ++ cbShFlShareName = offsetof (SHFLSTRING, String.utf8) + cbShare + 1; ++ pShFlShareName = RTMemAllocZ(cbShFlShareName); ++ if (!pShFlShareName) ++ return VERR_NO_MEMORY; + +- pShFlShareName->u16Length = cbShFlShareName; +- pShFlShareName->u16Size = cbShFlShareName + 1; +- memcpy (pShFlShareName->String.utf8, pszShare, cbShare + 1); ++ pShFlShareName->u16Length = cbShFlShareName; ++ pShFlShareName->u16Size = cbShFlShareName + 1; ++ memcpy (pShFlShareName->String.utf8, pszShare, cbShare + 1); + +- rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map); +- RTMemFree(pShFlShareName); ++ rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map); ++ RTMemFree(pShFlShareName); + +- if (RT_FAILURE (rc)) +- { +- RTMemFree(pShFlGlobalInfo); +- printf("vboxCallMapFolder failed rc=%d\n", rc); +- return EPROTO; +- } ++ if (RT_FAILURE (rc)) ++ { ++ RTMemFree(pShFlGlobalInfo); ++ printf("vboxCallMapFolder failed rc=%d\n", rc); ++ return (EPROTO); ++ } + +- pShFlGlobalInfo->uid = uid; +- pShFlGlobalInfo->gid = gid; ++ pShFlGlobalInfo->uid = uid; ++ pShFlGlobalInfo->gid = gid; + +- mp->mnt_data = pShFlGlobalInfo; ++ mp->mnt_data = pShFlGlobalInfo; + +- /* @todo root vnode. */ ++ /* @todo root vnode. */ + +- vfs_getnewfsid(mp); +- vfs_mountedfrom(mp, pszShare); ++ vfs_getnewfsid(mp); ++ vfs_mountedfrom(mp, pszShare); + +- printf("%s: Leave rc=0\n", __FUNCTION__); ++ printf("%s: Leave rc=0\n", __FUNCTION__); + +- return 0; +-} ++ return (0); ++}; + +-static int vboxvfs_unmount(struct mount *mp, int mntflags, struct thread *td) ++/* ++ * Unmount a shared folder. ++ * ++ * vboxvfs_unmount umounts the mounted file system. It return 0 ++ * on sucess and any relevant errno on failure. ++ */ ++static int vboxvfs_unmount(struct mount *mp, int mntflags) + { +- struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); +- int rc; +- int flags = 0; ++ struct thread *td = curthread; ++/* struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); */ ++ struct vboxvfs_mnt *vboxvfsmp; ++ int error; ++ int flags = 0; ++ ++ vboxvfsmp = VFSTOVBOXFS(mp); + +- rc = vboxCallUnmapFolder(&g_vboxSFClient, &pShFlGlobalInfo->map); +- if (RT_FAILURE(rc)) +- printf("Failed to unmap shared folder\n"); ++ error = vboxCallUnmapFolder(&g_vboxSFClient, &vboxvfsmp->map); ++ if (RT_FAILURE(error)) ++ printf("Failed to unmap shared folder\n"); + +- if (mntflags & MNT_FORCE) +- flags |= FORCECLOSE; ++ if (mntflags & MNT_FORCE) ++ flags |= FORCECLOSE; + +- /* There is 1 extra root vnode reference (vnode_root). */ +- rc = vflush(mp, 1, flags, td); +- if (rc) +- return rc; ++ /* There is 1 extra root vnode reference (vnode_root). */ ++ error = vflush(mp, 1, flags, td); ++ if (error) ++ return (error); + + +- RTMemFree(pShFlGlobalInfo); +- mp->mnt_data = NULL; ++ RTMemFree(vboxvfsmp); ++ mp->mnt_data = NULL; + +- return 0; ++ return (0); + } + +-static int vboxvfs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td) ++static int vboxvfs_root(struct mount *mp, int flags, struct vnode **vpp) + { +- int rc = 0; +- struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); +- struct vnode *vp; ++ int rc = 0; ++ struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); ++ struct vnode *vp; + +- printf("%s: Enter\n", __FUNCTION__); ++ printf("%s: Enter\n", __FUNCTION__); + +- vp = pShFlGlobalInfo->vnode_root; +- VREF(vp); ++ vp = pShFlGlobalInfo->vnode_root; ++ VREF(vp); + +- vn_lock(vp, flags | LK_RETRY, td); +- *vpp = vp; ++// vn_lock(vp, flags | LK_RETRY, td); ++ *vpp = vp; + +- printf("%s: Leave\n", __FUNCTION__); ++ printf("%s: Leave\n", __FUNCTION__); + +- return rc; ++ return (rc); + } + +-static int vboxvfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg, struct thread *td) ++/* ++ * Do operation associated with quotas, not supported ++ */ ++static int vboxvfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg) + { +- return EOPNOTSUPP; ++ return (EOPNOTSUPP); + } + + int vboxvfs_init(struct vfsconf *vfsp) + { +- int rc; +- +- /* Initialize the R0 guest library. */ +- rc = vboxInit(); +- if (RT_FAILURE(rc)) +- return ENXIO; +- +- /* Connect to the host service. */ +- rc = vboxConnect(&g_vboxSFClient); +- if (RT_FAILURE(rc)) +- { +- printf("Failed to get connection to host! rc=%d\n", rc); +- vboxUninit(); +- return ENXIO; +- } +- +- rc = vboxCallSetUtf8 (&g_vboxSFClient); +- if (RT_FAILURE (rc)) +- { +- printf("vboxCallSetUtf8 failed, rc=%d\n", rc); +- vboxDisconnect(&g_vboxSFClient); +- vboxUninit(); +- return EPROTO; +- } +- +- printf("Successfully loaded shared folder module\n"); +- +- return 0; ++ int rc = -1; ++ ++ /* Initialize the R0 guest library. */ ++ rc = vboxInit(); ++ if (RT_FAILURE(rc)) ++ { ++ printf("sfprov_connect: vboxConnect() failed rc=%d\n", rc); ++ return ENXIO; ++ } ++ ++ /* Connect to the host service. */ ++ rc = vboxConnect(&g_vboxSFClient); ++ if (RT_FAILURE(rc)) ++ { ++ printf("Failed to get connection to host! rc=%d\n", rc); ++ vboxUninit(); ++ return ENXIO; ++ } ++ ++ rc = vboxCallSetUtf8 (&g_vboxSFClient); ++ if (RT_FAILURE (rc)) ++ { ++ printf("vboxCallSetUtf8 failed, rc=%d\n", rc); ++ vboxDisconnect(&g_vboxSFClient); ++ vboxUninit(); ++ return EPROTO; ++ } ++ ++ printf("Successfully loaded shared folder module\n"); ++ ++ return (0); + } + + int vboxvfs_uninit(struct vfsconf *vfsp) + { +- vboxDisconnect(&g_vboxSFClient); +- vboxUninit(); ++ vboxDisconnect(&g_vboxSFClient); ++ vboxUninit(); + +- return 0; ++ return (0); + } + +-int vboxvfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) ++/* ++ * vboxvfs_statfs call ++ */ ++int vboxvfs_statfs(struct mount *mp, struct statfs *sbp) + { +- return 0; ++ struct vboxvfs_mnt *vboxvfsmp; ++ ++ vboxvfsmp = VFSTOVBOXFS(mp); ++ ++ sbp->f_bsize = vboxvfsmp->bsize; ++ sbp->f_iosize = vboxvfsmp->bsize; ++ sbp->f_blocks = vboxvfsmp->size >> vboxvfsmp->bshift; ++ sbp->f_bfree = 0; ++ sbp->f_bavail = 0; ++ sbp->f_files = 0; ++ sbp->f_ffree = 0; ++ ++ return (0); + } From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 07:51:09 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 52FA33A9 for ; Tue, 16 Jul 2013 07:51:09 +0000 (UTC) (envelope-from ccqin@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 2C1773E0 for ; Tue, 16 Jul 2013 07:51:09 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6G7p9ZR051509 for ; Tue, 16 Jul 2013 07:51:09 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6G7p9Tc051505 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 07:51:09 GMT (envelope-from ccqin@FreeBSD.org) Date: Tue, 16 Jul 2013 07:51:09 GMT Message-Id: <201307160751.r6G7p9Tc051505@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254825 - soc2013/ccqin/head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 07:51:09 -0000 Author: ccqin Date: Tue Jul 16 07:51:08 2013 New Revision: 254825 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254825 Log: merge takes lots of time, so... Deleted: soc2013/ccqin/head/ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 07:52:37 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 42AC03CE for ; Tue, 16 Jul 2013 07:52:37 +0000 (UTC) (envelope-from ccqin@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 1C2FA3EC for ; Tue, 16 Jul 2013 07:52:37 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6G7qaNW069836 for ; Tue, 16 Jul 2013 07:52:37 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6G7qaMm069830 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 07:52:36 GMT (envelope-from ccqin@FreeBSD.org) Date: Tue, 16 Jul 2013 07:52:36 GMT Message-Id: <201307160752.r6G7qaMm069830@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254826 - soc2013/ccqin/head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 07:52:37 -0000 Author: ccqin Date: Tue Jul 16 07:52:36 2013 New Revision: 254826 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254826 Log: another initial copy. Added: soc2013/ccqin/head/ (props changed) - copied from r254825, mirror/FreeBSD/head/ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 09:00:39 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8F7B5C9E for ; Tue, 16 Jul 2013 09:00:39 +0000 (UTC) (envelope-from ccqin@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 66035883 for ; Tue, 16 Jul 2013 09:00:39 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6G90dfr081595 for ; Tue, 16 Jul 2013 09:00:39 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6G90dKc081581 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 09:00:39 GMT (envelope-from ccqin@FreeBSD.org) Date: Tue, 16 Jul 2013 09:00:39 GMT Message-Id: <201307160900.r6G90dKc081581@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254831 - soc2013/ccqin/head/sys/net80211 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 09:00:39 -0000 Author: ccqin Date: Tue Jul 16 09:00:39 2013 New Revision: 254831 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254831 Log: Add the capability of returning multi-rate to the net80211 rate control code. Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Tue Jul 16 08:54:19 2013 (r254830) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Tue Jul 16 09:00:39 2013 (r254831) @@ -37,6 +37,25 @@ #define IEEE80211_RATECTL_TX_SUCCESS 1 #define IEEE80211_RATECTL_TX_FAILURE 0 +#define IEEE80211_RATECTL_NUM 4 + +#define IEEE80211_RATECTL_DS_FLAG 0x01 /* dual-stream rate */ +#define IEEE80211_RATECTL_CW40_FLAG 0x02 /* use HT40 */ +#define IEEE80211_RATECTL_SGI_FLAG 0x04 /* use short-GI */ +#define IEEE80211_RATECTL_HT_FLAG 0x08 /* use HT */ +#define IEEE80211_RATECTL_RTSCTS_FLAG 0x10 /* enable RTS/CTS protection */ +#define IEEE80211_RATECTL_STBC_FLAG 0x20 /* enable STBC */ +#define IEEE80211_RATECTL_TS_FLAG 0x40 /* triple-stream rate */ + +struct ieee80211_rc_series { + uint8_t rix; /* ratetable index, not rate code */ + uint8_t ratecode; /* hardware rate code */ + uint8_t tries; + uint8_t tx_power_cap; + uint16_t flags; + uint16_t max4msframelen; +}; + struct ieee80211_ratectl { const char *ir_name; int (*ir_attach)(const struct ieee80211vap *); @@ -46,6 +65,7 @@ void (*ir_node_init)(struct ieee80211_node *); void (*ir_node_deinit)(struct ieee80211_node *); int (*ir_rate)(struct ieee80211_node *, void *, uint32_t); + void (*ir_rates)(struct ieee80211_node *, struct ieee80211_rc_series *); void (*ir_tx_complete)(const struct ieee80211vap *, const struct ieee80211_node *, int, void *, void *); @@ -93,6 +113,14 @@ } static void __inline +ieee80211_ratectl_rates(struct ieee80211_node *ni, struct ieee80211_rc_series *rc) +{ + const struct ieee80211vap *vap = ni->ni_vap; + + vap->iv_rate->ir_rates(ni, rc); +} + +static void __inline ieee80211_ratectl_tx_complete(const struct ieee80211vap *vap, const struct ieee80211_node *ni, int status, void *arg1, void *arg2) { From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 10:47:31 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D128153C for ; Tue, 16 Jul 2013 10:47:31 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A8CB7D19 for ; Tue, 16 Jul 2013 10:47:31 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6GAlUH4033384 for ; Tue, 16 Jul 2013 10:47:30 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6GAlUBf033383 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 10:47:30 GMT (envelope-from bguan@FreeBSD.org) Date: Tue, 16 Jul 2013 10:47:30 GMT Message-Id: <201307161047.r6GAlUBf033383@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254836 - soc2013/bguan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 10:47:31 -0000 Author: bguan Date: Tue Jul 16 10:47:30 2013 New Revision: 254836 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254836 Log: Added: soc2013/bguan/ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 10:53:01 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4A507630 for ; Tue, 16 Jul 2013 10:53:01 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 22CBED5A for ; Tue, 16 Jul 2013 10:53:01 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6GAr1mS039319 for ; Tue, 16 Jul 2013 10:53:01 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6GAr1P0039313 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 10:53:01 GMT (envelope-from bguan@FreeBSD.org) Date: Tue, 16 Jul 2013 10:53:01 GMT Message-Id: <201307161053.r6GAr1P0039313@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254837 - soc2013/bguan/head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 10:53:01 -0000 Author: bguan Date: Tue Jul 16 10:53:00 2013 New Revision: 254837 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254837 Log: Added: soc2013/bguan/head/ (props changed) - copied from r254836, mirror/FreeBSD/head/ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 13:56:17 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C91D322D for ; Tue, 16 Jul 2013 13:56:17 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id BA496875 for ; Tue, 16 Jul 2013 13:56:17 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6GDuHNl019663 for ; Tue, 16 Jul 2013 13:56:17 GMT (envelope-from syuu@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6GDuHId019660 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 13:56:17 GMT (envelope-from syuu@FreeBSD.org) Date: Tue, 16 Jul 2013 13:56:17 GMT Message-Id: <201307161356.r6GDuHId019660@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to syuu@FreeBSD.org using -f From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254843 - in soc2013/syuu/bhyve_usb/usr.sbin/bhyve: . usb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 13:56:17 -0000 Author: syuu Date: Tue Jul 16 13:56:17 2013 New Revision: 254843 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254843 Log: timer function implemented Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile Tue Jul 16 12:22:36 2013 (r254842) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile Tue Jul 16 13:56:17 2013 (r254843) @@ -16,13 +16,13 @@ SRCS+= vmm_instruction_emul.c .PATH: ${.CURDIR}/usb -CFLAGS+=-I${.CURDIR}/usb/include -I${.CURDIR} +CFLAGS+=-I${.CURDIR}/usb/include -I${.CURDIR} SRCS+= core.c hcd-uhci.c NO_MAN= DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBPTHREAD} -LDADD= -lvmmapi -lmd -lpthread +LDADD= -lvmmapi -lmd -lpthread -lrt WARNS?= 2 Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Tue Jul 16 12:22:36 2013 (r254842) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Tue Jul 16 13:56:17 2013 (r254843) @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "pci_emul.h" #include "hw/usb.h" @@ -250,6 +252,14 @@ uint16_t ctrl; } UHCIPort; +typedef void(*timer_func_t)(void*); +typedef struct Timer { + timer_t timerid; + struct sigevent se; + timer_func_t func; + void *arg; +} Timer; + struct UHCIState { struct pci_uhci_softc *sc; PCIDevice dev; @@ -263,7 +273,7 @@ uint8_t sof_timing; uint8_t status2; /* bit 0 and 1 are used to generate UHCI_STS_USBINT */ int64_t expire_time; -// QEMUTimer *frame_timer; + Timer *frame_timer; // QEMUBH *bh; uint32_t frame_bytes; uint32_t frame_bandwidth; @@ -309,6 +319,77 @@ static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td); static void uhci_process_frame(UHCIState *s); +#define SECINNS (1000000000L) + +static int64_t timespec_to_ns(struct timespec *ts) +{ + return ((int64_t)(ts->tv_sec * SECINNS) + ts->tv_nsec); +} + +static struct timespec ns_to_timerspec(int64_t ns) +{ + struct timespec ts; + ts.tv_sec = ns / SECINNS; + ts.tv_nsec = ns % SECINNS; + return ts; +} + +static int64_t get_clock_ns(void) +{ + struct timespec ts; + if (clock_gettime(CLOCK_REALTIME, &ts)) { + perror("clock_gettime"); + exit(1); + } + return timespec_to_ns(&ts); +} + +static int64_t get_ticks_per_sec(void) +{ + return (1000000000L); +} + +void timer_handler(union sigval sigv) +{ + Timer *timer = (Timer *)sigv.sigval_ptr; + timer->func(timer->arg); +} + +static Timer *new_timer(timer_func_t func, void *arg) +{ + Timer *timer = (Timer *)calloc(1, sizeof(*timer)); + if (!timer) { + perror("calloc"); + exit(1); + } + timer->se.sigev_notify = SIGEV_THREAD; + timer->se.sigev_value.sigval_ptr = (Timer *)timer; + timer->se.sigev_notify_function = timer_handler; + timer->func = func; + timer->arg = arg; + if (timer_create(CLOCK_REALTIME, &timer->se, &timer->timerid)) { + perror("timer_create"); + exit(1); + } + return timer; +} + +static void mod_timer(Timer *timer, int64_t ns) +{ + struct itimerspec its; + + its.it_value = its.it_interval = ns_to_timerspec(ns); + timer_settime(timer->timerid, 0, &its, 0); +} + +static void del_timer(Timer *timer) +{ + struct itimerspec its; + + memset(&its, 0, sizeof(its)); + timer_settime(timer->timerid, 0, &its, 0); +} + static inline int32_t uhci_queue_token(UHCI_TD *td) { if ((td->token & (0xf << 15)) == 0) { @@ -498,7 +579,6 @@ } else { level = 0; } -// qemu_set_irq(s->dev.irq[s->irq_pin], level); if (level) pci_lintr_assert(s->sc->sc_pi); else @@ -518,6 +598,7 @@ pci_set_cfgdata8(sc->sc_pi, 0x6b, 0x00); s->cmd = 0; s->status = 0; + fprintf(usblog, "%s s->status = 0\n", __func__); s->status2 = 0; s->intr = 0; s->fl_base_addr = 0; @@ -551,14 +632,12 @@ static int uhci_post_load(void *opaque, int version_id) { -#if 0 UHCIState *s = opaque; if (version_id < 2) { - s->expire_time = qemu_get_clock_ns(vm_clock) + + s->expire_time = get_clock_ns() + (get_ticks_per_sec() / FRAME_TIMER_FREQ); } -#endif return 0; } @@ -602,12 +681,16 @@ if ((val & UHCI_CMD_RS) && !(s->cmd & UHCI_CMD_RS)) { /* start frame processing */ trace_usb_uhci_schedule_start(); -// s->expire_time = qemu_get_clock_ns(vm_clock) + -// (get_ticks_per_sec() / FRAME_TIMER_FREQ); -// qemu_mod_timer(s->frame_timer, s->expire_time); + s->expire_time = get_clock_ns() + + (get_ticks_per_sec() / FRAME_TIMER_FREQ); + mod_timer(s->frame_timer, s->expire_time); s->status &= ~UHCI_STS_HCHALTED; + fprintf(usblog, "%s status &= ~UHCI_STS_HCHALTED\n", __func__); + fprintf(usblog, "%s status = %x\n", __func__, s->status); } else if (!(val & UHCI_CMD_RS)) { s->status |= UHCI_STS_HCHALTED; + fprintf(usblog, "%s status |= UHCI_STS_HCHALTED\n", __func__); + fprintf(usblog, "%s status = %x\n", __func__, s->status); } if (val & UHCI_CMD_GRESET) { UHCIPort *port; @@ -618,10 +701,12 @@ port = &s->ports[i]; usb_device_reset(port->port.dev); } + fprintf(usblog, "%s:%d\n", __func__, __LINE__); uhci_reset(s); return; } if (val & UHCI_CMD_HCRESET) { + fprintf(usblog, "%s:%d\n", __func__, __LINE__); uhci_reset(s); return; } @@ -630,6 +715,8 @@ case 0x02: fprintf(usblog, "%s USBSTS val:%lx\n", __func__, val); s->status &= ~val; + fprintf(usblog, "%s s->status &= ~%lx\n", __func__, val); + fprintf(usblog, "%s s->status = %x\n", __func__, s->status); /* XXX: the chip spec is not coherent, so we add a hidden register to distinguish between IOC and SPD */ if (val & UHCI_STS_USBINT) @@ -760,6 +847,8 @@ if (s->cmd & UHCI_CMD_EGSM) { s->cmd |= UHCI_CMD_FGR; s->status |= UHCI_STS_RD; + fprintf(usblog, "%s s->status |= UHCI_STS_RD\n", __func__); + fprintf(usblog, "%s s->status = %x\n", __func__, s->status); uhci_update_irq(s); } } @@ -884,6 +973,8 @@ td->ctrl &= ~TD_CTRL_ACTIVE; s->status |= UHCI_STS_USBERR; + fprintf(usblog, "%s s->status |= UHCI_STS_USBERR\n", __func__); + fprintf(usblog, "%s s->status = %x\n", __func__, s->status); if (td->ctrl & TD_CTRL_IOC) { *int_mask |= 0x01; } @@ -1051,6 +1142,8 @@ /* invalid pid : frame interrupted */ uhci_async_free(async); s->status |= UHCI_STS_HCPERR; + fprintf(usblog, "%s s->status |= UHCI_STS_USBERR\n", __func__); + fprintf(usblog, "%s s->status = %x\n", __func__, s->status); uhci_update_irq(s); return TD_RESULT_STOP_FRAME; } @@ -1152,7 +1245,7 @@ assert(int_mask == 0); plink = ptd.link; } - usb_device_flush_ep_queue(q->ep->dev, q->ep); +// usb_device_flush_ep_queue(q->ep->dev, q->ep); } static void uhci_process_frame(UHCIState *s) @@ -1289,7 +1382,7 @@ UHCIState *s = opaque; uint64_t t_now, t_last_run; int i, frames; - const uint64_t frame_t /* = get_ticks_per_sec() / FRAME_TIMER_FREQ */; + const uint64_t frame_t = get_ticks_per_sec() / FRAME_TIMER_FREQ; s->completions_only = false; // qemu_bh_cancel(s->bh); @@ -1297,16 +1390,18 @@ if (!(s->cmd & UHCI_CMD_RS)) { /* Full stop */ trace_usb_uhci_schedule_stop(); -// qemu_del_timer(s->frame_timer); + del_timer(s->frame_timer); uhci_async_cancel_all(s); /* set hchalted bit in status - UHCI11D 2.1.2 */ s->status |= UHCI_STS_HCHALTED; + fprintf(usblog, "%s s->status |= UHCI_STS_HCHALTED\n", __func__); + fprintf(usblog, "%s s->status = %x\n", __func__, s->status); return; } /* We still store expire_time in our state, for migration */ t_last_run = s->expire_time - frame_t; -// t_now = qemu_get_clock_ns(vm_clock); + t_now = get_clock_ns(); /* Process up to MAX_FRAMES_PER_TICK frames */ frames = (t_now - t_last_run) / frame_t; @@ -1336,11 +1431,13 @@ if (s->pending_int_mask) { s->status2 |= s->pending_int_mask; s->status |= UHCI_STS_USBINT; + fprintf(usblog, "%s s->status |= UHCI_STS_USBINT\n", __func__); + fprintf(usblog, "%s s->status = %x\n", __func__, s->status); uhci_update_irq(s); } s->pending_int_mask = 0; -// qemu_mod_timer(s->frame_timer, t_now + frame_t); + mod_timer(s->frame_timer, t_now + frame_t); } /* @@ -1616,9 +1713,11 @@ } memset(&sc->sc_st, 0, sizeof(sc->sc_st)); + sc->sc_st.frame_timer = new_timer(uhci_frame_timer, &sc->sc_st); sc->sc_st.num_ports_vmstate = NB_PORTS; QTAILQ_INIT(&sc->sc_st.queues); sc->sc_st.sc = sc; + fprintf(usblog, "%s:%d\n", __func__, __LINE__); uhci_reset(&sc->sc_st); pci_emul_alloc_bar(pi, 4, PCIBAR_IO, 0x20); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 14:51:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7C56B556 for ; Tue, 16 Jul 2013 14:51:06 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 5F3C6B8E for ; Tue, 16 Jul 2013 14:51:06 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6GEp6Wi050695 for ; Tue, 16 Jul 2013 14:51:06 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6GEp6V5050689 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 14:51:06 GMT (envelope-from zcore@FreeBSD.org) Date: Tue, 16 Jul 2013 14:51:06 GMT Message-Id: <201307161451.r6GEp6V5050689@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254844 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 14:51:06 -0000 Author: zcore Date: Tue Jul 16 14:51:06 2013 New Revision: 254844 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254844 Log: use block_if and add ahci port Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Tue Jul 16 13:56:17 2013 (r254843) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Tue Jul 16 14:51:06 2013 (r254844) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011 NetApp, Inc. + * Copyright (c) 2013 ZCORE * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,8 +50,7 @@ #include "bhyverun.h" #include "pci_emul.h" #include "ahci.h" - -#define AHCI_REGSZ (AHCI_OFFSET+6*AHCI_STEP) +#include "block_if.h" /* * Debug printf @@ -63,20 +62,57 @@ /* * Per-device softc */ +struct ahci_port { + uint32_t clb; + uint32_t clbu; + uint32_t fb; + uint32_t fbu; + uint32_t is; + uint32_t ie; + uint32_t cmd; + uint32_t unused0; + uint32_t tfd; + uint32_t sig; + uint32_t ssts; + uint32_t sctl; + uint32_t serr; + uint32_t sact; + uint32_t ci; + uint32_t sntf; + uint32_t fbs; +}; + struct pci_ahci_softc { struct pci_devinst *asc_pi; - int asc_fd; - int vbsc_lastq; + struct blockif_ctxt *bctx; + pthread_mutex_t mtx; + int ports; + int vbsc_lastq; + uint32_t cap; + uint32_t ghc; + uint32_t is; + uint32_t pi; + uint32_t vs; + uint32_t ccc_ctl; + uint32_t ccc_pts; + uint32_t em_loc; + uint32_t em_ctl; + uint32_t cap2; + uint32_t bohc; + struct ahci_port port[AHCI_MAX_PORTS]; }; +static void +pci_ahci_ioreq_init(struct pci_ahci_softc *sc) +{ +} + static int pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { - struct stat sbuf; struct pci_ahci_softc *sc; - off_t size; - int fd; - int sectsz; + char bident[sizeof("XX:X")]; + struct blockif_ctxt *bctxt; if (opts == NULL) { printf("pci_ahci: backing device required\n"); @@ -84,44 +120,43 @@ } /* - * The supplied backing file has to exist + * Attempt to open the backing image. Use the PCI slot/func + * for the identifier string since that uniquely identifies + * a storage device. */ - fd = open(opts, O_RDWR); - if (fd < 0) { - perror("Could not open backing file"); - return (1); - } + snprintf(bident, sizeof(bident), "%d:%d", pi->pi_slot, pi->pi_func); - if (fstat(fd, &sbuf) < 0) { - perror("Could not stat backing file"); - close(fd); + bctxt = blockif_open(opts, bident); + if (bctxt == NULL) return (1); - } - - /* - * Deal with raw devices - */ - size = sbuf.st_size; - sectsz = DEV_BSIZE; - if (S_ISCHR(sbuf.st_mode)) { - if (ioctl(fd, DIOCGMEDIASIZE, &size) < 0 || - ioctl(fd, DIOCGSECTORSIZE, §sz)) { - perror("Could not fetch dev blk/sector size"); - close(fd); - return (1); - } - assert(size != 0); - assert(sectsz != 0); - } sc = malloc(sizeof(struct pci_ahci_softc)); memset(sc, 0, sizeof(struct pci_ahci_softc)); pi->pi_arg = sc; sc->asc_pi = pi; - sc->asc_fd = fd; + + /* + * Allocate blockif request structures and add them + * to the free list + */ + sc->bctx = bctxt; + pci_ahci_ioreq_init(sc); + + pthread_mutex_init(&sc->mtx, NULL); /* Intel Cougar Point AHCI */ + sc->ports = 6; + sc->cap = AHCI_CAP_64BIT | AHCI_CAP_SNCQ | AHCI_CAP_SSNTF | + AHCI_CAP_SMPS | AHCI_CAP_SSS | AHCI_CAP_SALP | + AHCI_CAP_SAL | AHCI_CAP_SCLO | (0x3 << AHCI_CAP_ISS_SHIFT)| + AHCI_CAP_PMD | AHCI_CAP_SSC | AHCI_CAP_PSC | + (0x1f << AHCI_CAP_NCS_SHIFT) | AHCI_CAP_EMS | + AHCI_CAP_SXS | (sc->ports - 1); + sc->pi = (1 << sc->ports) - 1; + sc->vs = 0x10300; + sc->cap2 = AHCI_CAP2_APST; + pci_set_cfgdata16(pi, PCIR_DEVICE, 0x1c03); pci_set_cfgdata16(pi, PCIR_VENDOR, 0x8086); pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE); @@ -130,58 +165,135 @@ pci_emul_add_msicap(pi, 1); - pci_emul_alloc_bar(pi, 5, PCIBAR_IO, AHCI_REGSZ); + pci_emul_alloc_bar(pi, 5, PCIBAR_IO, AHCI_OFFSET+sc->ports*AHCI_STEP); return (0); } static void -pci_ahci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, - int baridx, uint64_t offset, int size, uint64_t value) +pci_ahci_port_write(struct pci_ahci_softc *sc, uint64_t offset, uint64_t value) { - - assert(baridx == 5); + int port = (offset - AHCI_OFFSET) / AHCI_STEP; + offset = (offset - AHCI_OFFSET) % AHCI_STEP; switch (offset) { + case AHCI_P_CLB: + break; default: - DPRINTF(("pci_ahci: unknown i/o write offset %ld\n\r", offset)); + DPRINTF(("pci_ahci_port %d: unknown i/o write offset %ld\n\r", + port, offset)); value = 0; break; } } -uint64_t -pci_ahci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, - int baridx, uint64_t offset, int size) +static void +pci_ahci_host_write(struct pci_ahci_softc *sc, uint64_t offset, uint64_t value) { - uint32_t value; + switch (offset) { + case AHCI_CAP: + case AHCI_PI: + case AHCI_VS: + case AHCI_CAP2: + WPRINTF(("pci_ahci_host: read only registers: %ld\n", offset)); + break; + default: + DPRINTF(("pci_ahci_host: unknown i/o write offset %ld\n\r", offset)); + break; + } +} + +static void +pci_ahci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, + int baridx, uint64_t offset, int size, uint64_t value) +{ + struct pci_ahci_softc *sc = pi->pi_arg; assert(baridx == 5); + assert(size == 4); + + pthread_mutex_lock(&sc->mtx); + + if (offset < AHCI_OFFSET) + pci_ahci_host_write(sc, offset, value); + else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP) + pci_ahci_port_write(sc, offset, value); + else + DPRINTF(("pci_ahci: unknown i/o write offset %ld\n\r", offset)); + + pthread_mutex_unlock(&sc->mtx); +} + +static uint64_t +pci_ahci_host_read(struct pci_ahci_softc *sc, uint64_t offset) +{ + uint32_t value; switch (offset) { case AHCI_CAP: - assert(size == 4); - value = AHCI_CAP_64BIT | AHCI_CAP_SNCQ | AHCI_CAP_SSNTF | - AHCI_CAP_SMPS | AHCI_CAP_SSS | AHCI_CAP_SALP | - AHCI_CAP_SAL | AHCI_CAP_SCLO | (0x3 << AHCI_CAP_ISS_SHIFT)| - AHCI_CAP_PMD | AHCI_CAP_SSC | AHCI_CAP_PSC | - (0x1f << AHCI_CAP_NCS_SHIFT) | AHCI_CAP_EMS | - AHCI_CAP_SXS | 0x5; + value = sc->cap; break; + case AHCI_GHC: + value = sc->ghc; + case AHCI_IS: + value = sc->is; + case AHCI_PI: + value = sc->pi; case AHCI_VS: - assert(size == 4); - value = 0x10300; + value = sc->vs; break; case AHCI_CAP2: - assert(size == 4); - value = AHCI_CAP2_APST; + value = sc->cap2; break; default: - DPRINTF(("pci_ahci: unknown i/o read offset %ld\n\r", offset)); + DPRINTF(("pci_ahci_host: unknown i/o read offset %ld\n\r", offset)); + value = 0; + break; + } + return (value); +} + +static uint64_t +pci_ahci_port_read(struct pci_ahci_softc *sc, uint64_t offset) +{ + uint32_t value; + int port = (offset - AHCI_OFFSET) / AHCI_STEP; + offset = (offset - AHCI_OFFSET) % AHCI_STEP; + + switch (offset) { + case AHCI_P_CLB: + break; + default: + DPRINTF(("pci_ahci_port%d: unknown i/o read offset %ld\n\r", + port, offset)); value = 0; break; } + return value; +} + +static uint64_t +pci_ahci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, + int baridx, uint64_t offset, int size) +{ + uint32_t value; + struct pci_ahci_softc *sc = pi->pi_arg; + + assert(baridx == 5); + assert(size == 4); + + pthread_mutex_lock(&sc->mtx); + + if (offset < AHCI_OFFSET) + value = pci_ahci_host_read(sc, offset); + else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP) + value = pci_ahci_port_read(sc, offset); + else + DPRINTF(("pci_ahci: unknown i/o read offset %ld\n\r", offset)); + + pthread_mutex_unlock(&sc->mtx); + return (value); } From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 18:02:44 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BECFB85E for ; Tue, 16 Jul 2013 18:02:44 +0000 (UTC) (envelope-from ccqin@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id B11838FA for ; Tue, 16 Jul 2013 18:02:44 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6GI2ifL090428 for ; Tue, 16 Jul 2013 18:02:44 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6GI2iXk090425 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 18:02:44 GMT (envelope-from ccqin@FreeBSD.org) Date: Tue, 16 Jul 2013 18:02:44 GMT Message-Id: <201307161802.r6GI2iXk090425@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254849 - soc2013/ccqin/head/sys/net80211 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 18:02:44 -0000 Author: ccqin Date: Tue Jul 16 18:02:44 2013 New Revision: 254849 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254849 Log: If enable rts/cts and is pre-802.11n, blank tries 1, 2, 3. Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Tue Jul 16 16:37:08 2013 (r254848) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Tue Jul 16 18:02:44 2013 (r254849) @@ -65,7 +65,7 @@ void (*ir_node_init)(struct ieee80211_node *); void (*ir_node_deinit)(struct ieee80211_node *); int (*ir_rate)(struct ieee80211_node *, void *, uint32_t); - void (*ir_rates)(struct ieee80211_node *, struct ieee80211_rc_series *); + void (*ir_rates)(struct ieee80211_node *, struct ieee80211_rc_series *, int, size_t); void (*ir_tx_complete)(const struct ieee80211vap *, const struct ieee80211_node *, int, void *, void *); @@ -113,11 +113,17 @@ } static void __inline -ieee80211_ratectl_rates(struct ieee80211_node *ni, struct ieee80211_rc_series *rc) +ieee80211_ratectl_rates(struct ieee80211_node *ni, struct ieee80211_rc_series *rc, + int shortPreamble, size_t frameLen) { const struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211com *ic = vap->iv_ic; - vap->iv_rate->ir_rates(ni, rc); + vap->iv_rate->ir_rates(ni, rc, shortPreamble, frameLen); + + /* if enable rts/cts and is pre-802.11n, blank tries 1, 2, 3 */ + if ((rc[0].flags & IEEE80211_RATECTL_RTSCTS_FLAG) && !(ic->ic_htcaps & IEEE80211_HTC_HT)) + rc[1].tries = rc[2].tries = rc[3].tries = 0; } static void __inline From owner-svn-soc-all@FreeBSD.ORG Tue Jul 16 19:01:04 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 3C31557E for ; Tue, 16 Jul 2013 19:01:04 +0000 (UTC) (envelope-from ambarisha@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 2CD5CB96 for ; Tue, 16 Jul 2013 19:01:04 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6GJ13ZS074658 for ; Tue, 16 Jul 2013 19:01:03 GMT (envelope-from ambarisha@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6GJ13aG074638 for svn-soc-all@FreeBSD.org; Tue, 16 Jul 2013 19:01:03 GMT (envelope-from ambarisha@FreeBSD.org) Date: Tue, 16 Jul 2013 19:01:03 GMT Message-Id: <201307161901.r6GJ13aG074638@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ambarisha@FreeBSD.org using -f From: ambarisha@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254850 - in soc2013/ambarisha/head/usr.bin: dmget dms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 19:01:04 -0000 Author: ambarisha Date: Tue Jul 16 19:01:03 2013 New Revision: 254850 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254850 Log: Improves signal handling in dms, dmget Adds status updates Modified: soc2013/ambarisha/head/usr.bin/dmget/dm.h soc2013/ambarisha/head/usr.bin/dmget/dmget.c soc2013/ambarisha/head/usr.bin/dmget/dmget.h soc2013/ambarisha/head/usr.bin/dmget/fetch.c soc2013/ambarisha/head/usr.bin/dmget/utils.c soc2013/ambarisha/head/usr.bin/dms/dm.h soc2013/ambarisha/head/usr.bin/dms/dms.c soc2013/ambarisha/head/usr.bin/dms/dms.h soc2013/ambarisha/head/usr.bin/dms/utils.c soc2013/ambarisha/head/usr.bin/dms/worker.c Modified: soc2013/ambarisha/head/usr.bin/dmget/dm.h ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/dm.h Tue Jul 16 18:02:44 2013 (r254849) +++ soc2013/ambarisha/head/usr.bin/dmget/dm.h Tue Jul 16 19:01:03 2013 (r254850) @@ -11,6 +11,9 @@ #define DMS_UDS_PATH "/tmp/dms.uds" struct dmres { + int status; + int errcode; + char *errstr; }; struct dmreq { @@ -36,24 +39,35 @@ #define p_FLAG (1 << 10) #define r_FLAG (1 << 11) #define s_FLAG (1 << 12) +#define V_TTY (1 << 13) char *i_filename; char *URL; char *path; }; -struct msg { +struct dmmsg { char op; int len; char *buf; }; +struct xferstat { + char name[64]; + struct timeval start; /* start of transfer */ + struct timeval last; /* time of last update */ + struct timeval last2; /* time of previous last update */ + off_t size; /* size of file per HTTP hdr */ + off_t offset; /* starting offset in file */ + off_t rcvd; /* bytes already received */ + off_t lastrcvd; /* bytes received since last update */ +}; + #define DMREQ 1 #define DMRESP 2 -#define DMSTATREQ 3 -#define DMSTATRESP 4 -#define DMAUTHREQ 5 -#define DMAUTHRESP 6 -#define DMSIG 7 +#define DMAUTHREQ 3 +#define DMAUTHRESP 4 +#define DMSIG 5 +#define DMSTAT 6 #endif /* _DMCLIENT_H */ Modified: soc2013/ambarisha/head/usr.bin/dmget/dmget.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/dmget.c Tue Jul 16 18:02:44 2013 (r254849) +++ soc2013/ambarisha/head/usr.bin/dmget/dmget.c Tue Jul 16 19:01:03 2013 (r254850) @@ -1,25 +1,31 @@ #include #include #include +#include #include #include #include #include +#include #include "dm.h" #include "dmget.h" auth_t dmAuthMethod; +stat_display_t dmStatDisplayMethod; int dmTimeout; int dmRestartCalls; int dmDebug; int dmLastErrCode; char dmLastErrString[MAXERRSTRING]; -static int dms; -static int sigint; +static int sigint; +static int siginfo; + +static int dmg_error; +static char *dmg_errstr; static void * Malloc(size_t size) @@ -31,11 +37,70 @@ return ptr; } +void dm_sighandler(int signal) +{ + switch(signal) { + case SIGINT: + sigint = 1; + break; + case SIGINFO: + siginfo = 1; + break; + } +} + +static int +sigsafe_write(int sock, char *buf, int bufsize) +{ + int ret; + sigset_t sm; + sigemptyset(&sm); + sigaddset(&sm, SIGINT); + sigaddset(&sm, SIGINFO); + + sigprocmask(SIG_BLOCK, &sm, NULL); + ret = Write(sock, buf, bufsize); + sigprocmask(SIG_UNBLOCK, &sm, NULL); + + return ret; +} + +static int +sigsafe_read(int sock, char *buf, int bufsize) +{ + int ret, n = 0; + + /* If the first read was an error return + * because that could be because of a signal + * */ + ret = Read(sock, buf, bufsize); + if (ret == -1 || ret == 0) + return ret; + + /* But if we've already started reading, we keep reading */ + while ((ret == -1 && errno == EINTR) || n > 0 && n < bufsize) { + ret = read(sock, buf + n, bufsize - n); + if (ret == 0) { + /* Read ended prematurely + * Set dmg_error appropriately and return + */ + + break; + } + + if (ret != -1) + n += ret; + } + + if (ret != -1) + return(n); + return(ret); +} + static int mk_reqbuf(struct dmreq dmreq, char **reqbuf, char op) { - int bufsize = 0; - printf("mk_reqbuf() : Starting\n"); + int bufsize = 0, i = 0; bufsize += sizeof(bufsize); // Buffer size bufsize += 1; // Opcode @@ -46,9 +111,7 @@ *reqbuf = (char *) Malloc(bufsize); - int i = 0; - - memcpy(*reqbuf, &(bufsize), sizeof(bufsize)); + memcpy(*reqbuf, &bufsize, sizeof(bufsize)); i += sizeof(bufsize); *(*reqbuf+i) = op; @@ -87,99 +150,219 @@ strcpy(*reqbuf + i, dmreq.path); i += strlen(dmreq.path) + 1; - return bufsize; + return(i); } -static int -send_request(int sock, struct dmreq dmreq) +static struct dmres * +mk_dmres(char *buf, int buflen) { - char *reqbuf; - int bufsize = mk_reqbuf(dmreq, &reqbuf, DMREQ); - int err = Write(sock, reqbuf, bufsize); + int i = 0, len; + struct dmres *dmres; - free(reqbuf); - return (err); + dmres = (struct dmres*) Malloc(sizeof(struct dmres)); + + memcpy(&(dmres->status), buf + i, sizeof(dmres->status)); + i += sizeof(dmres->status); + + memcpy(&(dmres->errcode), buf + i, sizeof(dmres->errcode)); + i += sizeof(dmres->errcode); + + len = strlen(buf + i); + dmres->errstr = (char *) Malloc(len); + strcpy(dmres->errstr, buf + i); + + return dmres; +} + +static void +rm_dmres(struct dmres **dmres) +{ + free((*dmres)->errstr); + free(*dmres); + *dmres = NULL; } static int -keep_reading(int sock, char *buf, int size) +send_signal(int sock) { - int err = read(sock, buf, size); - while (err == -1 && errno == EINTR && sigint == 0) { - err = read(sock, buf, size); - } + struct dmmsg msg; + msg.op = DMSIG; + msg.buf = &signal; + msg.len = sizeof(signal); + return (send_msg(sock, msg)); +} - if (err == -1) - perror("read():"); +static int +write_fd(int sock, int fd) +{ + int ret; + char c; + struct msghdr msg; + struct iovec iov; + + char control[CMSG_SPACE(sizeof(int))]; + struct cmsghdr *cmptr; + + c = 0; + iov.iov_base = &c; + iov.iov_len = sizeof(c); + + msg.msg_control = (caddr_t) control; + msg.msg_controllen = CMSG_LEN(sizeof(int)); + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + + cmptr = CMSG_FIRSTHDR(&msg); + cmptr->cmsg_len = CMSG_LEN(sizeof(int)); + cmptr->cmsg_level = SOL_SOCKET; + cmptr->cmsg_type = SCM_RIGHTS; + *((int *) CMSG_DATA(cmptr)) = fd; + + ret = sendmsg(sock, &msg, 0); + if (ret == -1) + return (-1); + else + return (0); +} - return err; +static int +Write_fd(int sock, int fd) +{ + int ret = write_fd(sock, fd); + if (ret == -1) { + perror("Write_fd():"); + } else { + printf("Write_fd(): Success\n"); + } } static int -recv_response(int sock, struct dmres *dmres) +send_request(int sock, struct dmreq dmreq) { - int bufsize; - keep_reading(sock, &bufsize, sizeof(bufsize)); - bufsize -= sizeof(bufsize); + char *reqbuf; + int bufsize, err; - char *buf = (char *) Malloc(bufsize); - keep_reading(sock, buf, bufsize); + bufsize = mk_reqbuf(dmreq, &reqbuf, DMREQ); + err = sigsafe_write(sock, reqbuf, bufsize); - /* TODO: Check the error code in the response and set the - dmLastErrCode & dmLastErrString values */ + int fd = open(dmreq.path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); + Write_fd(sock, fd); + close(fd); + + free(reqbuf); + return(err); } -int -dm_request(struct dmreq dmreq) +static void +free_msg(struct dmmsg **msg) { - dms = socket(AF_UNIX, SOCK_STREAM, 0); - struct sockaddr_un dms_addr; - dms_addr.sun_family = AF_UNIX; - strncpy(dms_addr.sun_path, DMS_UDS_PATH, sizeof(dms_addr.sun_path)); - int err = Connect(dms, (struct sockaddr *) &dms_addr, sizeof(dms_addr)); - - send_request(dms, dmreq); - - struct dmres dmres; - recv_response(dms, &dmres); + free((*msg)->buf); + free(*msg); + *msg = NULL; } -static int -send_msg(int socket, struct msg msg) +static struct dmmsg * +recv_msg(int sock) { - int bufsize = sizeof(bufsize); // Buffer size - bufsize += 1; // Op - bufsize += msg.len; // Signal number + int err; + fd_set fds; + sigset_t sm; + struct dmmsg *msg; - char *sndbuf = (char *) Malloc(bufsize); + msg = (struct dmmsg *) Malloc(sizeof(struct dmmsg)); + + FD_ZERO(&fds); + FD_SET(sock, &fds); - int i = 0; - memcpy(sndbuf + i, &bufsize, sizeof(bufsize)); - i += sizeof(bufsize); + err = Select(sock + 1, &fds, NULL, NULL, NULL); + if (err == -1) + return(-1); - *(sndbuf + i) = msg.op; - i++; + sigemptyset(&sm); + sigaddset(&sm, SIGINT); + sigaddset(&sm, SIGINFO); + + sigprocmask(SIG_BLOCK, &sm, NULL); + err = Peel(sock, msg); + sigprocmask(SIG_UNBLOCK, &sm, NULL); + + if (err == -1) { + /* Set dmg_err* */ + free_msg(&msg); + return NULL; + } + + return msg; +} - memcpy(sndbuf + i, msg.buf, msg.len); - i += msg.len; +int +dmget(struct dmreq dmreq) +{ + int sock, err, ret, force; + struct sockaddr_un dms_addr; + struct dmres *dmres; + struct xferstat xs; - int nbytes = Write(socket, sndbuf, bufsize); - free(sndbuf); + sock = Socket(AF_UNIX, SOCK_STREAM, 0); - return (nbytes); -} + dms_addr.sun_family = AF_UNIX; + strncpy(dms_addr.sun_path, DMS_UDS_PATH, sizeof(dms_addr.sun_path)); + err = Connect(sock, (struct sockaddr *) &dms_addr, sizeof(dms_addr)); -void -dm_sighandler(int signal) -{ - struct msg msg; - msg.op = DMSIG; - msg.buf = &signal; - msg.len = sizeof(signal); - send_msg(dms, msg); + if (siginfo || sigint) + goto signal; - if (signal == SIGINT) { - close(dms); - exit(2); + send_request(sock, dmreq); + + while (!sigint) { + struct dmmsg *msg; + msg = recv_msg(sock); + if (msg == NULL) { + goto failure; + } + + if (sigint || siginfo) { + send_signal(sock); + goto signal; + } + + switch(msg->op) { + case DMRESP: + dmres = mk_dmres(msg->buf, msg->len); + free_msg(&msg); + if (dmres->status == 0){ + /* set dmLastErr* */ + rm_dmres(&dmres); + goto success; + } else { + rm_dmres(&dmres); + goto failure; + } + case DMSTAT: + force = *((int *)(msg->buf)); + memcpy(&xs, (msg->buf) + sizeof(force), sizeof(xs)); + free_msg(&msg); + dmStatDisplayMethod(&xs, force); + break; + case DMAUTHREQ: + default: + break; + } } + +signal: + ret = -1; + goto done; +failure: + ret = 1; + goto done; +success: + ret = 0; + goto done; +done: + /* Set dmLastErrCode dmLastErrString */ + close(sock); + return (ret); } Modified: soc2013/ambarisha/head/usr.bin/dmget/dmget.h ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/dmget.h Tue Jul 16 18:02:44 2013 (r254849) +++ soc2013/ambarisha/head/usr.bin/dmget/dmget.h Tue Jul 16 19:01:03 2013 (r254850) @@ -15,6 +15,8 @@ typedef int (*auth_t)(struct url *); extern auth_t dmAuthMethod; +typedef void (*stat_display_t) (struct xferstat *, int); +extern stat_display_t dmStatDisplayMethod; int dm_request(struct dmreq); void dm_sighandler(int sig); Modified: soc2013/ambarisha/head/usr.bin/dmget/fetch.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/fetch.c Tue Jul 16 18:02:44 2013 (r254849) +++ soc2013/ambarisha/head/usr.bin/dmget/fetch.c Tue Jul 16 19:01:03 2013 (r254850) @@ -88,28 +88,12 @@ static long w_secs; /* -w: retry delay */ static int family = PF_UNSPEC; /* -[46]: address family to use */ -static int sigalrm; /* SIGALRM received */ -static int siginfo; /* SIGINFO received */ static int sigint; /* SIGINT received */ static long ftp_timeout = TIMEOUT; /* default timeout for FTP transfers */ static long http_timeout = TIMEOUT;/* default timeout for HTTP transfers */ static char *buf; /* transfer buffer */ -struct xferstat { - char name[64]; - struct timeval start; /* start of transfer */ - struct timeval last; /* time of last update */ - struct timeval last2; /* time of previous last update */ - off_t size; /* size of file per HTTP hdr */ - off_t offset; /* starting offset in file */ - off_t rcvd; /* bytes already received */ - off_t lastrcvd; /* bytes received since last update */ -}; - -/* - * Signal handler - */ /* * Compute and display ETA */ @@ -274,7 +258,6 @@ dmreq.B_size = B_size; dmreq.S_size = S_size; dmreq.URL = URL; - printf("URL = %s\n", dmreq.URL); dmreq.path = path; dmreq.T_secs = T_secs; @@ -282,21 +265,27 @@ else dmreq.i_filename = ""; dmreq.flags = 0; - if (A_flag != 0) dmreq.flags |= A_FLAG; - if (F_flag != 0) dmreq.flags |= F_FLAG; - if (R_flag != 0) dmreq.flags |= R_FLAG; - if (U_flag != 0) dmreq.flags |= U_FLAG; - if (d_flag != 0) dmreq.flags |= d_FLAG; - if (i_flag != 0) dmreq.flags |= i_FLAG; - if (l_flag != 0) dmreq.flags |= l_FLAG; - if (m_flag != 0) dmreq.flags |= m_FLAG; - if (n_flag != 0) dmreq.flags |= n_FLAG; - if (p_flag != 0) dmreq.flags |= p_FLAG; - if (r_flag != 0) dmreq.flags |= r_FLAG; - if (s_flag != 0) dmreq.flags |= s_FLAG; - if (o_stdout != 0) dmreq.flags |= O_STDOUT; + if (A_flag) dmreq.flags |= A_FLAG; + if (F_flag) dmreq.flags |= F_FLAG; + if (R_flag) dmreq.flags |= R_FLAG; + if (U_flag) dmreq.flags |= U_FLAG; + if (d_flag) dmreq.flags |= d_FLAG; + if (i_flag) dmreq.flags |= i_FLAG; + if (l_flag) dmreq.flags |= l_FLAG; + if (m_flag) dmreq.flags |= m_FLAG; + if (n_flag) dmreq.flags |= n_FLAG; + if (p_flag) dmreq.flags |= p_FLAG; + if (r_flag) dmreq.flags |= r_FLAG; + if (s_flag) dmreq.flags |= s_FLAG; + if (o_stdout) dmreq.flags |= O_STDOUT; + if (v_tty) dmreq.flags |= V_TTY; + + + if (dmreq.flags & V_TTY) printf("v_tty is set\n"); + else printf("v_tty is not set\n"); - return (dm_request(dmreq)); + dmStatDisplayMethod = stat_display; + return (dmget(dmreq)); } static void Modified: soc2013/ambarisha/head/usr.bin/dmget/utils.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/utils.c Tue Jul 16 18:02:44 2013 (r254849) +++ soc2013/ambarisha/head/usr.bin/dmget/utils.c Tue Jul 16 19:01:03 2013 (r254850) @@ -116,20 +116,31 @@ } int -Peel(int sock, struct msg *msg) +Peel(int sock, struct dmmsg *msg) { int bufsize = 0; - Read(sock, &bufsize, sizeof(bufsize)); + int err; + err = Read(sock, &bufsize, sizeof(bufsize)); + if (err == 0) + return (-1); bufsize -= sizeof(bufsize); - Read(sock, &(msg->op), sizeof(msg->op)); + err = Read(sock, &(msg->op), sizeof(msg->op)); + if (err == 0) + return (-1); bufsize -= sizeof(msg->op); msg->buf = (char *) Malloc(bufsize); msg->len = bufsize; Read(sock, msg->buf, bufsize); - return 0; + if (err == 0) { + free(msg->buf); + msg->len = 0; + return (-1); + } + + return 1; } int @@ -144,3 +155,29 @@ } return err; } + +int +send_msg(int socket, struct dmmsg msg) +{ + int bufsize = sizeof(bufsize); // Buffer size + bufsize += 1; // Op + bufsize += msg.len; // Signal number + + char *sndbuf = (char *) Malloc(bufsize); + + int i = 0; + memcpy(sndbuf + i, &bufsize, sizeof(bufsize)); + i += sizeof(bufsize); + + *(sndbuf + i) = msg.op; + i++; + + memcpy(sndbuf + i, msg.buf, msg.len); + i += msg.len; + + int nbytes = Write(socket, sndbuf, bufsize); + free(sndbuf); + + return (nbytes); +} + Modified: soc2013/ambarisha/head/usr.bin/dms/dm.h ============================================================================== --- soc2013/ambarisha/head/usr.bin/dms/dm.h Tue Jul 16 18:02:44 2013 (r254849) +++ soc2013/ambarisha/head/usr.bin/dms/dm.h Tue Jul 16 19:01:03 2013 (r254850) @@ -1,5 +1,5 @@ -#ifndef _DMCLIENT_H -#define _DMCLIENT_H +#ifndef _DM_H +#define _DM_H #include #include @@ -11,6 +11,9 @@ #define DMS_UDS_PATH "/tmp/dms.uds" struct dmres { + int status; + int errcode; + char *errstr; }; struct dmreq { @@ -36,24 +39,35 @@ #define p_FLAG (1 << 10) #define r_FLAG (1 << 11) #define s_FLAG (1 << 12) +#define V_TTY (1 << 13) char *i_filename; char *URL; char *path; }; -struct msg { +struct dmmsg { char op; int len; char *buf; }; +struct xferstat { + char name[64]; + struct timeval start; /* start of transfer */ + struct timeval last; /* time of last update */ + struct timeval last2; /* time of previous last update */ + off_t size; /* size of file per HTTP hdr */ + off_t offset; /* starting offset in file */ + off_t rcvd; /* bytes already received */ + off_t lastrcvd; /* bytes received since last update */ +}; + #define DMREQ 1 #define DMRESP 2 -#define DMSTATREQ 3 -#define DMSTATRESP 4 -#define DMAUTHREQ 5 -#define DMAUTHRESP 6 -#define DMSIG 7 +#define DMAUTHREQ 3 +#define DMAUTHRESP 4 +#define DMSIG 5 +#define DMSTAT 6 #endif /* _DMCLIENT_H */ Modified: soc2013/ambarisha/head/usr.bin/dms/dms.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dms/dms.c Tue Jul 16 18:02:44 2013 (r254849) +++ soc2013/ambarisha/head/usr.bin/dms/dms.c Tue Jul 16 19:01:03 2013 (r254850) @@ -14,71 +14,168 @@ #include "list.h" #include "dms.h" -#define MAX_ALIVE_CONNECTIONS 256 +int stop; -static int sigint; +static int +read_fd(int sock) +{ + struct msghdr msg; + struct iovec iov[1]; + ssize_t n; + char c; + int newfd; + + union { + struct cmsghdr cm; + char control[CMSG_SPACE(sizeof(int))]; + } control_un; + struct cmsghdr *cmptr; + + msg.msg_control = control_un.control; + msg.msg_controllen = sizeof(control_un.control); + + msg.msg_name = NULL; + msg.msg_namelen = 0; + + iov[0].iov_base = &c; + iov[0].iov_len = sizeof(c); + msg.msg_iov = iov; + msg.msg_iovlen = 1; + + if ( (n = recvmsg(sock, &msg, 0)) <= 0) + return (n); + + if ( (cmptr = CMSG_FIRSTHDR(&msg)) != NULL && + cmptr->cmsg_len == CMSG_LEN(sizeof(int))) { + if (cmptr->cmsg_level != SOL_SOCKET) + /* ERROR : control level != SOL_SOCKET */; + + if (cmptr->cmsg_type != SCM_RIGHTS) + /* ERROR : control type != SCM_RIGHTS */; + + newfd = *((int *) CMSG_DATA(cmptr)); + } else { + newfd = -1; + } + + return newfd; +} static int -mk_dmjob(int sock, struct dmreq dmreq, struct dmjob *dmjob) +Read_fd(int sock) { + int ret = read_fd(sock); + if (ret == -1) { + perror("Read_fd():"); + } else { + printf("Read_fd(): Success\n"); + } + return(ret); +} + +static struct dmjob * +mk_dmjob(int sock, struct dmreq dmreq) +{ + struct dmjob *dmjob = (struct dmjob *) Malloc(sizeof(struct dmjob)); + /* Right now dmjob and dmreq are same */ dmjob->v_level = dmreq.v_level; dmjob->family = dmreq.family; dmjob->ftp_timeout = dmreq.ftp_timeout; dmjob->http_timeout = dmreq.http_timeout; dmjob->B_size = dmreq.B_size; + dmjob->S_size = dmreq.S_size; dmjob->T_secs = dmreq.T_secs; dmjob->flags = dmreq.flags; - dmjob->i_filename = dmreq.i_filename; - dmjob->URL = dmreq.URL; - dmjob->path = dmreq.path; - return 0; + + if (dmjob->flags & V_TTY) + printf("v_tty is set :)\n"); + else + printf("v_tty is already gone\n"); + printf("HELLO???\n"); + + dmjob->i_filename = (char *) Malloc(strlen(dmreq.i_filename) + 1); + strcpy(dmjob->i_filename, dmreq.i_filename); + + dmjob->URL = (char *) Malloc(strlen(dmreq.URL) + 1); + strcpy(dmjob->URL, dmreq.URL); + + dmjob->path = (char *) Malloc(strlen(dmreq.path) + 1); + strcpy(dmjob->path, dmreq.path); + + dmjob->fd = Read_fd(sock); + dmjob->csock = sock; + + return dmjob; } -static int -Mk_dmjob(int sock, struct dmreq dmreq, struct dmjob *dmjob) +static struct dmjob * +Mk_dmjob(int sock, struct dmreq dmreq) { - int err = mk_dmjob(sock, dmreq, dmjob); - if (err == -1) { + struct dmjob *dmjob = mk_dmjob(sock, dmreq); + if (dmjob == NULL) { perror("mk_dmjob():"); #if DEBUG } else { printf("mk_dmjob(): Success\n"); #endif } - return err; + return dmjob; +} + +static void +rm_dmjob(struct dmjob **dmjob) +{ + free((*dmjob)->i_filename); + free((*dmjob)->path); + free((*dmjob)->URL); + free(*dmjob); + *dmjob = NULL; } static int -parse_request(char *rcvbuf, int bufsize, struct dmreq *dmreq) +parse_request(char *rcvbuf, int bufsize) { int i = 0; + struct dmreq *dmreq = (struct dmreq *) Malloc(sizeof(struct dmreq)); + memcpy(&(dmreq->v_level), rcvbuf + i, sizeof(dmreq->v_level)); i += sizeof(dmreq->v_level); memcpy(&(dmreq->family), rcvbuf + i, sizeof(dmreq->family)); i += sizeof(dmreq->family); - memcpy(&(dmreq->ftp_timeout), rcvbuf, sizeof(dmreq->ftp_timeout)); + memcpy(&(dmreq->ftp_timeout), rcvbuf + i, sizeof(dmreq->ftp_timeout)); i += sizeof(dmreq->ftp_timeout); - memcpy(&(dmreq->http_timeout), rcvbuf, sizeof(dmreq->http_timeout)); + memcpy(&(dmreq->http_timeout), rcvbuf + i, sizeof(dmreq->http_timeout)); i += sizeof(dmreq->http_timeout); - memcpy(&(dmreq->B_size), rcvbuf, sizeof(dmreq->B_size)); + memcpy(&(dmreq->B_size), rcvbuf + i, sizeof(dmreq->B_size)); i += sizeof(dmreq->B_size); - memcpy(&(dmreq->S_size), rcvbuf, sizeof(dmreq->S_size)); + memcpy(&(dmreq->S_size), rcvbuf + i, sizeof(dmreq->S_size)); i += sizeof(dmreq->S_size); - memcpy(&(dmreq->T_secs), rcvbuf, sizeof(dmreq->T_secs)); + memcpy(&(dmreq->T_secs), rcvbuf + i, sizeof(dmreq->T_secs)); i += sizeof(dmreq->T_secs); - memcpy(&(dmreq->flags), rcvbuf, sizeof(dmreq->flags)); + memcpy(&(dmreq->flags), rcvbuf + i, sizeof(dmreq->flags)); + + printf("flags = %d\n", *(int *)(rcvbuf + i)); i += sizeof(dmreq->flags); - + printf("i after flags == %d\n honey", i); + + if (dmreq->flags & V_TTY) + printf("v_tty is STTIIIIIILLL set :)\n"); + else + printf("v_tty is already gone\n"); + printf("RARRRR\n"); + + write(1, rcvbuf, bufsize); + int sz = strlen(rcvbuf+i); dmreq->i_filename = (char *) Malloc(sz); strcpy(dmreq->i_filename, rcvbuf+i); @@ -94,29 +191,69 @@ strcpy(dmreq->path, rcvbuf+i); i += sz + 1; - return (0); + return dmreq; } static int -Parse_request(char *rcvbuf, int bufsize, struct dmreq *dmreq) +Parse_request(char *rcvbuf, int bufsize) { - int err = parse_request(rcvbuf, bufsize, dmreq); - if (err == -1) { + struct dmreq *dmreq = parse_request(rcvbuf, bufsize); + if (dmreq == NULL) { perror("Parse_request():"); #if DEBUG } else { printf("Parse_reqeust(): Success\n"); #endif } - return err; + return dmreq; +} + +static void +Free_request(struct dmreq **dmreq) +{ + free((*dmreq)->i_filename); + free((*dmreq)->URL); + free((*dmreq)->path); + free(*dmreq); + *dmreq = NULL; +} + +static void +send_report(int sock, struct dmrep report, char op) +{ + char *buf; + int bufsize = sizeof(report) - sizeof(report.errstr); + int errlen = strlen(report.errstr); + bufsize += errlen; + + buf = (char *) Malloc(bufsize); + int i = 0; + + memcpy(buf + i, &(report.status), sizeof(report.status)); + i += sizeof(report.status); + + memcpy(buf + i, &(report.errcode), sizeof(report.errcode)); + i += sizeof(report.errcode); + + strcpy(buf + i, report.errstr); + i += errlen; + + struct dmmsg msg; + msg.op = op; + msg.buf = buf; + msg.len = bufsize; + send_msg(sock, msg); + + free(buf); } static int handle_request(int csock, struct conn **conns) { - struct dmjob dmjob; - struct dmreq dmreq; - struct msg msg; + struct dmjob *dmjob; + struct dmreq *dmreq; + struct dmmsg msg; + struct dmrep report; int err; pid_t pid; @@ -124,38 +261,11 @@ switch (msg.op) { case DMREQ: - err = Parse_request(msg.buf, msg.len, &dmreq); - err = Mk_dmjob(csock, dmreq, &dmjob); - - int sockets[2]; - Socketpair(AF_LOCAL, SOCK_STREAM, 0, sockets); - - pid = fork(); - if (pid == 0) { - /* Close all unwanted fds */ - struct conn *cur = *conns; - while (cur != NULL) { - close(cur->client); - close(cur->worker); - *conns = rm_conn(*conns, cur); - cur = *conns; - } - - close(csock); - close(sockets[0]); - - /* Enter sandbox mode */ - // if(cap_enter() < 0) - // errx(2, "Worker: Couldn't enter sandbox mode"); - /* Can't do this till libfetch is modified */ - - run_worker(dmjob, sockets[1]); - exit(0); - } else { - //close(sockets[1]); - *conns = add_conn(*conns, csock, sockets[0]); - } - + dmreq = Parse_request(msg.buf, msg.len); + dmjob = Mk_dmjob(csock, *dmreq); + Free_request(&dmreq); + do_job(*dmjob, &report); + send_report(csock, report, DMRESP); default: /* Unknown opcode recieved */ return -1; @@ -168,14 +278,14 @@ void sigint_handler(int sig) { - sigint = 1; + stop = 1; exit(1); // Temporary *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Wed Jul 17 02:19:45 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 906A8B3 for ; Wed, 17 Jul 2013 02:19:45 +0000 (UTC) (envelope-from ccqin@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 826E3CDE for ; Wed, 17 Jul 2013 02:19:45 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6H2JjM6028124 for ; Wed, 17 Jul 2013 02:19:45 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6H2JjcT028113 for svn-soc-all@FreeBSD.org; Wed, 17 Jul 2013 02:19:45 GMT (envelope-from ccqin@FreeBSD.org) Date: Wed, 17 Jul 2013 02:19:45 GMT Message-Id: <201307170219.r6H2JjcT028113@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254862 - soc2013/ccqin/head/sys/net80211 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 02:19:45 -0000 Author: ccqin Date: Wed Jul 17 02:19:45 2013 New Revision: 254862 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254862 Log: Fix some rate option's logic. Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Wed Jul 17 01:34:25 2013 (r254861) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Wed Jul 17 02:19:45 2013 (r254862) @@ -118,12 +118,19 @@ { const struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = vap->iv_ic; + int i; vap->iv_rate->ir_rates(ni, rc, shortPreamble, frameLen); /* if enable rts/cts and is pre-802.11n, blank tries 1, 2, 3 */ - if ((rc[0].flags & IEEE80211_RATECTL_RTSCTS_FLAG) && !(ic->ic_htcaps & IEEE80211_HTC_HT)) - rc[1].tries = rc[2].tries = rc[3].tries = 0; + for (i = 0; i < IEEE80211_RATECTL_NUM && rc[i].flags & IEEE80211_RATECTL_RTSCTS_FLAG; i++) + { + if (!(ic->ic_htcaps & IEEE80211_HTC_HT)) + { + rc[1].tries = rc[2].tries = rc[3].tries = 0; + break; + } + } } static void __inline From owner-svn-soc-all@FreeBSD.ORG Wed Jul 17 03:02:35 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4009E7EC for ; Wed, 17 Jul 2013 03:02:35 +0000 (UTC) (envelope-from ccqin@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 3213BF27 for ; Wed, 17 Jul 2013 03:02:35 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6H32Z3A004944 for ; Wed, 17 Jul 2013 03:02:35 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6H32YOB004929 for svn-soc-all@FreeBSD.org; Wed, 17 Jul 2013 03:02:34 GMT (envelope-from ccqin@FreeBSD.org) Date: Wed, 17 Jul 2013 03:02:34 GMT Message-Id: <201307170302.r6H32YOB004929@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254864 - soc2013/ccqin/head/sys/net80211 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 03:02:35 -0000 Author: ccqin Date: Wed Jul 17 03:02:32 2013 New Revision: 254864 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254864 Log: For pre-802.11n, clear rts/cts flag of retries 1, 2, 3. If retry 0 enable rts/cts, blank tries 1, 2, 3. Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Wed Jul 17 02:37:40 2013 (r254863) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Wed Jul 17 03:02:32 2013 (r254864) @@ -118,18 +118,17 @@ { const struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = vap->iv_ic; - int i; vap->iv_rate->ir_rates(ni, rc, shortPreamble, frameLen); /* if enable rts/cts and is pre-802.11n, blank tries 1, 2, 3 */ - for (i = 0; i < IEEE80211_RATECTL_NUM && rc[i].flags & IEEE80211_RATECTL_RTSCTS_FLAG; i++) + if (!(ic->ic_htcaps & IEEE80211_HTC_HT)) { - if (!(ic->ic_htcaps & IEEE80211_HTC_HT)) - { + if (rc[0].flags & IEEE80211_RATECTL_RTSCTS_FLAG) rc[1].tries = rc[2].tries = rc[3].tries = 0; - break; - } + rc[1].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; + rc[2].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; + rc[3].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; } } From owner-svn-soc-all@FreeBSD.ORG Wed Jul 17 04:29:16 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1E3FC888 for ; Wed, 17 Jul 2013 04:29:16 +0000 (UTC) (envelope-from ambarisha@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 10AA42F7 for ; Wed, 17 Jul 2013 04:29:16 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6H4TFDN012172 for ; Wed, 17 Jul 2013 04:29:15 GMT (envelope-from ambarisha@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6H4TFZB012167 for svn-soc-all@FreeBSD.org; Wed, 17 Jul 2013 04:29:15 GMT (envelope-from ambarisha@FreeBSD.org) Date: Wed, 17 Jul 2013 04:29:15 GMT Message-Id: <201307170429.r6H4TFZB012167@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ambarisha@FreeBSD.org using -f From: ambarisha@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254865 - in soc2013/ambarisha/head/usr.bin: dmget dms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 04:29:16 -0000 Author: ambarisha Date: Wed Jul 17 04:29:15 2013 New Revision: 254865 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254865 Log: Trivial change : Fixed some silly debug printfs Modified: soc2013/ambarisha/head/usr.bin/dmget/fetch.c soc2013/ambarisha/head/usr.bin/dms/dms.c Modified: soc2013/ambarisha/head/usr.bin/dmget/fetch.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/fetch.c Wed Jul 17 03:02:32 2013 (r254864) +++ soc2013/ambarisha/head/usr.bin/dmget/fetch.c Wed Jul 17 04:29:15 2013 (r254865) @@ -280,10 +280,6 @@ if (o_stdout) dmreq.flags |= O_STDOUT; if (v_tty) dmreq.flags |= V_TTY; - - if (dmreq.flags & V_TTY) printf("v_tty is set\n"); - else printf("v_tty is not set\n"); - dmStatDisplayMethod = stat_display; return (dmget(dmreq)); } Modified: soc2013/ambarisha/head/usr.bin/dms/dms.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dms/dms.c Wed Jul 17 03:02:32 2013 (r254864) +++ soc2013/ambarisha/head/usr.bin/dms/dms.c Wed Jul 17 04:29:15 2013 (r254865) @@ -89,12 +89,6 @@ dmjob->T_secs = dmreq.T_secs; dmjob->flags = dmreq.flags; - if (dmjob->flags & V_TTY) - printf("v_tty is set :)\n"); - else - printf("v_tty is already gone\n"); - printf("HELLO???\n"); - dmjob->i_filename = (char *) Malloc(strlen(dmreq.i_filename) + 1); strcpy(dmjob->i_filename, dmreq.i_filename); @@ -164,17 +158,7 @@ memcpy(&(dmreq->flags), rcvbuf + i, sizeof(dmreq->flags)); - printf("flags = %d\n", *(int *)(rcvbuf + i)); i += sizeof(dmreq->flags); - printf("i after flags == %d\n honey", i); - - if (dmreq->flags & V_TTY) - printf("v_tty is STTIIIIIILLL set :)\n"); - else - printf("v_tty is already gone\n"); - printf("RARRRR\n"); - - write(1, rcvbuf, bufsize); int sz = strlen(rcvbuf+i); dmreq->i_filename = (char *) Malloc(sz); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 17 12:52:38 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B5B27351 for ; Wed, 17 Jul 2013 12:52:38 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A7283E0B for ; Wed, 17 Jul 2013 12:52:38 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6HCqcno066752 for ; Wed, 17 Jul 2013 12:52:38 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6HCqcFJ066742 for svn-soc-all@FreeBSD.org; Wed, 17 Jul 2013 12:52:38 GMT (envelope-from jmuniz@FreeBSD.org) Date: Wed, 17 Jul 2013 12:52:38 GMT Message-Id: <201307171252.r6HCqcFJ066742@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254878 - soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 12:52:38 -0000 Author: jmuniz Date: Wed Jul 17 12:52:37 2013 New Revision: 254878 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254878 Log: Updated PackageKit port Makefile: added pkgng option; enhanced back end selection; fixed manpages option, by adding docbook-xml to its dependencies; incremented the revision number; removed invalid argument: --disable-managed; performed satisfactory initial testing; and removed an empty line. Modified: soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Modified: soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile ============================================================================== --- soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Wed Jul 17 11:51:24 2013 (r254877) +++ soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Wed Jul 17 12:52:37 2013 (r254878) @@ -4,7 +4,7 @@ PORTNAME= PackageKit PORTVERSION= 0.6.11 -PORTREVISION?= 3 +PORTREVISION?= 4 CATEGORIES= ports-mgmt sysutils MASTER_SITES= http://www.packagekit.org/releases/ @@ -33,7 +33,6 @@ CONFIGURE_ARGS+=--with-security-framework=polkit \ --localstatedir=/var \ --disable-gtk-doc \ - --disable-managed \ --disable-browser-plugin \ --disable-gstreamer-plugin \ --disable-networkmanager \ @@ -44,31 +43,65 @@ MAKE_JOBS_UNSAFE=yes .if !defined(SLAVEPORT) -OPTIONS_DEFINE= PORTS MANPAGES +OPTIONS_DEFINE= MANPAGES PORTS PKGNG DUMMY OPTIONS_DEFAULT=PORTS -PORTS_DESC=Use portupgrade for management, dummy if disabled +PORTS_DESC= Include back end to use portupgrade and pkg +PKGNG_DESC= Include pkgng back end for software management +DUMMY_DESC= Include dummy back end for testing purposes .include . if ${PORT_OPTIONS:MMANPAGES} BUILD_DEPENDS+= ${LOCALBASE}/share/sgml/docbook/4.1/dtd/catalog:${PORTSDIR}/textproc/docbook-410 \ xsltproc:${PORTSDIR}/textproc/libxslt \ - ${LOCALBASE}/share/xsl/docbook/manpages/docbook.xsl:${PORTSDIR}/textproc/docbook-xsl + ${LOCALBASE}/share/xsl/docbook/manpages/docbook.xsl:${PORTSDIR}/textproc/docbook-xsl \ + ${LOCALBASE}/share/xml/docbook/4.2/catalog.xml:${PORTSDIR}/textproc/docbook-xml MAN1= pkcon.1 pkmon.1 pkgenpack.1 pk-debuginfo-install.1 . else CONFIGURE_ARGS+=--disable-man-pages . endif +. if ${PORT_OPTIONS:MDUMMY} || ( ! ${PORT_OPTIONS:MDUMMY} && ! ${PORT_OPTIONS:MPORTS} && ! ${PORT_OPTIONS:MPKGNG} ) +. if ! ${PORT_OPTIONS:MPORTS} && ! ${PORT_OPTIONS:MPKGNG} +CONFIGURE_ARGS+=--with-default-backend=dummy +PLIST_SUB+= BACKENDS="@comment " +.endif +CONFIGURE_ARGS+=--enable-dummy +.else +CONFIGURE_ARGS+=--disable-dummy +.endif + +. if ${PORT_OPTIONS:MPORTS} || ${PORT_OPTIONS:MPKGNG +PLIST_SUB+= BACKENDS="" +. endif + +. if ! ${PORT_OPTIONS:MPORTS} +CONFIGURE_ARGS+=--disable-ports +PLIST_SUB+= PORTS="@comment " +. endif + +. if ! ${PORT_OPTIONS:MPKGNG} +CONFIGURE_ARGS+=--disable-pkgng +PLIST_SUB+= PKGNG="@comment " +. endif + . if ${PORT_OPTIONS:MPORTS} +. if ! ${PORT_OPTIONS:MPKGNG} +CONFIGURE_ARGS+=--with-default-backend=ports +. endif RUN_DEPENDS+= ${LOCALBASE}/sbin/portupgrade:${PORTSDIR}/ports-mgmt/portupgrade USE_RUBY= yes -CONFIGURE_ARGS+=--enable-ports --with-default-backend=ports +CONFIGURE_ARGS+=--enable-ports PLIST_SUB+= PORTS="" -. else -CONFIGURE_ARGS+=--disable-ports --with-default-backend=dummy -PLIST_SUB+= PORTS="@comment " . endif +. if ${PORT_OPTIONS:MPKGNG} +RUN_DEPENDS+= ${LOCALBASE}/sbin/pkg:${PORTSDIR}/ports-mgmt/pkg +CONFIGURE_ARGS+=--enable-pkgng \ + --with-default-backend=pkgng +PLIST_SUB+= PKGNG="" +.endif + CONFIGURE_ARGS+=--disable-gtk-module PLIST_SUB+= GTK="@comment " From owner-svn-soc-all@FreeBSD.ORG Wed Jul 17 12:59:52 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 19AC349C for ; Wed, 17 Jul 2013 12:59:52 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id E5A0BE3C for ; Wed, 17 Jul 2013 12:59:51 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6HCxp8b010444 for ; Wed, 17 Jul 2013 12:59:51 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6HCxpeu010442 for svn-soc-all@FreeBSD.org; Wed, 17 Jul 2013 12:59:51 GMT (envelope-from jmuniz@FreeBSD.org) Date: Wed, 17 Jul 2013 12:59:51 GMT Message-Id: <201307171259.r6HCxpeu010442@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254879 - soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 12:59:52 -0000 Author: jmuniz Date: Wed Jul 17 12:59:51 2013 New Revision: 254879 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254879 Log: Updated pkg-plist: added all files installed for temporary pkgng backend; enhanced tags; removed tags from a couple of files that were not part of a back end; performed satisfactory initial testing. Modified: soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/pkg-plist Modified: soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/pkg-plist ============================================================================== --- soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/pkg-plist Wed Jul 17 12:52:37 2013 (r254878) +++ soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/pkg-plist Wed Jul 17 12:59:51 2013 (r254879) @@ -66,6 +66,9 @@ %%PORTS%%lib/packagekit-backend/libpk_backend_ports.a %%PORTS%%lib/packagekit-backend/libpk_backend_ports.la %%PORTS%%lib/packagekit-backend/libpk_backend_ports.so +%%PKGNG%%lib/packagekit-backend/libpk_backend_pkgng.a +%%PKGNG%%lib/packagekit-backend/libpk_backend_pkgng.la +%%PKGNG%%lib/packagekit-backend/libpk_backend_pkgng.so lib/packagekit-backend/libpk_backend_test_fail.a lib/packagekit-backend/libpk_backend_test_fail.la lib/packagekit-backend/libpk_backend_test_fail.so @@ -123,6 +126,9 @@ %%PORTS%%share/PackageKit/helpers/ports/portsBackend.rb %%PORTS%%share/PackageKit/helpers/ports/ruby_packagekit/enums.rb %%PORTS%%share/PackageKit/helpers/ports/ruby_packagekit/prints.rb +%%PKGNG%%share/PackageKit/helpers/pkgng/pkgngBackend.rb +%%PKGNG%%share/PackageKit/helpers/pkgng/ruby_packagekit/enums.rb +%%PKGNG%%share/PackageKit/helpers/pkgng/ruby_packagekit/prints.rb share/PackageKit/helpers/test_spawn/search-name.sh share/PackageKit/pk-upgrade-distro.sh share/PackageKit/transactions.db @@ -422,14 +428,16 @@ @dirrm share/gtk-doc/html/PackageKit @dirrmtry share/gtk-doc/html @dirrmtry share/gtk-doc -%%PORTS%%@dirrm share/PackageKit/website/img/thumbnails -%%PORTS%%@dirrm share/PackageKit/website/img -%%PORTS%%@dirrm share/PackageKit/website -%%PORTS%%@dirrm share/PackageKit/helpers/test_spawn +@dirrm share/PackageKit/website/img/thumbnails +@dirrm share/PackageKit/website/img +@dirrm share/PackageKit/website %%PORTS%%@dirrm share/PackageKit/helpers/ports/ruby_packagekit %%PORTS%%@dirrm share/PackageKit/helpers/ports -%%PORTS%%@dirrm share/PackageKit/helpers -%%PORTS%%@dirrm share/PackageKit +%%PKGNG%%@dirrm share/PackageKit/helpers/pkgng/ruby_packagekit +%%PKGNG%%@dirrm share/PackageKit/helpers/pkgng +%%BACKENDS%%@dirrm share/PackageKit/helpers/test_spawn +%%BACKENDS%%@dirrm share/PackageKit/helpers +%%BACKENDS%%@dirrm share/PackageKit @dirrm %%PYTHON_SITELIBDIR%%/packagekit @dirrm lib/packagekit-backend @dirrm include/PackageKit/packagekit-glib2 From owner-svn-soc-all@FreeBSD.ORG Wed Jul 17 17:17:16 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7FD045D2 for ; Wed, 17 Jul 2013 17:17:16 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 706DEE84 for ; Wed, 17 Jul 2013 17:17:16 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6HHHGiX009588 for ; Wed, 17 Jul 2013 17:17:16 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6HHHGso009577 for svn-soc-all@FreeBSD.org; Wed, 17 Jul 2013 17:17:16 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 17 Jul 2013 17:17:16 GMT Message-Id: <201307171717.r6HHHGso009577@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254890 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 17:17:16 -0000 Author: dpl Date: Wed Jul 17 17:17:16 2013 New Revision: 254890 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254890 Log: It works always, except when used --files/--files0 as options. Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c soc2013/dpl/head/contrib/xz/src/xz/coder.h soc2013/dpl/head/contrib/xz/src/xz/file_io.c soc2013/dpl/head/contrib/xz/src/xz/file_io.h soc2013/dpl/head/contrib/xz/src/xz/list.c soc2013/dpl/head/contrib/xz/src/xz/list.h soc2013/dpl/head/contrib/xz/src/xz/main.c soc2013/dpl/head/contrib/xz/src/xz/main.h soc2013/dpl/head/contrib/xz/src/xz/private.h Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.c Wed Jul 17 14:15:00 2013 (r254889) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.c Wed Jul 17 17:17:16 2013 (r254890) @@ -609,52 +609,51 @@ extern void -coder_run(file_pair pairs[], int files) +coder_run(file_pair *pair) { - int i; + if (pair == NULL ) + return; - for( i=0; i < files; i++) { - // Set and possibly print the filename for the progress message. - message_filename(pairs[i].src_name); - - // Assume that something goes wrong. - bool success = false; - - // Read the first chunk of input data. This is needed to detect - // the input file type (for now, only for decompression). - strm.next_in = in_buf.u8; - strm.avail_in = io_read(&pairs[i], &in_buf, IO_BUFFER_SIZE); - - if (strm.avail_in != SIZE_MAX) { - // Initialize the coder. This will detect the file format - // and, in decompression or testing mode, check the memory - // usage of the first Block too. This way we don't try to - // open the destination file if we see that coding wouldn't - // work at all anyway. This also avoids deleting the old - // "target" file if --force was used. - const enum coder_init_ret init_ret = coder_init(&pairs[i]); - - if (init_ret != CODER_INIT_ERROR && !user_abort) { - // Initialize the progress indicator. - const uint64_t in_size - = pairs[i].src_st.st_size <= 0 - ? 0 : pairs[i].src_st.st_size; - message_progress_start(&strm, in_size); - - // Do the actual coding or passthru. - if (init_ret == CODER_INIT_NORMAL) - success = coder_normal(&pairs[i]); - else - success = coder_passthru(&pairs[i]); + // Set and possibly print the filename for the progress message. + message_filename(pair->src_name); - message_progress_end(success); - } + // Assume that something goes wrong. + bool success = false; + + // Read the first chunk of input data. This is needed to detect + // the input file type (for now, only for decompression). + strm.next_in = in_buf.u8; + strm.avail_in = io_read(pair, &in_buf, IO_BUFFER_SIZE); + + if (strm.avail_in != SIZE_MAX) { + // Initialize the coder. This will detect the file format + // and, in decompression or testing mode, check the memory + // usage of the first Block too. This way we don't try to + // open the destination file if we see that coding wouldn't + // work at all anyway. This also avoids deleting the old + // "target" file if --force was used. + const enum coder_init_ret init_ret = coder_init(pair); + + if (init_ret != CODER_INIT_ERROR && !user_abort) { + // Initialize the progress indicator. + const uint64_t in_size + = pair->src_st.st_size <= 0 + ? 0 : pair->src_st.st_size; + message_progress_start(&strm, in_size); + + // Do the actual coding or passthru. + if (init_ret == CODER_INIT_NORMAL) + success = coder_normal(pair); + else + success = coder_passthru(pair); + + message_progress_end(success); } - - // Close the file pair. It needs to know if coding was successful to - // know if the source or target file should be unlinked. - io_close(&pairs[i], success); } + // Close the file pair. It needs to know if coding was successful to + // know if the source or target file should be unlinked. + io_close(pair, success); + return; } Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.h Wed Jul 17 14:15:00 2013 (r254889) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.h Wed Jul 17 17:17:16 2013 (r254890) @@ -58,4 +58,4 @@ extern void coder_set_compression_settings(void); /// Compress or decompress the given file -extern void coder_run(file_pair *pairs[], int files); +extern void coder_run(file_pair *pairs); Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Wed Jul 17 14:15:00 2013 (r254889) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Wed Jul 17 17:17:16 2013 (r254890) @@ -91,7 +91,7 @@ /// a small unavoidable race, but this is much better than nothing (the file /// could have been moved/replaced even hours earlier). static void -io_unlink(const char *name, const struct stat *known_st) +io_unlink(file_pair *pair, int dest) { #if defined(TUKLIB_DOSLIKE) // On DOS-like systems, st_ino is meaningless, so don't bother @@ -99,6 +99,19 @@ (void)known_st; #else struct stat new_st; + const char *name; + int fd; + struct stat *known_st; + //const char *name, int *fd, int *dirfd, const struct stat *known_st) + if (dest) { + name = pair->dest_name; + fd = &pair->dest_fd; + known_st = &pair->dest_st; + } else { + name = pair->src_name; + fd = &pair->src_fd; + known_st = &pair->src_st; + } // If --force was used, use stat() instead of lstat(). This way // (de)compressing symlinks works correctly. However, it also means @@ -110,7 +123,8 @@ // Probably it's not too bad though, so this doesn't need a more // complex fix. const int stat_ret = opt_force - ? stat(name, &new_st) : lstat(name, &new_st); + ? fstatat(pair->dir_fd, basename(name), &new_st, 0) + : fstatat(pair->dir_fd, basename(name), &new_st, AT_SYMLINK_NOFOLLOW); if (stat_ret # ifdef __VMS @@ -140,7 +154,7 @@ #endif // There's a race condition between lstat() and unlink() // but at least we have tried to avoid removing wrong file. - if (unlink(name)) + if (unlinkat(pair->dir_fd, basename(name), 0)) message_error(_("%s: Cannot remove: %s"), name, strerror(errno)); @@ -355,6 +369,9 @@ // doesn't hurt to have it just in case. do { pair->src_fd = open(pair->src_name, flags); +#if defined(CAPSICUM) + pair->dir_fd = open( dirname(pair->src_name), O_DIRECTORY); +#endif } while (pair->src_fd == -1 && errno == EINTR && !user_abort); if (!reg_files_only) @@ -513,36 +530,26 @@ if (is_empty_filename(src_name)) return NULL; - // Since we have only one file open at a time, we can use - // a statically allocated structure. - static file_pair pair; - - pair = (file_pair){ - .src_name = src_name, - .dest_name = NULL, - .src_fd = -1, - .dest_fd = -1, - .src_eof = false, - .dest_try_sparse = false, - .dest_pending_sparse = 0, - }; + file_pair *pair; + + pair = (file_pair*)malloc(sizeof(file_pair)); + pair->src_name = src_name; + pair->dest_name = NULL; + pair->dir_fd = -1; + pair->src_fd = -1; + pair->dest_fd = -1; + pair->src_eof = false; + pair->dest_try_sparse = false; + pair->dest_pending_sparse = 0; -/* pair = (file_pair *)malloc(sizeof(file_pair);*/ -/* pair.src_name = src_name;*/ -/* pair.dest_name = NULL;*/ -/* pair.src_fd = -1;*/ -/* pair.dest_fd = -1;*/ -/* pair.src_eof = false;*/ -/* pair.dest_try_sparse = false;*/ -/* pair.dest_pending_sparse = 0;*/ // Block the signals, for which we have a custom signal handler, so // that we don't need to worry about EINTR. signals_block(); - const bool error = io_open_src_real(&pair); + const bool error = io_open_src_real(pair); signals_unblock(); - return error ? NULL : &pair; + return error ? NULL : pair; } @@ -567,7 +574,7 @@ // NOTE: DOS-like systems are an exception to this, because // they don't allow unlinking files that are open. *sigh* if (success && !opt_keep_original) - io_unlink(pair->src_name, &pair->src_st); + io_unlink(pair, 0); #ifndef TUKLIB_DOSLIKE (void)close(pair->src_fd); @@ -694,7 +701,9 @@ io_open_dest(file_pair *pair) { signals_block(); - const bool ret = io_open_dest_real(pair); + bool ret = true; + if(pair != NULL) + ret = io_open_dest_real(pair); signals_unblock(); return ret; } @@ -736,15 +745,15 @@ // Closing destination file failed, so we cannot trust its // contents. Get rid of junk: - io_unlink(pair->dest_name, &pair->dest_st); + io_unlink(pair, 1); free(pair->dest_name); return true; } - // If the operation using this file wasn't successful, we git rid + // If the operation using this file wasn't successful, we get rid // of the junk file. if (!success) - io_unlink(pair->dest_name, &pair->dest_st); + io_unlink(pair, 1); free(pair->dest_name); @@ -797,6 +806,8 @@ signals_unblock(); + free(pair); + return; } @@ -966,48 +977,36 @@ } extern file_pair ** -io_list_open(char *filename[], int files) +io_open_files(char *filename[], int files) { int i; - file_pair *pairs[files]; + file_pair **pairs = (file_pair **)malloc(files * sizeof(file_pair *)); - //Open files a la list_file() - if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO) - message_fatal(_("--list works only on .xz files " - "(--format=xz or --format=auto)")); - + if( opt_mode == MODE_LIST) + if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO) + message_fatal(_("--list works only on .xz files " + "(--format=xz or --format=auto)")); + for ( i = 0; i < files; i++) { + if (filename[i] == NULL) { + break; + } + // Set and possibly print the filename for the progress message. message_filename(filename[i]); - - if (filename[i] == stdin_filename) { - message_error(_("--list does not support reading from " - "standard input")); - continue; - } - - // Unset opt_stdout so that io_open_src() won't accept special files. - // Set opt_force so that io_open_src() will follow symlinks. - opt_stdout = false; - opt_force = true; - pairs[i] = io_open_src(filename[i]); -#if defined(CAPSICUM) - limitfd(pairs[i]); -#endif - } - return pairs; -} -extern file_pair ** -io_coder_open(char *filename[], int files) -{ - int i; - file_pair *pairs[files]; + if (opt_mode == MODE_LIST) { + if (filename[i] == stdin_filename) { + message_error(_("--list does not support reading from " + "standard input")); + break; + } + + // Unset opt_stdout so that io_open_src() won't accept special files. + // Set opt_force so that io_open_src() will follow symlinks. + opt_stdout = false; + opt_force = true; + } - for ( i = 0; i < files; i++) { - // Set and possibly print the filename for the progress message. - message_filename(filename[i]); - - // Try to open the input file. pairs[i] = io_open_src(filename[i]); if( opt_mode != MODE_TEST ) io_open_dest(pairs[i]); @@ -1015,7 +1014,6 @@ limitfd(pairs[i]); #endif } - return pairs; } @@ -1023,19 +1021,31 @@ extern void limitfd(file_pair *pair) { - cap_rights_t rights = 0; + cap_rights_t rights; - rights |= CAP_READ; - if (cap_rights_limit(pair->src_fd, rights) < 0 && errno != ENOSYS){ - message_error("%s: %s", pair->src_name, strerror(errno)); - exit(E_ERROR); + if(pair->dir_fd != -1 ){ + rights = CAP_FSTATAT|CAP_UNLINKAT|CAP_LOOKUP; + if (cap_rights_limit(pair->dir_fd, rights) < 0 && errno != ENOSYS){ + message_error("%s: %s", pair->dest_name, strerror(errno)); + exit(E_ERROR); + } } - rights |= CAP_WRITE|CAP_FSTAT|CAP_FCHOWN; - rights |= CAP_FCHMOD|CAP_FUTIMES; - if (cap_rights_limit(pair->dest_fd, rights) < 0 && errno != ENOSYS){ - message_error("%s: %s", pair->dest_name, strerror(errno)); - exit(E_ERROR); + if(pair->src_fd != -1 ){ + rights = CAP_READ|CAP_SEEK; + if (cap_rights_limit(pair->src_fd, rights) < 0 && errno != ENOSYS){ + message_error("%s: %s", pair->src_name, strerror(errno)); + exit(E_ERROR); + } + } + + if(pair->dest_fd != -1 ){ + rights = CAP_WRITE|CAP_FSTAT|CAP_FCHOWN + |CAP_FCHMOD|CAP_FUTIMES; + if (cap_rights_limit(pair->dest_fd, rights) < 0 && errno != ENOSYS){ + message_error("%s: %s", pair->dest_name, strerror(errno)); + exit(E_ERROR); + } } return; } @@ -1043,29 +1053,28 @@ extern void cap_init(void) { - cap_rights_t *rights; + cap_rights_t rights; - if( cap_rights_get(STDIN_FILENO, rights) < 0) { + if( cap_rights_get(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) { message_error("%d: %s", STDIN_FILENO, strerror(errno)); exit(E_ERROR); - } else if (*rights == 0) { + } else if (rights == 0) { if (cap_rights_limit(STDIN_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ message_error("%d: %s", STDIN_FILENO, strerror(errno)); exit(E_ERROR); } } - if( cap_rights_get(STDOUT_FILENO, rights) < 0) { + if( cap_rights_get(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) { message_error("%d: %s", STDOUT_FILENO, strerror(errno)); exit(E_ERROR); - } else if (*rights == 0) { + } else if (rights == 0) { if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ message_error("%d: %s", STDOUT_FILENO, strerror(errno)); exit(E_ERROR); } } - if (cap_rights_limit(STDERR_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ message_error("%d: %s", STDERR_FILENO, strerror(errno)); exit(E_ERROR); Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.h Wed Jul 17 14:15:00 2013 (r254889) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.h Wed Jul 17 17:17:16 2013 (r254890) @@ -93,21 +93,14 @@ extern bool io_write(file_pair *pair, const io_buf *buf, size_t size); -/// \brief Open all the files as needed in lit_file(). +/// \brief Open all the files as needed. /// /// \param filenames Array containing all the filenames to be open. /// \param files Number of files to open. /// /// \return Returns an array of file_pairs. -extern file_pair ** io_list_open(char *filenames[], int files); +extern file_pair ** io_open_files(char *filenames[], int files); -/// \brief Open all the files as needed in coder_run(). -/// -/// \param filenames Array containing all the filenames to be open. -/// \param files Number of files to open. -/// -/// \return Returns an array of file_pairs. -extern file_pair ** io_coder_open(char *filenames[], int files); #if defined(CAPSICUM) /// \brief Limits fd using FreeBSD's Capsicum framework. Modified: soc2013/dpl/head/contrib/xz/src/xz/list.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/list.c Wed Jul 17 14:15:00 2013 (r254889) +++ soc2013/dpl/head/contrib/xz/src/xz/list.c Wed Jul 17 17:17:16 2013 (r254890) @@ -1057,9 +1057,8 @@ extern void -list_file(file_pair pairs[], int files) +list_file(file_pair *pair) { - int i; xz_file_info xfi = XZ_FILE_INFO_INIT; // Unset opt_stdout so that io_open_src() won't accept special files. @@ -1067,35 +1066,34 @@ opt_stdout = false; opt_force = true; - for (i = 0; i < files; i++) { - if (pairs[i] == NULL) - continue; - - if (!parse_indexes(&xfi, pairs[i])) { - bool fail; - - // We have three main modes: - // - --robot, which has submodes if --verbose is specified - // once or twice - // - Normal --list without --verbose - // - --list with one or two --verbose - if (opt_robot) - fail = print_info_robot(&xfi, pairs[i]); - else if (message_verbosity_get() <= V_WARNING) - fail = print_info_basic(&xfi, pairs[i]); - else - fail = print_info_adv(&xfi, pairs[i]); - - // Update the totals that are displayed after all - // the individual files have been listed. Don't count - // broken files. - if (!fail) - update_totals(&xfi); - - lzma_index_end(xfi.idx, NULL); - } - - io_close(pairs[i], false); + if (pair == NULL) + return; + + if (!parse_indexes(&xfi, pair)) { + bool fail; + + // We have three main modes: + // - --robot, which has submodes if --verbose is specified + // once or twice + // - Normal --list without --verbose + // - --list with one or two --verbose + if (opt_robot) + fail = print_info_robot(&xfi, pair); + else if (message_verbosity_get() <= V_WARNING) + fail = print_info_basic(&xfi, pair); + else + fail = print_info_adv(&xfi, pair); + + // Update the totals that are displayed after all + // the individual files have been listed. Don't count + // broken files. + if (!fail) + update_totals(&xfi); + + lzma_index_end(xfi.idx, NULL); } + + io_close(pair, false); + return; } Modified: soc2013/dpl/head/contrib/xz/src/xz/list.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/list.h Wed Jul 17 14:15:00 2013 (r254889) +++ soc2013/dpl/head/contrib/xz/src/xz/list.h Wed Jul 17 17:17:16 2013 (r254890) @@ -11,7 +11,7 @@ /////////////////////////////////////////////////////////////////////////////// /// \brief List information about the given .xz file -extern void list_file(const char *filename); +extern void list_file(file_pair *pairs); /// \brief Show the totals after all files have been listed Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/main.c Wed Jul 17 14:15:00 2013 (r254889) +++ soc2013/dpl/head/contrib/xz/src/xz/main.c Wed Jul 17 17:17:16 2013 (r254890) @@ -55,7 +55,7 @@ } -static const char * +static char * read_name(const args_info *args) { // FIXME: Maybe we should have some kind of memory usage limit here @@ -142,8 +142,7 @@ int main(int argc, char **argv) { - int files = 0; - + int forkpid, i, nfiles = 0; #if defined(_WIN32) && !defined(__CYGWIN__) InitializeCriticalSection(&exit_status_cs); #endif @@ -208,13 +207,9 @@ signals_init(); // Separate opening the files from list_file() and coder_run() - // We have to limit both functions with Capsicum. - file_pair * (*open)(const char **filename, int files) = opt_mode == MODE_LIST - ? &io_list_open : &io_coder_open; - // coder_run() handles compression, decompression, and testing. // list_file() is for --list. - void (*run)(const file_pair *pairs, int files) = opt_mode == MODE_LIST + void (*run)(file_pair *pair) = opt_mode == MODE_LIST ? &list_file : &coder_run; // Process the files given on the command line. Note that if no names @@ -248,14 +243,10 @@ // string and the code still knows that it is // handling the special case of stdin. args.arg_names[i] = (char *)stdin_filename; - files++; } + nfiles++; } - file_pair pairs[files] = open(args.arg_names, files); - cap_init(); - run(pairs, files); - // If --files or --files0 was used, process the filenames from the // given file or stdin. Note that here we don't consider "-" to // indicate stdin like we do with the command line arguments. @@ -263,19 +254,46 @@ // read_name() checks for user_abort so we don't need to // check it as loop termination condition. while (true) { - const char *name = read_name(&args); + char *name = read_name(&args); + printf("name: %s\n", name); if (name == NULL) break; // read_name() doesn't return empty names. assert(name[0] != '\0'); - run(name); + args.arg_count++; + args.arg_names[nfiles] = name; + nfiles++; } if (args.files_name != stdin_filename) (void)fclose(args.files_file); } + printf("nfiles: %d\n", nfiles); + for ( i = 0; (size_t)i < args.arg_count; i++) + printf("file: %s\n", args.arg_names[i]); + + file_pair **pairs = io_open_files(args.arg_names, nfiles); + + for( i = 0; i < nfiles; i++){ +#if defined(CAPSICUM) + if ( (forkpid = fork()) == -1 ){ + message_error("%d: %s", STDERR_FILENO, strerror(errno)); + exit(E_ERROR); + } else if ( forkpid != 0) { + /* Let the children compress */ + wait(NULL); + } else if (forkpid == 0){ + cap_init(); +#endif + run(pairs[i]); +#if defined(CAPSICUM) + exit(0); + } +#endif + } + // All files have now been handled. If in --list mode, display // the totals before exiting. We don't have signal handlers // enabled in --list mode, so we don't need to check user_abort. Modified: soc2013/dpl/head/contrib/xz/src/xz/main.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/main.h Wed Jul 17 14:15:00 2013 (r254889) +++ soc2013/dpl/head/contrib/xz/src/xz/main.h Wed Jul 17 17:17:16 2013 (r254890) @@ -17,6 +17,8 @@ E_WARNING = 2, }; +// To be used with unlinkat(), fstatat() at io_close(). +int dirfd; /// Sets the exit status after a warning or error has occurred. If new_status /// is E_WARNING and the old exit status was already E_ERROR, the exit Modified: soc2013/dpl/head/contrib/xz/src/xz/private.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/private.h Wed Jul 17 14:15:00 2013 (r254889) +++ soc2013/dpl/head/contrib/xz/src/xz/private.h Wed Jul 17 17:17:16 2013 (r254890) @@ -32,6 +32,8 @@ # if __FreeBSD_version >= 900041 # define CAPSICUM # include +# include +# include # endif #endif @@ -61,6 +63,11 @@ /// "(stdout)" when writing to standard output. char *dest_name; +#if defined(CAPSICUM) + // File descriptor of the directory where the files are. + int dir_fd; +#endif + /// File descriptor of the source file int src_fd; From owner-svn-soc-all@FreeBSD.ORG Wed Jul 17 17:36:08 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1F73ECC9 for ; Wed, 17 Jul 2013 17:36:08 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 11A88F69 for ; Wed, 17 Jul 2013 17:36:08 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6HHa7NG093926 for ; Wed, 17 Jul 2013 17:36:07 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6HHa7bV093920 for svn-soc-all@FreeBSD.org; Wed, 17 Jul 2013 17:36:07 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 17 Jul 2013 17:36:07 GMT Message-Id: <201307171736.r6HHa7bV093920@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254891 - soc2013/dpl/head/usr.bin/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 17:36:08 -0000 Author: dpl Date: Wed Jul 17 17:36:07 2013 New Revision: 254891 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254891 Log: Just commiting to have the latest version, so I can comment about the code with my mentor. Modified: soc2013/dpl/head/usr.bin/xz/Makefile Modified: soc2013/dpl/head/usr.bin/xz/Makefile ============================================================================== --- soc2013/dpl/head/usr.bin/xz/Makefile Wed Jul 17 17:17:16 2013 (r254890) +++ soc2013/dpl/head/usr.bin/xz/Makefile Wed Jul 17 17:36:07 2013 (r254891) @@ -48,14 +48,4 @@ DPADD= ${LIBLZMA} LDADD= -llzma -CLEANFILES+= testfile testfile.xz ktrace.out - -test: xz - -@rm testfile - -@rm testfile.xz - @echo one > testfile - -@ktrace -i ./xz testfile; \ - if [ $$? -ne 0 ]; \ - then kdump; \ - fi; .include From owner-svn-soc-all@FreeBSD.ORG Wed Jul 17 17:43:32 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 36A8BF54 for ; Wed, 17 Jul 2013 17:43:32 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 0E94AFB6 for ; Wed, 17 Jul 2013 17:43:32 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6HHhVNC071513 for ; Wed, 17 Jul 2013 17:43:31 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6HHhV3U071510 for svn-soc-all@FreeBSD.org; Wed, 17 Jul 2013 17:43:31 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 17 Jul 2013 17:43:31 GMT Message-Id: <201307171743.r6HHhV3U071510@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254892 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 17:43:32 -0000 Author: dpl Date: Wed Jul 17 17:43:31 2013 New Revision: 254892 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254892 Log: Just commiting to have the latest version, so I can comment about the code with my mentor. Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c soc2013/dpl/head/contrib/xz/src/xz/main.c Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Wed Jul 17 17:36:07 2013 (r254891) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Wed Jul 17 17:43:31 2013 (r254892) @@ -980,7 +980,7 @@ io_open_files(char *filename[], int files) { int i; - file_pair **pairs = (file_pair **)malloc(files * sizeof(file_pair *)); + file_pair **pairs = (file_pair **)malloc(sizeof(file_pair **)); if( opt_mode == MODE_LIST) if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO) @@ -1007,6 +1007,7 @@ opt_force = true; } + pairs[i] = (file_pair*)malloc(sizeof(file_pair *)); pairs[i] = io_open_src(filename[i]); if( opt_mode != MODE_TEST ) io_open_dest(pairs[i]); Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/main.c Wed Jul 17 17:36:07 2013 (r254891) +++ soc2013/dpl/head/contrib/xz/src/xz/main.c Wed Jul 17 17:43:31 2013 (r254892) @@ -255,24 +255,22 @@ // check it as loop termination condition. while (true) { char *name = read_name(&args); - printf("name: %s\n", name); if (name == NULL) break; // read_name() doesn't return empty names. assert(name[0] != '\0'); - args.arg_count++; args.arg_names[nfiles] = name; + printf("args.args_names[%d]: %s\n", nfiles, args.arg_names[nfiles]); nfiles++; + args.arg_count++; } - if (args.files_name != stdin_filename) (void)fclose(args.files_file); } - printf("nfiles: %d\n", nfiles); - for ( i = 0; (size_t)i < args.arg_count; i++) - printf("file: %s\n", args.arg_names[i]); + for ( i = 0; i < nfiles; i++) + printf("file[%d]: %s\n", i, args.arg_names[i]); file_pair **pairs = io_open_files(args.arg_names, nfiles); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 18 09:20:52 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1C8CF2E3 for ; Thu, 18 Jul 2013 09:20:52 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 0B1B8121 for ; Thu, 18 Jul 2013 09:20:52 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6I9Kp3E002519 for ; Thu, 18 Jul 2013 09:20:51 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6I9Kp2c002495 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 09:20:51 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 18 Jul 2013 09:20:51 GMT Message-Id: <201307180920.r6I9Kp2c002495@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254912 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 09:20:52 -0000 Author: mattbw Date: Thu Jul 18 09:20:51 2013 New Revision: 254912 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254912 Log: add stub for refresh_cache Added: soc2013/mattbw/backend/actions/refresh_cache.c Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions.h soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Thu Jul 18 07:43:55 2013 (r254911) +++ soc2013/mattbw/backend/Makefile Thu Jul 18 09:20:51 2013 (r254912) @@ -18,6 +18,7 @@ actions/get_repo_list.c \ actions/install_files.c \ actions/install_packages.c \ + actions/refresh_cache.c \ actions/remove_packages.c \ actions/resolve.c \ actions/search_groups.c \ Modified: soc2013/mattbw/backend/actions.h ============================================================================== --- soc2013/mattbw/backend/actions.h Thu Jul 18 07:43:55 2013 (r254911) +++ soc2013/mattbw/backend/actions.h Thu Jul 18 09:20:51 2013 (r254912) @@ -33,8 +33,9 @@ gboolean get_repo_list_thread(PkBackend *backend); gboolean install_files_thread(PkBackend *backend); gboolean install_packages_thread(PkBackend *backend); -gboolean resolve_thread(PkBackend *backend); +gboolean refresh_cache_thread(PkBackend *backend); gboolean remove_packages_thread(PkBackend *backend); +gboolean resolve_thread(PkBackend *backend); gboolean search_groups_thread(PkBackend *backend); gboolean search_names_thread(PkBackend *backend); gboolean simulate_install_files_thread(PkBackend *backend); Added: soc2013/mattbw/backend/actions/refresh_cache.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/refresh_cache.c Thu Jul 18 09:20:51 2013 (r254912) @@ -0,0 +1,42 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include /* gboolean */ +#include /* bool, true, false */ +#include "../pk-backend.h" /* pk..., Pk... */ +#include "pkg.h" /* pkg... */ + +#include "../actions.h" /* refresh_cache_thread prototype */ +#include "../pkgutils.h" /* pkgutils_... */ +#include "../query.h" /* query_... */ + +/* + * The thread that performs a RefreshCache operation. Should be invoked + * by the pk_backend_refresh_cache hook. + */ +gboolean +refresh_cache_thread(PkBackend *backend) +{ + bool success; + + success = false; + pk_backend_finished(backend); + return success ? TRUE : FALSE; +} Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 18 07:43:55 2013 (r254911) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 18 09:20:51 2013 (r254912) @@ -166,6 +166,14 @@ } void +pk_backend_refresh_cache(PkBackend *backend, gboolean force) +{ + + INTENTIONALLY_IGNORE(force); /* not yet supported */ + THREAD(backend, refresh_cache_thread); +} + +void pk_backend_remove_packages(PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove) { From owner-svn-soc-all@FreeBSD.ORG Thu Jul 18 11:06:40 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 3C2FEBBC for ; Thu, 18 Jul 2013 11:06:40 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 1F7037C4 for ; Thu, 18 Jul 2013 11:06:40 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IB6dr4085615 for ; Thu, 18 Jul 2013 11:06:39 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6IB6dDi085607 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 11:06:39 GMT (envelope-from dpl@FreeBSD.org) Date: Thu, 18 Jul 2013 11:06:39 GMT Message-Id: <201307181106.r6IB6dDi085607@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254913 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 11:06:40 -0000 Author: dpl Date: Thu Jul 18 11:06:39 2013 New Revision: 254913 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254913 Log: Bug with the first filename from arguments. Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c soc2013/dpl/head/contrib/xz/src/xz/main.c Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Thu Jul 18 09:20:51 2013 (r254912) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Thu Jul 18 11:06:39 2013 (r254913) @@ -986,11 +986,14 @@ if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO) message_fatal(_("--list works only on .xz files " "(--format=xz or --format=auto)")); + + for ( i = 0; i Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E6FEC540 for ; Thu, 18 Jul 2013 12:48:13 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id BEBBCBD7 for ; Thu, 18 Jul 2013 12:48:13 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6ICmDQL041605 for ; Thu, 18 Jul 2013 12:48:13 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6ICmDja041597 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 12:48:13 GMT (envelope-from zcore@FreeBSD.org) Date: Thu, 18 Jul 2013 12:48:13 GMT Message-Id: <201307181248.r6ICmDja041597@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254914 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 12:48:14 -0000 Author: zcore Date: Thu Jul 18 12:48:13 2013 New Revision: 254914 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254914 Log: group register i/o and add better dbg support Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Jul 18 11:06:39 2013 (r254913) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Jul 18 12:48:13 2013 (r254914) @@ -55,8 +55,9 @@ /* * Debug printf */ -static int pci_ahci_debug; -#define DPRINTF(params) if (pci_ahci_debug) printf params +static FILE *dbg; +#define dprintf(format, arg...) do{fprintf(dbg, format, ##arg);fflush(dbg);}while(0) +#define DPRINTF(params) dprintf params #define WPRINTF(params) printf params /* @@ -119,6 +120,9 @@ return (1); } + dbg = fopen("/tmp/log", "w+"); + DPRINTF(("pci_ahci initializing\n")); + /* * Attempt to open the backing image. Use the PCI slot/func * for the identifier string since that uniquely identifies @@ -231,20 +235,21 @@ switch (offset) { case AHCI_CAP: - value = sc->cap; - break; case AHCI_GHC: - value = sc->ghc; case AHCI_IS: - value = sc->is; case AHCI_PI: - value = sc->pi; case AHCI_VS: - value = sc->vs; - break; + case AHCI_CCCC: + case AHCI_CCCP: + case AHCI_EM_LOC: + case AHCI_EM_CTL: case AHCI_CAP2: - value = sc->cap2; + { + uint32_t *p = &sc->cap; + p += (offset - AHCI_CAP) / sizeof(uint32_t); + value = *p; break; + } default: DPRINTF(("pci_ahci_host: unknown i/o read offset %ld\n\r", offset)); value = 0; @@ -262,7 +267,27 @@ switch (offset) { case AHCI_P_CLB: + case AHCI_P_CLBU: + case AHCI_P_FB: + case AHCI_P_FBU: + case AHCI_P_IS: + case AHCI_P_IE: + case AHCI_P_CMD: + case AHCI_P_TFD: + case AHCI_P_SIG: + case AHCI_P_SSTS: + case AHCI_P_SCTL: + case AHCI_P_SERR: + case AHCI_P_SACT: + case AHCI_P_CI: + case AHCI_P_SNTF: + case AHCI_P_FBS: + { + uint32_t *p= &sc->port[port].clb; + p += (offset - AHCI_P_CLB) / sizeof(uint32_t); + value = *p; break; + } default: DPRINTF(("pci_ahci_port%d: unknown i/o read offset %ld\n\r", port, offset)); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 18 13:20:10 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3D2D320B for ; Thu, 18 Jul 2013 13:20:10 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 2EDF8DD0 for ; Thu, 18 Jul 2013 13:20:10 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IDKA7O032627 for ; Thu, 18 Jul 2013 13:20:10 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6IDKAHV032605 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 13:20:10 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 18 Jul 2013 13:20:10 GMT Message-Id: <201307181320.r6IDKAHV032605@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254915 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 13:20:10 -0000 Author: mattbw Date: Thu Jul 18 13:20:09 2013 New Revision: 254915 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254915 Log: coded RefreshCache; not sure how to proceed to test it Modified: soc2013/mattbw/backend/actions/refresh_cache.c soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/actions/refresh_cache.c ============================================================================== --- soc2013/mattbw/backend/actions/refresh_cache.c Thu Jul 18 12:48:13 2013 (r254914) +++ soc2013/mattbw/backend/actions/refresh_cache.c Thu Jul 18 13:20:09 2013 (r254915) @@ -16,6 +16,35 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * This file contains code from the PKGNG source code (pkg/update.c); + * its copyright notice is as follows: + * + * Copyright (c) 2011-2012 Baptiste Daroussin + * Copyright (c) 2011-2012 Julien Laffaye + * Copyright (c) 2011-2012 Marin Atanasov Nikolov + * 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 + * in this position and unchanged. + * 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(S) ``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(S) 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 /* gboolean */ @@ -26,6 +55,7 @@ #include "../actions.h" /* refresh_cache_thread prototype */ #include "../pkgutils.h" /* pkgutils_... */ #include "../query.h" /* query_... */ +#include "../utils.h" /* STATUS */ /* * The thread that performs a RefreshCache operation. Should be invoked @@ -34,9 +64,26 @@ gboolean refresh_cache_thread(PkBackend *backend) { - bool success; + gboolean force; + int err; + struct pkg_repo *repo; + + err = EPKG_FATAL; + + STATUS(backend, PK_STATUS_ENUM_QUERY); + + force = pk_backend_get_bool(backend, "force"); + + repo = NULL; + while (pkg_repos(&repo) == EPKG_OK) { + err = pkg_update(repo, force); + /* Intentionally silence already-up-to-date errors. */ + if (err == EPKG_UPTODATE) + err = EPKG_OK; + else if (err != EPKG_OK) + break; + } - success = false; pk_backend_finished(backend); - return success ? TRUE : FALSE; + return (err == EPKG_OK) ? TRUE : FALSE; } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 18 12:48:13 2013 (r254914) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 18 13:20:09 2013 (r254915) @@ -169,7 +169,7 @@ pk_backend_refresh_cache(PkBackend *backend, gboolean force) { - INTENTIONALLY_IGNORE(force); /* not yet supported */ + (void)pk_backend_set_bool(backend, "force", force); THREAD(backend, refresh_cache_thread); } From owner-svn-soc-all@FreeBSD.ORG Thu Jul 18 15:53:53 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 17507569 for ; Thu, 18 Jul 2013 15:53:53 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 092347D9 for ; Thu, 18 Jul 2013 15:53:53 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IFrqbn055628 for ; Thu, 18 Jul 2013 15:53:52 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6IFrq6Z055626 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 15:53:52 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 18 Jul 2013 15:53:52 GMT Message-Id: <201307181553.r6IFrq6Z055626@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254917 - soc2013/mattbw/backend/actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 15:53:53 -0000 Author: mattbw Date: Thu Jul 18 15:53:52 2013 New Revision: 254917 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254917 Log: emit (somewhat misleading) error for failed refresh Modified: soc2013/mattbw/backend/actions/refresh_cache.c Modified: soc2013/mattbw/backend/actions/refresh_cache.c ============================================================================== --- soc2013/mattbw/backend/actions/refresh_cache.c Thu Jul 18 14:06:01 2013 (r254916) +++ soc2013/mattbw/backend/actions/refresh_cache.c Thu Jul 18 15:53:52 2013 (r254917) @@ -55,7 +55,7 @@ #include "../actions.h" /* refresh_cache_thread prototype */ #include "../pkgutils.h" /* pkgutils_... */ #include "../query.h" /* query_... */ -#include "../utils.h" /* STATUS */ +#include "../utils.h" /* STATUS, ERR */ /* * The thread that performs a RefreshCache operation. Should be invoked @@ -80,8 +80,12 @@ /* Intentionally silence already-up-to-date errors. */ if (err == EPKG_UPTODATE) err = EPKG_OK; - else if (err != EPKG_OK) + else if (err != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_REPO_NOT_AVAILABLE, + "could not update repo"); break; + } } pk_backend_finished(backend); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 18 16:54:20 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4539598E for ; Thu, 18 Jul 2013 16:54:20 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 27B71B2A for ; Thu, 18 Jul 2013 16:54:20 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IGsJJ8025899 for ; Thu, 18 Jul 2013 16:54:19 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6IGsJpd025896 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 16:54:19 GMT (envelope-from bguan@FreeBSD.org) Date: Thu, 18 Jul 2013 16:54:19 GMT Message-Id: <201307181654.r6IGsJpd025896@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254919 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 16:54:20 -0000 Author: bguan Date: Thu Jul 18 16:54:19 2013 New Revision: 254919 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254919 Log: update the xen usbfront Added: soc2013/bguan/head/sys/dev/xen/usbfront/ soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Added: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Thu Jul 18 16:54:19 2013 (r254919) @@ -0,0 +1,343 @@ +/* + * A simple template of PV front driver for XenBSD device + * + * Copyright (c) 2013 Bei Guan + * + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +//__FBSDID("$FreeBSD: release/9.1.0/sys/dev/xen/usbfront/usbfront.c 237873 2013-07-01 05:13:50Z ken $"); +__FBSDID("$FreeBSD$"); + +#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 + +#include +#include +#include + +#include +#include + +#include "xenbus_if.h" + +#ifdef DEBUG +#define DPRINTK(fmt, args...) \ + printf("[XEN] %s: " fmt, __func__, ##args) +#else +#define DPRINTK(fmt, args...) +#endif + +static int usbfront_detach(device_t dev); + +/** + * Entry point to this code when a new device is created. Allocate the basic + * structures and the ring buffers for communication with the backend, and + * inform the backend of the appropriate details for those. Switch to + * Connected state. + */ +static int +usbfront_probe(device_t dev) +{ + + printf("[gbdebug-pvusb]probe:xenbus_get_type: %s\n", xenbus_get_type(dev)); + if (!strcmp(xenbus_get_type(dev), "vusb")) { + device_set_desc(dev, "Virtual PV USB Device"); + //device_quiet(dev); + return (0); + } + + return (ENXIO); +} + +/* + * Setup supplies the backend dir, virtual device. We place an event + * channel and shared frame entries. We watch backend to wait if it's + * ok. + * TODO + */ +static int +usbfront_attach(device_t dev) +{ + struct xenhci_softc *sc; + int err; + int rid; + + int i; + int num_ports; + int usb_version; + const char *backend_path; + + printf("[gbdebug-pvusb]usbfront_attach\n"); + + sc = device_get_softc(dev); + + /* initialise some bus fields */ + sc->sc_bus.parent = dev; + + /* set up the bus struct */ + sc->sc_bus.methods = &xenhci_bus_methods; + + /* setup devices array */ + sc->sc_bus.devices = sc->sc_devices; + sc->sc_bus.devices_max = XENHCI_MAX_DEVICES; + + /* set the bus revision, read the revision from xenstore */ + backend_path = xenbus_get_otherend_path(dev); + err = xs_scanf(XST_NIL, backend_path, "usb-ver", NULL, "%d", &usb_version); + if (err) { + xenbus_dev_fatal(dev, err, "reading usb-ver"); + return (err); + } + printf("[gbdebug-pvusb]usbfront_attach:usb_version=%d\n", usb_version); + + switch (usb_version) { + case USB_VER_USB11: + sc->sc_bus.usbrev = USB_REV_1_1; + break; + case USB_VER_USB20: + sc->sc_bus.usbrev = USB_REV_2_0; + break; + default: + sc->sc_bus.usbrev = USB_REV_UNKNOWN; + xenbus_dev_fatal(dev, err, "invalid usb version"); + return (err); + } + + /* allocate resource for usb host controller (copy from xhci_pci.c) */ + pci_enable_busmaster(dev); + + rid = PCI_CBMEM; + sc->sc_io_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (!sc->sc_io_res) { + device_printf(dev, "Could not map memory\n"); + goto error; + } + sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); + sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); + sc->sc_io_size = rman_get_size(sc->sc_io_res); + + usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0); + + rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_SHAREABLE | RF_ACTIVE); + if (sc->sc_irq_res == NULL) { + device_printf(dev, "Could not allocate IRQ\n"); + } + + sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); + if (sc->sc_bus.bdev == NULL) { + device_printf(dev, "Could not add USB device\n"); + goto error; + } + device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); + + + /* xen related stuff*/ + err = xs_scanf(XST_NIL, backend_path, "num-ports", NULL, "%d", &num_ports); + if (err) { + xenbus_dev_fatal(dev, err, "reading num-ports"); + goto error; + } + printf("[gbdebug-pvusb]create_hcdev_1:num_ports=%d\n", num_ports); + + if (num_ports < 1 || num_ports > USB_MAXCHILDREN) { + xenbus_dev_fatal(dev, err, "invalid num-ports"); + goto error; + } + + sc->xb_dev = dev; + sc->rh_numports = num_ports; + + for (i = 0; i < USB_URB_RING_SIZE; i++) { + sc->shadow[i].req.id = i + 1; + sc->shadow[i].urb = NULL; + } + sc->shadow[USB_URB_RING_SIZE-1].req.id = 0x0fff; + + + /* attach the xen host controller */ + err = device_probe_and_attach(sc->sc_bus.bdev); + if (err) { + device_printf(dev, "XENHCI halt/start/probe failed err=%d\n", err); + goto error; + } + return (0); + +error: + usbfront_detach(dev); + return (ENXIO); +} + +static int +usbfront_suspend(device_t dev) +{ + printf("[gbdebug-pvusb]usbfront_suspend\n"); + + return (0); +} + +static int +usbfront_resume(device_t dev) +{ + printf("[gbdebug-pvusb]usbfront_resume\n"); + + //struct xenhci_softc *sc = device_get_softc(dev); + + DPRINTK("usbfront_resume: %s\n", xenbus_get_node(dev)); + + //TODO + //usbfront_free(sc); + //usbfront_initialize(sc); + + return (0); +} + +static int +usbfront_detach(device_t dev) +{ + printf("[gbdebug-pvusb]usbfront_detach\n"); + + //struct xenhci_softc *sc = device_get_softc(dev); + + DPRINTK("usbfront_remove: %s removed\n", xenbus_get_node(dev)); + + //TODO + //usbfront_free(sc); + //mtx_destroy(&sc->xb_io_lock); + + return 0; +} + +/** + * Callback received when the backend's state changes. + */ +static void +usbfront_backend_changed(device_t dev, XenbusState backend_state) +{ + printf("[gbdebug-pvusb]usbfront_backend_changed: backend_state=%d\n", backend_state); + + //struct xenhci_softc *sc = device_get_softc(dev); + + //DPRINTK("backend_state=%d\n", backend_state); + + switch (backend_state) { + case XenbusStateUnknown: + case XenbusStateInitialising: + case XenbusStateReconfigured: + case XenbusStateReconfiguring: + case XenbusStateClosed: + break; + + case XenbusStateInitWait: + case XenbusStateInitialised: + //TODO + //usbfront_initialize(sc); + printf("[gbdebug-pvusb]usbfront_backend_changed: initialize(sc)\n"); + break; + + case XenbusStateConnected: + //TODO + //usbfront_initialize(sc); + //usbfront_connect(sc); + printf("[gbdebug-pvusb]usbfront_backend_changed: initialize(sc);connect(sc)\n"); + break; + + case XenbusStateClosing: + //if (sc->users > 0) { + // xenbus_dev_error(dev, -EBUSY, "Device in use; refusing to close"); + //} else { + //TODO + //usbfront_closing(dev); + printf("[gbdebug-pvusb]usbfront_backend_changed: closing(dev)\n"); + //} + break; + } +} + + +/* ** Driver registration ** */ +static device_method_t usbfront_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, usbfront_probe), + DEVMETHOD(device_attach, usbfront_attach), + DEVMETHOD(device_detach, usbfront_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, usbfront_suspend), + DEVMETHOD(device_resume, usbfront_resume), + + /* Xenbus interface */ + DEVMETHOD(xenbus_otherend_changed, usbfront_backend_changed), + + { 0, 0 } +}; + +static driver_t usbfront_driver = { + "xu", + usbfront_methods, + sizeof(struct xenhci_softc), +}; + +devclass_t usbfront_devclass; + +DRIVER_MODULE(xusb, xenbusb_front, usbfront_driver, usbfront_devclass, 0, 0); Added: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Thu Jul 18 16:54:19 2013 (r254919) @@ -0,0 +1,161 @@ +/* $FreeBSD$ */ + +/*- + * Copyright (c) 2013 Bei Guan. All rights reserved. + * Xen Host Controller Interface + * + * 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. + * + * 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. + */ + +#ifndef _USBFRONT_H_ +#define _USBFRONT_H_ + +#define XENHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) +#define PCI_CBMEM 0x10 + +/* USB ports. This is arbitrary. + * From USB 2.0 spec Table 11-13, offset 7, a hub can + * have up to 255 ports. The most yet reported is 10. + * FIXME ?? + */ +#define USB_MAXCHILDREN 31 + +#define USB_URB_RING_SIZE __RING_SIZE((usbif_urb_sring_t *)0, PAGE_SIZE) + + +//FIXME:? +struct list_head { + struct list_head *next, *prev; +}; + +/* ring request shadow */ +struct usb_shadow { + usbif_urb_request_t req; + struct urb *urb; +}; + +/* virtual roothub port status */ +struct rhport_status { + unsigned int status; + unsigned resuming:1; /* in resuming */ + unsigned c_connection:1; /* connection changed */ + unsigned long timeout; +}; + +/* status of attached device */ +struct vdevice_status { + int devnum; + enum usb_dev_state status; + enum usb_dev_speed speed; +}; + +///////////////////////////////////////////////// +// Moved to xenhci.h +///////////////////////////////////////////////// +struct xenhci_softc { + /* base device */ + struct usb_bus sc_bus; + /* configure message */ + struct usb_bus_msg sc_config_msg[2]; + + struct usb_callout sc_callout; + + struct usb_device *sc_devices[XENHCI_MAX_DEVICES]; + struct resource *sc_io_res; + struct resource *sc_irq_res; + + void *sc_intr_hdl; + bus_size_t sc_io_size; + bus_space_tag_t sc_io_tag; + bus_space_handle_t sc_io_hdl; + + /* Virtual Host Controller has 4 urb queues */ + struct list_head pending_submit_list; //?? + struct list_head pending_unlink_list; //?? + struct list_head in_progress_list; //?? + struct list_head giveback_waiting_list; //?? + + //spinlock_t lock; + + /* timer that kick pending and giveback waiting urbs */ + //struct timer_list watchdog;//?? + unsigned long actions; + + /* virtual root hub */ + int rh_numports; + struct rhport_status ports[USB_MAXCHILDREN]; + struct vdevice_status devices[USB_MAXCHILDREN]; + + + /* Xen related staff */ + /* shared ring */ + device_t xb_dev; + int urb_ring_ref; + int conn_ring_ref; + usbif_urb_front_ring_t urb_ring; + usbif_conn_front_ring_t conn_ring; + + /* event channel */ + unsigned int irq; + struct usb_shadow shadow[USB_URB_RING_SIZE]; + unsigned long shadow_free; + + /* ring response thread */ + struct task *ringthread;//struct task_struct *kthread; + struct list_head *wait_list; //wait_queue_head_t wq;???????? + unsigned int waiting_resp;// +}; + +/* + * all bus methods are defined here +*/ + + + +extern struct usb_bus_methods xenhci_bus_methods; + +struct usb_bus_methods xenhci_bus_methods = { + .endpoint_init = NULL, //xhci_ep_init, + .endpoint_uninit = NULL, //xhci_ep_uninit, + .xfer_setup = NULL, //xhci_xfer_setup, + .xfer_unsetup = NULL, //xhci_xfer_unsetup, + .get_dma_delay = NULL, //xhci_get_dma_delay, + .device_init = NULL, //xhci_device_init, + .device_uninit = NULL, //xhci_device_uninit, + .device_resume = NULL, //xhci_device_resume, + .device_suspend = NULL, //xhci_device_suspend, + .set_hw_power = NULL, //xhci_set_hw_power, + .roothub_exec = NULL, //xhci_roothub_exec, + .xfer_poll = NULL, //xhci_do_poll, + .start_dma_delay = NULL, //xhci_start_dma_delay, + .set_address = NULL, //xhci_set_address, + .clear_stall = NULL, //xhci_ep_clear_stall, + .device_state_change = NULL, //xhci_device_state_change, + .set_hw_power_sleep = NULL, //xhci_set_hw_power_sleep, + .set_endpoint_mode = NULL, //xhci_set_endpoint_mode, +}; + + +/* prototypes */ +//usb_error_t xenhci_init(struct xenhci_softc *, device_t); + +#endif /* _USBFRONT_H_ */ From owner-svn-soc-all@FreeBSD.ORG Thu Jul 18 16:57:59 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 840D19EB for ; Thu, 18 Jul 2013 16:57:59 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 7447BB53 for ; Thu, 18 Jul 2013 16:57:59 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IGvxRe026707 for ; Thu, 18 Jul 2013 16:57:59 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6IGvxeq026705 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 16:57:59 GMT (envelope-from bguan@FreeBSD.org) Date: Thu, 18 Jul 2013 16:57:59 GMT Message-Id: <201307181657.r6IGvxeq026705@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254920 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 16:57:59 -0000 Author: bguan Date: Thu Jul 18 16:57:59 2013 New Revision: 254920 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254920 Log: probe and attach xen usb host controller Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Thu Jul 18 16:54:19 2013 (r254919) +++ soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Thu Jul 18 16:57:59 2013 (r254920) @@ -92,7 +92,7 @@ * Entry point to this code when a new device is created. Allocate the basic * structures and the ring buffers for communication with the backend, and * inform the backend of the appropriate details for those. Switch to - * Connected state. + * Connected state. */ static int usbfront_probe(device_t dev) From owner-svn-soc-all@FreeBSD.ORG Thu Jul 18 16:58:51 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D3F17A09 for ; Thu, 18 Jul 2013 16:58:51 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id C4B8AB59 for ; Thu, 18 Jul 2013 16:58:51 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IGwpfr026861 for ; Thu, 18 Jul 2013 16:58:51 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6IGwpvh026859 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 16:58:51 GMT (envelope-from bguan@FreeBSD.org) Date: Thu, 18 Jul 2013 16:58:51 GMT Message-Id: <201307181658.r6IGwpvh026859@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254921 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 16:58:51 -0000 Author: bguan Date: Thu Jul 18 16:58:51 2013 New Revision: 254921 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254921 Log: head file for usbfront.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Thu Jul 18 16:57:59 2013 (r254920) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Thu Jul 18 16:58:51 2013 (r254921) @@ -35,7 +35,7 @@ /* USB ports. This is arbitrary. * From USB 2.0 spec Table 11-13, offset 7, a hub can * have up to 255 ports. The most yet reported is 10. - * FIXME ?? + * FIXME ?? */ #define USB_MAXCHILDREN 31 From owner-svn-soc-all@FreeBSD.ORG Thu Jul 18 17:01:02 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D14A9A6D for ; Thu, 18 Jul 2013 17:01:02 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id C355FB74 for ; Thu, 18 Jul 2013 17:01:02 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IH12dt075131 for ; Thu, 18 Jul 2013 17:01:02 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6IH12Bx075129 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 17:01:02 GMT (envelope-from bguan@FreeBSD.org) Date: Thu, 18 Jul 2013 17:01:02 GMT Message-Id: <201307181701.r6IH12Bx075129@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254922 - soc2013/bguan/head/sys/xen/interface/io MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 17:01:02 -0000 Author: bguan Date: Thu Jul 18 17:01:02 2013 New Revision: 254922 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254922 Log: head file for sys/dev/xen/usbfront Modified: soc2013/bguan/head/sys/xen/interface/io/usbif.h Modified: soc2013/bguan/head/sys/xen/interface/io/usbif.h ============================================================================== --- soc2013/bguan/head/sys/xen/interface/io/usbif.h Thu Jul 18 16:58:51 2013 (r254921) +++ soc2013/bguan/head/sys/xen/interface/io/usbif.h Thu Jul 18 17:01:02 2013 (r254922) @@ -28,8 +28,8 @@ #ifndef __XEN_PUBLIC_IO_USBIF_H__ #define __XEN_PUBLIC_IO_USBIF_H__ -#include "ring.h" -#include "../grant_table.h" +#include +#include enum usb_spec_version { USB_VER_UNKNOWN = 0, @@ -128,7 +128,7 @@ typedef struct usbif_urb_response usbif_urb_response_t; DEFINE_RING_TYPES(usbif_urb, struct usbif_urb_request, struct usbif_urb_response); -#define USB_URB_RING_SIZE __CONST_RING_SIZE(usbif_urb, PAGE_SIZE) +//#define USB_URB_RING_SIZE __CONST_RING_SIZE(usbif_urb, PAGE_SIZE) /* * RING for notifying connect/disconnect events to frontend @@ -146,6 +146,6 @@ typedef struct usbif_conn_response usbif_conn_response_t; DEFINE_RING_TYPES(usbif_conn, struct usbif_conn_request, struct usbif_conn_response); -#define USB_CONN_RING_SIZE __CONST_RING_SIZE(usbif_conn, PAGE_SIZE) +//#define USB_CONN_RING_SIZE __CONST_RING_SIZE(usbif_conn, PAGE_SIZE) #endif /* __XEN_PUBLIC_IO_USBIF_H__ */ From owner-svn-soc-all@FreeBSD.ORG Thu Jul 18 17:43:53 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B89AF6AC for ; Thu, 18 Jul 2013 17:43:53 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 9B69ED0B for ; Thu, 18 Jul 2013 17:43:53 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IHhr9i082890 for ; Thu, 18 Jul 2013 17:43:53 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6IHhr9u082885 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 17:43:53 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 18 Jul 2013 17:43:53 GMT Message-Id: <201307181743.r6IHhr9u082885@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254923 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 17:43:53 -0000 Author: mattbw Date: Thu Jul 18 17:43:53 2013 New Revision: 254923 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254923 Log: implement SearchFiles, rudimentary testing at the moment Added: soc2013/mattbw/backend/actions/search_files.c Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions.h soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Thu Jul 18 17:01:02 2013 (r254922) +++ soc2013/mattbw/backend/Makefile Thu Jul 18 17:43:53 2013 (r254923) @@ -21,6 +21,7 @@ actions/refresh_cache.c \ actions/remove_packages.c \ actions/resolve.c \ + actions/search_files.c \ actions/search_groups.c \ actions/search_names.c Modified: soc2013/mattbw/backend/actions.h ============================================================================== --- soc2013/mattbw/backend/actions.h Thu Jul 18 17:01:02 2013 (r254922) +++ soc2013/mattbw/backend/actions.h Thu Jul 18 17:43:53 2013 (r254923) @@ -36,6 +36,7 @@ gboolean refresh_cache_thread(PkBackend *backend); gboolean remove_packages_thread(PkBackend *backend); gboolean resolve_thread(PkBackend *backend); +gboolean search_files_thread(PkBackend *backend); gboolean search_groups_thread(PkBackend *backend); gboolean search_names_thread(PkBackend *backend); gboolean simulate_install_files_thread(PkBackend *backend); Added: soc2013/mattbw/backend/actions/search_files.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/search_files.c Thu Jul 18 17:43:53 2013 (r254923) @@ -0,0 +1,101 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include /* assert */ +#include /* bool, TRUE, FALSE */ +#include "../pk-backend.h" +#include "pkg.h" + +#include "../actions.h" /* search_files_thread prototype */ +#include "../db.h" /* db_open_remote */ +#include "../utils.h" /* INTENTIONALLY_IGNORE */ +#include "../pkgutils.h" /* pkgutils_... */ + +/* + * Searches for packages containing specified files. + */ +gboolean +search_files_thread(PkBackend *backend) +{ + bool at_least_one; + gboolean success; + guint filec; + guint i; + struct pkg *pkg; + struct pkgdb *db; + struct pkgdb_it *it; + gchar **filev; + + assert(backend != NULL); + db = NULL; + it = NULL; + pkg = NULL; + success = FALSE; + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + (void)pk_backend_set_percentage(backend, 0); + + db = db_open_remote(backend); + if (db == NULL) + goto cleanup; + + filev = pk_backend_get_strv(backend, "search"); + if (filev == NULL) { + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "search is NULL"); + goto cleanup; + } + filec = g_strv_length(filev); + if (filec == 0) { + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "no files given"); + goto cleanup; + } + + for (i = 0; i < filec; i++) { + at_least_one = false; + + it = pkgdb_query_which(db, filev[i], false); + if (it != NULL) { + while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) + == EPKG_OK) { + pkgutils_emit(pkg, backend, + pkgutils_pkg_current_state(pkg)); + at_least_one = true; + } + } + + /* TODO: specifically name file? */ + if (at_least_one == false) + ERR(backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, + "no matches for file"); + + (void)pk_backend_set_percentage(backend, + ((i + 1) * 100) / filec); + } + + success = TRUE; + +cleanup: + pkg_free(pkg); + pkgdb_it_free(it); + pkgdb_close(db); + + (void)pk_backend_finished(backend); + return success; +} Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 18 17:01:02 2013 (r254922) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 18 17:43:53 2013 (r254923) @@ -194,6 +194,15 @@ } void +pk_backend_search_files(PkBackend *backend, PkBitfield filters, gchar **search) +{ + + INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ + INTENTIONALLY_IGNORE(search); /* retrieved from backend */ + THREAD(backend, search_files_thread); +} + +void pk_backend_search_groups(PkBackend *backend, PkBitfield filters, gchar **values) { From owner-svn-soc-all@FreeBSD.ORG Fri Jul 19 08:46:34 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 09FF0766 for ; Fri, 19 Jul 2013 08:46:34 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id EFA2EA08 for ; Fri, 19 Jul 2013 08:46:33 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6J8kXAg087430 for ; Fri, 19 Jul 2013 08:46:33 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6J8kX5e087425 for svn-soc-all@FreeBSD.org; Fri, 19 Jul 2013 08:46:33 GMT (envelope-from dpl@FreeBSD.org) Date: Fri, 19 Jul 2013 08:46:33 GMT Message-Id: <201307190846.r6J8kX5e087425@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254943 - in soc2013/dpl/head: contrib/xz/src/xz usr.bin/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jul 2013 08:46:34 -0000 Author: dpl Date: Fri Jul 19 08:46:33 2013 New Revision: 254943 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254943 Log: Finished with xz! Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c soc2013/dpl/head/contrib/xz/src/xz/main.c soc2013/dpl/head/contrib/xz/src/xz/main.h soc2013/dpl/head/usr.bin/xz/Makefile Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Fri Jul 19 06:42:15 2013 (r254942) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Fri Jul 19 08:46:33 2013 (r254943) @@ -102,7 +102,6 @@ const char *name; int fd; struct stat *known_st; - //const char *name, int *fd, int *dirfd, const struct stat *known_st) if (dest) { name = pair->dest_name; fd = &pair->dest_fd; @@ -987,9 +986,6 @@ message_fatal(_("--list works only on .xz files " "(--format=xz or --format=auto)")); - for ( i = 0; i Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 575C981E for ; Fri, 19 Jul 2013 08:48:46 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 48CDAA23 for ; Fri, 19 Jul 2013 08:48:46 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6J8mkiQ095464 for ; Fri, 19 Jul 2013 08:48:46 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6J8mkmF095459 for svn-soc-all@FreeBSD.org; Fri, 19 Jul 2013 08:48:46 GMT (envelope-from dpl@FreeBSD.org) Date: Fri, 19 Jul 2013 08:48:46 GMT Message-Id: <201307190848.r6J8mkmF095459@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254944 - soc2013/dpl/head/lib/libz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jul 2013 08:48:46 -0000 Author: dpl Date: Fri Jul 19 08:48:46 2013 New Revision: 254944 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254944 Log: Changed Makefile so that we can make without problems under acme. Modified: soc2013/dpl/head/lib/libz/Makefile Modified: soc2013/dpl/head/lib/libz/Makefile ============================================================================== --- soc2013/dpl/head/lib/libz/Makefile Fri Jul 19 08:46:33 2013 (r254943) +++ soc2013/dpl/head/lib/libz/Makefile Fri Jul 19 08:48:46 2013 (r254944) @@ -13,7 +13,8 @@ # -Wstrict-prototypes -Wmissing-prototypes CFLAGS+= -DHAS_snprintf -DHAS_vsnprintf -I${.CURDIR} - +#TODEL +CFLAGS+= -Wall -g -fno-color-output WARNS?= 3 CLEANFILES+= example.o example foo.gz minigzip.o minigzip From owner-svn-soc-all@FreeBSD.ORG Sat Jul 20 08:50:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8AFAB52E for ; Sat, 20 Jul 2013 08:50:06 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 7CE56A3B for ; Sat, 20 Jul 2013 08:50:06 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6K8o6rN069578 for ; Sat, 20 Jul 2013 08:50:06 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6K8o6H0069562 for svn-soc-all@FreeBSD.org; Sat, 20 Jul 2013 08:50:06 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 20 Jul 2013 08:50:06 GMT Message-Id: <201307200850.r6K8o6H0069562@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254959 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jul 2013 08:50:06 -0000 Author: zcore Date: Sat Jul 20 08:50:06 2013 New Revision: 254959 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254959 Log: fix pci bar type and add more register i/o Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Jul 20 07:58:03 2013 (r254958) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Jul 20 08:50:06 2013 (r254959) @@ -60,10 +60,18 @@ #define DPRINTF(params) dprintf params #define WPRINTF(params) printf params -/* - * Per-device softc - */ +struct ahci_ioreq { + struct blockif_req io_req; + struct ahci_port *io_pr; + uint32_t io_genid; + STAILQ_ENTRY(ahci_ioreq) io_list; + int io_didx; + uint8_t *io_status; +}; + struct ahci_port { + struct blockif_ctxt *bctx; + struct pci_ahci_softc *pr_sc; uint32_t clb; uint32_t clbu; uint32_t fb; @@ -81,11 +89,26 @@ uint32_t ci; uint32_t sntf; uint32_t fbs; + + /* + * i/o request info + */ + struct ahci_ioreq *ioreq; + int ioqsz; + int iofree; + STAILQ_HEAD(ahci_fhead, ahci_ioreq) iofhd; +}; + +struct ahci_cmd_hdr { + uint16_t flags; + uint16_t prdtl; + uint32_t prdbc; + uint64_t ctba; + uint32_t reserved[4]; }; struct pci_ahci_softc { struct pci_devinst *asc_pi; - struct blockif_ctxt *bctx; pthread_mutex_t mtx; int ports; int vbsc_lastq; @@ -103,14 +126,64 @@ struct ahci_port port[AHCI_MAX_PORTS]; }; +/* + * blockif callback routine - this runs in the context of the blockif + * i/o thread, so the mutex needs to be acquired. + */ static void -pci_ahci_ioreq_init(struct pci_ahci_softc *sc) +pci_ahci_ioreq_cb(struct blockif_req *br, int err) { + struct ahci_port *pr; + struct pci_ahci_softc *sc; + struct ahci_ioreq *vio; + + vio = br->br_param; + pr = vio->io_pr; + sc = pr->pr_sc; + + DPRINTF(("ahci_ioreq_cb %d\n", err)); + pthread_mutex_lock(&sc->mtx); + + /* TODO */ + + /* + * Move the blockif request back to the free list + */ + STAILQ_INSERT_TAIL(&pr->iofhd, vio, io_list); + pr->iofree++; + + pthread_mutex_unlock(&sc->mtx); + DPRINTF(("%s exit\n", __func__)); + +} + +static void +pci_ahci_ioreq_init(struct ahci_port *pr) +{ + struct ahci_ioreq *vr; + int i; + + pr->ioqsz = blockif_queuesz(pr->bctx); + pr->ioreq = calloc(pr->ioqsz, sizeof(struct ahci_ioreq)); + STAILQ_INIT(&pr->iofhd); + + /* + * Add all i/o request entries to the free queue + */ + for (i = 0; i < pr->ioqsz; i++) { + vr = &pr->ioreq[i]; + vr->io_pr = pr; + vr->io_req.br_callback = pci_ahci_ioreq_cb; + vr->io_req.br_param = vr; + STAILQ_INSERT_TAIL(&pr->iofhd, vr, io_list); + pr->iofree++; + } } static int pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { + int i; struct pci_ahci_softc *sc; char bident[sizeof("XX:X")]; struct blockif_ctxt *bctxt; @@ -140,12 +213,14 @@ pi->pi_arg = sc; sc->asc_pi = pi; + for (i = 0; i < AHCI_MAX_PORTS; i++) + sc->port[i].pr_sc = sc; /* * Allocate blockif request structures and add them * to the free list */ - sc->bctx = bctxt; - pci_ahci_ioreq_init(sc); + sc->port[0].bctx = bctxt; + pci_ahci_ioreq_init(&sc->port[0]); pthread_mutex_init(&sc->mtx, NULL); @@ -169,7 +244,7 @@ pci_emul_add_msicap(pi, 1); - pci_emul_alloc_bar(pi, 5, PCIBAR_IO, AHCI_OFFSET+sc->ports*AHCI_STEP); + pci_emul_alloc_bar(pi, 5, PCIBAR_MEM32, AHCI_OFFSET+sc->ports*AHCI_STEP); return (0); } @@ -179,14 +254,51 @@ { int port = (offset - AHCI_OFFSET) / AHCI_STEP; offset = (offset - AHCI_OFFSET) % AHCI_STEP; + struct ahci_port *p = &sc->port[port]; + DPRINTF(("pci_ahci_port %d: write offset 0x%lx value 0x%lx\n\r", + port, offset, value)); switch (offset) { case AHCI_P_CLB: + p->clb = value; + break; + case AHCI_P_CLBU: + p->clbu = value; + break; + case AHCI_P_FB: + p->fb = value; + break; + case AHCI_P_FBU: + p->fbu = value; break; + case AHCI_P_IS: + p->is &= ~value; + break; + case AHCI_P_IE: + p->ie = value & 0xfdc000ff; + break; + case AHCI_P_CMD: + /* TODO */ + break; + case AHCI_P_TFD: + case AHCI_P_SIG: + case AHCI_P_SSTS: + WPRINTF(("pci_ahci_port: read only registers 0x%lx\n", offset)); + break; + case AHCI_P_SCTL: + /* TODO */ + break; + case AHCI_P_SERR: + p->serr &= ~value; + break; + case AHCI_P_SACT: + break; + case AHCI_P_CI: + /* TODO */ + break; + case AHCI_P_SNTF: + case AHCI_P_FBS: default: - DPRINTF(("pci_ahci_port %d: unknown i/o write offset %ld\n\r", - port, offset)); - value = 0; break; } } @@ -194,15 +306,17 @@ static void pci_ahci_host_write(struct pci_ahci_softc *sc, uint64_t offset, uint64_t value) { + DPRINTF(("pci_ahci_host: write offset 0x%lx value 0x%lx\n\r", + offset, value)); + switch (offset) { case AHCI_CAP: case AHCI_PI: case AHCI_VS: case AHCI_CAP2: - WPRINTF(("pci_ahci_host: read only registers: %ld\n", offset)); + WPRINTF(("pci_ahci_host: read only registers 0x%lx\n", offset)); break; default: - DPRINTF(("pci_ahci_host: unknown i/o write offset %ld\n\r", offset)); break; } } @@ -223,7 +337,7 @@ else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP) pci_ahci_port_write(sc, offset, value); else - DPRINTF(("pci_ahci: unknown i/o write offset %ld\n\r", offset)); + DPRINTF(("pci_ahci: unknown i/o write offset 0x%lx\n\r", offset)); pthread_mutex_unlock(&sc->mtx); } @@ -251,10 +365,12 @@ break; } default: - DPRINTF(("pci_ahci_host: unknown i/o read offset %ld\n\r", offset)); value = 0; break; } + DPRINTF(("pci_ahci_host: read offset 0x%lx value 0x%x\n\r", + offset, value)); + return (value); } @@ -274,6 +390,7 @@ case AHCI_P_IE: case AHCI_P_CMD: case AHCI_P_TFD: + /* TODO */ case AHCI_P_SIG: case AHCI_P_SSTS: case AHCI_P_SCTL: @@ -289,11 +406,11 @@ break; } default: - DPRINTF(("pci_ahci_port%d: unknown i/o read offset %ld\n\r", - port, offset)); value = 0; break; } + DPRINTF(("pci_ahci_port %d: read offset 0x%lx value 0x%x\n\r", + port, offset, value)); return value; } @@ -315,7 +432,7 @@ else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP) value = pci_ahci_port_read(sc, offset); else - DPRINTF(("pci_ahci: unknown i/o read offset %ld\n\r", offset)); + DPRINTF(("pci_ahci: unknown i/o read offset 0x%lx\n\r", offset)); pthread_mutex_unlock(&sc->mtx); From owner-svn-soc-all@FreeBSD.ORG Sat Jul 20 19:23:44 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C16B714A for ; Sat, 20 Jul 2013 19:23:44 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id B1B80127 for ; Sat, 20 Jul 2013 19:23:44 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6KJNiXo031429 for ; Sat, 20 Jul 2013 19:23:44 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6KJNi1b031424 for svn-soc-all@FreeBSD.org; Sat, 20 Jul 2013 19:23:44 GMT (envelope-from dpl@FreeBSD.org) Date: Sat, 20 Jul 2013 19:23:44 GMT Message-Id: <201307201923.r6KJNi1b031424@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254982 - soc2013/dpl/head/lib/libz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jul 2013 19:23:44 -0000 Author: dpl Date: Sat Jul 20 19:23:44 2013 New Revision: 254982 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254982 Log: Zlib gzip code is limited now. Modified: soc2013/dpl/head/lib/libz/gzlib.c Modified: soc2013/dpl/head/lib/libz/gzlib.c ============================================================================== --- soc2013/dpl/head/lib/libz/gzlib.c Sat Jul 20 16:58:17 2013 (r254981) +++ soc2013/dpl/head/lib/libz/gzlib.c Sat Jul 20 19:23:44 2013 (r254982) @@ -18,6 +18,14 @@ #endif #endif +#if defined(__FreeBSD__) +# include +# if __FreeBSD_version >= 900041 +# define CAPSICUM +# include +# endif +#endif + /* Local functions */ local void gz_reset OF((gz_statep)); local gzFile gz_open OF((const void *, int, const char *)); @@ -251,6 +259,10 @@ free(state); return NULL; } +#ifdef CAPSICUM + cap_rights_limit(state->fd, CAP_READ|CAP_SEEK|CAP_WRITE|CAP_FSTAT); + printf("CAPSICUM: fd %d limited\n", state->fd); +#endif if (state->mode == GZ_APPEND) state->mode = GZ_WRITE; /* simplify later checks */ From owner-svn-soc-all@FreeBSD.ORG Sat Jul 20 19:25:00 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DE81815F for ; Sat, 20 Jul 2013 19:25:00 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id D0CD812B for ; Sat, 20 Jul 2013 19:25:00 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6KJP0VA043064 for ; Sat, 20 Jul 2013 19:25:00 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6KJP01w043062 for svn-soc-all@FreeBSD.org; Sat, 20 Jul 2013 19:25:00 GMT (envelope-from dpl@FreeBSD.org) Date: Sat, 20 Jul 2013 19:25:00 GMT Message-Id: <201307201925.r6KJP01w043062@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254983 - soc2013/dpl/head/lib/libz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jul 2013 19:25:00 -0000 Author: dpl Date: Sat Jul 20 19:25:00 2013 New Revision: 254983 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254983 Log: Deleted debugging code. Modified: soc2013/dpl/head/lib/libz/gzlib.c Modified: soc2013/dpl/head/lib/libz/gzlib.c ============================================================================== --- soc2013/dpl/head/lib/libz/gzlib.c Sat Jul 20 19:23:44 2013 (r254982) +++ soc2013/dpl/head/lib/libz/gzlib.c Sat Jul 20 19:25:00 2013 (r254983) @@ -261,7 +261,6 @@ } #ifdef CAPSICUM cap_rights_limit(state->fd, CAP_READ|CAP_SEEK|CAP_WRITE|CAP_FSTAT); - printf("CAPSICUM: fd %d limited\n", state->fd); #endif if (state->mode == GZ_APPEND) state->mode = GZ_WRITE; /* simplify later checks */