ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/include/thunks.h
(Generate patch)

Comparing SheepShaver/src/include/thunks.h (file contents):
Revision 1.6 by gbeauche, 2004-04-18T23:03:52Z vs.
Revision 1.13 by gbeauche, 2005-07-03T22:02:01Z

# Line 32 | Line 32 | enum {
32    NATIVE_VIDEO_INSTALL_ACCEL,
33    NATIVE_VIDEO_VBL,
34    NATIVE_VIDEO_DO_DRIVER_IO,
35 +  NATIVE_ETHER_AO_GET_HWADDR,
36 +  NATIVE_ETHER_AO_ADD_MULTI,
37 +  NATIVE_ETHER_AO_DEL_MULTI,
38 +  NATIVE_ETHER_AO_SEND_PACKET,
39    NATIVE_ETHER_IRQ,
40    NATIVE_ETHER_INIT,
41    NATIVE_ETHER_TERM,
# Line 51 | Line 55 | enum {
55    NATIVE_GET_IND_RESOURCE,
56    NATIVE_GET_1_IND_RESOURCE,
57    NATIVE_R_GET_RESOURCE,
54  NATIVE_DISABLE_INTERRUPT,
55  NATIVE_ENABLE_INTERRUPT,
58    NATIVE_MAKE_EXECUTABLE,
59    NATIVE_CHECK_LOAD_INVOC,
60    NATIVE_SYNC_HOOK,
# Line 60 | Line 62 | enum {
62    NATIVE_FILLRECT_HOOK,
63    NATIVE_BITBLT,
64    NATIVE_INVRECT,
65 <  NATIVE_FILLRECT_8,
64 <  NATIVE_FILLRECT_32,
65 >  NATIVE_FILLRECT,
66    NATIVE_OP_MAX
67   };
68  
# Line 88 | Line 89 | extern uint32 NativeRoutineDescriptor(in
89  
90   /*
91   *  Helpers to share 32-bit addressable data with MacOS
92 + *
93 + *  There are two distinct allocatable regions:
94 + *
95 + *  - The Data region is used to share data between MacOS and
96 + *    SheepShaver. This is stack-like allocation since it is
97 + *    meant to only hold temporary data which dies at the end
98 + *    of the current function scope.
99 + *
100 + *  - The Procedure region is used to hold permanent M68K or
101 + *    PowerPC code to assist native routine implementations.
102 + *
103 + *  - The Procedure region grows up whereas the Data region
104 + *    grows down. They may intersect into the ZeroPage, which
105 + *    is a read-only page with all bits set to zero. In practise,
106 + *    the intersection is unlikely since the Procedure region is
107 + *    static and the Data region is meant to be small (< 256 KB).
108   */
109  
110   class SheepMem {
# Line 96 | Line 113 | protected:
113          static uint32  page_size;
114          static uintptr zero_page;
115          static uintptr base;
116 <        static uintptr top;
117 <        static const uint32 size = 0x40000; // 256 KB
116 >        static uintptr data;
117 >        static uintptr proc;
118 >        static const uint32 size = 0x80000; // 512 KB
119   public:
120          static bool Init(void);
121          static void Exit(void);
122          static uint32 PageSize();
123 <        static uintptr ZeroPage();
124 <        static uintptr Reserve(uint32 size);
123 >        static uint32 ZeroPage();
124 >        static uint32 Reserve(uint32 size);
125          static void Release(uint32 size);
126 +        static uint32 ReserveProc(uint32 size);
127          friend class SheepVar;
128   };
129  
# Line 119 | Line 138 | inline uint32 SheepMem::PageSize()
138    return page_size;
139   }
140  
141 < inline uintptr SheepMem::ZeroPage()
141 > inline uint32 SheepMem::ZeroPage()
142   {
143    return zero_page;
144   }
145  
146 < inline uintptr SheepMem::Reserve(uint32 size)
146 > inline uint32 SheepMem::Reserve(uint32 size)
147   {
148 <        top -= align(size);
149 <        assert(top >= base);
150 <        return top;
148 >        data -= align(size);
149 >        assert(data >= proc);
150 >        return data;
151   }
152  
153   inline void SheepMem::Release(uint32 size)
154   {
155 <        top += align(size);
155 >        data += align(size);
156   }
157  
158 + inline uint32 SheepMem::ReserveProc(uint32 size)
159 + {
160 +        uint32 mproc = proc;
161 +        proc += align(size);
162 +        assert(proc < data);
163 +        return mproc;
164 + }
165 +
166 + static inline uint32 SheepProc(const uint8 *proc, uint32 proc_size)
167 + {
168 +        uint32 mac_proc = SheepMem::ReserveProc(proc_size);
169 +        Host2Mac_memcpy(mac_proc, proc, proc_size);
170 +        return mac_proc;
171 + }
172 +
173 + #define BUILD_SHEEPSHAVER_PROCEDURE(PROC)                                                       \
174 +        static uint32 PROC = 0;                                                                                 \
175 +        if (PROC == 0)                                                                                                  \
176 +                PROC = SheepProc(PROC##_template, sizeof(PROC##_template))
177 +
178   class SheepVar
179   {
180 <        uintptr m_base;
181 <        uint32  m_size;
180 >        uint32 m_base;
181 >        uint32 m_size;
182   public:
183          SheepVar(uint32 requested_size);
184          ~SheepVar() { SheepMem::Release(m_size); }
185 <        uintptr addr() const { return m_base; }
147 <        void *ptr() const { return (void *)addr(); }
185 >        uint32 addr() const { return m_base; }
186   };
187  
188   inline SheepVar::SheepVar(uint32 requested_size)
# Line 155 | Line 193 | inline SheepVar::SheepVar(uint32 request
193  
194   // TODO: optimize for 32-bit platforms
195  
196 < template< int size >
196 > template< int requested_size >
197   struct SheepArray : public SheepVar
198   {
199 <        SheepArray() : SheepVar(size) { }
162 <        uint8 *ptr() const { return (uint8 *)addr(); }
199 >        SheepArray() : SheepVar(requested_size) { }
200   };
201  
202   struct SheepVar32 : public SheepVar
# Line 168 | Line 205 | struct SheepVar32 : public SheepVar
205          SheepVar32(uint32 value) : SheepVar(4) { set_value(value); }
206          uint32 value() const { return ReadMacInt32(addr()); }
207          void set_value(uint32 v) { WriteMacInt32(addr(), v); }
171        uint32 *ptr() const { return (uint32 *)addr(); }
208   };
209  
210   struct SheepString : public SheepVar
211   {
212          SheepString(const char *str) : SheepVar(strlen(str) + 1)
213 <                { if (str) strcpy((char *)addr(), str); else WriteMacInt8(addr(), 0); }
213 >                { if (str) strcpy(value(), str); else WriteMacInt8(addr(), 0); }
214          char *value() const
215 <                { return (char *)addr(); }
180 <        char *ptr() const
181 <                { return (char *)addr(); }
215 >                { return (char *)Mac2HostAddr(addr()); }
216   };
217  
218   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines