📄 l1_command.c
字号:
rack = 0; t = rnum / 100; /* rack class (CPU/IO) */ if (t > RACK_CLASS_MASK(rack) >> RACK_CLASS_SHFT(rack)) return ELSC_ERROR_MODULE; RACK_ADD_CLASS(rack, t); rnum %= 100; t = rnum / 10; /* rack group */ if (t > RACK_GROUP_MASK(rack) >> RACK_GROUP_SHFT(rack)) return ELSC_ERROR_MODULE; RACK_ADD_GROUP(rack, t); t = rnum % 10; /* rack number (one-based) */ if (t-1 > RACK_NUM_MASK(rack) >> RACK_NUM_SHFT(rack)) return ELSC_ERROR_MODULE; RACK_ADD_NUM(rack, t); for( t = 0; t < MAX_BRICK_TYPES; t++ ) { if( brick_types[t] == bricktype ) return RBT_TO_MODULE(rack, bay, t); } return ELSC_ERROR_MODULE;}int elsc_partition_set(elsc_t *e, int partition){ char msg[BRL1_QSIZE]; /* L1 request/response info */ int subch; /* system controller subchannel used */ int len; /* length of message */ /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); if( (subch = sc_open( e, L1_ADDR_LOCAL )) < 0 ) { return ELSC_ERROR_CMD_SEND; } if( (len = sc_construct_msg( e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_PARTITION_SET, 2, L1_ARG_INT, partition )) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( sc_command( e, subch, msg, msg, &len ) ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( e, subch ); /* check response */ if( sc_interpret_resp( msg, 0 ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return( 0 );}int elsc_partition_get(elsc_t *e){ char msg[BRL1_QSIZE]; /* L1 request/response info */ int subch; /* system controller subchannel used */ int len; /* length of message */ uint32_t partition_id; /* used to copy partition id out of msg */ /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); if( (subch = sc_open( e, L1_ADDR_LOCAL )) < 0 ) { return ELSC_ERROR_CMD_SEND; } if( (len = sc_construct_msg( e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_PARTITION_GET, 0 )) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( sc_command( e, subch, msg, msg, &len ) ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( e, subch ); /* check response */ if( sc_interpret_resp( msg, 2, L1_ARG_INT, &partition_id ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return( partition_id );}/* * elsc_cons_subch selects the "active" console subchannel for this node * (i.e., the one that will currently receive input) */int elsc_cons_subch(elsc_t *e, uint ch){ char msg[BRL1_QSIZE]; /* L1 request/response info */ int subch; /* system controller subchannel used */ int len; /* length of message */ /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); subch = sc_open( e, L1_ADDR_LOCAL ); if( (len = sc_construct_msg( e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_CONS_SUBCH, 2, L1_ARG_INT, ch)) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( SC_COMMAND( e, subch, msg, msg, &len ) ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( e, subch ); /* check response */ if( sc_interpret_resp( msg, 0 ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return 0;}/* * elsc_cons_node should only be executed by one node. It declares to * the system controller that the node from which it is called will be * the owner of the system console. */int elsc_cons_node(elsc_t *e){ char msg[BRL1_QSIZE]; /* L1 request/response info */ int subch; /* system controller subchannel used */ int len; /* length of message */ /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); subch = sc_open( e, L1_ADDR_LOCAL ); if( (len = sc_construct_msg( e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_CONS_NODE, 0 )) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( SC_COMMAND( e, subch, msg, msg, &len ) ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( e, subch ); /* check response */ if( sc_interpret_resp( msg, 0 ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return 0;} /* elsc_display_line writes up to 12 characters to either the top or bottom * line of the L1 display. line points to a buffer containing the message * to be displayed. The zero-based line number is specified by lnum (so * lnum == 0 specifies the top line and lnum == 1 specifies the bottom). * Lines longer than 12 characters, or line numbers not less than * L1_DISPLAY_LINES, cause elsc_display_line to return an error. */int elsc_display_line(elsc_t *e, char *line, int lnum){ char msg[BRL1_QSIZE]; int subch; /* system controller subchannel used */ int len; /* number of msg buffer bytes used */ /* argument sanity checking */ if( !(lnum < L1_DISPLAY_LINES) ) return( ELSC_ERROR_CMD_ARGS ); if( !(strlen( line ) <= L1_DISPLAY_LINE_LENGTH) ) return( ELSC_ERROR_CMD_ARGS ); /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); subch = sc_open( (l1sc_t *)e, L1_ADDR_LOCAL ); if( (len = sc_construct_msg( (l1sc_t *)e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, (L1_REQ_DISP1+lnum), 2, L1_ARG_ASCII, line )) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( SC_COMMAND( (l1sc_t *)e, subch, msg, msg, &len ) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( (l1sc_t *)e, subch ); /* check response */ if( sc_interpret_resp( msg, 0 ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return 0;}/* elsc_display_mesg silently drops message characters beyond the 12th. */int elsc_display_mesg(elsc_t *e, char *chr){ char line[L1_DISPLAY_LINE_LENGTH+1]; int numlines, i; int result; numlines = (strlen( chr ) + L1_DISPLAY_LINE_LENGTH - 1) / L1_DISPLAY_LINE_LENGTH; if( numlines > L1_DISPLAY_LINES ) numlines = L1_DISPLAY_LINES; for( i = 0; i < numlines; i++ ) { strncpy( line, chr, L1_DISPLAY_LINE_LENGTH ); line[L1_DISPLAY_LINE_LENGTH] = '\0'; /* generally we want to leave the first line of the L1 display * alone (so the L1 can manipulate it). If you need to be able * to display to both lines (for debugging purposes), define * L1_DISP_2LINES in irix/kern/ksys/l1.h, or add -DL1_DISP_2LINES * to your 'defs file. */#if defined(L1_DISP_2LINES) if( (result = elsc_display_line( e, line, i )) < 0 )#else if( (result = elsc_display_line( e, line, i+1 )) < 0 )#endif return result; chr += L1_DISPLAY_LINE_LENGTH; } return 0;}int elsc_password_set(elsc_t *e, char *password){ /* shush compiler */ e = e; password = password; /* fill in buffer with the opcode & params; call elsc_command */ return 0;}int elsc_password_get(elsc_t *e, char *password){ /* shush compiler */ e = e; password = password; /* fill in buffer with the opcode & params; call elsc_command */ return 0;}/* * sc_portspeed_get * * retrieve the current portspeed setting for the bedrock II */int sc_portspeed_get(l1sc_t *sc){ char msg[BRL1_QSIZE]; int len; /* length of message being sent */ int subch; /* system controller subchannel used */ int portspeed_a, portspeed_b; /* ioport clock rates */ bzero( msg, BRL1_QSIZE ); subch = sc_open( sc, L1_ADDR_LOCAL ); if( (len = sc_construct_msg( sc, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_PORTSPEED, 0 )) < 0 ) { sc_close( sc, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( sc_command( sc, subch, msg, msg, &len ) < 0 ) { sc_close( sc, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( sc, subch ); /* check response */ if( sc_interpret_resp( msg, 4, L1_ARG_INT, &portspeed_a, L1_ARG_INT, &portspeed_b ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } /* for the c-brick, we ignore the portspeed_b value */ return (portspeed_a ? 600 : 400);}/* * elsc_power_query * * To be used after system reset, this command returns 1 if the reset * was the result of a power-on, 0 otherwise. * * The power query status is cleared to 0 after it is read. */int elsc_power_query(elsc_t *e){ e = e; /* shush the compiler */ /* fill in buffer with the opcode & params; call elsc_command */ return 1;}int elsc_rpwr_query(elsc_t *e, int is_master){ /* shush the compiler */ e = e; is_master = is_master; /* fill in buffer with the opcode & params; call elsc_command */ return 0;} /* * elsc_power_down * * Sets up system to shut down in "sec" seconds (or modifies the * shutdown time if one is already in effect). Use 0 to power * down immediately. */int elsc_power_down(elsc_t *e, int sec){ /* shush compiler */ e = e; sec = sec; /* fill in buffer with the opcode & params; call elsc_command */ return 0;}int elsc_system_reset(elsc_t *e){ char msg[BRL1_QSIZE]; int subch; /* system controller subchannel used */ int len; /* number of msg buffer bytes used */ int result; /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); if( (subch = sc_open( e, L1_ADDR_LOCAL )) < 0 ) { return ELSC_ERROR_CMD_SEND; } if( (len = sc_construct_msg( e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_RESET, 0 )) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( (result = sc_command( e, subch, msg, msg, &len )) ) { sc_close( e, subch ); if( result == SC_NMSG ) { /* timeout is OK. We've sent the reset. Now it's just * a matter of time... */ return( 0 ); } return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( e, subch ); /* check response */ if( sc_interpret_resp( msg, 0 ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return 0;}int elsc_power_cycle(elsc_t *e){ /* shush compiler */ e = e; /* fill in buffer with the opcode & params; call sc_command */ return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -