From owner-p4-projects@FreeBSD.ORG Wed Feb 20 22:26:15 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2A0C916A405; Wed, 20 Feb 2008 22:26:15 +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 E29F716A400 for ; Wed, 20 Feb 2008 22:26:14 +0000 (UTC) (envelope-from rrs@cisco.com) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id CEE7113C447 for ; Wed, 20 Feb 2008 22:26:14 +0000 (UTC) (envelope-from rrs@cisco.com) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m1KMQE10009524 for ; Wed, 20 Feb 2008 22:26:14 GMT (envelope-from rrs@cisco.com) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m1KMQEDO009521 for perforce@freebsd.org; Wed, 20 Feb 2008 22:26:14 GMT (envelope-from rrs@cisco.com) Date: Wed, 20 Feb 2008 22:26:14 GMT Message-Id: <200802202226.m1KMQEDO009521@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rrs@cisco.com using -f From: "Randall R. Stewart" To: Perforce Change Reviews Cc: Subject: PERFORCE change 135846 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: Wed, 20 Feb 2008 22:26:15 -0000 http://perforce.freebsd.org/chv.cgi?CH=135846 Change 135846 by rrs@rrs-mips2-jnpr on 2008/02/20 22:26:14 s9 indent Affected files ... .. //depot/projects/mips2-jnpr/src/sys/mips/mips32/octeon32/octeon_ebt3000_cf.c#3 edit Differences ... ==== //depot/projects/mips2-jnpr/src/sys/mips/mips32/octeon32/octeon_ebt3000_cf.c#3 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2007 Cavium Networks (support@cavium.com). All rights +Copyright (c) 2003-2007 Cavium Networks (support@cavium.com). All rights reserved. Redistribution and use in source and binary forms, with or without @@ -17,25 +17,25 @@ * Neither the name of Cavium Networks nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written - permission. + permission. -This Software, including technical data, may be subject to U.S. export -control laws, including the U.S. Export Administration Act and its -associated regulations, and may be subject to export or import -regulations in other countries. You warrant that You will comply -strictly in all respects with all such regulations and acknowledge that -you have the responsibility to obtain licenses to export, re-export or -import the Software. +This Software, including technical data, may be subject to U.S. export +control laws, including the U.S. Export Administration Act and its +associated regulations, and may be subject to export or import +regulations in other countries. You warrant that You will comply +strictly in all respects with all such regulations and acknowledge that +you have the responsibility to obtain licenses to export, re-export or +import the Software. -TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" -AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS -OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT -TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY -REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT -DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF -TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, -LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION -OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR +TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" +AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS +OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT +TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY +REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT +DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF +TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, +LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION +OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. */ @@ -106,8 +106,8 @@ /* Globals */ -int bus_width; -void *base_addr; +int bus_width; +void *base_addr; /* Device softc */ struct cf_priv { @@ -122,11 +122,11 @@ }; /* Device parameters */ -struct drive_param{ +struct drive_param { union { char buf[SECTOR_SIZE]; struct hd_driveid driveid; - } u; + } u; char model[MODEL_STR_SIZE]; uint32_t nr_sectors; @@ -135,48 +135,49 @@ uint16_t tracks; uint16_t sec_track; -} drive_param; +} drive_param; /* GEOM class implementation */ -static g_access_t cf_access; -static g_start_t cf_start; -static g_ioctl_t cf_ioctl; +static g_access_t cf_access; +static g_start_t cf_start; +static g_ioctl_t cf_ioctl; struct g_class g_cf_class = { - .name = "CF", - .version = G_VERSION, - .start = cf_start, - .access = cf_access, - .ioctl = cf_ioctl, + .name = "CF", + .version = G_VERSION, + .start = cf_start, + .access = cf_access, + .ioctl = cf_ioctl, }; /* Device methods */ -static int cf_probe(device_t); -static void cf_identify(driver_t *, device_t); -static int cf_attach(device_t); -static int cf_attach_geom(void *, int); +static int cf_probe(device_t); +static void cf_identify(driver_t *, device_t); +static int cf_attach(device_t); +static int cf_attach_geom(void *, int); /* ATA methods */ -static void cf_cmd_identify(void); -static void cf_cmd_write(uint32_t, uint32_t, void *); -static void cf_cmd_read(uint32_t, uint32_t, void *); -static void cf_wait_busy(void); -static void cf_send_cmd(uint32_t, uint8_t); -static void cf_attach_geom_proxy(void *arg, int flag); +static void cf_cmd_identify(void); +static void cf_cmd_write(uint32_t, uint32_t, void *); +static void cf_cmd_read(uint32_t, uint32_t, void *); +static void cf_wait_busy(void); +static void cf_send_cmd(uint32_t, uint8_t); +static void cf_attach_geom_proxy(void *arg, int flag); /* Miscelenous */ -static void cf_swap_ascii(unsigned char[], char[]); +static void cf_swap_ascii(unsigned char[], char[]); /* ------------------------------------------------------------------- * * cf_access() * * ------------------------------------------------------------------- */ -static int cf_access (struct g_provider *pp, int r, int w, int e) +static int +cf_access(struct g_provider *pp, int r, int w, int e) { pp->sectorsize = drive_param.sector_size; - pp->stripesize = drive_param.heads * drive_param.sec_track * drive_param.sector_size; - pp->mediasize = pp->stripesize * drive_param.tracks; + pp->stripesize = drive_param.heads * drive_param.sec_track * drive_param.sector_size; + pp->mediasize = pp->stripesize * drive_param.tracks; return (0); } @@ -185,33 +186,32 @@ /* ------------------------------------------------------------------- * * cf_start() * * ------------------------------------------------------------------- */ -static void cf_start (struct bio *bp) +static void +cf_start(struct bio *bp) { /* - * Handle actual I/O requests. The request is passed down through - * the bio struct. - */ + * Handle actual I/O requests. The request is passed down through + * the bio struct. + */ - if(bp->bio_cmd & BIO_GETATTR) { + if (bp->bio_cmd & BIO_GETATTR) { if (g_handleattr_int(bp, "GEOM::fwsectors", drive_param.sec_track)) - return; - if (g_handleattr_int(bp, "GEOM::fwheads", drive_param.heads)) - return; - g_io_deliver(bp, ENOIOCTL); - return; + return; + if (g_handleattr_int(bp, "GEOM::fwheads", drive_param.heads)) + return; + g_io_deliver(bp, ENOIOCTL); + return; } - if ((bp->bio_cmd & (BIO_READ | BIO_WRITE))) { if (bp->bio_cmd & BIO_READ) { cf_cmd_read(bp->bio_length / drive_param.sector_size, - bp->bio_offset / drive_param.sector_size, bp->bio_data); + bp->bio_offset / drive_param.sector_size, bp->bio_data); } else if (bp->bio_cmd & BIO_WRITE) { cf_cmd_write(bp->bio_length / drive_param.sector_size, - bp->bio_offset/drive_param.sector_size, bp->bio_data); + bp->bio_offset / drive_param.sector_size, bp->bio_data); } - bp->bio_resid = 0; bp->bio_completed = bp->bio_length; g_io_deliver(bp, 0); @@ -219,9 +219,10 @@ } -static int cf_ioctl (struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td) +static int +cf_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td) { - return (0); + return (0); } @@ -231,20 +232,21 @@ * * Read nr_sectors from the device starting from start_sector. */ -static void cf_cmd_read (uint32_t nr_sectors, uint32_t start_sector, void *buf) +static void +cf_cmd_read(uint32_t nr_sectors, uint32_t start_sector, void *buf) { unsigned long lba; uint32_t count; uint16_t *ptr_16; - uint8_t *ptr_8; + uint8_t *ptr_8; - /*#define OCTEON_VISUAL_CF_0 1*/ + /* #define OCTEON_VISUAL_CF_0 1 */ #ifdef OCTEON_VISUAL_CF_0 - octeon_led_write_char(0, 'R'); + octeon_led_write_char(0, 'R'); #endif - ptr_8 = (uint8_t*)buf; - ptr_16 = (uint16_t*)buf; - lba = start_sector; + ptr_8 = (uint8_t *) buf; + ptr_16 = (uint16_t *) buf; + lba = start_sector; while (nr_sectors--) { @@ -252,27 +254,32 @@ cf_send_cmd(lba, CMD_READ_SECTOR); if (bus_width == 8) { - volatile uint8_t *task_file = (volatile uint8_t*)base_addr; - volatile uint8_t dummy; + volatile uint8_t *task_file = (volatile uint8_t *)base_addr; + volatile uint8_t dummy; + for (count = 0; count < SECTOR_SIZE; count++) { *ptr_8++ = task_file[TF_DATA]; - if ((count & 0xf) == 0) dummy = task_file[TF_STATUS]; + if ((count & 0xf) == 0) + dummy = task_file[TF_STATUS]; } } else { - volatile uint16_t *task_file = (volatile uint16_t*)base_addr; - volatile uint16_t dummy; - for (count = 0; count < SECTOR_SIZE; count+=2) { + volatile uint16_t *task_file = (volatile uint16_t *)base_addr; + volatile uint16_t dummy; + + for (count = 0; count < SECTOR_SIZE; count += 2) { uint16_t temp; + temp = task_file[TF_DATA]; *ptr_16++ = SWAP_SHORT(temp); - if ((count & 0xf) == 0) dummy = task_file[TF_STATUS/2]; + if ((count & 0xf) == 0) + dummy = task_file[TF_STATUS / 2]; } - } + } - lba ++; + lba++; } #ifdef OCTEON_VISUAL_CF_0 - octeon_led_write_char(0, ' '); + octeon_led_write_char(0, ' '); #endif } @@ -283,20 +290,21 @@ * * Write nr_sectors to the device starting from start_sector. */ -static void cf_cmd_write (uint32_t nr_sectors, uint32_t start_sector, void *buf) +static void +cf_cmd_write(uint32_t nr_sectors, uint32_t start_sector, void *buf) { uint32_t lba; uint32_t count; uint16_t *ptr_16; - uint8_t *ptr_8; - - /*#define OCTEON_VISUAL_CF_1 1*/ + uint8_t *ptr_8; + + /* #define OCTEON_VISUAL_CF_1 1 */ #ifdef OCTEON_VISUAL_CF_1 - octeon_led_write_char(1, 'W'); + octeon_led_write_char(1, 'W'); #endif lba = start_sector; - ptr_8 = (uint8_t*)buf; - ptr_16 = (uint16_t*)buf; + ptr_8 = (uint8_t *) buf; + ptr_16 = (uint16_t *) buf; while (nr_sectors--) { @@ -304,29 +312,32 @@ if (bus_width == 8) { volatile uint8_t *task_file; - volatile uint8_t dummy; + volatile uint8_t dummy; - task_file = (volatile uint8_t *) base_addr; + task_file = (volatile uint8_t *)base_addr; for (count = 0; count < SECTOR_SIZE; count++) { - task_file[TF_DATA] = *ptr_8++; - if ((count & 0xf) == 0) dummy = task_file[TF_STATUS]; + task_file[TF_DATA] = *ptr_8++; + if ((count & 0xf) == 0) + dummy = task_file[TF_STATUS]; } } else { volatile uint16_t *task_file; - volatile uint16_t dummy; + volatile uint16_t dummy; - task_file = (volatile uint16_t *) base_addr; - for (count = 0; count < SECTOR_SIZE; count+=2) { + task_file = (volatile uint16_t *)base_addr; + for (count = 0; count < SECTOR_SIZE; count += 2) { uint16_t temp = *ptr_16++; - task_file[TF_DATA] = SWAP_SHORT(temp); - if ((count & 0xf) == 0) dummy = task_file[TF_STATUS/2]; + + task_file[TF_DATA] = SWAP_SHORT(temp); + if ((count & 0xf) == 0) + dummy = task_file[TF_STATUS / 2]; } - } + } - lba ++; + lba++; } #ifdef OCTEON_VISUAL_CF_1 - octeon_led_write_char(1, ' '); + octeon_led_write_char(1, ' '); #endif } @@ -335,68 +346,74 @@ * cf_cmd_identify() * * ------------------------------------------------------------------- * * - * Read parameters and other information from the drive and store + * Read parameters and other information from the drive and store * it in the drive_param structure * */ -static void cf_cmd_identify (void) +static void +cf_cmd_identify(void) { int count; uint8_t status; if (bus_width == 8) { - volatile uint8_t *task_file; + volatile uint8_t *task_file; - task_file = (volatile uint8_t *) base_addr; + task_file = (volatile uint8_t *)base_addr; while ((status = task_file[TF_STATUS]) & STATUS_BSY) { DELAY(WAIT_DELAY); - } + } - task_file[TF_SECTOR_COUNT] = 0; - task_file[TF_SECTOR_NUMBER] = 0; - task_file[TF_CYL_LSB] = 0; - task_file[TF_CYL_MSB] = 0; - task_file[TF_DRV_HEAD] = 0; - task_file[TF_COMMAND] = CMD_IDENTIFY; + task_file[TF_SECTOR_COUNT] = 0; + task_file[TF_SECTOR_NUMBER] = 0; + task_file[TF_CYL_LSB] = 0; + task_file[TF_CYL_MSB] = 0; + task_file[TF_DRV_HEAD] = 0; + task_file[TF_COMMAND] = CMD_IDENTIFY; cf_wait_busy(); - for (count = 0; count < SECTOR_SIZE; count++) - drive_param.u.buf[count] = task_file[TF_DATA]; + for (count = 0; count < SECTOR_SIZE; count++) + drive_param.u.buf[count] = task_file[TF_DATA]; } else { volatile uint16_t *task_file; - task_file = (volatile uint16_t *) base_addr; + task_file = (volatile uint16_t *)base_addr; - while ((status = (task_file[TF_STATUS/2]>>8)) & STATUS_BSY) { + while ((status = (task_file[TF_STATUS / 2] >> 8)) & STATUS_BSY) { DELAY(WAIT_DELAY); } - task_file[TF_SECTOR_COUNT/2] = 0; /* this includes TF_SECTOR_NUMBER */ - task_file[TF_CYL_LSB/2] = 0; /* this includes TF_CYL_MSB */ - task_file[TF_DRV_HEAD/2] = 0 | (CMD_IDENTIFY<<8); /* this includes TF_COMMAND */ + task_file[TF_SECTOR_COUNT / 2] = 0; /* this includes + * TF_SECTOR_NUMBER */ + task_file[TF_CYL_LSB / 2] = 0; /* this includes TF_CYL_MSB */ + task_file[TF_DRV_HEAD / 2] = 0 | (CMD_IDENTIFY << 8); /* this includes + * TF_COMMAND */ cf_wait_busy(); - for (count = 0; count < SECTOR_SIZE; count+=2) { + for (count = 0; count < SECTOR_SIZE; count += 2) { uint16_t temp; + temp = task_file[TF_DATA]; - + /* endianess will be swapped below */ - drive_param.u.buf[count] = (temp & 0xff); - drive_param.u.buf[count+1] = (temp & 0xff00)>>8; + drive_param.u.buf[count] = (temp & 0xff); + drive_param.u.buf[count + 1] = (temp & 0xff00) >> 8; } } cf_swap_ascii(drive_param.u.driveid.model, drive_param.model); - drive_param.sector_size = 512; /* SWAP_SHORT (drive_param.u.driveid.sector_bytes); */ - drive_param.heads = SWAP_SHORT (drive_param.u.driveid.cur_heads); - drive_param.tracks = SWAP_SHORT (drive_param.u.driveid.cur_cyls); - drive_param.sec_track = SWAP_SHORT (drive_param.u.driveid.cur_sectors); - drive_param.nr_sectors = SWAP_LONG (drive_param.u.driveid.lba_capacity); + drive_param.sector_size = 512; /* SWAP_SHORT + * (drive_param.u.driveid.sector_bytes) + * ; */ + drive_param.heads = SWAP_SHORT(drive_param.u.driveid.cur_heads); + drive_param.tracks = SWAP_SHORT(drive_param.u.driveid.cur_cyls); + drive_param.sec_track = SWAP_SHORT(drive_param.u.driveid.cur_sectors); + drive_param.nr_sectors = SWAP_LONG(drive_param.u.driveid.lba_capacity); } @@ -408,38 +425,39 @@ * Send command to read/write one sector specified by lba. * */ -static void cf_send_cmd (uint32_t lba, uint8_t cmd) +static void +cf_send_cmd(uint32_t lba, uint8_t cmd) { uint8_t status; if (bus_width == 8) { volatile uint8_t *task_file; - task_file = (volatile uint8_t *) base_addr; + task_file = (volatile uint8_t *)base_addr; - while ( (status = task_file[TF_STATUS]) & STATUS_BSY) { + while ((status = task_file[TF_STATUS]) & STATUS_BSY) { DELAY(WAIT_DELAY); } - task_file[TF_SECTOR_COUNT] = 1; + task_file[TF_SECTOR_COUNT] = 1; task_file[TF_SECTOR_NUMBER] = (lba & 0xff); - task_file[TF_CYL_LSB] = ((lba >> 8) & 0xff); - task_file[TF_CYL_MSB] = ((lba >> 16) & 0xff); - task_file[TF_DRV_HEAD] = ((lba >> 24) & 0xff) | 0xe0; - task_file[TF_COMMAND] = cmd; + task_file[TF_CYL_LSB] = ((lba >> 8) & 0xff); + task_file[TF_CYL_MSB] = ((lba >> 16) & 0xff); + task_file[TF_DRV_HEAD] = ((lba >> 24) & 0xff) | 0xe0; + task_file[TF_COMMAND] = cmd; } else { volatile uint16_t *task_file; - task_file = (volatile uint16_t *) base_addr; + task_file = (volatile uint16_t *)base_addr; - while ( (status = (task_file[TF_STATUS/2]>>8)) & STATUS_BSY) { + while ((status = (task_file[TF_STATUS / 2] >> 8)) & STATUS_BSY) { DELAY(WAIT_DELAY); } - task_file[TF_SECTOR_COUNT/2] = 1 | ((lba & 0xff) << 8); - task_file[TF_CYL_LSB/2] = ((lba >> 8) & 0xff) | (((lba >> 16) & 0xff) << 8); - task_file[TF_DRV_HEAD/2] = (((lba >> 24) & 0xff) | 0xe0) | (cmd << 8); + task_file[TF_SECTOR_COUNT / 2] = 1 | ((lba & 0xff) << 8); + task_file[TF_CYL_LSB / 2] = ((lba >> 8) & 0xff) | (((lba >> 16) & 0xff) << 8); + task_file[TF_DRV_HEAD / 2] = (((lba >> 24) & 0xff) | 0xe0) | (cmd << 8); } @@ -451,45 +469,48 @@ * ------------------------------------------------------------------- * * * Wait until the drive finishes a given command and data is - * ready to be transferred. This is done by repeatedly checking + * ready to be transferred. This is done by repeatedly checking * the BSY and DRQ bits of the status register. When the controller - * is ready for data transfer, it clears the BSY bit and sets the + * is ready for data transfer, it clears the BSY bit and sets the * DRQ bit. * */ -static void cf_wait_busy (void) +static void +cf_wait_busy(void) { uint8_t status; - /*#define OCTEON_VISUAL_CF_2 1*/ + /* #define OCTEON_VISUAL_CF_2 1 */ #ifdef OCTEON_VISUAL_CF_2 - static int where0 = 0; + static int where0 = 0; - octeon_led_run_wheel(&where0, 2); + octeon_led_run_wheel(&where0, 2); #endif if (bus_width == 8) { volatile uint8_t *task_file; + task_file = (volatile uint8_t *)base_addr; - status = task_file[TF_STATUS]; - while ((status & STATUS_BSY) == STATUS_BSY || (status & STATUS_DRQ) != STATUS_DRQ ) { + status = task_file[TF_STATUS]; + while ((status & STATUS_BSY) == STATUS_BSY || (status & STATUS_DRQ) != STATUS_DRQ) { DELAY(WAIT_DELAY); status = task_file[TF_STATUS]; } } else { volatile uint16_t *task_file; + task_file = (volatile uint16_t *)base_addr; - status = task_file[TF_STATUS/2]>>8; - while ((status & STATUS_BSY) == STATUS_BSY || (status & STATUS_DRQ) != STATUS_DRQ ) { + status = task_file[TF_STATUS / 2] >> 8; + while ((status & STATUS_BSY) == STATUS_BSY || (status & STATUS_DRQ) != STATUS_DRQ) { DELAY(WAIT_DELAY); - status = (uint8_t)(task_file[TF_STATUS/2]>>8); + status = (uint8_t) (task_file[TF_STATUS / 2] >> 8); } } #ifdef OCTEON_VISUAL_CF_2 - octeon_led_write_char(2, ' '); + octeon_led_write_char(2, ' '); #endif } @@ -497,18 +518,19 @@ * cf_swap_ascii() * * ------------------------------------------------------------------- * * - * The ascii string returned by the controller specifying - * the model of the drive is byte-swaped. This routine + * The ascii string returned by the controller specifying + * the model of the drive is byte-swaped. This routine * corrects the byte ordering. * */ -static void cf_swap_ascii (unsigned char str1[], char str2[]) +static void +cf_swap_ascii(unsigned char str1[], char str2[]) { int i; for (i = 0; i < MODEL_STR_SIZE; i++) { - str2[i] = str1[i^1]; - } + str2[i] = str1[i ^ 1]; + } } @@ -516,7 +538,8 @@ * cf_probe() * * ------------------------------------------------------------------- */ -static int cf_probe (device_t dev) +static int +cf_probe(device_t dev) { if (!octeon_board_real()) return ENXIO; @@ -534,56 +557,58 @@ * cf_identify() * * ------------------------------------------------------------------- * * - * Find the bootbus region for the CF to determine - * 16 or 8 bit and check to see if device is + * Find the bootbus region for the CF to determine + * 16 or 8 bit and check to see if device is * inserted. * */ -static void cf_identify (driver_t *drv, device_t parent) +static void +cf_identify(driver_t * drv, device_t parent) { uint8_t status; - int bus_region; + int bus_region; int count = 0; - octeon_mio_boot_reg_cfgx_t cfg; + octeon_mio_boot_reg_cfgx_t cfg; - if (!octeon_board_real()) return 1; + if (!octeon_board_real()) + return 1; - base_addr = (void *) OCTEON_PHYS2PTR(OCTEON_CF_COMMON_BASE_ADDR); + base_addr = (void *)OCTEON_PHYS2PTR(OCTEON_CF_COMMON_BASE_ADDR); - for (bus_region = 0; bus_region < 8; bus_region++) - { - cfg.word64 = oct_read64(OCTEON_MIO_BOOT_REG_CFGX(bus_region)); - if (cfg.bits.base == OCTEON_CF_COMMON_BASE_ADDR >> 16) - { - bus_width = (cfg.bits.width) ? 16: 8; - printf("Compact flash found in bootbus region %d (%d bit).\n", bus_region, bus_width); - break; - } - } + for (bus_region = 0; bus_region < 8; bus_region++) { + cfg.word64 = oct_read64(OCTEON_MIO_BOOT_REG_CFGX(bus_region)); + if (cfg.bits.base == OCTEON_CF_COMMON_BASE_ADDR >> 16) { + bus_width = (cfg.bits.width) ? 16 : 8; + printf("Compact flash found in bootbus region %d (%d bit).\n", bus_region, bus_width); + break; + } + } if (bus_width == 8) { volatile uint8_t *task_file; - task_file = (volatile uint8_t *) base_addr; + + task_file = (volatile uint8_t *)base_addr; /* Check if CF is inserted */ - while ( (status = task_file[TF_STATUS]) & STATUS_BSY){ - if ((count++) == NR_TRIES ) { + while ((status = task_file[TF_STATUS]) & STATUS_BSY) { + if ((count++) == NR_TRIES) { printf("Compact Flash not present\n"); return; - } + } DELAY(WAIT_DELAY); - } + } } else { volatile uint16_t *task_file; - task_file = (volatile uint16_t *) base_addr; + + task_file = (volatile uint16_t *)base_addr; /* Check if CF is inserted */ - while ( (status = (task_file[TF_STATUS/2]>>8)) & STATUS_BSY){ - if ((count++) == NR_TRIES ) { + while ((status = (task_file[TF_STATUS / 2] >> 8)) & STATUS_BSY) { + if ((count++) == NR_TRIES) { printf("Compact Flash not present\n"); return; - } + } DELAY(WAIT_DELAY); - } + } } BUS_ADD_CHILD(parent, 0, "cf", 0); @@ -594,25 +619,27 @@ * cf_attach_geom() * * ------------------------------------------------------------------- */ -static int cf_attach_geom (void *arg, int flag) +static int +cf_attach_geom(void *arg, int flag) { struct cf_priv *cf_priv; - cf_priv = (struct cf_priv *) arg; + cf_priv = (struct cf_priv *)arg; cf_priv->cf_geom = g_new_geomf(&g_cf_class, "cf%d", device_get_unit(cf_priv->dev)); cf_priv->cf_provider = g_new_providerf(cf_priv->cf_geom, cf_priv->cf_geom->name); cf_priv->cf_geom->softc = cf_priv; - g_error_provider(cf_priv->cf_provider, 0); + g_error_provider(cf_priv->cf_provider, 0); - return (0); + return (0); } /* ------------------------------------------------------------------- * * cf_attach_geom() * * ------------------------------------------------------------------- */ -static void cf_attach_geom_proxy (void *arg, int flag) +static void +cf_attach_geom_proxy(void *arg, int flag) { - cf_attach_geom(arg, flag); + cf_attach_geom(arg, flag); } @@ -621,11 +648,13 @@ * cf_attach() * * ------------------------------------------------------------------- */ -static int cf_attach (device_t dev) +static int +cf_attach(device_t dev) { struct cf_priv *cf_priv; - if (!octeon_board_real()) return ENXIO; + if (!octeon_board_real()) + return ENXIO; cf_priv = device_get_softc(dev); cf_priv->dev = dev; @@ -634,24 +663,24 @@ g_post_event(cf_attach_geom_proxy, cf_priv, M_WAITOK, NULL); bioq_init(&cf_priv->cf_bq); - return 0; + return 0; } static device_method_t cf_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, cf_probe), - DEVMETHOD(device_identify, cf_identify), - DEVMETHOD(device_attach, cf_attach), - DEVMETHOD(device_detach, bus_generic_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), + /* Device interface */ + DEVMETHOD(device_probe, cf_probe), + DEVMETHOD(device_identify, cf_identify), + DEVMETHOD(device_attach, cf_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), - { 0, 0 } + {0, 0} }; static driver_t cf_driver = { - "cf", - cf_methods, + "cf", + cf_methods, sizeof(struct cf_priv) };