コード例 #1
0
/* this function must be called with interrupt disabled */
static void clear_all_buffer(struct r8a66597 *r8a66597,
			     struct r8a66597_pipe *pipe)
{
	u16 tmp;

	if (!pipe || pipe->info.pipenum == 0)
		return;

	pipe_stop(r8a66597, pipe);
	r8a66597_bset(r8a66597, ACLRM, pipe->pipectr);
	tmp = r8a66597_read(r8a66597, pipe->pipectr);
	tmp = r8a66597_read(r8a66597, pipe->pipectr);
	tmp = r8a66597_read(r8a66597, pipe->pipectr);
	r8a66597_bclr(r8a66597, ACLRM, pipe->pipectr);
}
コード例 #2
-1
ファイル: lms_entry.c プロジェクト: Makarevich/lsamod-digest
/* service_main */
static VOID WINAPI service_main(DWORD argc, LPTSTR *argv) {
    config_t        conf;
    void*           net;
    void*           threads;
    void*           pipe;

    h_service = RegisterServiceCtrlHandler(LDMSVC_SERVICE_NAME, handler);
    if(h_service == NULL) {
        return;
    }

    set_state1(SERVICE_START_PENDING);        // SERVICE_START_PENDING

    // open the heap
    if(!heap_start()) {
        dout("Failed to create the heap\n");
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    // parse configuration
    if(!config_parse_args(&conf, argc, argv)) {
        heap_stop();
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    if(0) {
        dout(va("PORT: %u\n", conf.port));
        dout(va("PIPE: %s\n", conf.pipe));
        dout(va("MAXC: %u\n", conf.maxconn));
    }

    // open network
    if((net = net_start()) == NULL) {
        heap_stop();
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    // open the pipe
    if((pipe = pipe_start(conf.pipe)) == NULL) {
        net_stop(net);
        heap_stop();
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    // connect the pipe
    if(!pipe_open(pipe)) {
        pipe_stop(pipe);
        net_stop(net);
        heap_stop();
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    // start threads
    if((threads = threads_start(net, pipe, conf.maxconn)) == NULL) {
        pipe_stop(pipe);
        net_stop(net);
        heap_stop();
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    set_state1(SERVICE_RUNNING);              // SERVICE_RUNNING

    while(svc_state == SERVICE_RUNNING) {
        if(!net_is_ready(net)) {
            net_bind(net, NULL, conf.port);
        }

        if(!threads_think(threads)) {
            break;
        }

        Sleep(1);
    }

    set_state1(SERVICE_STOP_PENDING);         // SERVICE_STOP_PENDING

    // close everything here
    threads_stop(threads);
    pipe_stop(pipe);
    net_stop(net);
    heap_stop();

    set_state2(SERVICE_STOPPED, 0);           // SERVICE_STOPPED
}