paul@93 | 1 | /* |
paul@93 | 2 | * A pipe opener resource. |
paul@93 | 3 | * |
paul@93 | 4 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@93 | 5 | * |
paul@93 | 6 | * This program is free software; you can redistribute it and/or |
paul@93 | 7 | * modify it under the terms of the GNU General Public License as |
paul@93 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@93 | 9 | * the License, or (at your option) any later version. |
paul@93 | 10 | * |
paul@93 | 11 | * This program is distributed in the hope that it will be useful, |
paul@93 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@93 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@93 | 14 | * GNU General Public License for more details. |
paul@93 | 15 | * |
paul@93 | 16 | * You should have received a copy of the GNU General Public License |
paul@93 | 17 | * along with this program; if not, write to the Free Software |
paul@93 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@93 | 19 | * Boston, MA 02110-1301, USA |
paul@93 | 20 | */ |
paul@93 | 21 | |
paul@65 | 22 | #pragma once |
paul@65 | 23 | |
paul@94 | 24 | #include <mem/memory.h> |
paul@94 | 25 | #include <fsserver/pipe_opener_interface.h> |
paul@94 | 26 | #include <fsserver/pipe_paging.h> |
paul@94 | 27 | #include <fsserver/resource.h> |
paul@65 | 28 | |
paul@93 | 29 | |
paul@93 | 30 | |
paul@65 | 31 | /* Support for providing access to pipes. */ |
paul@65 | 32 | |
paul@65 | 33 | class PipeOpenerResource : public Resource, public PipeOpener |
paul@65 | 34 | { |
paul@65 | 35 | protected: |
paul@70 | 36 | Memory *_memory; |
paul@70 | 37 | |
paul@66 | 38 | long open_endpoint(PipePaging *paging, bool writing, l4_cap_idx_t *endpoint); |
paul@65 | 39 | |
paul@65 | 40 | public: |
paul@70 | 41 | explicit PipeOpenerResource(Memory *memory); |
paul@70 | 42 | |
paul@65 | 43 | /* Server details. */ |
paul@65 | 44 | |
paul@65 | 45 | int expected_items(); |
paul@65 | 46 | |
paul@65 | 47 | ipc_server_handler_type handler(); |
paul@65 | 48 | |
paul@65 | 49 | void *interface() |
paul@65 | 50 | { return static_cast<PipeOpener *>(this); } |
paul@65 | 51 | |
paul@65 | 52 | /* PipeOpener interface methods. */ |
paul@65 | 53 | |
paul@66 | 54 | long pipe(offset_t size, l4_cap_idx_t *reader, l4_cap_idx_t *writer); |
paul@65 | 55 | }; |
paul@65 | 56 | |
paul@65 | 57 | // vim: tabstop=4 expandtab shiftwidth=4 |