$title('crport - create a port and attach a buffer pool to it') $compact crport: DO; $include(:rmx:inc/rmxplm.ext) $include(:rmx:inc/error.lit) $include(dcom.lit) $include(err.ext) DECLARE NOEXCEPT LITERALLY '0'; /* no exception handling by system */ $eject $subtitle('create$buf$pool') /******************************************************************** * * PROC NAME: create$buf$pool * * DESCRIPTION: Create a buffer pool with the attributes passed by the caller. * Create an initial number of 1K buffers and release them to the * buffer pool. Return a token for the buffer pool to the caller. * * CALL: buf$pool$tok = create$buf$pool(max_bufs, init_num_bufs, * attrs, status_ptr); * INPUTS: max_bufs - maximum number of buffers for buffer pool * init_num_bufs - initial number of buffers for buffer * pool. * attrs - buffer pool creation attributes * status_ptr - points to a status word * * RETURNS: buf$pool$tok - token for newly created buffer pool * *********************************************************************/ create$buf$pool: PROCEDURE(max_bufs, init_num_bufs, attrs, status_ptr) TOKEN PUBLIC; DECLARE /* Parameters */ max_bufs WORD, /* maximum number of buffers in buffer pool */ init_num_bufs WORD, /* initial number of buffers in pool */ attrs WORD, /* buffer pool creation attributes */ status_ptr POINTER; /* exception pointer */ DECLARE /* Local Variables */ status BASED status_ptr WORD , buf_pool TOKEN, /* buffer pool complete with buffers */ buf_tok TOKEN, /* buffer token */ i WORD; /* local index */ DECLARE /* Literals */ BUFSIZE LITERALLY '1026', /* buffer size - must be at least (max_num_chain_elements * 8) + 2 */ BFLAGS LITERALLY '010B'; /* single buffer, don't release */ buf_pool = rq$create$buffer$pool(max_bufs, attrs, status_ptr); CALL error$check(10, status); DO i = 1 to init_num_bufs; buf_tok = rq$create$segment(BUFSIZE, status_ptr); CALL error$check(20, status); CALL rq$release$buffer(buf_pool, buf_tok, BFLAGS, status_ptr); CALL error$check(30, status); END; RETURN buf_pool; END create$buf$pool; $eject $subtitle('get$dport') /******************************************************************** * * PROC NAME: get$dport * * DESCRIPTION: This procedure creates a port for data transport service. * A buffer pool is created and attached to the port. * A token for the newly created port and buffer pool are * returned to the caller. * * CALL: dport$tok = get$dport(port_num,buf_pool_ptr, b_attrs, * status_ptr) * * INPUTS: port_num - port number assigned to newly created port * b_attrs - buffer pool creation attributes * status_ptr - points to status word * OUTPUTS: buf_pool_ptr - points to buffer pool token attached to * the newly created port * RETURNS: dport$tok - token to newly created port * *********************************************************************/ get$dport: PROCEDURE(port_num, buf_pool_ptr,b_attrs, status_ptr) TOKEN PUBLIC; DECLARE /* Parameters */ port_num WORD, /* port id for new port */ buf_pool_ptr POINTER, /* points to buffer pool */ b_attrs WORD, /* buffer pool creation attributes */ status_ptr POINTER; DECLARE /* Literals */ NUM_TRANS LITERALLY '10', /* max number outstanding trans at port */ DATACOM LITERALLY '2', /* indicates data com port */ PFLAGS LITERALLY '0', /* fifo, fragmentation flags */ MAXBUFS LITERALLY '30', /* maximum # buffers in pool */ INITBUFS LITERALLY '10'; /* initial number of buffers */ DECLARE /* locals */ bpool BASED buf_pool_ptr TOKEN, port_t TOKEN, /* local port */ bufpool_t TOKEN, /* buffer pool with initial alloc of buffers */ port_info port_info_s, loc_status WORD, /* local status word */ status BASED status_ptr WORD; /* Begin get$dport */ port_info.port_id = port_num; port_info.type = DATACOM; port_info.reserved = 0; port_info.flags = PFLAGS; port_t = rq$create$port(NUM_TRANS, @port_info, status_ptr); CALL error$check(40, status); bufpool_t = create$buf$pool(MAXBUFS, INITBUFS, b_attrs, status_ptr); CALL error$check(50, status); bpool = bufpool_t; CALL rq$attach$buffer$pool(bufpool_t, port_t, status_ptr); CALL error$check(60, status); RETURN port_t; END get$dport; END crport;