source: soft/giet_vm/giet_drivers/rdk_driver.c @ 313

Last change on this file since 313 was 313, checked in by alain, 11 years ago

The main modif is in TTY driver: The hard lock implemented in the
vci_multi_tty component is not used anymore, because this (non cacheable)
lock was not scalable... It has been replaced by a software (cacheable) lock
that has a better scalability in case of hardware cache coherence.
(see the _tty_get_lock() and _tty_release_lock() functions)

File size: 3.6 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File      : rdk_driver.c
3// Date      : 13/02/2014
4// Author    : alain greiner
5// Maintainer: cesar fuguet
6// Copyright (c) UPMC-LIP6
7///////////////////////////////////////////////////////////////////////////////////
8// The rdk_driver.c and rdk_driver.h files are part ot the GIET-VM kernel.
9//
10// This driver supports a virtual disk implemented as a memory segment,
11// in the address space.
12//
13// The _rdk_read() and _rdk_write() blocking functions use a software memcpy,
14// whatever the selected mode. They return only when the transfer is completed.
15// As the number of concurrent accesses is not bounded, these functions
16// don't use the _ioc_lock variable.
17///////////////////////////////////////////////////////////////////////////////////
18
19#include <giet_config.h>
20#include <rdk_driver.h>
21#include <utils.h>
22#include <tty_driver.h>
23#include <ctx_handler.h>
24
25///////////////////////////////////////////////////////////////////////////////
26//       _rdk_init()
27// This function does nothing, and return 0 for success.
28///////////////////////////////////////////////////////////////////////////////
29unsigned int _rdk_init( unsigned int channel )
30{
31    return 0;
32}
33
34///////////////////////////////////////////////////////////////////////////////
35//     _rdk_read()
36// Transfer data from the RAMDISK to a memory buffer.
37// - mode     : BOOT / KERNEL / USER
38// - lba      : first block index on the block device
39// - buffer   : virtual base address of the memory buffer
40// - count    : number of blocks to be transfered.
41// Returns 0 if success, > 0 if error.
42///////////////////////////////////////////////////////////////////////////////
43unsigned int _rdk_read( unsigned int lba, 
44                        unsigned int buffer, 
45                        unsigned int count) 
46{
47
48#if GIET_DEBUG_IOC_DRIVER
49_printf("\n[IOC DEBUG] Enter _rdk_read() at cycle %d"
50        "\n - vaddr   = %x"
51        "\n - sectors = %d"
52        "\n - lba     = %x",
53        _get_proctime(), buffer, count, lba );
54#endif
55
56    char* src = (char*)&seg_ram_disk_base + (512*lba);
57    char* dst = (char*)buffer;
58    _memcpy( dst, src, count*512 );
59
60    return 0;
61}
62
63///////////////////////////////////////////////////////////////////////////////
64//     _rdk_write()
65// Transfer data from a memory buffer to the block device.
66// - mode     : BOOT / KERNEL / USER
67// - lba      : first block index on the block device
68// - buffer   : virtual base address of the memory buffer
69// - count    : number of blocks to be transfered.
70// Returns 0 if success, > 0 if error.
71///////////////////////////////////////////////////////////////////////////////
72unsigned int _rdk_write( unsigned int lba, 
73                         unsigned int buffer, 
74                         unsigned int count ) 
75{
76
77#if GIET_DEBUG_IOC_DRIVER
78_printf("\n[IOC DEBUG] Enter _rdk_write() at cycle %d"
79        "\n - vaddr   = %x"
80        "\n - sectors = %d"
81        "\n - lba     = %x",
82        _get_proctime(), buffer, count, lba );
83#endif
84
85    char* dst = (char*)&seg_ram_disk_base + (512*lba);
86    char* src = (char*)buffer;
87    _memcpy( dst, src, count*512 );
88
89    return 0;
90}
91
92///////////////////////////////////////////////////////////////////////////////
93//     _rdk_get_block_size()
94// This function returns the block_size.
95///////////////////////////////////////////////////////////////////////////////
96unsigned int _rdk_get_block_size() 
97{
98    return 512;
99}
100
101
102// Local Variables:
103// tab-width: 4
104// c-basic-offset: 4
105// c-file-offsets:((innamespace . 0)(inline-open . 0))
106// indent-tabs-mode: nil
107// End:
108// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
109
Note: See TracBrowser for help on using the repository browser.