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

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

?? xilinx-load.c

?? 開放源碼實時操作系統源碼.
?? C
字號:
//==========================================================================
//
//      xilinx-load.c
//
//      FPGA support for NMI uEngine picasso
//
//==========================================================================
//####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);
}

#if 0
/**
 * 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);
}
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品电影院| 国产精品77777竹菊影视小说| 成人性生交大片免费看在线播放| 综合在线观看色| 美女一区二区三区| 色就色 综合激情| 久久久另类综合| 日韩电影在线一区| 欧洲精品视频在线观看| 日本一区二区三区久久久久久久久不| 91精品国产全国免费观看| 国产午夜精品一区二区三区嫩草| 2023国产一二三区日本精品2022| 欧美成人午夜电影| 亚洲国产另类av| 99re热视频精品| 欧美变态tickling挠脚心| 亚洲一区在线观看网站| 成人国产精品免费观看动漫| 精品国产制服丝袜高跟| 亚洲bdsm女犯bdsm网站| 在线观看91视频| 亚洲一区二区3| 一本到不卡免费一区二区| 欧美国产在线观看| 国产精品一区二区果冻传媒| 91精品国产一区二区三区| 亚洲国产aⅴ天堂久久| 欧美最新大片在线看| 亚洲一区二区三区爽爽爽爽爽| 亚洲成人在线观看视频| 欧美亚一区二区| 亚洲一区免费在线观看| 91久久线看在观草草青青| 综合久久国产九一剧情麻豆| 成人高清av在线| 综合欧美亚洲日本| 色香蕉成人二区免费| 一级特黄大欧美久久久| 色婷婷激情综合| 亚洲成人第一页| 欧美一区二区三区免费大片 | 日韩激情一二三区| 欧美在线视频你懂得| 亚洲一二三区视频在线观看| 欧美图片一区二区三区| 亚洲一区在线免费观看| 欧美一区国产二区| 国产真实乱子伦精品视频| 国产日韩在线不卡| 99精品黄色片免费大全| 亚洲一区二区三区四区在线免费观看 | 在线欧美一区二区| 午夜精品一区二区三区电影天堂 | 午夜精彩视频在线观看不卡| 欧美日韩中字一区| 韩国精品久久久| 中文字幕一区二区三区四区不卡| 偷拍一区二区三区| 91麻豆精品国产91久久久资源速度| 久久伊人蜜桃av一区二区| 国产精品资源网| 亚洲欧洲精品天堂一级 | 亚洲成人动漫在线免费观看| 欧美一级夜夜爽| 国产成人精品影院| 亚洲国产一区视频| 国产视频一区在线播放| 色美美综合视频| 国产在线一区二区综合免费视频| 欧美偷拍一区二区| 开心九九激情九九欧美日韩精美视频电影 | 欧美日韩国产经典色站一区二区三区| 国产亚洲制服色| 欧美色图一区二区三区| 国产精品综合网| 亚洲国产一区二区三区青草影视| www.在线成人| 免费成人你懂的| 一区二区三区成人在线视频| 亚洲精品一线二线三线无人区| 亚洲国产精品麻豆| 国产网站一区二区三区| 91.com在线观看| 99国产精品国产精品毛片| 极品瑜伽女神91| 亚洲一二三四在线| 国产日本欧美一区二区| 欧美肥胖老妇做爰| 日本国产一区二区| 成人午夜电影网站| 久久精品国产久精国产爱| 亚洲aaa精品| 亚洲一二三专区| 亚洲人快播电影网| 国产精品国产三级国产三级人妇| 99精品视频免费在线观看| 国内不卡的二区三区中文字幕 | 国产蜜臀av在线一区二区三区| 国内成人精品2018免费看| 亚洲五码中文字幕| 一区二区久久久| 亚洲伦理在线免费看| 国产精品久久久爽爽爽麻豆色哟哟 | 制服丝袜成人动漫| 在线观看日韩国产| 精品视频999| 欧美日韩免费电影| 欧美精品久久一区| 欧美性色综合网| 欧美亚洲丝袜传媒另类| 欧美中文字幕一二三区视频| 99久久国产综合精品麻豆 | 中文字幕第一区| 国产日产欧美一区| 国产亚洲精品bt天堂精选| 日韩精品中文字幕一区二区三区| 国产高清视频一区| 成人黄色综合网站| 色婷婷久久99综合精品jk白丝 | 91精彩视频在线| 91丝袜美女网| 91免费看视频| 欧美亚洲精品一区| 欧美日韩成人激情| 91麻豆精品国产91久久久久| 欧美一卡2卡3卡4卡| 欧美tickle裸体挠脚心vk| 久久品道一品道久久精品| 久久久电影一区二区三区| 日本一区二区三区四区在线视频| 欧美日韩1234| 日韩欧美视频一区| 综合分类小说区另类春色亚洲小说欧美| 欧美中文字幕一区| 欧美亚洲国产一区二区三区va| 成人性色生活片| 欧美视频一区二区三区四区 | 国产精品国模大尺度视频| 亚洲欧洲日韩一区二区三区| 亚洲欧美经典视频| 亚欧色一区w666天堂| 久久99热这里只有精品| 粉嫩13p一区二区三区| 91精品1区2区| 精品国产精品一区二区夜夜嗨 | 97国产一区二区| 欧美日韩黄色一区二区| 欧美成人精品3d动漫h| 亚洲精品一区二区三区福利| 中文字幕一区免费在线观看 | 一区二区三区蜜桃| 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲免费观看在线观看| 日韩激情一二三区| 成人午夜视频在线观看| 欧美精品三级在线观看| 国产精品人成在线观看免费| 日韩国产欧美在线播放| 成人av手机在线观看| 欧美一级黄色大片| 亚洲欧美视频一区| 国产一区二区精品在线观看| 91国偷自产一区二区开放时间 | 日韩欧美国产系列| 亚洲欧洲精品一区二区三区不卡| 国产视频在线观看一区二区三区| 日韩久久久精品| 亚洲一区二区三区三| 丰满岳乱妇一区二区三区| 欧洲激情一区二区| 中文字幕一区二区三区不卡| 精品影视av免费| 色八戒一区二区三区| 国产情人综合久久777777| 视频在线观看91| 91国产免费观看| 国产精品电影院| 国产精品88av| 久久久www成人免费无遮挡大片| 久久综合九色综合欧美98 | 国产精品午夜在线观看| 老司机免费视频一区二区| 欧美少妇bbb| 亚洲精品视频免费观看| 波多野结衣亚洲| 欧美激情一区二区三区在线| 蜜桃精品在线观看| 3d成人动漫网站| 日产国产欧美视频一区精品| 欧美在线免费视屏| 亚洲一级在线观看| 欧美天堂亚洲电影院在线播放| 欧美va亚洲va| 麻豆成人综合网| 欧美一级精品大片| 精品综合久久久久久8888| 精品国产污网站| 国产伦精品一区二区三区视频青涩| 成人国产亚洲欧美成人综合网|