shared memory driver(1)

data structure:

(一) data structure:

1. shared memory for write:

Changed the write pointer.
the shared write buffer:        buffer[SMD_BUFFER_SIZE],
indicating the write start location    write, can be opreated,
indicating the read start location    read, just can be read, not be write
what about the size? Is it just mean the size of the buffer? Not others?
typedef struct smd_tx_stream_tag
{
    unsigned int write;
    const unsigned int read;
    unsigned int size;
    const unsigned char res[20];
    unsigned char   buffer[SMD_BUFFER_SIZE];
    const unsigned char   protection[32];
} __attribute__ ((packed)) T_SMD_TX_STREAM;

2. shared memory for read:

Changed the read pointer.
typedef struct smd_rx_stream_tag
{
    const unsigned int write;
    unsigned int read;
    const unsigned int size;
    const unsigned char res[20];
    const unsigned char   buffer[SMD_BUFFER_SIZE];
    const unsigned char   protection[32];   /*boundary protection*/
} __attribute__ ((packed)) T_SMD_RX_STREAM;

3. channel

3.1 stream channel

stream channel integrated the tx/rx stream
using the stream channel to discriptor the tx/rx stream
and the ap,bp stream state.
typedef struct smd_stream_channel_tag
{
        unsigned int ap_ch_status;
        const unsigned int bp_ch_status;
    const unsigned char res[24];
        T_SMD_TX_STREAM tx_stream;
        T_SMD_RX_STREAM rx_stream;
    const unsigned char   protection[32]; /*boundary protection*/
} __attribute__ ((packed)) T_SMD_STREAM_CHANNEL;

3.2 state channel

discriptor the ab,bp system state
typedef struct smd_state_channel_tag
{
    unsigned int         ap_state;
    const unsigned int     bp_state;
    const unsigned char       res[24];
    const unsigned char      protection[32];   /*boundary protection*/
}__attribute__ ((packed)) T_SMD_STATE_CHANNEL;

4 smd_map

integrated all the channels i.e. the whole shared memory
struct smd_map
{
    T_SMD_STATE_CHANNEL  ch0; //state
    T_SMD_STREAM_CHANNEL ch1;
    T_SMD_STREAM_CHANNEL ch2;
    T_SMD_STREAM_CHANNEL ch3;
    T_SMD_STREAM_CHANNEL ch4;
    T_SMD_STREAM_CHANNEL ch5;
    T_SMD_STREAM_CHANNEL ch6;
};

5 the added data structure in driver

5.1 a specific smd tty

struct smd_tty_info
{
    int id;
    /* the common tty data structure
         * write operation: tx stream, read operation: rx stream
     */
    struct tty_port port;
    /*the hardware corresponding:*/
    int a2b_int_sc;
    int a2b_int_tx;
    int a2b_int_rx;
    int b2a_irq_sc;
    int b2a_irq_tx;
    int b2a_irq_rx;
    T_SMD_STREAM_CHANNEL *ch;
};

5.2 global smd tty descriptor

struct smd_driver_info
{
    struct smd_map *map;
    struct smd_tty_info smd_tty[SMD_TTY_MAX];
    struct class *k2u_class;
    struct device *modem_dev;
    unsigned int ap_state;/*should be deleted, exist */
    unsigned int bp_state;
    struct work_struct    uevent_work;
};


你可能感兴趣的:(memory,shared)