Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 3f6c16fe16537320ac079b2bb3b44a55c9d9611a)
+++ kernel/generic/src/console/cmd.c	(revision 0dfa93b0cda81f93598fc30620d75a22c14f06d2)
@@ -695,4 +695,5 @@
 {
 	uint8_t *ptr = NULL;
+	
 #ifdef IO_SPACE_BOUNDARY
 	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
@@ -700,13 +701,16 @@
 	else
 #endif
-		ptr = (uint8_t*) km_map(argv[0].intval, sizeof(uint8_t),
+		ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),
 		    PAGE_NOT_CACHEABLE);
+	
 	const uint8_t val = pio_read_8(ptr);
-	printf("read %"PRIxn": %"PRIx8"\n", argv[0].intval, val);
+	printf("read %" PRIxn ": %" PRIx8 "\n", argv[0].intval, val);
+	
 #ifdef IO_SPACE_BOUNDARY
 	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
 		return 1;
 #endif
-	km_unmap((uintptr_t)ptr, sizeof(uint8_t));
+	
+	km_unmap((uintptr_t) ptr, sizeof(uint8_t));
 	return 1;
 }
@@ -721,30 +725,5 @@
 {
 	uint16_t *ptr = NULL;
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		ptr = (void *)argv[0].intval;
-	else
-#endif
-		ptr = (uint16_t*)km_map(argv[0].intval, sizeof(uint16_t),
-		    PAGE_NOT_CACHEABLE);
-	const uint16_t val = pio_read_16(ptr);
-	printf("read %"PRIxn": %"PRIx16"\n", argv[0].intval, val);
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		return 1;
-#endif
-	km_unmap((uintptr_t)ptr, sizeof(uint16_t));
-	return 1;
-}
-
-/** Read 4 bytes from phys memory or io port.
- *
- * @param argv Argument vector.
- *
- * @return 0 on failure, 1 on success.
- */
-static int cmd_pio_read_32(cmd_arg_t *argv)
-{
-	uint32_t *ptr = NULL;
+	
 #ifdef IO_SPACE_BOUNDARY
 	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
@@ -752,17 +731,20 @@
 	else
 #endif
-		ptr = (uint32_t*)km_map(argv[0].intval, sizeof(uint32_t),
+		ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t),
 		    PAGE_NOT_CACHEABLE);
-	const uint32_t val = pio_read_32(ptr);
-	printf("read %"PRIxn": %"PRIx32"\n", argv[0].intval, val);
+	
+	const uint16_t val = pio_read_16(ptr);
+	printf("read %" PRIxn ": %" PRIx16 "\n", argv[0].intval, val);
+	
 #ifdef IO_SPACE_BOUNDARY
 	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
 		return 1;
 #endif
-	km_unmap((uintptr_t)ptr, sizeof(uint32_t));
-	return 1;
-}
-
-/** Write 1 byte to phys memory or io port.
+	
+	km_unmap((uintptr_t) ptr, sizeof(uint16_t));
+	return 1;
+}
+
+/** Read 4 bytes from phys memory or io port.
  *
  * @param argv Argument vector.
@@ -770,7 +752,8 @@
  * @return 0 on failure, 1 on success.
  */
-static int cmd_pio_write_8(cmd_arg_t *argv)
-{
-	uint8_t *ptr = NULL;
+static int cmd_pio_read_32(cmd_arg_t *argv)
+{
+	uint32_t *ptr = NULL;
+	
 #ifdef IO_SPACE_BOUNDARY
 	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
@@ -778,18 +761,20 @@
 	else
 #endif
-		ptr = (uint8_t*)km_map(argv[0].intval, sizeof(uint8_t),
+		ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t),
 		    PAGE_NOT_CACHEABLE);
-	printf("write %"PRIxn": %"PRIx8"\n", argv[0].intval,
-	    (uint8_t)argv[1].intval);
-	pio_write_8(ptr, (uint8_t)argv[1].intval);
+	
+	const uint32_t val = pio_read_32(ptr);
+	printf("read %" PRIxn ": %" PRIx32 "\n", argv[0].intval, val);
+	
 #ifdef IO_SPACE_BOUNDARY
 	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
 		return 1;
 #endif
-	km_unmap((uintptr_t)ptr, sizeof(uint8_t));
-	return 1;
-}
-
-/** Write 2 bytes to phys memory or io port.
+	
+	km_unmap((uintptr_t) ptr, sizeof(uint32_t));
+	return 1;
+}
+
+/** Write 1 byte to phys memory or io port.
  *
  * @param argv Argument vector.
@@ -797,7 +782,8 @@
  * @return 0 on failure, 1 on success.
  */
-static int cmd_pio_write_16(cmd_arg_t *argv)
-{
-	uint16_t *ptr = NULL;
+static int cmd_pio_write_8(cmd_arg_t *argv)
+{
+	uint8_t *ptr = NULL;
+	
 #ifdef IO_SPACE_BOUNDARY
 	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
@@ -805,18 +791,21 @@
 	else
 #endif
-		ptr = (uint16_t*)km_map(argv[0].intval, sizeof(uint16_t),
+		ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),
 		    PAGE_NOT_CACHEABLE);
-	printf("write %"PRIxn": %"PRIx16"\n", argv[0].intval,
-	    (uint16_t)argv[1].intval);
-	pio_write_16(ptr, (uint16_t)argv[1].intval);
+	
+	printf("write %" PRIxn ": %" PRIx8 "\n", argv[0].intval,
+	    (uint8_t) argv[1].intval);
+	pio_write_8(ptr, (uint8_t) argv[1].intval);
+	
 #ifdef IO_SPACE_BOUNDARY
 	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
 		return 1;
 #endif
-	km_unmap((uintptr_t)ptr, sizeof(uint16_t));
-	return 1;
-}
-
-/** Write 4 bytes to phys memory or io port.
+	
+	km_unmap((uintptr_t) ptr, sizeof(uint8_t));
+	return 1;
+}
+
+/** Write 2 bytes to phys memory or io port.
  *
  * @param argv Argument vector.
@@ -824,7 +813,8 @@
  * @return 0 on failure, 1 on success.
  */
-static int cmd_pio_write_32(cmd_arg_t *argv)
-{
-	uint32_t *ptr = NULL;
+static int cmd_pio_write_16(cmd_arg_t *argv)
+{
+	uint16_t *ptr = NULL;
+	
 #ifdef IO_SPACE_BOUNDARY
 	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
@@ -832,14 +822,48 @@
 	else
 #endif
-		ptr = (uint32_t*)km_map(argv[0].intval, sizeof(uint32_t),
+		ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t),
 		    PAGE_NOT_CACHEABLE);
-	printf("write %"PRIxn": %"PRIx32"\n", argv[0].intval,
-	    (uint32_t)argv[1].intval);
-	pio_write_32(ptr, (uint32_t)argv[1].intval);
+	
+	printf("write %" PRIxn ": %" PRIx16 "\n", argv[0].intval,
+	    (uint16_t) argv[1].intval);
+	pio_write_16(ptr, (uint16_t) argv[1].intval);
+	
 #ifdef IO_SPACE_BOUNDARY
 	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
 		return 1;
 #endif
-	km_unmap((uintptr_t)ptr, sizeof(uint32_t));
+	
+	km_unmap((uintptr_t) ptr, sizeof(uint16_t));
+	return 1;
+}
+
+/** Write 4 bytes to phys memory or io port.
+ *
+ * @param argv Argument vector.
+ *
+ * @return 0 on failure, 1 on success.
+ */
+static int cmd_pio_write_32(cmd_arg_t *argv)
+{
+	uint32_t *ptr = NULL;
+	
+#ifdef IO_SPACE_BOUNDARY
+	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
+		ptr = (void *) argv[0].intval;
+	else
+#endif
+		ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t),
+		    PAGE_NOT_CACHEABLE);
+	
+	printf("write %" PRIxn ": %" PRIx32 "\n", argv[0].intval,
+	    (uint32_t) argv[1].intval);
+	pio_write_32(ptr, (uint32_t) argv[1].intval);
+	
+#ifdef IO_SPACE_BOUNDARY
+	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
+		return 1;
+#endif
+	
+	km_unmap((uintptr_t) ptr, sizeof(uint32_t));
 	return 1;
 }
