//////////////////////// \brief SysCreateInterface (service, name, msgSize) - Create a new interface Create a new interface. Interfaces allow clients to open connections to a service \param service (handle_id_t) Handle ID of the service hosting the interface \param name (const char*) Name of the interface, \param msgSize (uint16_t) Maximum message size for all connections \return Handle ID of s
| 2259 | /// \return Handle ID of service on success, negative error code on failure |
| 2260 | ///////////////////////////// |
| 2261 | long SysCreateInterface(regs64_t* r){ |
| 2262 | process_t* currentProcess = Scheduler::GetCurrentProcess(); |
| 2263 | |
| 2264 | Handle* svcHandle; |
| 2265 | if(Scheduler::FindHandle(currentProcess, SC_ARG0(r), &svcHandle)){ |
| 2266 | Log::Warning("SysCreateInterface: Invalid handle ID %d", SC_ARG0(r)); |
| 2267 | return -EINVAL; |
| 2268 | } |
| 2269 | |
| 2270 | if(!svcHandle->ko->IsType(Service::TypeID())){ |
| 2271 | Log::Warning("SysCreateInterface: Invalid handle type (ID %d)", SC_ARG0(r)); |
| 2272 | return -EINVAL; |
| 2273 | } |
| 2274 | |
| 2275 | size_t nameLength; |
| 2276 | if(strlenSafe(reinterpret_cast<const char*>(SC_ARG1(r)), nameLength, currentProcess->addressSpace)){ |
| 2277 | return -EFAULT; |
| 2278 | } |
| 2279 | |
| 2280 | char name[nameLength + 1]; |
| 2281 | strncpy(name, reinterpret_cast<const char*>(SC_ARG1(r)), nameLength); |
| 2282 | name[nameLength] = 0; |
| 2283 | |
| 2284 | Service* svc = reinterpret_cast<Service*>(svcHandle->ko.get()); |
| 2285 | |
| 2286 | FancyRefPtr<MessageInterface> interface; |
| 2287 | long ret = svc->CreateInterface(interface, name, SC_ARG2(r)); |
| 2288 | |
| 2289 | if(ret){ |
| 2290 | return ret; |
| 2291 | } |
| 2292 | |
| 2293 | Handle& handle = Scheduler::RegisterHandle(currentProcess, static_pointer_cast<KernelObject, MessageInterface>(interface)); |
| 2294 | |
| 2295 | return handle.id; |
| 2296 | } |
| 2297 | |
| 2298 | ///////////////////////////// |
| 2299 | /// \brief SysInterfaceAccept (interface) - Accept connections on an interface |
nothing calls this directly
no test coverage detected