Changeset 8b655705 in mainline for uspace/srv/loader/main.c


Ignore:
Timestamp:
2011-04-15T19:38:07Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9dd730d1
Parents:
6b9e85b (diff), b2fb47f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/loader/main.c

    r6b9e85b r8b655705  
    5050#include <fcntl.h>
    5151#include <sys/types.h>
    52 #include <ipc/ipc.h>
    5352#include <ipc/services.h>
    5453#include <ipc/loader.h>
     
    9594
    9695/** Used to limit number of connections to one. */
    97 static bool connected;
     96static bool connected = false;
    9897
    9998static void ldr_get_taskid(ipc_callid_t rid, ipc_call_t *request)
     
    106105       
    107106        if (!async_data_read_receive(&callid, &len)) {
    108                 ipc_answer_0(callid, EINVAL);
    109                 ipc_answer_0(rid, EINVAL);
     107                async_answer_0(callid, EINVAL);
     108                async_answer_0(rid, EINVAL);
    110109                return;
    111110        }
     
    115114       
    116115        async_data_read_finalize(callid, &task_id, len);
    117         ipc_answer_0(rid, EOK);
     116        async_answer_0(rid, EOK);
    118117}
    119118
     
    135134        }
    136135       
    137         ipc_answer_0(rid, rc);
     136        async_answer_0(rid, rc);
    138137}
    139138
     
    155154        }
    156155       
    157         ipc_answer_0(rid, rc);
     156        async_answer_0(rid, rc);
    158157}
    159158
     
    188187                if (_argv == NULL) {
    189188                        free(buf);
    190                         ipc_answer_0(rid, ENOMEM);
     189                        async_answer_0(rid, ENOMEM);
    191190                        return;
    192191                }
     
    220219        }
    221220       
    222         ipc_answer_0(rid, rc);
     221        async_answer_0(rid, rc);
    223222}
    224223
     
    244243                if (_filv == NULL) {
    245244                        free(buf);
    246                         ipc_answer_0(rid, ENOMEM);
     245                        async_answer_0(rid, ENOMEM);
    247246                        return;
    248247                }
     
    271270        }
    272271       
    273         ipc_answer_0(rid, EOK);
     272        async_answer_0(rid, EOK);
    274273}
    275274
     
    287286        if (rc != EE_OK) {
    288287                DPRINTF("Failed to load executable '%s'.\n", pathname);
    289                 ipc_answer_0(rid, EINVAL);
     288                async_answer_0(rid, EINVAL);
    290289                return 1;
    291290        }
     
    304303                /* Statically linked program */
    305304                is_dyn_linked = false;
    306                 ipc_answer_0(rid, EOK);
     305                async_answer_0(rid, EOK);
    307306                return 0;
    308307        }
     
    312311                DPRINTF("Failed to load interpreter '%s.'\n",
    313312                    prog_info.interp);
    314                 ipc_answer_0(rid, EINVAL);
     313                async_answer_0(rid, EINVAL);
    315314                return 1;
    316315        }
    317316       
    318317        is_dyn_linked = true;
    319         ipc_answer_0(rid, EOK);
     318        async_answer_0(rid, EOK);
    320319       
    321320        return 0;
     
    343342                DPRINTF("Entry point: %p\n", interp_info.entry);
    344343               
    345                 ipc_answer_0(rid, EOK);
     344                async_answer_0(rid, EOK);
    346345                elf_run(&interp_info, &pcb);
    347346        } else {
    348347                /* Statically linked program */
    349                 ipc_answer_0(rid, EOK);
     348                async_answer_0(rid, EOK);
    350349                elf_run(&prog_info, &pcb);
    351350        }
     
    367366        /* Already have a connection? */
    368367        if (connected) {
    369                 ipc_answer_0(iid, ELIMIT);
     368                async_answer_0(iid, ELIMIT);
    370369                return;
    371370        }
     
    374373       
    375374        /* Accept the connection */
    376         ipc_answer_0(iid, EOK);
     375        async_answer_0(iid, EOK);
    377376       
    378377        /* Ignore parameters, the connection is already open */
     
    408407                        /* Not reached */
    409408                default:
    410                         retval = ENOENT;
     409                        retval = EINVAL;
    411410                        break;
    412411                }
    413                 if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP) {
    414                         DPRINTF("Responding EINVAL to method %d.\n",
    415                             IPC_GET_IMETHOD(call));
    416                         ipc_answer_0(callid, EINVAL);
    417                 }
     412               
     413                if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP)
     414                        async_answer_0(callid, retval);
    418415        }
    419416}
     
    423420int main(int argc, char *argv[])
    424421{
    425         sysarg_t phonead;
    426         task_id_t id;
    427         int rc;
    428 
    429         connected = false;
    430 
     422        /* Set a handler of incomming connections. */
     423        async_set_client_connection(ldr_connection);
     424       
    431425        /* Introduce this task to the NS (give it our task ID). */
    432         id = task_get_id();
    433         rc = async_req_2_0(PHONE_NS, NS_ID_INTRO, LOWER32(id), UPPER32(id));
     426        task_id_t id = task_get_id();
     427        int rc = async_req_2_0(PHONE_NS, NS_ID_INTRO, LOWER32(id), UPPER32(id));
    434428        if (rc != EOK)
    435429                return -1;
    436 
    437         /* Set a handler of incomming connections. */
    438         async_set_client_connection(ldr_connection);
    439430       
    440431        /* Register at naming service. */
    441         if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, &phonead) != 0)
     432        if (service_register(SERVICE_LOAD) != EOK)
    442433                return -2;
    443 
     434       
    444435        async_manager();
    445436       
Note: See TracChangeset for help on using the changeset viewer.