PERFORCE change 165368 for review

Alexander Motin mav at FreeBSD.org
Mon Jun 29 08:07:54 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=165368

Change 165368 by mav at 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 <sys/libkern.h>
 #include <sys/kernel.h>
 #include <sys/sysctl.h>
+#else
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#endif
 
 #include <cam/cam.h>
 #include <cam/cam_ccb.h>
@@ -45,7 +51,7 @@
 #include <cam/ata/ata_all.h>
 #include <sys/sbuf.h>
 
-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 @@
+


More information about the p4-projects mailing list