예제 #1
0
파일: control.c 프로젝트: imphil/sources
void control_channel_send(struct endpoint_handle *ep, uint8_t *data, uint32_t size) {
    unsigned int words = (size+3)>>2;
    unsigned int wordsperpacket = optimsoc_noc_maxpacketsize()-4;

    for (int i=0;i<words;i=i+wordsperpacket) {
        ctrl_request.buffer[0] = (ep->domain << OPTIMSOC_DEST_LSB) |
                (1 << OPTIMSOC_CLASS_LSB) |
                (optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
                (CTRL_REQUEST_CHAN_DATA << CTRL_REQUEST_LSB);
        ctrl_request.buffer[1] = (unsigned int) ep->ep;
        ctrl_request.buffer[2] = i;
        if (((i+wordsperpacket) >= words)) {
            ctrl_request.buffer[3] = size - i * wordsperpacket;
        } else {
            ctrl_request.buffer[3] = 0;
        }

        int sz = words - i;
        if (sz>wordsperpacket)
            sz = wordsperpacket;

        for (int d=0;d<sz;d++) {
            ctrl_request.buffer[4+d] = ((unsigned int *)data)[i+d];
        }

        optimsoc_mp_simple_send(4+sz,ctrl_request.buffer);
    }
}
예제 #2
0
파일: control.c 프로젝트: chethann/optimsoc
void control_msg_data(struct endpoint_handle *ep, uint32_t address, void* buffer,
                      uint32_t size) {
    // TODO: what if size%4!=0?
    assert(size % 4 == 0);

    trace_msg_data_begin(ep, address, size);

    unsigned int words = (size+3)>>2;
    unsigned int wordsperpacket = optimsoc_noc_maxpacketsize()-4;

    for (int i=0;i<words;i=i+wordsperpacket) {
        ctrl_request.buffer[0] = (ep->domain << OPTIMSOC_DEST_LSB) |
                (1 << OPTIMSOC_CLASS_LSB) |
                (optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
                (CTRL_REQUEST_MSG_DATA << CTRL_REQUEST_LSB);
        ctrl_request.buffer[1] = (unsigned int) ep->ep;
        ctrl_request.buffer[2] = (uint32_t) address;
        ctrl_request.buffer[3] = i;

        int sz = words - i;
        if (sz>wordsperpacket)
            sz = wordsperpacket;

        for (int d=0;d<sz;d++) {
            ctrl_request.buffer[2+d] = ((unsigned int *)buffer)[i+d];
        }

        trace_msg_data_send(ep, ctrl_request.buffer[2], sz);
        optimsoc_mp_simple_send(2+sz,ctrl_request.buffer);
    }

    ctrl_request.buffer[0] = (ep->domain << OPTIMSOC_DEST_LSB) |
            (1 << OPTIMSOC_CLASS_LSB) |
            (optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
            (CTRL_REQUEST_MSG_COMPLETE << CTRL_REQUEST_LSB);
    ctrl_request.buffer[1] = (unsigned int) ep->ep;
    ctrl_request.buffer[2] = (uint32_t) address;
    ctrl_request.buffer[3] = size;

    trace_msg_complete_send(ep, address, size);
    optimsoc_mp_simple_send(4, ctrl_request.buffer);

    trace_msg_data_end(ep);
}