用户操作
[即时聊天] [发私信] [加为好友]
fudan_abc
最近评论
yzdai:知道了,是SCSI设备号,CH,...等
yzdai:粗过了一遍.很棒很棒是不用多说.有些调用例就更好了.不是fs而是系统的调用例,比如禁止/允许USB/SCSI端口或设备,或取参数.还有漏掉的图.
zlzdsp或楼主有WORD/PDF请发一下或放在CSDN上.
"...,比如/dev/sda,然后读写这个文件就可以了"是对的.
"没有命令界面"是说没有console,要在自启动文件里自动运行应用程序.那也一样.<……
yzdai:粗过了一遍.很棒很棒是不用多说.有些调用例就更好了.不是fs而是系统的调用例,比如禁止/允许USB/SCSI端口或设备,或取参数.还有漏掉的图.
zlzdsp或楼主有WORD/PDF请发一下或放在CSDN上.
"...,比如/dev/sda,然后读写这个文件就可以了"是对的.
"没有命令界面"是说没有console,要在自启动文件里自动运行应用程序.那也一样.<……
yzdai:在过度疲劳的工作中看到楼主的文章,失笑了多回了.
虽然没太懂,也没来得及看完.我借助它解决了SCSI 设备号固定于硬端口的问题.
赞一个: 是金子总是要发光的.
yzdai:sd 2:0:0:0: Attached scsi removable disk sda
请问上面的 2:0:0:0 的含义?
文章分类
收藏
    相册
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky

    原创 kdb代码分析(七)收藏

     | 旧一篇: kdb代码分析(六)

    在大家都进入了kdb之后,in control的那个cpu就开始执行1566行的kdb_local()函数了.依然定义于kdb/kdbmain.c:

       1134 /*

       1135  * kdb_local

       1136  *

       1137  *      The main code for kdb.  This routine is invoked on a specific

       1138  *      processor, it is not global.  The main kdb() routine ensures

       1139  *      that only one processor at a time is in this routine.  This

       1140  *      code is called with the real reason code on the first entry

       1141  *      to a kdb session, thereafter it is called with reason SWITCH,

       1142  *      even if the user goes back to the original cpu.

       1143  *

       1144  * Inputs:

       1145  *      reason          The reason KDB was invoked

       1146  *      error           The hardware-defined error code

       1147  *      regs            The exception frame at time of fault/breakpoint.  NULL

       1148  *                      for reason SILENT or CPU_UP, otherwise valid.

       1149  *      db_result       Result code from the break or debug point.

       1150  * Returns:

       1151  *      0       KDB was invoked for an event which it wasn't responsible

       1152  *      1       KDB handled the event for which it was invoked.

       1153  *      KDB_CMD_GO      User typed 'go'.

       1154  *      KDB_CMD_CPU     User switched to another cpu.

       1155  *      KDB_CMD_SS      Single step.

       1156  *      KDB_CMD_SSB     Single step until branch.

       1157  * Locking:

       1158  *      none

       1159  * Remarks:

       1160  *      none

       1161  */

       1162

       1163 static int

       1164 kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, kdb_dbtrap_t db_result)

       1165 {

       1166         char *cmdbuf;

       1167         int diag;

       1168         struct task_struct *kdb_current = kdb_curr_task(smp_processor_id());

       1169

       1170         /* If kdb has been entered for an event which has been/will be

       1171          * recovered then silently return.  We have to get this far into kdb in

       1172          * order to synchronize all the cpus, typically only one cpu (monarch)

       1173          * knows that the event is recoverable but the other cpus (slaves) may

       1174          * also be driven into kdb before that decision is made by the monarch.

       1175          *

       1176          * To pause in kdb even for recoverable events, 'set RECOVERY_PAUSE 1'

       1177          */

       1178         KDB_DEBUG_STATE("kdb_local 1", reason);

       1179         if (reason == KDB_REASON_ENTER

       1180             && KDB_FLAG(RECOVERY)

       1181             && !KDB_FLAG(CATASTROPHIC)) {

       1182                 int recovery_pause = 0;

       1183                 kdbgetintenv("RECOVERY_PAUSE", &recovery_pause);

       1184                 if (recovery_pause == 0)

       1185                         reason = KDB_REASON_SILENT;

       1186                 else

       1187                         kdb_printf("%s: Recoverable error detected but"

       1188                                    " RECOVERY_PAUSE is set, staying in KDB\n",

       1189                                    __FUNCTION__);

       1190         }

       1191

       1192         KDB_DEBUG_STATE("kdb_local 2", reason);

       1193         kdb_go_count = 0;

       1194         if (kdb_quiet(reason)) {

       1195                 /* no message */

       1196         } else if (reason == KDB_REASON_DEBUG) {

       1197                 /* special case below */

       1198         } else {

       1199                 kdb_printf("\nEntering kdb (current=0x%p, pid %d) ", kdb_current, kdb_current->pid);

       1200 #if defined(CONFIG_SMP)

       1201                 kdb_printf("on processor %d ", smp_processor_id());

       1202 #endif

       1203         }

       1204

       1205         switch (reason) {

       1206         case KDB_REASON_DEBUG:

       1207         {

       1208                 /*

       1209                  * If re-entering kdb after a single step

       1210                  * command, don't print the message.

       1211                  */

       1212                 switch(db_result) {

       1213                 case KDB_DB_BPT:

       1214                         kdb_printf("\nEntering kdb (0x%p, pid %d) ", kdb_current, kdb_current->pid);

       1215 #if defined(CONFIG_SMP)

       1216                         kdb_printf("on processor %d ", smp_processor_id());

       1217 #endif

       1218                         kdb_printf("due to Debug @ " kdb_machreg_fmt "\n", kdba_getpc(regs));

       1219                         break;

       1220                 case KDB_DB_SSB:

       1221                         /*

       1222                          * In the midst of ssb command. Just return.

       1223                          */

       1224                         KDB_DEBUG_STATE("kdb_local 3", reason);

       1225                         return KDB_CMD_SSB;     /* Continue with SSB command */

       1226

       1227                         break;

       1228                 case KDB_DB_SS:

       1229                         break;

       1230                 case KDB_DB_SSBPT:

       1231                         KDB_DEBUG_STATE("kdb_local 4", reason);

       1232                         return 1;       /* kdba_db_trap did the work */

       1233                 default:

       1234                         kdb_printf("kdb: Bad result from kdba_db_trap: %d\n",

       1235                                    db_result);

       1236                         break;

       1237                 }

       1238

       1239         }

       1240                 break;

       1241         case KDB_REASON_ENTER:

       1242                 if (KDB_STATE(KEYBOARD))

       1243                         kdb_printf("due to Keyboard Entry\n");

       1244                 else

       1245                         kdb_printf("due to KDB_ENTER()\n");

       1246                 break;

       1247         case KDB_REASON_KEYBOARD:

       1248                 KDB_STATE_SET(KEYBOARD);

       1249                 kdb_printf("due to Keyboard Entry\n");

       1250                 break;

       1251         case KDB_REASON_ENTER_SLAVE:    /* drop through, slaves only get released via cpu switch */

       1252         case KDB_REASON_SWITCH:

       1253                 kdb_printf("due to cpu switch\n");

       1254                 if (KDB_STATE(GO_SWITCH)) {

       1255                         KDB_STATE_CLEAR(GO_SWITCH);

       1256                         KDB_DEBUG_STATE("kdb_local 5", reason);

       1257                         return KDB_CMD_GO;

       1258                 }

       1259                 break;

       1260         case KDB_REASON_OOPS:

       1261                 kdb_printf("Oops: %s\n", kdb_diemsg);

       1262                 kdb_printf("due to oops @ " kdb_machreg_fmt "\n", kdba_getpc(regs));

       1263                 kdba_dumpregs(regs, NULL, NULL);

       1264                 break;

       1265         case KDB_REASON_NMI:

       1266                 kdb_printf("due to NonMaskable Interrupt @ " kdb_machreg_fmt "\n",

       1267                           kdba_getpc(regs));

       1268                 kdba_dumpregs(regs, NULL, NULL);

       1269                 break;

       1270         case KDB_REASON_BREAK:

       1271                 kdb_printf("due to Breakpoint @ " kdb_machreg_fmt "\n", kdba_getpc(regs));

       1272                 /*

       1273                  * Determine if this breakpoint is one that we

       1274                  * are interested in.

       1275                  */

       1276                 if (db_result != KDB_DB_BPT) {

       1277                         kdb_printf("kdb: error return from kdba_bp_trap: %d\n", db_result);

       1278                         KDB_DEBUG_STATE("kdb_local 6", reason);

       1279                         return 0;       /* Not for us, dismiss it */

       1280                 }

       1281                 break;

       1282         case KDB_REASON_RECURSE:

       1283                 kdb_printf("due to Recursion @ " kdb_machreg_fmt "\n", kdba_getpc(regs));

       1284                 break;

       1285         case KDB_REASON_CPU_UP:

       1286         case KDB_REASON_SILENT:

       1287                 KDB_DEBUG_STATE("kdb_local 7", reason);

       1288                 if (reason == KDB_REASON_CPU_UP)

       1289                         kdba_cpu_up();

       1290                 return KDB_CMD_GO;      /* Silent entry, silent exit */

       1291                 break;

       1292         default:

       1293                 kdb_printf("kdb: unexpected reason code: %d\n", reason);

       1294                 KDB_DEBUG_STATE("kdb_local 8", reason);

       1295                 return 0;       /* Not for us, dismiss it */

       1296         }

       1297

       1298         kdba_local_arch_setup();

       1299

       1300         kdba_set_current_task(kdb_current);

       1301

       1302         while (1) {

       1303                 /*

       1304                  * Initialize pager context.

       1305                  */

       1306                 kdb_nextline = 1;

       1307                 KDB_STATE_CLEAR(SUPPRESS);

       1308 #ifdef kdba_setjmp

       1309                 /*

       1310                  * Use kdba_setjmp/kdba_longjmp to break out of

       1311                  * the pager early and to attempt to recover from kdb errors.

       1312                  */

       1313                 KDB_STATE_CLEAR(LONGJMP);

       1314                 if (kdbjmpbuf) {

       1315                         if (kdba_setjmp(&kdbjmpbuf[smp_processor_id()])) {

       1316                                 /* Command aborted (usually in pager) */

       1317                                 continue;

       1318                         }