From owner-p4-projects@FreeBSD.ORG Mon Jun 29 08:07:54 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6B38F1065674; Mon, 29 Jun 2009 08:07:53 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2B5CC106566C for ; Mon, 29 Jun 2009 08:07:53 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 189148FC16 for ; Mon, 29 Jun 2009 08:07:53 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n5T87qPX073617 for ; Mon, 29 Jun 2009 08:07:52 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5T87qBh073615 for perforce@freebsd.org; Mon, 29 Jun 2009 08:07:52 GMT (envelope-from mav@freebsd.org) Date: Mon, 29 Jun 2009 08:07:52 GMT Message-Id: <200906290807.n5T87qBh073615@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mav@freebsd.org using -f From: Alexander Motin To: Perforce Change Reviews Cc: Subject: PERFORCE change 165368 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jun 2009 08:07:54 -0000 http://perforce.freebsd.org/chv.cgi?CH=165368 Change 165368 by mav@mav_mavbook on 2009/06/29 08:07:02 Expose ATA functions to user-level. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.c#10 edit .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.h#10 edit .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#24 edit .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.h#2 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.c#10 (text+ko) ==== @@ -36,6 +36,12 @@ #include #include #include +#else +#include +#include +#include +#include +#endif #include #include @@ -45,7 +51,7 @@ #include #include -static int +int ata_version(int ver) { int bit; @@ -171,4 +177,47 @@ ataio->cmd.sector_count_exp = val >> 32; } -#endif /* _KERNEL */ +void +ata_bswap(int8_t *buf, int len) +{ + u_int16_t *ptr = (u_int16_t*)(buf + len); + + while (--ptr >= (u_int16_t*)buf) + *ptr = ntohs(*ptr); +} + +void +ata_btrim(int8_t *buf, int len) +{ + int8_t *ptr; + + for (ptr = buf; ptr < buf+len; ++ptr) + if (!*ptr || *ptr == '_') + *ptr = ' '; + for (ptr = buf + len - 1; ptr >= buf && *ptr == ' '; --ptr) + *ptr = 0; +} + +void +ata_bpack(int8_t *src, int8_t *dst, int len) +{ + int i, j, blank; + + for (i = j = blank = 0 ; i < len; i++) { + if (blank && src[i] == ' ') continue; + if (blank && src[i] != ' ') { + dst[j++] = src[i]; + blank = 0; + continue; + } + if (src[i] == ' ') { + blank = 1; + if (i == 0) + continue; + } + dst[j++] = src[i]; + } + while (j < len) + dst[j++] = 0x00; +} + ==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.h#10 (text+ko) ==== @@ -78,6 +78,7 @@ u_int8_t sector_count_exp; }; +int ata_version(int ver); void ata_print_ident(struct ata_params *ident_data); void ata_36bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features, @@ -90,4 +91,8 @@ void ata_pm_read_cmd(struct ccb_ataio *ataio, int reg, int port); void ata_pm_write_cmd(struct ccb_ataio *ataio, int reg, int port, uint64_t val); +void ata_bswap(int8_t *buf, int len); +void ata_btrim(int8_t *buf, int len); +void ata_bpack(int8_t *src, int8_t *dst, int len); + #endif ==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#24 (text+ko) ==== @@ -206,50 +206,6 @@ } static void -bswap(int8_t *buf, int len) -{ - u_int16_t *ptr = (u_int16_t*)(buf + len); - - while (--ptr >= (u_int16_t*)buf) - *ptr = ntohs(*ptr); -} - -static void -btrim(int8_t *buf, int len) -{ - int8_t *ptr; - - for (ptr = buf; ptr < buf+len; ++ptr) - if (!*ptr || *ptr == '_') - *ptr = ' '; - for (ptr = buf + len - 1; ptr >= buf && *ptr == ' '; --ptr) - *ptr = 0; -} - -static void -bpack(int8_t *src, int8_t *dst, int len) -{ - int i, j, blank; - - for (i = j = blank = 0 ; i < len; i++) { - if (blank && src[i] == ' ') continue; - if (blank && src[i] != ' ') { - dst[j++] = src[i]; - blank = 0; - continue; - } - if (src[i] == ' ') { - blank = 1; - if (i == 0) - continue; - } - dst[j++] = src[i]; - } - while (j < len) - dst[j++] = 0x00; -} - -static void probe_periph_init() { } @@ -706,16 +662,16 @@ strncmp(ident_buf->model, "NEC", 3) && strncmp(ident_buf->model, "Pioneer", 7) && strncmp(ident_buf->model, "SHARP", 5)) { - bswap(ident_buf->model, sizeof(ident_buf->model)); - bswap(ident_buf->revision, sizeof(ident_buf->revision)); - bswap(ident_buf->serial, sizeof(ident_buf->serial)); + ata_bswap(ident_buf->model, sizeof(ident_buf->model)); + ata_bswap(ident_buf->revision, sizeof(ident_buf->revision)); + ata_bswap(ident_buf->serial, sizeof(ident_buf->serial)); } - btrim(ident_buf->model, sizeof(ident_buf->model)); - bpack(ident_buf->model, ident_buf->model, sizeof(ident_buf->model)); - btrim(ident_buf->revision, sizeof(ident_buf->revision)); - bpack(ident_buf->revision, ident_buf->revision, sizeof(ident_buf->revision)); - btrim(ident_buf->serial, sizeof(ident_buf->serial)); - bpack(ident_buf->serial, ident_buf->serial, sizeof(ident_buf->serial)); + ata_btrim(ident_buf->model, sizeof(ident_buf->model)); + ata_bpack(ident_buf->model, ident_buf->model, sizeof(ident_buf->model)); + ata_btrim(ident_buf->revision, sizeof(ident_buf->revision)); + ata_bpack(ident_buf->revision, ident_buf->revision, sizeof(ident_buf->revision)); + ata_btrim(ident_buf->serial, sizeof(ident_buf->serial)); + ata_bpack(ident_buf->serial, ident_buf->serial, sizeof(ident_buf->serial)); if ((periph->path->device->flags & CAM_DEV_UNCONFIGURED) == 0) { /* Check that it is the same device. */ ==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.h#2 (text+ko) ==== @@ -1,0 +1,1 @@ +