2009年6月26日 星期五

2009年6月24日 星期三

[ARM] Buffer allocation for device DMA and DCache coherence

For more detailed description, refer Documentation/DMA-mapping.txt.

  • Consistent DMA mappings
    • Synchronous, coherent
    • No cache coherence issue
    • Limited resource, CONSISTENT_DMA_SIZE(usually 2MB)
    • Slow in access, access to memory directly
    • Non-cacheable, Non-bufferable(NCNB)
    • Function
      • Buffer allocation/free: pci_alloc_consistent/pci_free_consistent, dma_alloc_coherent/dma_free_coherent
    * Never use dma_sync_single/dma_map_single on a NCNB memory address, or you will get a BUG().

  • Streaming DMA mappings
    • Cacheable, Bufferable buffer
    • faster, more in quantity (compare to Consistent DMA mappings)
    • Has cache coherence issue
      • Flush the cache, write data to memory (PCI_DMA_TODEVICE) when:
        • After software changes the content of the DMA buffer
        • Before DMA start
      • Invalidate the cache, read data from memory (PCI_DMA_FROMDEVICE) when:
        • Before reading the DMA buffer
        • After DMA stop
    • Function
      • Buffer allocation/free: kmalloc/kfree
      • Map/Unmap: pci_map_single/pci_unmap_single, dma_map_single/dma_unmap_single
      • Cache coherence : dma_sync_single/pci_dma_sync_single/... (PCI_DMA_TODEVICE/PCI_DMA_FROMDEVICE)
    * memory allocated by kmalloc(GPF_DMA) is still cacheable buffer, which would require cache flush/invalidate. (by experience)

    * It seems that cache invalidate will NOT clean the cached write buffer; if there are memory writes without cache flush, even cache invalidation is done after device DMA, the data read may still be the previous cached memory write. So ensure the cache is flushed properly before device starting DMA. (by experience, ARM11MPCore)

Inline Assembly

Professional Linux Programming, p44
The Linux Kernel and the GNU Toolchain
Inline Assembly

__asm__ ( Machine specific assembly instructions
: Machine specific registers affected by the instruction
: Machine specific registers required as inputs)

__asm__ __volatile ("stw %0,0(%1); eieio"
: //no output registers here
: "r"(data), "r"(address));

Consistent buffer size available

include/asm-generic/pci-dma-compat.h: pci_alloc_consistent ->
arch/arm/mm/consistent.c: dma_alloc_coherent ->
arch/arm/mm/consistent.c: __dma_alloc

arch/arm/mm/consistent.c

static void *
__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
pgprot_t prot)
{
(..................)

size >= (CONSISTENT_END - CONSISTENT_BASE)) {

(..................)



arch/arm/mm/consistent.c
/* Sanity check size */
#if (CONSISTENT_DMA_SIZE % SZ_2M)
#error "CONSISTENT_DMA_SIZE must be multiple of 2MiB"
#endif

#define CONSISTENT_END (0xffe00000)
#define CONSISTENT_BASE (CONSISTENT_END - CONSISTENT_DMA_SIZE)


arch/arm/include/asm/memory.h
/*
* Size of DMA-consistent memory region. Must be multiple of 2M,
* between 2MB and 14MB inclusive.
*/
#ifndef CONSISTENT_DMA_SIZE
#define CONSISTENT_DMA_SIZE SZ_2M
#endif

[ARM] Buffer allocated by dma_alloc_coherent cannot be invalidated/cleaned/flushed by dma_cache_maint

Buffer allocated by dma_alloc_coherent cannot be invalidated/cleaned/flushed by dma_cache_maint, or you will get an BUG()

Buffer allocated by dma_alloc_coherent will have address at 0xfXXX_XXXX

arch/arm/mm/consistent.c


/*
* Make an area consistent for devices.
* Note: Drivers should NOT use this function directly, as it will break
* platforms with CONFIG_DMABOUNCE.
* Use the driver DMA support - see dma-mapping.h (dma_sync_*)
*/
void dma_cache_maint(const void *start, size_t size, int direction)
{
const void *end = start + size;

BUG_ON(!virt_addr_valid(start) || !virt_addr_valid(end - 1));

switch (direction) {
case DMA_FROM_DEVICE: /* invalidate only */
dmac_inv_range(start, end);
outer_inv_range(__pa(start), __pa(end));
break;
case DMA_TO_DEVICE: /* writeback only */
dmac_clean_range(start, end);
outer_clean_range(__pa(start), __pa(end));
break;
case DMA_BIDIRECTIONAL: /* writeback and invalidate */
dmac_flush_range(start, end);
outer_flush_range(__pa(start), __pa(end));
break;
default:
BUG();
}
}
EXPORT_SYMBOL(dma_cache_maint);



arch/arm/include/asm/memory.h
#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory)


PAGE_OFFSET=0xc000_0000
high_memory=0xd000_0000

PAGE_OFFSET(0xc000_0000) < addr < high_memory(0xd000_0000)

2009年6月16日 星期二

要不要打『泡』啊

話說每天早上剛到公司,第一件事情就是泡咖啡
公司有提供咖啡機,我自己買了牛奶用微波爐熱一熱
加在一起~~~堪比 史達巴克施 啊....

而就在今天早上,我正泡完咖啡,在洗牛奶杯的時候
我們 天真無邪可愛純真無人能比的 助理小姐 在我旁邊...
輕輕地...說了一句...讓人心動無比、血脈噴張的話.......

「要不要打(ㄆㄠˋ)啊....要不要打(ㄆㄠˋ)啊....要不要打(ㄆㄠˋ)啊....要不要打(ㄆㄠˋ)啊....」(迴音~~~~)

(臉紅~~~~)
(心跳~~~~)

「這...這...男已婚女已嫁,小孩都三個了(按: 是合起來三個),而且七年還沒到~~讓人家...考慮考慮嘛.....」

(被 助理小姐 鐵之拳 打飛~~咻~~~~~~~~~~~~~閃)

這不是我要誤會呀....我知道您說的是 奶泡 啊~~
可是 泡 跟 炮(砲) 發音根本是一樣的嘛~~~~~~

(謎之聲: 但是不是心裡其實是想要的??)
(被 老婆大人的10噸鐵鎚 打飛~~咻~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~閃)

(落井下石的邪惡同事: 打奶(ㄆㄠˋ)也不錯啊~~~)

InsiderInsights 提供美國公司的高層股票交易資料

美國公司的高層買賣股票是要申報的,而這些資料都會公佈出來,以維護投資人權益
可以在這裡查詢
http://www.insiderinsights.com/

Who Is An Insider?
http://www.insiderinsights.com/about/insider.php

Insider Data: An Information Flow To Know! Why investors should use insider data in their investing process.
http://www.insiderinsights.com/about/use_it.php

Why Insider Data Exists
http://www.insiderinsights.com/about/exists.php

Legal Versus Illegal Insider Trading
http://www.insiderinsights.com/about/legal.php

subscribe是很貴的 ($29.95 per month, or $299.50 per year,對我來說很貴....),但是他們有提供免費查詢

免費查詢
http://www.insiderinsights.com/free/



美國Yahoo Finance也有提供這些資料
http://finance.yahoo.com/

先找到一家公司股票資料,可利用 Get Quotes 搜尋
然後左邊有 More on XXXX 找Ownership -> Insider Transaction
其他的資料也很多

2009年6月15日 星期一

國泰世華 匯款指示 (Remittance instruction)

國泰世華銀行
BENEFICIARY BANK: CATHAY UNITED BANK
SWIFT CODE: UWCBTWTP
ADDRESS: NO.65, KUAN CHIEN ROAD,TAIPEI,TAIWAN,R.O.C.

2009年6月12日 星期五

Generating System ACE files

  1. Start iMPACT 10.1
  2. Cancel the "iMPACT Project" window
  3. [(double click)SystemACE]
  4. [Operating Mode: Novice] -> [Next]
  5. [Select System ACE CF Size: Generic]
    [Reserve Space: 0]
    -> [Next]
  6. [Name: (the name you like)]
    [Location: (generated file location)]
    -> [Next]
  7. [Assign Configuration Address and Design Name: (check the address you need, and the name you like)]
    -> [Next]
  8. (Information summary)-> [Finish]
  9. Repeat the following steps until all Config Address is assigned)
    • [Add Device Config Address X: OK]
    • [(Select the bit file)]
    • [Would you like to add another design file to Config Address X: No]
  10. [(double click)Generate File] -> [ACE File Generation Option ...: OK]

2009年6月11日 星期四

話說回來我也是懦夫呀 .....

不好意思,我就是個懦夫.....
http://blogs.myoops.org/lucifer.php/2009/06/08/slave

各位懦夫們請注意!
http://blogs.myoops.org/lucifer.php/2009/06/10/slave2

http://blogs.myoops.org/lucifer.php/2009/06/10/slave2#c59165

這個時代笑貧不笑娼,你婊子當的好好的,我們也不理你。居然還想立貞潔牌坊,這就有點過分了。

(這...這是經典阿~~~)

http://blogs.myoops.org/lucifer.php/2009/06/10/slave2#c59116
(Lucifer:孩子,你媽沒教你嗎?發幾篇不同留言要換IP呀!這樣才能營造眾人聲討的氣氛呀! 114.32.68.41 這個下次換一個了好嗎?)

(查IP!!查IP!!查IP!!)

http://blogs.myoops.org/lucifer.php/2009/06/08/slave#c58887
鳳梨的閩南語為「旺來」
和「On-line」諧音
故稱On-line Game為「鳳梨遊戲」


光看留言就能學到很多了......

2009年6月10日 星期三

Hardware design using ESL

Hardware design using ESL
http://www.eetimes.com/news/design/rss/showArticle.jhtml?articleID=206107055&cid=RSSfeed_eetimes_designRSS

Electronic System Level (ESL)

Integrated ESL flows can be extremely effective for algorithmic-based designs,


1. write untimed C code

to model the system and develop algorithms.

develop a bit-accurate C model partitioned into functions that are roughly equivalent to the major hardware blocks in the system. The conformance tests are then run on the C code to verify correctness.


2. then refined for hardware implementation using C synthesis
automatically generates the RTL implementation

optimize the blocks in the system for hardware implementation. This is based on an iterative process of running high-level synthesis and checking the performance, area and power of each block in the system. The C code is then modified as needed to improve the block

sequential equivalence checking is used to verify that the optimized C code is functionally the same as the "golden" C code

A subset of the system-level simulation is run to verify that all the blocks, including changed blocks, continue to work together as expected. This process continues until all blocks have been optimized for hardware implementation.

Formal equivalence checking is used throughout the process to keep C code refinements in sync with the original untimed model and to comprehensively verify that the RTL functionality matches the C code.

Experienced designers write the initial C code so that much of it can be reused in later refinements. This requires an understanding of how to express hardware detail in C code while maintaining fast simulations.

3. Once all blocks are optimized and the design meets the quality targets, the entire system is synthesized from C to RTL. Sequential equivalence-checking is run once again to verify that the RTL for the ASIC has the exact functionality of the "golden" C code. At this point, a final sign-off verification is run on the RTL before moving on to RTL synthesis.



Three major differences exist between this integrated ESL flow when compared to a traditional flow that uses handwritten RTL

1. by creating C code, designers can focus on the algorithm development, because changes are easier and quicker to make

2. majority of simulation is done in C code, which typically simulates about 10,000 times faster than RTL, allowing more vectors to run in less time

designers have greater opportunity to improve their algorithms and design quality

3. RTL is formally verified. Having an automated, formally verified path from system to RTL guarantees the correctness of the RTL and requires only one RTL simulation.



FPGA in ESL
There are times when an FPGA prototype, instead of a virtual one, is more appropriate.
1. performance of the hardware is subjective
2. the number of vectors required overwhelms even C simulation

1. untimed, bit-accurate C code

tight integration of both hardware and software, which directly influences the verification effort

partitioning needs to consider hardware/software partitioning along with the major hardware blocks in the subsystem

2. The C code is modified to be synthesizable, and high-level synthesis is used to construct RTL for the prototype. This RTL is rarely simulated, because it is immediately put on an FPGA for exhaustive testing

RTL for the FPGA is now the "golden" simulation model

3. Because many of the architectural decisions needed for the FPGA may not apply to the ASIC implementation, a new version of the C code targeted for the ASIC hardware must be developed


eliminates virtually all RTL simulation
C simulation is only used for initial testing and debugging, and the only RTL simulation is for final RTL signoff. By eliminating the traditional long simulation times, this ESL flow delivers massive reductions in the development time and significantly increases the quality of the product

2009年6月7日 星期日

RMA information of Freerunner

OpenMoko Freerunner repair service
http://www.pulster.de/engl/index.html?d__omrepair__OpenMoko_Freerunner_repair_service793.htm

89 eur, include all new service parts and assembling service and return shipping charges


Qinyi ElectronicsCo.,Limited
http://www.qinyielectronics.com/

Accessories for the OpenMoko FreeRunner: Display
http://trisoft.de/en_freerunner_zubehoer.htm

Support
http://wiki.openmoko.org/wiki/Support
Repair/RMA/Return/Swap
* Order from webshop, please contact store@openmoko.com
* Get phone from distributor, please contact distributor directly

What about by group purchase in Taiwan?


Reference mailing list
Re: Broken Screen
http://article.gmane.org/gmane.comp.handhelds.openmoko.community/37011/match=repair
http://thread.gmane.org/gmane.comp.handhelds.openmoko.device-owners/5989/focus=37011
> 1. If it's possible to just puchase a new screen
Yes, at least Trisoft sells screens separately.


Replacing the Openmoko Touchscreen
http://thread.gmane.org/gmane.comp.handhelds.openmoko.community/21845/focus=22460