亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? xilinx-load.c

?? 開放源碼實時操作系統源碼.
?? C
字號:
//==========================================================================
//
//      xilinx-load.c
//
//      FPGA support for NMI uEngine uE250 PCI
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 2003 Gary Thomas <gary@mind.be>
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s):    David Mazur <david@mind.be>
// Contributors: gthomas
// Date:         2003-02-20
// Purpose:      FPGA support
// Description:  
//
//####DESCRIPTIONEND####
//
//========================================================================*/

#include <pkgconf/hal.h>
#include <pkgconf/system.h>
#include CYGBLD_HAL_PLATFORM_H
#include CYGHWR_MEMORY_LAYOUT_H

#include <cyg/infra/cyg_type.h>         // base types
#include <cyg/infra/cyg_trac.h>         // tracing macros
#include <cyg/infra/cyg_ass.h>          // assertion macros
#include <cyg/infra/diag.h>             // diagnostic printing

#include <cyg/hal/hal_io.h>             // IO macros
#include <cyg/hal/hal_if.h>             // calling interface API
#include <cyg/hal/hal_arch.h>           // Register state info
#include <cyg/hal/hal_diag.h>
#include <cyg/hal/hal_intr.h>           // Interrupt names
#include <cyg/hal/hal_cache.h>
#include <cyg/io/pci_hw.h>
#include <cyg/io/pci.h>

#include <cyg/hal/plx.h>

#define FPGA_PROG 0x00020000
#define FPGA_INIT 0x00000002
#define FPGA_DONE 0x00080000

#define _FPGA_PROG_BASE 0x0c000000
#define FPGA_PROG_BASE (*((volatile cyg_uint32 *)(_FPGA_PROG_BASE)))

#define FPGA_DONE_DRV   0x8
#define FPGA_INIT_DRV   0x10
#define FPGA_WRITE      0x20

#define VGA_PROG_CTRL  0x4008
#define VGA_PROG_DATA  0x400C

#define VGA_DONE       0x1
#define VGA_INIT       0x2
#define VGA_PROG       0x4
#define VGA_DONE_DRV   0x8
#define VGA_INIT_DRV   0x10
#define VGA_WRITE      0x20


#include <cyg/compress/zlib.h>

extern char _end;

static z_stream stream;

#define FEEDBACK_COUNT 16
#define ZCHAR_BUF_SIZE 256
struct _zchar_info {
    char  buf[ZCHAR_BUF_SIZE];
    char *ptr;
    int   avail;
    int   feedback;
    int   total;
};

// Internal allocator for decompression - just use bottom of heap
// which will be reclaimed by eCos once the system is initialized
static void *
_zcalloc(void *opaque, unsigned int items, unsigned int size)
{
    static char *ptr = (char *)&_end;
    char *res = ptr;

//    diag_printf("%s(%p,%d,%d) = %p\n", __FUNCTION__, opaque, items, size, res);
    ptr += (size*items);
    return res;
}

static void 
_zcfree(void *opaque, void *ptr)
{
//    diag_printf("%s(%p,%p)\n", __FUNCTION__, opaque, ptr);    
}

static int
_zchar(void)
{
    int err;
    struct _zchar_info *info = (struct _zchar_info *)stream.opaque;
    static char spin[] = "|/-\\|-";
    static int tick = 0;

    if (info->avail == 0) {
        stream.next_out = info->buf;
        stream.avail_out = sizeof(info->buf);
        info->ptr = info->buf;
        err = inflate(&stream, Z_SYNC_FLUSH);
        info->avail = (char *)stream.next_out - info->buf;
        if (--info->feedback == 0) {
            diag_printf("%c\b", spin[tick++]);
            if (tick >= (sizeof(spin)-1)) {
                tick = 0;
            }
            info->feedback = FEEDBACK_COUNT;
        }
    }
    if (info->avail) {
        info->avail--;
        info->total++;
        return *(info->ptr)++;
    } else {
        // End of data stream
        return -1;
    }
}

/**
 * A little bit swapping function, necessary due to the xilinx bit file format.
 */
static const cyg_uint8 _swapped[] = {
    0x00, 0x08, 0x04, 0x0C, 0x02, 0x0A, 0x06, 0x0E,
    0x01, 0x09, 0x05, 0x0D, 0x03, 0x0B, 0x07, 0x0F
};

static cyg_uint8 
bitswap(cyg_uint8 byte)
{
    cyg_uint8 _new = (_swapped[byte & 0x0F] << 4) | (_swapped[(byte >> 4) & 0x0F]);
    return _new;
}

typedef int _bitfile_fun(void);
typedef void _download_fun(_bitfile_fun *_bitfile);

/**
 * Gets the tag at given location in the bitfile.
 */
static cyg_uint8 
bitfile_get_tag(_bitfile_fun *_bitfile)
{
    return (*_bitfile)();
}

static cyg_uint16 
bitfile_get_len16(_bitfile_fun *_bitfile)
{
    cyg_uint16 length;

    length = (*_bitfile)() << 8;
    length |= (*_bitfile)();

    return length;
}

static int 
bitfile_get_len32(_bitfile_fun *_bitfile)
{
    cyg_uint32 length;

    length = (*_bitfile)() << 24;
    length |= (*_bitfile)() << 16;
    length |= (*_bitfile)() << 8;
    length |= (*_bitfile)();

    return length;
}

/**
 * Process a string tag.
 */
static void 
bitfile_process_string_tag(char *description, _bitfile_fun *_bitfile)
{
    int len,i;

    len = bitfile_get_len16(_bitfile);
    diag_printf(description);
    for (i = 0; i < len; i++) {
        diag_printf("%c", (*_bitfile)());
    }
}

/**
 * Process the 'e' tag in the bit file, which is the actual code that is to
 * be programmed on the fpga.
 */
static void 
bitfile_process_tag_e(_bitfile_fun *_bitfile)
{
    int len,count,i;
    cyg_uint8 byte;
    cyg_uint32 word;

    len = bitfile_get_len32(_bitfile);

    *PXA2X0_GPCR0 = FPGA_PROG;

    for (count=0; count<10000; count++)
        if ((*PXA2X0_GPLR0 & FPGA_INIT) == 0)
            break;
    if ((*PXA2X0_GPLR0 & FPGA_INIT) != 0)
        diag_printf("INIT did not go low. FPGA programming failed\n");

    *PXA2X0_GPSR0 = FPGA_PROG;

    for (count=0; count<10000; count++)
        if ((*PXA2X0_GPLR0 & FPGA_INIT) != 0)
            break;
    if ((*PXA2X0_GPLR0 & FPGA_INIT) == 0)
        diag_printf("INIT did not go high. FPGA programming failed\n");

    for( i=0; i<len; i++) {
        if ((*PXA2X0_GPLR0 & FPGA_INIT) == 0) {
            diag_printf("CRC Error. FPGA programming failed\n");
        }

        byte = (*_bitfile)();
        word = 0;

        if (byte & (0x01 << 7)) word|=(0x01);
        if (byte & (0x01 << 6)) word|=(0x01 << 18);
        if (byte & (0x01 << 5)) word|=(0x01 << 14);
        if (byte & (0x01 << 4)) word|=(0x01 << 1);
        if (byte & (0x01 << 3)) word|=(0x01 << 4);
        if (byte & (0x01 << 2)) word|=(0x01 << 6);
        if (byte & (0x01 << 1)) word|=(0x01 << 9);
        if (byte & (0x01)) word|=(0x01 << 30);

        FPGA_PROG_BASE = word;
    }

    for (count=0; count<10000; count++)
        if ((*PXA2X0_GPLR0 & FPGA_DONE) != 0)
            break;
    if ((*PXA2X0_GPLR0 & FPGA_DONE) == 0)
        diag_printf("DONE did not go high. FPGA programming failed\n");

}

/**
 * Process the 'e' tag in the bit file, which is the actual code that is to
 * be programmed on the fpga.
 */
static void 
vga_bitfile_process_tag_e(_bitfile_fun *_bitfile)
{
    int len,count,i;
    cyg_uint8 byte;

    len = bitfile_get_len32(_bitfile);

    localbus_writeb(VGA_WRITE,  VGA_PROG_CTRL);
    localbus_writeb(VGA_WRITE | VGA_PROG,  VGA_PROG_CTRL);

    for (count=0; count<10000; count++)
        if (localbus_readb(VGA_PROG_CTRL) & VGA_INIT)
            break;
    if (!(localbus_readb(VGA_PROG_CTRL) & VGA_INIT))
        diag_printf("INIT did not go high. VGA FPGA programming failed\n");

    localbus_writeb(VGA_PROG, VGA_PROG_CTRL);

    for (i=0; i<len; i++) {
        byte = (*_bitfile)();
        localbus_writeb(bitswap(byte),VGA_PROG_DATA);
    } 

    for (count=0; count<10000; count++)
        if (localbus_readb(VGA_PROG_CTRL) & VGA_DONE)
            break;
    if (!(localbus_readb(VGA_PROG_CTRL) & VGA_DONE))
        diag_printf("DONE did not go high. VGA FPGA programming failed\n");

    localbus_writeb(VGA_PROG | VGA_WRITE,  VGA_PROG_CTRL);
}

//
// Download a bitstream
//
static void
download_bitstream(char *title, _bitfile_fun *_bitfile, _download_fun *_download)
{
    int len, tag;

    diag_printf("Load %s(", title);

    len = bitfile_get_len16(_bitfile);
    while (len-- > 0) {
        (*_bitfile)();  // Skip
    }
    len = bitfile_get_len16(_bitfile);

    tag = 0;
    while (tag != 'e') {

        tag = bitfile_get_tag(_bitfile);
        switch (tag) {
        case 'a':
            bitfile_process_string_tag("Design:", _bitfile);
            break;

        case 'b':
            bitfile_process_string_tag(", Part:", _bitfile);
            break;

        case 'c':
            bitfile_process_string_tag(", Date:", _bitfile);
            break;

        case 'd':
            bitfile_process_string_tag(" ", _bitfile);
            break;

        case 'e':
            (*_download)(_bitfile);
            break;

        default:
            diag_printf("Unknown tag. aborting...\n");
            return;
        }
    }
}


/**
 * Process a bitfile located at the given address.
 */
void 
load_fpga(cyg_uint8 *compressed_bitfile, int len) 
{
    int err;
    struct _zchar_info zchar_data;

    stream.zalloc = _zcalloc;
    stream.zfree = _zcfree;
    stream.next_in = compressed_bitfile;
    stream.avail_in = len;
    stream.next_out = 0;
    stream.avail_out = 0;
    stream.opaque = (void *)&zchar_data;
    zchar_data.avail = 0;
    zchar_data.feedback = FEEDBACK_COUNT;
    zchar_data.total = 0;
    err = inflateInit(&stream);
    if (err) {
        diag_printf("%s: Can't init stream\n", __FUNCTION__);
        return;
    }
    // Set up to download FPGA bitstreap
    *PXA2X0_GPSR0 = FPGA_PROG;
    download_bitstream("PCI ctlr", _zchar, bitfile_process_tag_e);
    inflateEnd(&stream);
    diag_printf(") %x bytes\n", zchar_data.total);
}

/**
 * Process a bitfile located at the given address.
 */
void 
load_vga(cyg_uint8 *compressed_bitfile, int len)
{
    int err;
    struct _zchar_info zchar_data;

    stream.zalloc = _zcalloc;
    stream.zfree = _zcfree;
    stream.next_in = compressed_bitfile;
    stream.avail_in = len;
    stream.next_out = 0;
    stream.avail_out = 0;
    stream.opaque = (void *)&zchar_data;
    zchar_data.avail = 0;
    zchar_data.feedback = FEEDBACK_COUNT;
    zchar_data.total = 0;
    err = inflateInit(&stream);
    if (err) {
        diag_printf("%s: Can't init stream\n", __FUNCTION__);
        return;
    }
    download_bitstream("VGA ctlr", _zchar, vga_bitfile_process_tag_e);
    inflateEnd(&stream);
    diag_printf(") %x bytes\n", zchar_data.total);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产香蕉久久精品综合网| 日韩欧美在线不卡| 久久精品国产精品亚洲精品| 国产精品久久久久精k8| 欧美一区在线视频| 在线亚洲欧美专区二区| 国产成人一区在线| 男女视频一区二区| 亚洲制服丝袜av| 日韩一区在线免费观看| 亚洲精品一区在线观看| 欧美美女喷水视频| 在线免费不卡视频| 99久久夜色精品国产网站| 狠狠久久亚洲欧美| 琪琪一区二区三区| 亚洲成人av一区二区三区| 亚洲精品一二三区| 国产精品伦理在线| 国产欧美va欧美不卡在线| 欧美sm极限捆绑bd| 日韩视频在线你懂得| 欧美日韩国产经典色站一区二区三区| 91偷拍与自偷拍精品| 成人av电影观看| 国产91精品精华液一区二区三区 | 欧美一区二区三区不卡| 在线视频国内自拍亚洲视频| 91蝌蚪porny| 99re成人精品视频| 成人精品电影在线观看| 成人激情午夜影院| bt7086福利一区国产| 成人短视频下载| 97久久精品人人澡人人爽| 成人av网站免费| 91视频91自| 91精品福利视频| 欧美在线免费视屏| 欧美精品xxxxbbbb| 欧美一区二区三区视频免费 | 久久久久久久网| 久久先锋影音av鲁色资源| 久久这里只有精品6| 久久久99久久| 国产精品久久久久久久第一福利 | 午夜精品123| 三级一区在线视频先锋| 欧美bbbbb| 国产aⅴ综合色| 91视频xxxx| 欧美精品丝袜久久久中文字幕| 欧美一区二区人人喊爽| 精品国产凹凸成av人网站| 国产亚洲欧美一级| 综合久久久久久| 亚洲风情在线资源站| 免费欧美在线视频| 国产sm精品调教视频网站| 色中色一区二区| 欧美一区三区四区| 国产日韩亚洲欧美综合| 亚洲精品videosex极品| 视频一区欧美精品| 国产精品资源网站| 色一情一伦一子一伦一区| 欧美日韩二区三区| 久久亚洲一级片| 亚洲精品视频免费看| 日本不卡一二三区黄网| 成人性生交大片| 欧美精品久久天天躁| 久久久亚洲欧洲日产国码αv| 亚洲欧洲精品天堂一级| 日韩在线一二三区| 成人一区二区三区在线观看| 欧美三级在线视频| 国产视频一区在线播放| 亚洲午夜久久久久久久久电影院| 激情丁香综合五月| 欧洲在线/亚洲| 久久久综合视频| 亚洲成a人v欧美综合天堂| 国产精品小仙女| 欧美日韩黄色一区二区| 久久久噜噜噜久久人人看| 色综合天天综合给合国产| 777久久久精品| 欧美经典三级视频一区二区三区| 午夜精品久久一牛影视| 成人手机电影网| 777久久久精品| 亚洲精品伦理在线| 国产精品一品二品| 日韩一卡二卡三卡| 亚洲精品午夜久久久| 国产成人av自拍| 日韩三级伦理片妻子的秘密按摩| 中文字幕永久在线不卡| 久久se这里有精品| 欧美在线观看视频一区二区三区| 国产婷婷一区二区| 国内精品写真在线观看| 欧美二区乱c少妇| 亚洲欧美日韩国产成人精品影院 | 亚洲欧洲中文日韩久久av乱码| 久久91精品国产91久久小草| 欧美天天综合网| 亚洲人精品午夜| 国产+成+人+亚洲欧洲自线| 日韩午夜电影av| 日韩精品三区四区| 欧美在线观看视频一区二区| 专区另类欧美日韩| 不卡高清视频专区| 久久久久久久av麻豆果冻| 精品一区二区三区香蕉蜜桃| 91精品国产综合久久久久| 亚洲一二三四久久| 91福利在线看| 亚洲久本草在线中文字幕| 成人短视频下载| 中文字幕中文乱码欧美一区二区| 国产精品99久久久久久久vr | 久久奇米777| 久久99深爱久久99精品| 91精品国产综合久久精品app| 亚洲高清免费视频| 欧美手机在线视频| 亚洲成人免费视频| 欧美男同性恋视频网站| 五月天亚洲精品| 欧美区在线观看| 日本三级亚洲精品| 欧美一区二区三区在线观看| 久久精品99国产精品| 精品日韩一区二区| 国产美女精品在线| 国产精品乱码人人做人人爱| 成人小视频在线| 亚洲六月丁香色婷婷综合久久 | 在线亚洲一区观看| 亚洲成人你懂的| 日韩欧美国产1| 激情欧美一区二区三区在线观看| 久久嫩草精品久久久精品一| 国产成人丝袜美腿| 亚洲色图在线视频| 欧美性色综合网| 日韩国产一二三区| 欧美精品一区男女天堂| 国产999精品久久久久久| 成人欧美一区二区三区1314 | 在线不卡欧美精品一区二区三区| 日韩精品成人一区二区在线| 精品少妇一区二区三区免费观看 | www.日韩精品| 亚洲免费在线播放| 欧美老女人在线| 国产一区二三区好的| 国产精品沙发午睡系列990531| 色综合一个色综合亚洲| 天天做天天摸天天爽国产一区| 精品国产一区二区三区久久影院| 国产999精品久久久久久| 夜夜嗨av一区二区三区| 日韩欧美国产精品| 91蜜桃网址入口| 秋霞成人午夜伦在线观看| 久久精品视频一区| 欧美三级在线视频| 国产成人精品免费网站| 亚洲综合图片区| 久久伊99综合婷婷久久伊| 色婷婷精品大视频在线蜜桃视频| 奇米精品一区二区三区在线观看| 国产精品蜜臀在线观看| 91精品国产综合久久久久久久久久| 国产白丝精品91爽爽久久| 夜夜嗨av一区二区三区四季av| 久久免费美女视频| 欧美日韩一区二区欧美激情| 久久99精品久久久| 亚洲愉拍自拍另类高清精品| 久久香蕉国产线看观看99| 欧美三级日韩三级| 成人免费高清在线观看| 美女一区二区久久| 亚洲人成精品久久久久久| 精品国产一区二区精华| 欧洲亚洲国产日韩| 成人一道本在线| 久久97超碰国产精品超碰| 午夜激情一区二区三区| 综合婷婷亚洲小说| 国产女人18毛片水真多成人如厕 | 国产精品中文欧美| 视频精品一区二区| 亚洲最大成人网4388xx| 国产精品久久久久久久久晋中|