| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com) | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the documentation of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial Usage | 
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and Nokia. | 
|---|
| 14 | ** | 
|---|
| 15 | ** GNU Lesser General Public License Usage | 
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 19 | ** packaging of this file.  Please review the following information to | 
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 22 | ** | 
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain | 
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL | 
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | 
|---|
| 26 | ** package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please | 
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | /*! | 
|---|
| 43 | \page qt-embedded-porting-operatingsystem.html | 
|---|
| 44 |  | 
|---|
| 45 | \title Porting Qt for Embedded Linux to Another Operating System | 
|---|
| 46 | \ingroup qt-embedded-linux | 
|---|
| 47 |  | 
|---|
| 48 | \l{Qt for Embedded Linux} is reasonably platform-independent, making use of | 
|---|
| 49 | the standard C library and some POSIX functions, but only a Linux | 
|---|
| 50 | implementation is publically available. If you are looking for a | 
|---|
| 51 | non-Linux commercial implementation, it is worth contacting \l | 
|---|
| 52 | {mailto:sales@trolltech.com}{sales@trolltech.com} to see if we can | 
|---|
| 53 | help. | 
|---|
| 54 |  | 
|---|
| 55 | There are several issues to be aware of if you plan to do your own | 
|---|
| 56 | port to another operating system. In particular you must resolve | 
|---|
| 57 | \l{Qt for Embedded Linux}'s shared memory and semaphores (used to share | 
|---|
| 58 | window regions), and you must provide something similar to | 
|---|
| 59 | Unix-domain sockets for inter-application communication. You must | 
|---|
| 60 | also provide a screen driver, and if you want to implement sound | 
|---|
| 61 | you must provide your own sound server. Finally you must modify | 
|---|
| 62 | the event dispatcher used by \l{Qt for Embedded Linux}. | 
|---|
| 63 |  | 
|---|
| 64 | Contents: | 
|---|
| 65 |  | 
|---|
| 66 | \tableofcontents | 
|---|
| 67 |  | 
|---|
| 68 | \section1 Shared Memory and Semaphores | 
|---|
| 69 |  | 
|---|
| 70 | \l{Qt for Embedded Linux} uses System V IPC (shared memory and semaphores) | 
|---|
| 71 | to share window regions between client and server. When porting, | 
|---|
| 72 | something similar must be provided; otherwise it will not be | 
|---|
| 73 | possible to run multiple applications. | 
|---|
| 74 |  | 
|---|
| 75 | System V semaphores are also used for synchronizing access to the | 
|---|
| 76 | framebuffer. | 
|---|
| 77 |  | 
|---|
| 78 | \list | 
|---|
| 79 | \o Modify \c qsharedmemory_p.cpp | 
|---|
| 80 | \o Modify \c qlock_qws.cpp | 
|---|
| 81 | \o Modify \c qwslock.cpp | 
|---|
| 82 | \endlist | 
|---|
| 83 |  | 
|---|
| 84 | \section1 Inter-Application Communication | 
|---|
| 85 |  | 
|---|
| 86 | To communicate between applications, \l{Qt for Embedded Linux} uses the | 
|---|
| 87 | Unix-domain sockets. When porting, something similar must be | 
|---|
| 88 | provided; otherwise it will not be possible to run multiple | 
|---|
| 89 | applications. | 
|---|
| 90 |  | 
|---|
| 91 | It should be possible to use message queues or similar mechanisms | 
|---|
| 92 | to achieve this. With the exception of QCOP messages, individual | 
|---|
| 93 | messages should be no more than a few bytes in length (QCOP | 
|---|
| 94 | messages are generated by the client applications and not Qt for | 
|---|
| 95 | Embedded Linux). | 
|---|
| 96 |  | 
|---|
| 97 | \list | 
|---|
| 98 | \o Modify \c qwssocket_qws.cpp | 
|---|
| 99 | \endlist | 
|---|
| 100 |  | 
|---|
| 101 | \section1 Screen Management | 
|---|
| 102 |  | 
|---|
| 103 | When rendering, the default behavior in \l{Qt for Embedded Linux} is | 
|---|
| 104 | for each client to render its widgets into memory while the server is | 
|---|
| 105 | responsible for putting the contents of the memory onto the screen | 
|---|
| 106 | using the screen driver. | 
|---|
| 107 |  | 
|---|
| 108 | When porting, a new screen driver must be implemented, providing a | 
|---|
| 109 | byte pointer to a memory-mapped framebuffer and information about | 
|---|
| 110 | width, height and bit depth (the latter information can most | 
|---|
| 111 | likely be hard-coded). | 
|---|
| 112 |  | 
|---|
| 113 | \list | 
|---|
| 114 | \o Reimplement \c qscreen_qws.cpp | 
|---|
| 115 | \endlist | 
|---|
| 116 |  | 
|---|
| 117 | \section1 Sound Management | 
|---|
| 118 |  | 
|---|
| 119 | To implement sound, \l{Qt for Embedded Linux} uses a Linux style device (\c | 
|---|
| 120 | /dev/dsp). If you want to use the \l{Qt for Embedded Linux} sound server on | 
|---|
| 121 | another platform you must reimplement it. | 
|---|
| 122 |  | 
|---|
| 123 | \list | 
|---|
| 124 | \o Reimplement \c qsoundqss_qws.cpp | 
|---|
| 125 | \endlist | 
|---|
| 126 |  | 
|---|
| 127 | \section1 Event Dispatching | 
|---|
| 128 |  | 
|---|
| 129 | \l{Qt for Embedded Linux} uses an event dispatcher to pass events to and | 
|---|
| 130 | from the \l{Qt for Embedded Linux} server application. Reimplement the \c | 
|---|
| 131 | select() function to enable \l{Qt for Embedded Linux} to dispatch events on | 
|---|
| 132 | your platform. | 
|---|
| 133 |  | 
|---|
| 134 | \list | 
|---|
| 135 | \o Modify \c qeventdispatcher_qws.cpp | 
|---|
| 136 | \endlist | 
|---|
| 137 | */ | 
|---|
| 138 |  | 
|---|
| 139 | /*! | 
|---|
| 140 | \page qt-embedded-porting-device.html | 
|---|
| 141 |  | 
|---|
| 142 | \title Porting Qt for Embedded Linux to a New Architecture | 
|---|
| 143 | \ingroup qt-embedded-linux | 
|---|
| 144 |  | 
|---|
| 145 | When porting \l{Qt for Embedded Linux} to a new architecture there are | 
|---|
| 146 | several issues to be aware of: You must provide suitable hardware | 
|---|
| 147 | drivers, and you must ensure to implement platform dependent | 
|---|
| 148 | atomic operations to enable multithreading on the new | 
|---|
| 149 | architecture. | 
|---|
| 150 |  | 
|---|
| 151 | \section1 Hardware Drivers | 
|---|
| 152 |  | 
|---|
| 153 | When running a \l{Qt for Embedded Linux} application, it either runs as a | 
|---|
| 154 | server or connects to an existing server. All system generated | 
|---|
| 155 | events, including keyboard and mouse events, are passed to the | 
|---|
| 156 | server application which then propagates the event to the | 
|---|
| 157 | appropriate client. When rendering, the default behavior is for | 
|---|
| 158 | each client to render its widgets into memory while the server is | 
|---|
| 159 | responsible for putting the contents of the memory onto the | 
|---|
| 160 | screen. | 
|---|
| 161 |  | 
|---|
| 162 | The various hardware drivers are loaded by the server | 
|---|
| 163 | application when it starts running, using Qt's \l {How to Create | 
|---|
| 164 | Qt Plugins}{plugin system}. | 
|---|
| 165 |  | 
|---|
| 166 | Derive from the QWSMouseHandler, QWSKeyboardHandler and QScreen | 
|---|
| 167 | classes to create a custom mouse, keyboard and screen driver | 
|---|
| 168 | respectively. To load the drivers into the server application at | 
|---|
| 169 | runtime, you must also create corresponding plugins. See the | 
|---|
| 170 | following documentation for more details: | 
|---|
| 171 |  | 
|---|
| 172 | \list | 
|---|
| 173 | \o \l{Qt for Embedded Linux Pointer Handling}{Pointer Handling} | 
|---|
| 174 | \o \l{Qt for Embedded Linux Character Input}{Character Input} | 
|---|
| 175 | \o \l{Qt for Embedded Linux Display Management}{Display Management} | 
|---|
| 176 | \endlist | 
|---|
| 177 |  | 
|---|
| 178 | \section1 Atomic Operations | 
|---|
| 179 |  | 
|---|
| 180 | Qt uses an optimization called \l {Implicitly Shared Classes}{implicit sharing} | 
|---|
| 181 | for many of its value classes; implicitly shared classes can safely be | 
|---|
| 182 | copied across threads. This technology is implemented using atomic | 
|---|
| 183 | operations; i.e., \l{Qt for Embedded Linux} requires that platform-specific | 
|---|
| 184 | atomic operations are implemented to support Linux. | 
|---|
| 185 |  | 
|---|
| 186 | When porting \l{Qt for Embedded Linux} to a new architecture, it is | 
|---|
| 187 | important to ensure that the platform-specific atomic operations | 
|---|
| 188 | are implemented in a corresponding header file, and that this file | 
|---|
| 189 | is located in Qt's \c src/corelib/arch directory. | 
|---|
| 190 |  | 
|---|
| 191 | See the \l {Implementing Atomic Operations}{atomic operations} | 
|---|
| 192 | documentation for more details. | 
|---|
| 193 | */ | 
|---|