Annotation of MiNT/src/dos.c, revision 1.1.1.5

1.1       root        1: /*
                      2: 
1.1.1.3   root        3: Copyright 1990,1991,1992 Eric R. Smith.
                      4: 
                      5: Copyright 1992 Atari Corporation.
                      6: 
                      7: All rights reserved.
1.1       root        8: 
                      9: */
                     10: 
                     11: 
                     12: 
                     13: /* miscellaneous DOS functions, and the DOS initialization function */
                     14: 
                     15: 
                     16: 
                     17: #include "mint.h"
                     18: 
                     19: 
                     20: 
                     21: #define DOS_MAX 0x140
                     22: 
                     23: 
                     24: 
                     25: Func dos_tab[DOS_MAX];
                     26: 
                     27: short dos_max = DOS_MAX;
                     28: 
                     29: 
                     30: 
                     31: static void alarmme P_((PROC *));
                     32: 
                     33: 
                     34: 
1.1.1.2   root       35: long ARGS_ON_STACK 
1.1       root       36: 
                     37: s_version()
                     38: 
                     39: {
                     40: 
                     41:        return Sversion();
                     42: 
                     43: }
                     44: 
                     45: 
                     46: 
                     47: /*
                     48: 
                     49:  * Super(new_ssp): change to supervisor mode.
                     50: 
                     51:  */
                     52: 
                     53: 
                     54: 
1.1.1.2   root       55: long ARGS_ON_STACK
1.1       root       56: 
                     57: s_uper(new_ssp)
                     58: 
                     59:        long new_ssp;
                     60: 
                     61: {
                     62: 
                     63:        int in_super;
                     64: 
                     65:        long r;
                     66: 
                     67: 
                     68: 
1.1.1.2   root       69:        TRACE(("Super"));
1.1       root       70: 
                     71:        in_super = curproc->ctxt[SYSCALL].sr & 0x2000;
                     72: 
                     73: 
                     74: 
                     75:        if (new_ssp == 1) {
                     76: 
                     77:                r = in_super ? -1L : 0;
                     78: 
                     79:        }
                     80: 
                     81:        else {
                     82: 
                     83:                curproc->ctxt[SYSCALL].sr ^= 0x2000;
                     84: 
                     85:                r = curproc->ctxt[SYSCALL].ssp;
                     86: 
                     87:                if (in_super) {
                     88: 
                     89:                        if (new_ssp == 0) {
                     90: 
1.1.1.2   root       91:                                DEBUG(("bad Super call"));
1.1       root       92: 
                     93:                                raise(SIGSYS);
                     94: 
                     95:                        }
                     96: 
                     97:                        else {
                     98: 
                     99:                                curproc->ctxt[SYSCALL].usp = 
                    100: 
                    101:                                        curproc->ctxt[SYSCALL].ssp;
                    102: 
                    103:                                curproc->ctxt[SYSCALL].ssp = new_ssp;
                    104: 
                    105:                        }
                    106: 
                    107:                }
                    108: 
                    109:                else {
                    110: 
                    111:                        curproc->ctxt[SYSCALL].ssp = 
                    112: 
                    113:                            new_ssp ? new_ssp : curproc->ctxt[SYSCALL].usp;
                    114: 
                    115:                }
                    116: 
                    117:        }
                    118: 
                    119:        return r;
                    120: 
                    121: }
                    122: 
                    123: 
                    124: 
                    125: /*
                    126: 
                    127:  * get/set time and date functions
                    128: 
                    129:  */
                    130: 
1.1.1.2   root      131: long ARGS_ON_STACK t_getdate() { return datestamp; }
1.1       root      132: 
1.1.1.2   root      133: long ARGS_ON_STACK t_gettime() { return timestamp; }
1.1       root      134: 
                    135: 
                    136: 
1.1.1.2   root      137: long ARGS_ON_STACK t_setdate(date)
1.1       root      138: 
                    139:        int date;
                    140: 
                    141: {
                    142: 
1.1.1.4   root      143:        long r;
                    144: 
                    145: 
                    146: 
                    147: /* Only the superuser may set date or time */
                    148: 
                    149:        if (curproc->euid != 0)
                    150: 
                    151:                return EACCDN;
                    152: 
                    153:        r = Tsetdate(date);
1.1       root      154: 
                    155:        datestamp = Tgetdate();
                    156: 
                    157:        return r;
                    158: 
                    159: }
                    160: 
                    161: 
                    162: 
1.1.1.2   root      163: long ARGS_ON_STACK t_settime(time)
1.1       root      164: 
                    165:        int time;
                    166: 
                    167: {
                    168: 
1.1.1.4   root      169:        long r;
                    170: 
                    171: 
                    172: 
                    173:        if (curproc->euid != 0)
                    174: 
                    175:                return EACCDN;
                    176: 
                    177:        r = Tsettime(time);
1.1       root      178: 
                    179:        timestamp = Tgettime();
                    180: 
                    181:        return r;
                    182: 
                    183: }
                    184: 
                    185: 
                    186: 
                    187: /*
                    188: 
                    189:  * GEMDOS extension: Syield(): give up the processor if any other
                    190: 
                    191:  * processes are waiting. Always returns 0.
                    192: 
                    193:  */
                    194: 
                    195: 
                    196: 
1.1.1.2   root      197: long ARGS_ON_STACK
1.1       root      198: 
                    199: s_yield()
                    200: 
                    201: {
                    202: 
                    203: /* reward the nice process */
                    204: 
                    205:        curproc->curpri = curproc->pri;
                    206: 
                    207:        sleep(READY_Q, curproc->wait_cond);
                    208: 
                    209:        return 0;
                    210: 
                    211: }
                    212: 
                    213: 
                    214: 
                    215: /*
                    216: 
                    217:  * GEMDOS extension:
                    218: 
                    219:  * Prenice(pid, delta) sets the process priority level for process pid.
                    220: 
                    221:  * A "nice" value < 0 increases priority, one > 0 decreases it.
                    222: 
                    223:  * Always returns the new priority (so Prenice(pid, 0) queries the current
                    224: 
                    225:  * priority).
                    226: 
                    227:  *
                    228: 
                    229:  * NOTE: for backward compatibility, Pnice(delta) is provided and is equivalent
                    230: 
                    231:  * to Prenice(Pgetpid(), delta)
                    232: 
                    233:  */
                    234: 
                    235: 
                    236: 
1.1.1.2   root      237: long ARGS_ON_STACK
1.1       root      238: 
                    239: p_renice(pid, delta)
                    240: 
                    241:        int pid, delta;
                    242: 
                    243: {
                    244: 
                    245:        PROC *p;
                    246: 
                    247: 
                    248: 
1.1.1.2   root      249:        if (pid <= 0 || 0 == (p = pid2proc(pid))) {
1.1       root      250: 
                    251:                return EFILNF;
                    252: 
                    253:        }
                    254: 
                    255: 
                    256: 
                    257:        if (curproc->euid && curproc->euid != p->ruid
                    258: 
                    259:            && curproc->ruid != p->ruid) {
                    260: 
1.1.1.2   root      261:                DEBUG(("Prenice: process ownership error"));
1.1       root      262: 
                    263:                return EACCDN;
                    264: 
                    265:        }
                    266: 
                    267:        p->pri -= delta;
                    268: 
                    269:        if (p->pri < MIN_NICE) p->pri = MIN_NICE;
                    270: 
                    271:        if (p->pri > MAX_NICE) p->pri = MAX_NICE;
                    272: 
                    273:        p->curpri = p->pri;
                    274: 
                    275:        return ((long)p->pri) & 0x0ffff;
                    276: 
                    277: }
                    278: 
                    279: 
                    280: 
1.1.1.2   root      281: long ARGS_ON_STACK
1.1       root      282: 
                    283: p_nice(delta)
                    284: 
                    285:        int delta;
                    286: 
                    287: {
                    288: 
                    289:        return p_renice(curproc->pid,delta);
                    290: 
                    291: }
                    292: 
                    293: 
                    294: 
                    295: /*
                    296: 
                    297:  * GEMDOS extensions: routines for getting/setting process i.d.'s and
                    298: 
                    299:  * user i.d.'s
                    300: 
                    301:  */
                    302: 
                    303: 
                    304: 
1.1.1.2   root      305: long ARGS_ON_STACK p_getpid() { return curproc->pid; }
1.1       root      306: 
                    307: 
                    308: 
1.1.1.2   root      309: long ARGS_ON_STACK p_getppid() { return curproc->ppid; }
1.1       root      310: 
                    311: 
                    312: 
1.1.1.2   root      313: long ARGS_ON_STACK p_getpgrp() { return curproc->pgrp; }
1.1       root      314: 
                    315: 
                    316: 
                    317: /* note: Psetpgrp(0, ...) is equivalent to Psetpgrp(Pgetpid(), ...) */
                    318: 
                    319: /* also note: Psetpgrp(x, 0) is equivalent to Psetpgrp(x, x) */
                    320: 
                    321: 
                    322: 
1.1.1.2   root      323: long ARGS_ON_STACK p_setpgrp(pid, newgrp)
1.1       root      324: 
                    325:        int pid, newgrp;
                    326: 
                    327: {
                    328: 
                    329:        PROC *p;
                    330: 
                    331: 
                    332: 
                    333:        if (pid == 0)
                    334: 
                    335:                p = curproc;
                    336: 
1.1.1.2   root      337:        else if (0 == (p = pid2proc(pid)))
1.1       root      338: 
                    339:                return EFILNF;
                    340: 
                    341:        if ( (curproc->euid) && (p->ruid != curproc->ruid)
                    342: 
                    343:              && (p->ppid != curproc->pid) )
                    344: 
                    345:                return EACCDN;
                    346: 
                    347: 
                    348: 
1.1.1.3   root      349:        if (newgrp < 0)
                    350: 
                    351:                return p->pgrp;
                    352: 
                    353: 
                    354: 
1.1       root      355:        if (newgrp == 0)
                    356: 
                    357:                newgrp = p->pid;
                    358: 
                    359: 
                    360: 
                    361:        return (p->pgrp = newgrp);
                    362: 
                    363: }
                    364: 
                    365: 
                    366: 
1.1.1.2   root      367: long ARGS_ON_STACK p_getuid() { return curproc->ruid; }
1.1       root      368: 
1.1.1.2   root      369: long ARGS_ON_STACK p_getgid() { return curproc->rgid; }
1.1       root      370: 
1.1.1.2   root      371: long ARGS_ON_STACK p_geteuid() { return curproc->euid; }
1.1       root      372: 
1.1.1.2   root      373: long ARGS_ON_STACK p_getegid() { return curproc->egid; }
1.1       root      374: 
                    375: 
                    376: 
1.1.1.2   root      377: long ARGS_ON_STACK
1.1       root      378: 
                    379: p_setuid(id)
                    380: 
                    381:        int id;
                    382: 
                    383: {
                    384: 
1.1.1.2   root      385:        if (curproc->euid == 0 || curproc->ruid == id) {
1.1       root      386: 
                    387:                curproc->ruid = curproc->euid = id;
                    388: 
                    389:                return id;
                    390: 
                    391:        }
                    392: 
                    393:        return EACCDN;
                    394: 
                    395: }
                    396: 
                    397: 
                    398: 
1.1.1.2   root      399: long ARGS_ON_STACK
1.1       root      400: 
                    401: p_setgid(id)
                    402: 
                    403:        int id;
                    404: 
                    405: {
                    406: 
1.1.1.2   root      407:        if (curproc->euid == 0 || curproc->egid == 0 || curproc->rgid == id) {
1.1       root      408: 
                    409:                curproc->egid = curproc->rgid = id;
                    410: 
                    411:                return id;
                    412: 
                    413:        }
                    414: 
                    415:        return EACCDN;
                    416: 
                    417: }
                    418: 
                    419: 
                    420: 
                    421: /*
                    422: 
                    423:  * a way to get/set process-specific user information. the user information
                    424: 
                    425:  * longword is set to "arg", unless arg is -1. In any case, the old
                    426: 
                    427:  * value of the longword is returned.
                    428: 
                    429:  */
                    430: 
                    431: 
                    432: 
1.1.1.2   root      433: long ARGS_ON_STACK
1.1       root      434: 
                    435: p_usrval(arg)
                    436: 
                    437:        long arg;
                    438: 
                    439: {
                    440: 
                    441:        long r;
                    442: 
                    443: 
                    444: 
1.1.1.2   root      445:        TRACE(("Pusrval"));
1.1       root      446: 
                    447:        r = curproc->usrdata;
                    448: 
                    449:        if (arg != -1L)
                    450: 
                    451:                curproc->usrdata = arg;
                    452: 
                    453:        return r;
                    454: 
                    455: }
                    456: 
                    457: 
                    458: 
                    459: /*
                    460: 
                    461:  * set the file creation mask to "mode". Returns the old value of the
                    462: 
                    463:  * mask.
                    464: 
                    465:  */
                    466: 
1.1.1.2   root      467: long ARGS_ON_STACK p_umask(mode)
1.1       root      468: 
                    469:        unsigned mode;
                    470: 
                    471: {
                    472: 
                    473:        long oldmask = curproc->umask;
                    474: 
                    475: 
                    476: 
                    477:        curproc->umask = mode & (~S_IFMT);
                    478: 
                    479:        return oldmask;
                    480: 
                    481: }
                    482: 
                    483: 
                    484: 
                    485: /*
                    486: 
                    487:  * get/set the domain of a process. domain 0 is the default (TOS) domain.
                    488: 
                    489:  * domain 1 is the MiNT domain. for now, domain affects read/write system
                    490: 
                    491:  * calls and filename translation.
                    492: 
                    493:  */
                    494: 
                    495: 
                    496: 
1.1.1.2   root      497: long ARGS_ON_STACK
1.1       root      498: 
                    499: p_domain(arg)
                    500: 
                    501:        int arg;
                    502: 
                    503: {
                    504: 
                    505:        long r;
                    506: 
1.1.1.2   root      507:        TRACE(("Pdomain(%d)", arg));
1.1       root      508: 
                    509: 
                    510: 
                    511:        r = curproc->domain;
                    512: 
                    513:        if (arg >= 0)
                    514: 
                    515:                curproc->domain = arg;
                    516: 
                    517:        return r;
                    518: 
                    519: }
                    520: 
                    521: 
                    522: 
                    523: /*
                    524: 
                    525:  * get process resource usage. 8 longwords are returned, as follows:
                    526: 
                    527:  *     r[0] == system time used by process
                    528: 
                    529:  *     r[1] == user time used by process
                    530: 
                    531:  *     r[2] == system time used by process' children
                    532: 
                    533:  *     r[3] == user time used by process' children
                    534: 
                    535:  *     r[4] == memory used by process
                    536: 
                    537:  *     r[5] - r[7]: reserved for future use
                    538: 
                    539:  */
                    540: 
                    541: 
                    542: 
1.1.1.2   root      543: long ARGS_ON_STACK
1.1       root      544: 
                    545: p_rusage(r)
                    546: 
                    547:        long *r;
                    548: 
                    549: {
                    550: 
                    551:        r[0] = curproc->systime;
                    552: 
                    553:        r[1] = curproc->usrtime;
                    554: 
                    555:        r[2] = curproc->chldstime;
                    556: 
                    557:        r[3] = curproc->chldutime;
                    558: 
                    559:        r[4] = memused(curproc);
                    560: 
                    561:        return 0;
                    562: 
                    563: }
                    564: 
                    565: 
                    566: 
                    567: /*
                    568: 
                    569:  * get/set resource limits i to value v. The old limit is always returned;
                    570: 
                    571:  * if v == -1, the limit is unchanged, otherwise it is set to v. Possible
                    572: 
                    573:  * values for i are:
                    574: 
                    575:  *    1:  max. cpu time        (milliseconds)
                    576: 
                    577:  *    2:  max. core memory allowed
                    578: 
                    579:  *    3:  max. amount of malloc'd memory allowed
                    580: 
                    581:  */
                    582: 
1.1.1.2   root      583: long ARGS_ON_STACK
1.1       root      584: 
                    585: p_setlimit(i, v)
                    586: 
                    587:        int i;
                    588: 
                    589:        long v;
                    590: 
                    591: {
                    592: 
                    593:        long oldlimit;
                    594: 
                    595: 
                    596: 
                    597:        switch(i) {
                    598: 
                    599:        case 1:
                    600: 
                    601:                oldlimit = curproc->maxcpu;
                    602: 
                    603:                if (v >= 0) curproc->maxcpu = v;
                    604: 
                    605:                break;
                    606: 
                    607:        case 2:
                    608: 
                    609:                oldlimit = curproc->maxcore;
                    610: 
                    611:                if (v >= 0) {
                    612: 
                    613:                        curproc->maxcore = v;
                    614: 
                    615:                        recalc_maxmem(curproc);
                    616: 
                    617:                }
                    618: 
                    619:                break;
                    620: 
                    621:        case 3:
                    622: 
                    623:                oldlimit = curproc->maxdata;
                    624: 
                    625:                if (v >= 0) {
                    626: 
                    627:                        curproc->maxdata = v;
                    628: 
                    629:                        recalc_maxmem(curproc);
                    630: 
                    631:                }
                    632: 
                    633:                break;
                    634: 
                    635:        default:
                    636: 
1.1.1.2   root      637:                DEBUG(("Psetlimit: invalid mode %d", i));
1.1       root      638: 
                    639:                return EINVFN;
                    640: 
                    641:        }
                    642: 
1.1.1.2   root      643:        TRACE(("p_setlimit(%d, %ld): oldlimit = %ld", i, v, oldlimit));
1.1       root      644: 
                    645:        return oldlimit;
                    646: 
                    647: }
                    648: 
                    649: 
                    650: 
                    651: /*
                    652: 
                    653:  * pause: just sleeps on IO_Q, with wait_cond == -1. only a signal will
                    654: 
                    655:  * wake us up
                    656: 
                    657:  */
                    658: 
                    659: 
                    660: 
1.1.1.2   root      661: long ARGS_ON_STACK
1.1       root      662: 
                    663: p_pause()
                    664: 
                    665: {
                    666: 
1.1.1.2   root      667:        TRACE(("Pause"));
                    668: 
1.1       root      669:        sleep(IO_Q, -1L);
                    670: 
                    671:        return 0;
                    672: 
                    673: }
                    674: 
                    675: 
                    676: 
                    677: /*
                    678: 
                    679:  * helper function for t_alarm: this will be called when the timer goes
                    680: 
                    681:  * off, and raises SIGALRM
                    682: 
                    683:  */
                    684: 
                    685: 
                    686: 
                    687: static void
                    688: 
                    689: alarmme(p)
                    690: 
                    691:        PROC *p;
                    692: 
                    693: {
                    694: 
                    695:        p->alarmtim = 0;
                    696: 
                    697:        post_sig(p, SIGALRM);
                    698: 
                    699: }
                    700: 
                    701: 
                    702: 
                    703: /*
                    704: 
                    705:  * t_alarm(x): set the alarm clock to go off in "x" seconds. returns the
                    706: 
                    707:  * old value of the alarm clock
                    708: 
                    709:  */
                    710: 
                    711: 
                    712: 
1.1.1.2   root      713: long ARGS_ON_STACK
1.1       root      714: 
                    715: t_alarm(x)
                    716: 
                    717:        long x;
                    718: 
                    719: {
                    720: 
                    721:        long oldalarm;
                    722: 
1.1.1.5 ! root      723:        oldalarm = t_malarm(x*1000);
        !           724: 
        !           725:        oldalarm = (oldalarm+999)/1000;         /* convert to seconds */
        !           726: 
        !           727:        return oldalarm;
        !           728: 
        !           729: }
        !           730: 
        !           731: 
        !           732: 
        !           733: /*
        !           734: 
        !           735:  * t_malarm(x): set the alarm clock to go off in "x" milliseconds. returns
        !           736: 
        !           737:  * the old value ofthe alarm clock
        !           738: 
        !           739:  */
        !           740: 
        !           741: 
        !           742: 
        !           743: long ARGS_ON_STACK
        !           744: 
        !           745: t_malarm(x)
        !           746: 
        !           747:        long x;
        !           748: 
        !           749: {
        !           750: 
        !           751:        long oldalarm;
        !           752: 
1.1       root      753:        TIMEOUT *t;
                    754: 
                    755: 
                    756: 
                    757: /* see how many milliseconds there were to the alarm timeout */
                    758: 
                    759:        oldalarm = 0;
                    760: 
                    761: 
                    762: 
                    763:        if (curproc->alarmtim) {
                    764: 
                    765:                for (t = tlist; t; t = t->next) {
                    766: 
                    767:                        oldalarm += t->when;
                    768: 
                    769:                        if (t == curproc->alarmtim)
                    770: 
                    771:                                goto foundalarm;
                    772: 
                    773:                }
                    774: 
1.1.1.2   root      775:                DEBUG(("Talarm: old alarm not found!"));
1.1       root      776: 
                    777:                oldalarm = 0;
                    778: 
                    779:                curproc->alarmtim = 0;
                    780: 
                    781: foundalarm:
                    782: 
                    783:                ;
                    784: 
                    785:        }
                    786: 
                    787: 
                    788: 
                    789: /* we were just querying the alarm */
                    790: 
                    791:        if (x < 0)
                    792: 
                    793:                return oldalarm;
                    794: 
                    795: 
                    796: 
                    797: /* cancel old alarm */
                    798: 
                    799:        if (curproc->alarmtim)
                    800: 
                    801:                canceltimeout(curproc->alarmtim);
                    802: 
                    803: 
                    804: 
1.1.1.5 ! root      805: /* add a new alarm, to occur in x milliseconds */
1.1       root      806: 
                    807:        if (x)
                    808: 
1.1.1.5 ! root      809:                curproc->alarmtim = addtimeout(x, alarmme);
1.1       root      810: 
                    811:        else
                    812: 
                    813:                curproc->alarmtim = 0;
                    814: 
                    815: 
                    816: 
                    817:        return oldalarm;
                    818: 
                    819: }
                    820: 
                    821: 
                    822: 
                    823: /*
                    824: 
                    825:  * sysconf(which): returns information about system configuration.
                    826: 
                    827:  * "which" specifies which aspect of the system configuration is to
                    828: 
                    829:  * be returned:
                    830: 
                    831:  *     -1      max. value of "which" allowed
                    832: 
                    833:  *     0       max. number of memory regions per proc
                    834: 
                    835:  *     1       max. length of Pexec() execution string {ARG_MAX}
                    836: 
                    837:  *     2       max. number of open files per process   {OPEN_MAX}
                    838: 
                    839:  *     3       number of supplementary group id's      {currently 0}
                    840: 
                    841:  *     4       max. number of processes per uid        {CHILD_MAX}
                    842: 
                    843:  *
                    844: 
                    845:  * unlimited values (e.g. CHILD_MAX) are returned as 0x7fffffffL
                    846: 
                    847:  *
                    848: 
                    849:  * See also Dpathconf() in dosdir.c.
                    850: 
                    851:  */
                    852: 
                    853: 
                    854: 
1.1.1.2   root      855: long ARGS_ON_STACK
1.1       root      856: 
                    857: s_ysconf(which)
                    858: 
                    859:        int which;
                    860: 
                    861: {
                    862: 
                    863:        if (which == -1)
                    864: 
                    865:                return 4;
                    866: 
                    867: 
                    868: 
                    869:        switch(which) {
                    870: 
                    871:                case 0:
                    872: 
                    873:                        return UNLIMITED;
                    874: 
                    875:                case 1:
                    876: 
                    877:                        return 126;
                    878: 
                    879:                case 2:
                    880: 
                    881:                        return MAX_OPEN;
                    882: 
                    883:                case 3:
                    884: 
                    885:                        return 0;
                    886: 
                    887:                case 4:
                    888: 
                    889:                        return UNLIMITED;
                    890: 
                    891:                default:
                    892: 
                    893:                        return EINVFN;
                    894: 
                    895:        }
                    896: 
                    897: }
                    898: 
                    899: 
                    900: 
                    901: /*
                    902: 
1.1.1.3   root      903:  * Salert: send an ALERT message to the user, via the same mechanism
                    904: 
                    905:  * the kernel does (i.e. u:\pipe\alert, if it's available
                    906: 
                    907:  */
                    908: 
                    909: 
                    910: 
                    911: long ARGS_ON_STACK
                    912: 
                    913: s_alert(str)
                    914: 
                    915:        char *str;
                    916: 
                    917: {
                    918: 
                    919: /* how's this for confusing code? _ALERT tries to format the
                    920: 
                    921:  * string as an alert box; if it fails, we let the full-fledged
                    922: 
                    923:  * ALERT function (which will try _ALERT, and fail again)
                    924: 
                    925:  * print the alert to the debugging device
                    926: 
                    927:  */
                    928: 
                    929:        if (_ALERT(str) == 0)
                    930: 
                    931:                ALERT(str);
                    932: 
                    933:        return 0;
                    934: 
                    935: }
                    936: 
                    937: 
                    938: 
                    939: /*
                    940: 
1.1       root      941:  * routine for initializing DOS
                    942: 
                    943:  *
                    944: 
                    945:  * NOTE: before adding new functions, check the definition of
                    946: 
                    947:  * DOS_MAX at the top of this file to make sure that there
                    948: 
                    949:  * is room; if not, increase DOS_MAX.
                    950: 
                    951:  */
                    952: 
                    953: 
                    954: 
                    955: void
                    956: 
                    957: init_dos()
                    958: 
                    959: {
                    960: 
                    961: /* miscellaneous initialization goes here */
                    962: 
                    963:        timestamp = Tgettime();
                    964: 
                    965:        datestamp = Tgetdate();
                    966: 
                    967: 
                    968: 
                    969: /* dos table initialization */
                    970: 
                    971:        dos_tab[0x00] = p_term0;
                    972: 
                    973:        dos_tab[0x01] = c_conin;
                    974: 
                    975:        dos_tab[0x02] = c_conout;
                    976: 
                    977:        dos_tab[0x03] = c_auxin;
                    978: 
                    979:        dos_tab[0x04] = c_auxout;
                    980: 
                    981:        dos_tab[0x05] = c_prnout;
                    982: 
                    983:        dos_tab[0x06] = c_rawio;
                    984: 
                    985:        dos_tab[0x07] = c_rawcin;
                    986: 
                    987:        dos_tab[0x08] = c_necin;
                    988: 
                    989:        dos_tab[0x09] = c_conws;
                    990: 
                    991:        dos_tab[0x0a] = c_conrs;
                    992: 
                    993:        dos_tab[0x0b] = c_conis;
                    994: 
                    995:        dos_tab[0x0e] = d_setdrv;
                    996: 
                    997:        dos_tab[0x10] = c_conos;
                    998: 
                    999:        dos_tab[0x11] = c_prnos;
                   1000: 
                   1001:        dos_tab[0x12] = c_auxis;
                   1002: 
                   1003:        dos_tab[0x13] = c_auxos;
                   1004: 
                   1005:        dos_tab[0x14] = m_addalt;
                   1006: 
1.1.1.3   root     1007:        dos_tab[0x15] = s_realloc;
                   1008: 
1.1       root     1009:        dos_tab[0x19] = d_getdrv;
                   1010: 
                   1011:        dos_tab[0x1a] = f_setdta;
                   1012: 
                   1013:        dos_tab[0x20] = s_uper;
                   1014: 
                   1015:        dos_tab[0x2a] = t_getdate;
                   1016: 
                   1017:        dos_tab[0x2b] = t_setdate;
                   1018: 
                   1019:        dos_tab[0x2c] = t_gettime;
                   1020: 
                   1021:        dos_tab[0x2d] = t_settime;
                   1022: 
                   1023:        dos_tab[0x2f] = f_getdta;
                   1024: 
                   1025:        dos_tab[0x30] = s_version;
                   1026: 
                   1027:        dos_tab[0x31] = p_termres;
                   1028: 
                   1029:        dos_tab[0x36] = d_free;
                   1030: 
                   1031:        dos_tab[0x39] = d_create;
                   1032: 
                   1033:        dos_tab[0x3a] = d_delete;
                   1034: 
                   1035:        dos_tab[0x3b] = d_setpath;
                   1036: 
                   1037:        dos_tab[0x3c] = f_create;
                   1038: 
                   1039:        dos_tab[0x3d] = f_open;
                   1040: 
                   1041:        dos_tab[0x3e] = f_close;
                   1042: 
                   1043:        dos_tab[0x3f] = f_read;
                   1044: 
                   1045:        dos_tab[0x40] = f_write;
                   1046: 
                   1047:        dos_tab[0x41] = f_delete;
                   1048: 
                   1049:        dos_tab[0x42] = f_seek;
                   1050: 
                   1051:        dos_tab[0x43] = f_attrib;
                   1052: 
                   1053:        dos_tab[0x44] = m_xalloc;
                   1054: 
                   1055:        dos_tab[0x45] = f_dup;
                   1056: 
                   1057:        dos_tab[0x46] = f_force;
                   1058: 
                   1059:        dos_tab[0x47] = d_getpath;
                   1060: 
                   1061:        dos_tab[0x48] = m_alloc;
                   1062: 
                   1063:        dos_tab[0x49] = m_free;
                   1064: 
                   1065:        dos_tab[0x4a] = m_shrink;
                   1066: 
                   1067:        dos_tab[0x4b] = p_exec;
                   1068: 
                   1069:        dos_tab[0x4c] = p_term;
                   1070: 
                   1071:        dos_tab[0x4e] = f_sfirst;
                   1072: 
                   1073:        dos_tab[0x4f] = f_snext;
                   1074: 
                   1075:        dos_tab[0x56] = f_rename;
                   1076: 
                   1077:        dos_tab[0x57] = f_datime;
                   1078: 
                   1079:        dos_tab[0x5c] = f_lock;
                   1080: 
                   1081: 
                   1082: 
                   1083: /* MiNT extensions to GEMDOS */
                   1084: 
                   1085: 
                   1086: 
                   1087:        dos_tab[0xff] = s_yield;
                   1088: 
                   1089:        dos_tab[0x100] = f_pipe;
                   1090: 
                   1091:        dos_tab[0x104] = f_cntl;
                   1092: 
1.1.1.2   root     1093:        dos_tab[0x105] = f_instat;
1.1       root     1094: 
1.1.1.2   root     1095:        dos_tab[0x106] = f_outstat;
1.1       root     1096: 
1.1.1.2   root     1097:        dos_tab[0x107] = f_getchar;
1.1       root     1098: 
1.1.1.2   root     1099:        dos_tab[0x108] = f_putchar;
1.1       root     1100: 
                   1101:        dos_tab[0x109] = p_wait;
                   1102: 
                   1103:        dos_tab[0x10a] = p_nice;
                   1104: 
                   1105:        dos_tab[0x10b] = p_getpid;
                   1106: 
                   1107:        dos_tab[0x10c] = p_getppid;
                   1108: 
                   1109:        dos_tab[0x10d] = p_getpgrp;
                   1110: 
                   1111:        dos_tab[0x10e] = p_setpgrp;
                   1112: 
                   1113:        dos_tab[0x10f] = p_getuid;
                   1114: 
                   1115:        dos_tab[0x110] = p_setuid;
                   1116: 
                   1117:        dos_tab[0x111] = p_kill;
                   1118: 
                   1119:        dos_tab[0x112] = p_signal;
                   1120: 
                   1121:        dos_tab[0x113] = p_vfork;
                   1122: 
                   1123:        dos_tab[0x114] = p_getgid;
                   1124: 
                   1125:        dos_tab[0x115] = p_setgid;
                   1126: 
1.1.1.3   root     1127: 
                   1128: 
1.1       root     1129:        dos_tab[0x116] = p_sigblock;
                   1130: 
                   1131:        dos_tab[0x117] = p_sigsetmask;
                   1132: 
                   1133:        dos_tab[0x118] = p_usrval;
                   1134: 
                   1135:        dos_tab[0x119] = p_domain;
                   1136: 
                   1137:        dos_tab[0x11a] = p_sigreturn;
                   1138: 
                   1139:        dos_tab[0x11b] = p_fork;
                   1140: 
                   1141:        dos_tab[0x11c] = p_wait3;
                   1142: 
                   1143:        dos_tab[0x11d] = f_select;
                   1144: 
                   1145:        dos_tab[0x11e] = p_rusage;
                   1146: 
                   1147:        dos_tab[0x11f] = p_setlimit;
                   1148: 
                   1149:        dos_tab[0x120] = t_alarm;
                   1150: 
                   1151:        dos_tab[0x121] = p_pause;
                   1152: 
                   1153:        dos_tab[0x122] = s_ysconf;
                   1154: 
                   1155:        dos_tab[0x123] = p_sigpending;
                   1156: 
                   1157:        dos_tab[0x124] = d_pathconf;
                   1158: 
                   1159:        dos_tab[0x125] = p_msg;
                   1160: 
                   1161:        dos_tab[0x126] = f_midipipe;
                   1162: 
                   1163:        dos_tab[0x127] = p_renice;
                   1164: 
                   1165:        dos_tab[0x128] = d_opendir;
                   1166: 
                   1167:        dos_tab[0x129] = d_readdir;
                   1168: 
                   1169:        dos_tab[0x12a] = d_rewind;
                   1170: 
                   1171:        dos_tab[0x12b] = d_closedir;
                   1172: 
                   1173:        dos_tab[0x12c] = f_xattr;
                   1174: 
                   1175:        dos_tab[0x12d] = f_link;
                   1176: 
                   1177:        dos_tab[0x12e] = f_symlink;
                   1178: 
                   1179:        dos_tab[0x12f] = f_readlink;
                   1180: 
                   1181:        dos_tab[0x130] = d_cntl;
                   1182: 
                   1183:        dos_tab[0x131] = f_chown;
                   1184: 
                   1185:        dos_tab[0x132] = f_chmod;
                   1186: 
                   1187:        dos_tab[0x133] = p_umask;
                   1188: 
                   1189:        dos_tab[0x134] = p_semaphore;
                   1190: 
                   1191:        dos_tab[0x135] = d_lock;
                   1192: 
                   1193:        dos_tab[0x136] = p_sigpause;
                   1194: 
                   1195:        dos_tab[0x137] = p_sigaction;
                   1196: 
                   1197:        dos_tab[0x138] = p_geteuid;
                   1198: 
                   1199:        dos_tab[0x139] = p_getegid;
                   1200: 
1.1.1.2   root     1201:        dos_tab[0x13a] = p_waitpid;
                   1202: 
                   1203:        dos_tab[0x13b] = d_getcwd;
                   1204: 
1.1.1.3   root     1205:        dos_tab[0x13c] = s_alert;
                   1206: 
1.1.1.5 ! root     1207:        dos_tab[0x13d] = t_malarm;
        !          1208: 
1.1       root     1209: }
                   1210: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.