Skip to content

Commit 210604a

Browse files
author
pablomarx
committed
Merge pull request #1 from pablomarx/squeak341
Updating to Squeak v3.4-1 VM with Squeak v3.2 image.
2 parents 72724cc + 986b623 commit 210604a

31 files changed

+38487
-29792
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ASOPT=--warn -mcpu=arm1176jzf-s
3737
# available
3838
CCOPT=-O6 -ffreestanding -marm -mcpu=arm1176jzf-s -std=c99 -fpack-struct -Wno-packed-bitfield-compat
3939

40-
CFLAGS=-DSQ_CONFIG_DONE=1 -DNO_ISNAN=1 -fshort-wchar -DTYPE_LOWLEVEL -DTARGET_RPI -DLIB_HUB -DLIB_HID -DLIB_KBD -DFINAL -Iusb -Isqueak -Ibcm2835 -Ilib
40+
CFLAGS=-DSQ_CONFIG_DONE=1 -DSQUEAK_BUILTIN_PLUGIN=1 -DNO_ISNAN=1 -fshort-wchar -DTYPE_LOWLEVEL -DTARGET_RPI -DLIB_HUB -DLIB_HID -DLIB_KBD -DFINAL -Iusb -Isqueak -Ibcm2835 -Ilib
4141

4242
BUILDDIR=build
4343

bcm2835/config.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* config.h. Generated automatically by configure. */
2+
/* config.h.in -- template for config.h -*- C -*-
3+
*
4+
* Copyright (C) 1996-2002 Ian Piumarta and other authors/contributors
5+
* as listed elsewhere in this file.
6+
* All rights reserved.
7+
*
8+
* This file is part of Unix Squeak.
9+
*
10+
* This file is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE.
13+
*
14+
* You may use and/or distribute this file ONLY as part of Squeak, under
15+
* the terms of the Squeak License as described in `LICENSE' in the base of
16+
* this distribution, subject to the following restrictions:
17+
*
18+
* 1. The origin of this software must not be misrepresented; you must not
19+
* claim that you wrote the original software. If you use this software
20+
* in a product, an acknowledgment to the original author(s) (and any
21+
* other contributors mentioned herein) in the product documentation
22+
* would be appreciated but is not required.
23+
*
24+
* 2. This notice must not be removed or altered in any source distribution.
25+
*
26+
* Using (or modifying this file for use) in any context other than Squeak
27+
* changes these copyright conditions. Read the file `COPYING' in the
28+
* directory `platforms/unix/doc' before proceeding with any such use.
29+
*
30+
* You are not allowed to distribute a modified version of this file
31+
* under its original name without explicit permission to do so. If
32+
* you change it, rename it.
33+
*/
34+
35+
36+
*
37+
* Last edited: 2002-11-30 16:00:59 by piumarta on calvin.inria.fr
38+
*/
39+
40+
/* typedefs */
41+
42+
/* #undef size_t */
43+
/* #undef socklen_t */
44+
45+
#define squeakInt64 long long
46+
47+
/* architecture */
48+
49+
#define OS_TYPE "unix"
50+
51+
#define VM_HOST "armv6l-none-eabi"
52+
#define VM_HOST_CPU "armv6l"
53+
/* #undef VM_HOST_VENDOR */
54+
#define VM_HOST_OS "none-eabi"
55+
56+
#undef WORDS_BIGENDIAN
57+
#undef DOUBLE_WORD_ALIGNMENT
58+
#define DOUBLE_WORD_ORDER 1
59+
60+
/* other configured variables */
61+
62+
#define SQ_VERSION "3.4-5170"
63+
#define VM_VERSION "3.4-1"
64+
#define VM_LIBDIR "/usr/local/lib/squeak/3.4-1"
65+
#define VM_MODULE_PREFIX ""
66+
/* #undef VM_DLSYM_PREFIX */

bcm2835/sqPlatformSpecific.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#undef sqImageFileWrite
99
#undef sqAllocateMemory
1010

11+
#undef ioMSecs
12+
#undef ioLowResMSecs
13+
#undef ioMicroMSecs
1114

1215
typedef struct _rpiImageFile {
1316
unsigned char *base;
@@ -16,6 +19,7 @@ typedef struct _rpiImageFile {
1619
} rpiImageFile;
1720

1821
#define sqImageFile rpiImageFile *
22+
#define squeakFileOffsetType unsigned int
1923

2024
void sqImageFileClose(sqImageFile f);
2125
sqImageFile sqImageFileOpen(char *fileName, char *mode);
@@ -25,8 +29,4 @@ void sqImageFileSeek(sqImageFile f, int pos);
2529
int sqImageFileWrite(void *ptr, int elementSize, int count, sqImageFile f);
2630
void * sqAllocateMemory(int minHeapSize, int desiredHeapSize);
2731

28-
#undef ioMSecs
29-
#undef ioLowResMSecs
30-
#undef ioMicroMSecs
31-
3232
#define ScreenDepth 32

bcm2835/sqRpiDisplay.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "sq.h"
2+
#include "sqRpiDisplay.h"
3+
24
#include "framebuffer.h"
35
#include "types.h"
46
#include "barrier.h"
@@ -123,8 +125,11 @@ int ioSetFullScreen(int fullScreen) {
123125
return 0;
124126
}
125127

128+
int ioScreenDepth(void) {
129+
return ScreenDepth;
130+
}
131+
126132
int ioHasDisplayDepth(int depth) {
127-
printf("%s depth=%i\n", __PRETTY_FUNCTION__, depth);
128133
if (depth == ScreenDepth) {
129134
return true;
130135
}

bcm2835/sqRpiDisplay.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef __RPI_DISPLAY
2+
#define __RPI_DISPLAY
3+
4+
void moveCursor(int x, int y);
5+
6+
#endif

bcm2835/sqRpiHid.c

Lines changed: 152 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "sq.h"
2+
#include "sqRpiDisplay.h"
3+
24
#include "keyboard.h"
35
#include "mouse.h"
46
#include "timer.h" // watchdog
@@ -16,6 +18,18 @@ extern int interruptCheckCounter;
1618
extern int interruptKeycode;
1719
extern int interruptPending; /* set to true by RecordKeystroke if interrupt key is pressed */
1820

21+
/*** Variables -- Event Recording ***/
22+
#define MillisecondClockMask 536870911
23+
#define MAX_EVENT_BUFFER 64
24+
static sqInputEvent eventBuffer[MAX_EVENT_BUFFER];
25+
static int eventBufferGet = 0;
26+
static int eventBufferPut = 0;
27+
28+
static char lastKeys[255];
29+
static int lastMouseX = 0;
30+
static int lastMouseY = 0;
31+
static int lastMouseButton = 0;
32+
1933
void RecordKeystroke(unsigned char key, struct KeyboardModifiers modifiers) {
2034
int keystate;
2135

@@ -33,7 +47,7 @@ void RecordKeystroke(unsigned char key, struct KeyboardModifiers modifiers) {
3347
if (modifiers.LeftGui || modifiers.RightGui) {
3448
keyModifier = 1 << 11;
3549
}
36-
keystate = (keyModifier) | (key & 0xff);
50+
keystate = (keyModifier << 8) | (key & 0xff);
3751

3852
if (keystate == interruptKeycode) {
3953
/* Note: interrupt key is "meta"; it not reported as a keystroke */
@@ -76,6 +90,143 @@ int ioPeekKeystroke(void) {
7690
return ioGetKeystrokeAndAdvance(false);
7791
}
7892

93+
sqInputEvent *nextEventPut(void) {
94+
sqInputEvent *evt;
95+
evt = eventBuffer + eventBufferPut;
96+
eventBufferPut = (eventBufferPut + 1) % MAX_EVENT_BUFFER;
97+
if (eventBufferGet == eventBufferPut) {
98+
/* buffer overflow; drop the last event */
99+
eventBufferGet = (eventBufferGet + 1) % MAX_EVENT_BUFFER;
100+
}
101+
return evt;
102+
}
103+
104+
void rpiProcessMouseEvents(void) {
105+
int mouseCount = MouseCount();
106+
if (mouseCount == 0) {
107+
return;
108+
}
109+
110+
uint32_t mouse = MouseGetAddress(0);
111+
int position = MouseGetPosition(mouse);
112+
int posX = (position >> 16) & 0xffff;
113+
int posY = position & 0xffff;
114+
115+
int mouseButtons = MouseGetButtons(mouse);
116+
int buttonState = 0;
117+
if (mouseButtons & 0x01) {
118+
buttonState |= RedButtonBit;
119+
}
120+
if (mouseButtons & 0x02) {
121+
buttonState |= BlueButtonBit;
122+
}
123+
if (mouseButtons & 0x04) {
124+
buttonState |= YellowButtonBit;
125+
}
126+
127+
if (posX != lastMouseX || posY != lastMouseY || buttonState != lastMouseButton) {
128+
lastMouseX = posX;
129+
lastMouseY = posY;
130+
lastMouseButton = buttonState;
131+
moveCursor(lastMouseX, lastMouseY);
132+
133+
sqMouseEvent *event = (sqMouseEvent*) nextEventPut();
134+
135+
/* first the basics */
136+
event->type = EventTypeMouse;
137+
event->timeStamp = ioMSecs() & MillisecondClockMask;
138+
event->x = lastMouseX;
139+
event->y = lastMouseY;
140+
/* then the buttons */
141+
event->buttons = lastMouseButton & 0x07;
142+
/* then the modifiers */
143+
event->modifiers = 0; //buttonState >> 3;
144+
/* clean up reserved */
145+
event->reserved1 = 0;
146+
}
147+
}
148+
149+
void rpiRegisterKeyboardEvent(int keyCode, int pressCode, int modifiers) {
150+
sqKeyboardEvent *evt = (sqKeyboardEvent*) nextEventPut();
151+
/* first the basics */
152+
evt->type = EventTypeKeyboard;
153+
evt->timeStamp = ioMSecs() & MillisecondClockMask;
154+
/* now the key code */
155+
/* press code must differentiate */
156+
evt->charCode = keyCode;
157+
evt->pressCode = pressCode;
158+
evt->modifiers = modifiers;
159+
160+
evt->reserved1=evt->reserved2=evt->reserved3= 0;
161+
}
162+
163+
void rpiProcessKeyboardEvents(void) {
164+
int keyboardCount = KeyboardCount();
165+
if (keyboardCount == 0) {
166+
return;
167+
}
168+
169+
uint32_t keyboard = KeyboardGetAddress(0);
170+
int keysDown = KeyboardGetKeyDownCount(keyboard);
171+
172+
struct KeyboardModifiers keyModifiers = KeyboardGetModifiers(keyboard);
173+
int modifiers = 0;
174+
if (keyModifiers.LeftControl || keyModifiers.RightControl) {
175+
modifiers |= CtrlKeyBit;
176+
}
177+
if (keyModifiers.LeftShift || keyModifiers.RightShift) {
178+
modifiers |= ShiftKeyBit;
179+
}
180+
if (keyModifiers.LeftAlt || keyModifiers.RightAlt) {
181+
modifiers |= OptionKeyBit;
182+
}
183+
if (keyModifiers.LeftGui || keyModifiers.RightGui) {
184+
modifiers |= CommandKeyBit;
185+
}
186+
187+
char theseKeys[keysDown];
188+
189+
for (int i=0; i<keysDown; i++) {
190+
int keyCode = KeyboardGetKeyDown(keyboard, i);
191+
unsigned char key = (keyModifiers.LeftShift || keyModifiers.RightShift ? KeysShift[keyCode] : KeysNormal[keyCode]);
192+
theseKeys[i] = key;
193+
194+
if (lastKeys[key] == 0) {
195+
lastKeys[key] = 1;
196+
rpiRegisterKeyboardEvent(key, EventKeyDown, modifiers);
197+
rpiRegisterKeyboardEvent(key, EventKeyChar, modifiers);
198+
}
199+
}
200+
201+
for (int i=0; i<255; i++) {
202+
if (lastKeys[i] != 0) {
203+
bool matched = false;
204+
for (int j=0; j<keysDown; j++) {
205+
if (theseKeys[j] == i) {
206+
matched = true;
207+
}
208+
}
209+
210+
if (matched == false) {
211+
lastKeys[i] = 0;
212+
rpiRegisterKeyboardEvent(i, EventKeyUp, modifiers);
213+
}
214+
}
215+
}
216+
}
217+
218+
int ioGetNextEvent(sqInputEvent *evt) {
219+
ioProcessEvents();
220+
rpiProcessMouseEvents();
221+
rpiProcessKeyboardEvents();
222+
223+
if (eventBufferGet == eventBufferPut) {
224+
return false;
225+
}
226+
*evt = eventBuffer[eventBufferGet];
227+
eventBufferGet = (eventBufferGet+1) % MAX_EVENT_BUFFER;
228+
return true;
229+
}
79230

80231
int ioProcessEvents(void) {
81232
//printf("%s\n", __PRETTY_FUNCTION__);
@@ -109,8 +260,6 @@ int ioProcessEvents(void) {
109260
for (int mouseIndex=0; mouseIndex<mouseCount; mouseIndex++) {
110261
uint32_t mouse = MouseGetAddress(mouseIndex);
111262
MousePoll(mouse);
112-
//int position = MouseGetPosition(mouse);
113-
//printf("mouse: x=%i, y=%i\n", ((position>>16)&0xffff), (position&0xffff));
114263
}
115264

116265
watchdog_reset();

bcm2835/sqRpiMinimal.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ int ioExit(void) {
2626
while(1) __asm__("nop");
2727
}
2828

29-
30-
/*** Directory ***/
31-
32-
int dir_Delimitor(void) {
33-
return '/';
34-
}
35-
3629
/*** System Attributes ***/
3730
extern char vmPath[];
3831
extern char shortImageName[];

0 commit comments

Comments
 (0)