⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strata-instance.html

📁 ecos3.0 beta 的官方文档,html格式
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!-- Copyright (C) 2009 Free Software Foundation, Inc.                                -->
<!-- This material may be distributed only subject to the terms      -->
<!-- and conditions set forth in the Open Publication License, v1.0  -->
<!-- or later (the latest version is presently available at          -->
<!-- http://www.opencontent.org/openpub/).                           -->
<!-- Distribution of the work or derivative of the work in any       -->
<!-- standard (paper) book form is prohibited unless prior           -->
<!-- permission is obtained from the copyright holder.               -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Instantiating a Strata Device</TITLE
><meta name="MSSmartTagsPreventParsing" content="TRUE">
<META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="eCos Reference Manual"
HREF="ecos-ref.html"><LINK
REL="UP"
TITLE="Intel Strata Flash Device Driver"
HREF="devs-flash-strata.html"><LINK
REL="PREVIOUS"
TITLE="Overview"
HREF="strata.html"><LINK
REL="NEXT"
TITLE="Strata-Specific Functions"
HREF="strata-api-other.html"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>eCos Reference Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="strata.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="strata-api-other.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="STRATA-INSTANCE"
></A
>Instantiating a Strata Device</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN20932"
></A
><H2
>Name</H2
>Instantiating&nbsp;--&nbsp;including the driver in an eCos target</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN20935"
></A
><H2
>Synopsis</H2
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN20936"
></A
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="FUNCSYNOPSISINFO"
>#include &lt;cyg/io/strata_dev.h&gt;
      </PRE
></TD
></TR
></TABLE
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int cyg_strata_init_nop</CODE
>(struct cyg_flash_dev* device);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int cyg_strata_init_check_devid_XX</CODE
>(struct cyg_flash_dev* device);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int cyg_strata_init_cfi_XX</CODE
>(struct cyg_flash_dev* device);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int cyg_strata_erase_XX</CODE
>(struct cyg_flash_dev* device, cyg_flashaddr_t addr);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int cyg_strata_program_XX</CODE
>(struct cyg_flash_dev* device, cyg_flashaddr_t addr, const void* data, size_t len);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int cyg_strata_bufprogram_XX</CODE
>(struct cyg_flash_dev* device, cyg_flashaddr_t addr, const void* data, size_t len);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int cyg_strata_lock_j3_XX</CODE
>(struct cyg_flash_dev* device, const cyg_flashaddr_t addr);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int cyg_strata_unlock_j3_XX</CODE
>(struct cyg_flash_dev* device, const cyg_flashaddr_t addr);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int cyg_strata_lock_k3_XX</CODE
>(struct cyg_flash_dev* device, const cyg_flashaddr_t addr);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int cyg_strata_unlock_k3_XX</CODE
>(struct cyg_flash_dev* device, const cyg_flashaddr_t addr);</CODE
></P
><P
></P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="STRATA-INSTANCE-DESCRIPTION"
></A
><H2
>Description</H2
><P
>The Strata family contains a number of different devices, all
supporting the same basic set of operations but with various common or
uncommon extensions. The range includes:
    </P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>28FxxxB3 Boot Block</DT
><DD
><P
>These support 8 8K boot blocks as well as the usual 64K blocks. There
is no buffered write capability. The only locking mechanism available
involves manipulating voltages on certain pins.
        </P
></DD
><DT
>28FxxxC3</DT
><DD
><P
>These also have boot blocks. There is no buffered write capability.
Individual blocks can be locked and unlocked in software.
        </P
></DD
><DT
>28FxxxJ3</DT
><DD
><P
>These are uniform devices where all blocks are 128K. Buffered writes
are supported. Blocks can be locked individually, but the only unlock
operation is a global unlock-all.
        </P
></DD
><DT
>28FxxxK3</DT
><DD
><P
>These are also uniform devices with 128K blocks. Buffered writes are
supported. Individual blocks can be locked and unlocked in software.
        </P
></DD
></DL
></DIV
><P
>Each of these comes in a range of sizes and bus widths. There are also
platform-specific issues such as how many devices are actually present
on the board and where they are mapped in the address space. The
Strata driver package cannot know all this information. Instead it
is the responsibility of another package, usually the platform HAL, to
instantiate some flash device structures. Two pieces of information
are especially important: the bus configuration and the boot block
layout.
    </P
><P
>Flash devices are typically 8-bits, 16-bits, or 32-bits wide (64-bit
devices are not yet in common use). Most 16-bit devices will also
support 8-bit accesses, but not all. Similarly 32-bit devices can be
accessed 16-bits at a time or 8-bits at a time. A board will have one
or more of these devices on the bus. For example there may be a single
16-bit device on a 16-bit bus, or two 16-bit devices on a 32-bit bus.
The processor's bus logic determines which combinations are possible,
and usually there will be a trade off between cost and performance.
For example two 16-bit devices in parallel can provide twice the
memory bandwidth of a single device. The driver supports the following
combinations:
    </P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>8</DT
><DD
><P
>A single 8-bit flash device on an 8-bit bus.
        </P
></DD
><DT
>16</DT
><DD
><P
>A single 16-bit flash device on a 16-bit bus.
        </P
></DD
><DT
>32</DT
><DD
><P
>A single 32-bit flash device on an 32-bit bus.
        </P
></DD
><DT
>88</DT
><DD
><P
>Two parallel 8-bit devices on an 16-bit bus.
        </P
></DD
><DT
>8888</DT
><DD
><P
>Four parallel 8-bit devices on a 32-bit bus.
        </P
></DD
><DT
>1616</DT
><DD
><P
>Two parallel 16-bit devices on a 32-bit bus, with one device providing
the bottom two bytes of each 32-bit datum and the other device
providing the upper two bytes.
        </P
></DD
><DT
>16as8</DT
><DD
><P
>A single 16-bit flash device connected to an 8-bit bus.
        </P
></DD
></DL
></DIV
><P
>These configuration all require slightly different code to manipulate
the hardware. The Strata driver package provides separate functions
for each configuration, for example
<CODE
CLASS="FUNCTION"
>cyg_strata_erase_16</CODE
> and
<CODE
CLASS="FUNCTION"
>cyg_strata_program_1616</CODE
>. 
    </P
><DIV
CLASS="CAUTION"
><P
></P
><TABLE
CLASS="CAUTION"
BORDER="1"
WIDTH="100%"
><TR
><TD
ALIGN="CENTER"
><B
>Caution</B
></TD
></TR
><TR
><TD
ALIGN="LEFT"
><P
>At the time of writing not all the configurations have been tested.
    </P
></TD
></TR
></TABLE
></DIV
><P
>The second piece of information is the boot block layout. Flash
devices are subdivided into blocks (also known as sectors, both terms
are in common use). Some operations such as erase work on a whole
block at a time, and for most applications a block is the smallest
unit that gets updated. A typical block size is 64K. It is inefficient
to use an entire 64K block for small bits of configuration data and
similar information, so some flash devices also support a number of
smaller boot blocks. A typical 2MB flash device could have eight 8K
blocks and 31 full-size 64K blocks. The boot blocks may appear at the
bottom or the top of the device. So-called uniform devices do not have
boot blocks, just full-size ones. The driver needs to know the boot
block layout. With modern devices it can work this out at run-time,
but often it is better to provide the information statically.
    </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="STRATA-INSTANCE-EXAMPLE"
></A
><H2
>Example</H2
><P
>Flash support is usually specific to each platform. Even if two
platforms happen to use the same flash device there are likely to be
differences such as the location in the address map. Hence there is
little possibility of re-using the platform-specific code, and this
code is generally placed in the platform HAL rather than in a separate
package. Typically this involves a separate file and a corresponding
compile property in the platform HAL's CDL:
    </P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>cdl_package CYGPKG_HAL_M68K_KIKOO {
    &#8230;
    compile -library=libextras.a kikoo_flash.c
    &#8230;
}
    </PRE
></TD
></TR
></TABLE
><P
>The contents of this file will not be accessed directly, only
indirectly via the generic flash API, so normally it would be removed
by link-time garbage collection. To avoid this the object file has to
go into <TT
CLASS="FILENAME"
>libextras.a</TT
>.
    </P
><P
>The actual file <TT
CLASS="FILENAME"
>kikoo_flash.c</TT
> will look something like:
    </P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>#include &lt;pkgconf/system.h&gt;
#ifdef CYGPKG_DEVS_FLASH_STRATA_V2

#include &lt;cyg/io/flash.h&gt;
#include &lt;cyg/io/strata_dev.h&gt;

static const CYG_FLASH_FUNS(hal_kikoo_flash_strata_funs,
    &amp;cyg_strata_init_check_devid_16,
    &amp;cyg_flash_devfn_query_nop,
    &amp;cyg_strata_erase_16,
    &amp;cyg_strata_bufprogram_16,
    (int (*)(struct cyg_flash_dev*, const cyg_flashaddr_t, void*, size_t))0,
    &amp;cyg_strata_lock_j3_16,
    &amp;cyg_strata_unlock_j3_16);

static const cyg_strata_dev hal_kikoo_flash_priv = {
    .manufacturer_code = CYG_FLASH_STRATA_MANUFACTURER_INTEL,
    .device_code = 0x0017,
    .bufsize    = 16,
    .block_info = {
        { 0x00020000, 64 } // 64 * 128K blocks
    }
};

CYG_FLASH_DRIVER(hal_kikoo_flash,
                 &amp;hal_kikoo_flash_strata_funs,
                 0,
                 0x60000000,
                 0x601FFFFF,
                 1,
                 hal_kikoo_flash_priv.block_info,
                 &amp;hal_kikoo_flash_priv
);
#endif
    </PRE
></TD
></TR
></TABLE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -