1 /* 2 * JZ4730 CPM server. 3 * 4 * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include <l4/devices/cpm-jz4730.h> 23 #include <l4/devices/memory.h> 24 #include "cpm-server.h" 25 26 #include <l4/re/dataspace> 27 #include <l4/re/env> 28 #include <l4/re/util/object_registry> 29 30 #include <l4/sys/types.h> 31 32 // Virtual addresses for the CPM and LCD register blocks. 33 34 static l4_addr_t cpm_virt_base = 0, cpm_virt_base_end = 0; 35 36 37 38 // Access to peripheral memory. 39 40 static int setup_memory() 41 { 42 if (get_memory("jz4730-cpm", &cpm_virt_base, &cpm_virt_base_end)) 43 return 1; 44 45 return 0; 46 } 47 48 49 50 static L4Re::Util::Registry_server<> server; 51 52 53 54 /* Main program. */ 55 56 int main(void) 57 { 58 if (setup_memory()) return 1; 59 60 /* Initialise the CPM abstraction. */ 61 62 Cpm_jz4730_chip cpm_device(cpm_virt_base, 3686400); 63 64 /* Initialise and register a server object. */ 65 66 Cpm_server server_obj(&cpm_device); 67 server.registry()->register_obj(&server_obj, "cpm"); 68 69 /* Enter the IPC server loop. */ 70 71 server.loop(); 72 return 0; 73 }