From d20115ec82e2881755457a85add614db8b32bbe6 Mon Sep 17 00:00:00 2001 From: crc Date: Tue, 19 Feb 2019 17:19:55 +0000 Subject: [PATCH] retro/native: add a missing file, update RELEASE_NOTES FossilOrigin-Name: d2eea72001bb4d913bb351867062e0e55966c298f9a7daa240bdaf5054f8ebd4 --- RELEASE_NOTES.md | 7 +++ interfaces/native/image.c | 79 ++++++++++++++++++---------------- interfaces/native/io_x86.forth | 62 ++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 37 deletions(-) create mode 100644 interfaces/native/io_x86.forth diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c6e81db..c304f57 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -77,6 +77,13 @@ June 2019. - add random number generator - add image:save +### native + +- add port i/o words +- add cmos rtc driver +- add serial port driver +- now builds properly on openbsd + ## Tools - use strlcpy, strlcat instead of strcpy and strcat diff --git a/interfaces/native/image.c b/interfaces/native/image.c index 7939e31..9c68f70 100644 --- a/interfaces/native/image.c +++ b/interfaces/native/image.c @@ -1,6 +1,6 @@ #include -int32_t ngaImageCells = 9788; -int32_t ngaImage[] = { 1793,-1,9711,9787,201906,0,10,1,10,2,10,3,10,4,10,5,10,6,10, +int32_t ngaImageCells = 9883; +int32_t ngaImage[] = { 1793,-1,9806,9882,201906,0,10,1,10,2,10,3,10,4,10,5,10,6,10, 7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,10, 17,10,18,10,19,10,20,10,21,10,22,10,23,10,24,10,25,10,26,10, 68223234,1,2575,85000450,1,656912,355,339,268505089,66,65,135205121,66,10,101384453,0,9,10,2049,59, @@ -159,7 +159,7 @@ int32_t ngaImage[] = { 1793,-1,9711,9787,201906,0,10,1,10,2,10,3,10,4,10,5,10,6, 2065,10,1,3112,2049,2065,4,16,10,3093,3146,147,118,58,117,112,100,97,116,101, 45,117,115,105,110,103,0,4,1793,3153,15,4,8,10,1,3149,2049,2077,16,10, 3128,3167,147,99,111,112,121,0,1793,3176,1,59,2049,2065,2049,62,10,1,3169,2049, - 2252,3,3,10,3159,3196,147,83,99,111,112,101,76,105,115,116,0,9121,9152,10, + 2252,3,3,10,3159,3196,147,83,99,111,112,101,76,105,115,116,0,9201,9247,10, 3183,3205,147,123,123,0,2049,1570,2,1,3196,2049,62,16,10,3199,3230,147,45,45, 45,114,101,118,101,97,108,45,45,45,0,2049,1570,1,3196,2049,2908,16,10,3214, 3244,147,125,125,0,1,3196,2049,59,4,15,11,1793,3258,3841,3196,4097,2,10,1, @@ -179,7 +179,7 @@ int32_t ngaImage[] = { 1793,-1,9711,9787,201906,0,10,1,10,2,10,3,10,4,10,5,10,6, 2065,4097,3312,10,3480,3538,134,84,101,109,112,83,116,114,105,110,103,115,0,32, 3523,3556,134,84,101,109,112,83,116,114,105,110,103,77,97,120,0,512,3539,3568, 147,83,84,82,73,78,71,83,0,2049,1543,3841,3538,3841,3556,19,18,10,3557,3588, - 134,67,117,114,114,101,110,116,0,27,10,3577,3603,147,115,58,112,111,105,110, + 134,67,117,114,114,101,110,116,0,1,10,3577,3603,147,115,58,112,111,105,110, 116,101,114,0,3841,3588,3841,3556,19,2049,3568,17,10,3590,3622,147,115,58,110,101, 120,116,0,1,3588,2049,3009,3841,3588,3841,3538,11,1793,3638,1,0,4097,3588,10,1, 3633,9,10,3557,3652,147,115,58,116,101,109,112,0,2,2049,82,2049,2908,2049,3603, @@ -457,36 +457,41 @@ int32_t ngaImage[] = { 1793,-1,9711,9787,201906,0,10,1,10,2,10,3,10,4,10,5,10,6, 9073,1793,9084,3,10,1,9082,2049,67,10,9016,9105,147,100,58,119,111,114,100,115, 45,119,105,116,104,0,2049,1835,2049,4655,1793,9116,2049,165,2049,9066,10,1,9111,2049, 7005,10,9089,9129,147,70,82,69,69,0,2049,3568,1,1025,18,2049,1835,18,10,9121, - 9151,134,105,111,58,80,111,114,116,73,79,0,0,9138,9164,147,105,100,101,110, - 116,105,102,121,0,3841,9151,2049,2567,1793,9231,1,2000,2049,8857,2,2049,2602,1793,9219, - 3,2049,3697,73,79,32,68,69,86,73,67,69,32,84,89,80,69,32,50,48, - 48,48,32,78,79,84,32,70,79,85,78,68,0,1,9182,2049,8950,2049,8913,10, - 1,9179,1793,9226,4097,9151,10,1,9223,2049,67,10,1,9170,9,10,9121,9248,147,105, - 111,58,112,111,114,116,105,111,0,2049,9164,3841,9151,2049,8831,10,9235,9265,147,105, - 111,58,105,110,98,0,1,0,2049,9248,10,9255,9281,147,105,111,58,111,117,116, - 98,0,1,1,2049,9248,10,9270,112,134,67,77,79,83,58,65,68,68,82,69, - 83,83,0,9286,113,134,67,77,79,83,58,68,65,84,65,0,9302,9328,147,114, - 116,99,58,113,117,101,114,121,0,1,112,2049,9281,1,113,2049,9265,10,9315,9351, - 147,114,116,99,58,115,101,99,111,110,100,0,1,0,2049,9328,10,9337,9370,147, - 114,116,99,58,109,105,110,117,116,101,0,1,2,2049,9328,10,9356,9387,147,114, - 116,99,58,104,111,117,114,0,1,4,2049,9328,10,9375,9403,147,114,116,99,58, - 100,97,121,0,1,7,2049,9328,10,9392,9421,147,114,116,99,58,109,111,110,116, - 104,0,1,8,2049,9328,10,9408,9438,147,114,116,99,58,121,101,97,114,0,1, - 9,2049,9328,10,9426,9451,147,116,105,109,101,0,2049,9387,2049,8964,1,58,2049,8900, - 2049,9370,2049,8964,2049,8913,10,9443,1016,134,115,101,114,105,97,108,58,67,79,77, - 49,0,9466,760,134,115,101,114,105,97,108,58,67,79,77,50,0,9481,1000,134, - 115,101,114,105,97,108,58,67,79,77,51,0,9496,744,134,115,101,114,105,97, - 108,58,67,79,77,52,0,9511,9541,134,115,101,114,105,97,108,58,80,111,114, - 116,0,760,9526,9557,147,115,101,114,105,97,108,58,112,111,114,116,0,3841,9541, - 10,9542,9580,147,115,101,114,105,97,108,58,114,101,99,101,105,118,101,100,63, - 0,2049,9557,1,5,17,2049,9265,1,1,21,2049,2583,10,9560,9610,147,115,101,114, - 105,97,108,58,101,109,112,116,121,63,0,2049,9557,1,5,17,2049,9265,1,32, - 21,2049,2583,10,9593,9638,147,115,101,114,105,97,108,58,114,101,97,100,0,2049, - 9580,1793,9647,2049,9557,2049,9265,10,1,9642,2049,2494,2049,9638,10,9623,9670,147,115,101, - 114,105,97,108,58,119,114,105,116,101,0,2049,9610,1793,9679,2049,9557,2049,9281,10, - 1,9674,2049,2494,2049,9670,10,9654,9701,147,115,101,114,105,97,108,58,115,101,110, - 100,0,1793,9706,2049,9670,10,1,9703,2049,4023,10,9686,9726,147,115,101,114,105,97, - 108,58,105,110,105,116,0,1,0,2049,9557,1,1,17,2049,9281,1,128,2049,9557, - 1,3,17,2049,9281,1,3,2049,9557,2049,9281,1,0,2049,9557,1,1,17,2049,9281, - 1,3,2049,9557,1,3,17,2049,9281,1,199,2049,9557,1,2,17,2049,9281,1,11, - 2049,9557,1,4,17,2049,9281,10,0 }; + 9148,134,78,117,109,98,101,114,0,0,48,49,50,51,52,53,54,55,56,57, + 65,66,67,68,69,70,0,9138,9149,134,68,73,71,73,84,83,0,9166,9187,147, + 99,111,110,118,101,114,116,0,1,9149,4,2049,4082,3841,9148,1,16,19,17,4097, + 9148,10,9121,9213,159,112,114,101,102,105,120,58,48,0,2049,2908,1,0,4097,9148, + 1793,9224,2049,9187,10,1,9221,2049,4023,3841,9148,2049,134,10,9201,9246,134,105,111,58, + 80,111,114,116,73,79,0,0,9233,9259,147,105,100,101,110,116,105,102,121,0, + 3841,9246,2049,2567,1793,9326,1,2000,2049,8857,2,2049,2602,1793,9314,3,2049,3697,73,79, + 32,68,69,86,73,67,69,32,84,89,80,69,32,50,48,48,48,32,78,79, + 84,32,70,79,85,78,68,0,1,9277,2049,8950,2049,8913,10,1,9274,1793,9321,4097, + 9246,10,1,9318,2049,67,10,1,9265,9,10,9201,9343,147,105,111,58,112,111,114, + 116,105,111,0,2049,9259,3841,9246,2049,8831,10,9330,9360,147,105,111,58,105,110,98, + 0,1,0,2049,9343,10,9350,9376,147,105,111,58,111,117,116,98,0,1,1,2049, + 9343,10,9365,112,134,67,77,79,83,58,65,68,68,82,69,83,83,0,9381,113, + 134,67,77,79,83,58,68,65,84,65,0,9397,9423,147,114,116,99,58,113,117, + 101,114,121,0,1,112,2049,9376,1,113,2049,9360,10,9410,9446,147,114,116,99,58, + 115,101,99,111,110,100,0,1,0,2049,9423,10,9432,9465,147,114,116,99,58,109, + 105,110,117,116,101,0,1,2,2049,9423,10,9451,9482,147,114,116,99,58,104,111, + 117,114,0,1,4,2049,9423,10,9470,9498,147,114,116,99,58,100,97,121,0,1, + 7,2049,9423,10,9487,9516,147,114,116,99,58,109,111,110,116,104,0,1,8,2049, + 9423,10,9503,9533,147,114,116,99,58,121,101,97,114,0,1,9,2049,9423,10,9521, + 9546,147,116,105,109,101,0,2049,9482,2049,8964,1,58,2049,8900,2049,9465,2049,8964,2049, + 8913,10,9538,1016,134,115,101,114,105,97,108,58,67,79,77,49,0,9561,760,134, + 115,101,114,105,97,108,58,67,79,77,50,0,9576,1000,134,115,101,114,105,97, + 108,58,67,79,77,51,0,9591,744,134,115,101,114,105,97,108,58,67,79,77, + 52,0,9606,9636,134,115,101,114,105,97,108,58,80,111,114,116,0,760,9621,9652, + 147,115,101,114,105,97,108,58,112,111,114,116,0,3841,9636,10,9637,9675,147,115, + 101,114,105,97,108,58,114,101,99,101,105,118,101,100,63,0,2049,9652,1,5, + 17,2049,9360,1,1,21,2049,2583,10,9655,9705,147,115,101,114,105,97,108,58,101, + 109,112,116,121,63,0,2049,9652,1,5,17,2049,9360,1,32,21,2049,2583,10,9688, + 9733,147,115,101,114,105,97,108,58,114,101,97,100,0,2049,9675,1793,9742,2049,9652, + 2049,9360,10,1,9737,2049,2494,2049,9733,10,9718,9765,147,115,101,114,105,97,108,58, + 119,114,105,116,101,0,2049,9705,1793,9774,2049,9652,2049,9376,10,1,9769,2049,2494,2049, + 9765,10,9749,9796,147,115,101,114,105,97,108,58,115,101,110,100,0,1793,9801,2049, + 9765,10,1,9798,2049,4023,10,9781,9821,147,115,101,114,105,97,108,58,105,110,105, + 116,0,1,0,2049,9652,1,1,17,2049,9376,1,128,2049,9652,1,3,17,2049,9376, + 1,3,2049,9652,2049,9376,1,0,2049,9652,1,1,17,2049,9376,1,3,2049,9652,1, + 3,17,2049,9376,1,199,2049,9652,1,2,17,2049,9376,1,11,2049,9652,1,4,17, + 2049,9376,10,0 }; diff --git a/interfaces/native/io_x86.forth b/interfaces/native/io_x86.forth new file mode 100644 index 0000000..9694fda --- /dev/null +++ b/interfaces/native/io_x86.forth @@ -0,0 +1,62 @@ +~~~ +{{ + 'Number var + '0123456789ABCDEF 'DIGITS s:const + :convert (c-) &DIGITS swap s:index-of @Number #16 * + !Number ; +---reveal--- + :prefix:0 (s-n) + n:inc #0 !Number [ convert ] s:for-each @Number class:data ; immediate +}} +~~~ + +~~~ +{{ + 'io:PortIO var + :identify + @io:PortIO n:zero? [ + #2000 io:scan-for dup n:negative? + [ drop 'IO_DEVICE_TYPE_2000_NOT_FOUND s:put nl ] + [ !io:PortIO ] choose ] if ; + ---reveal--- + :io:portio identify @io:PortIO io:invoke ; +}} +~~~ + +~~~ +:io:inb (p-n) #0 io:portio ; +:io:outb (vp-) #1 io:portio ; +~~~ + +~~~ +#112 'CMOS:ADDRESS const +#113 'CMOS:DATA const + +:rtc:query CMOS:ADDRESS io:outb CMOS:DATA io:inb ; +:rtc:second #0 rtc:query ; +:rtc:minute #2 rtc:query ; +:rtc:hour #4 rtc:query ; +:rtc:day #7 rtc:query ; +:rtc:month #8 rtc:query ; +:rtc:year #9 rtc:query ; + +:time rtc:hour n:put $: c:put rtc:minute n:put nl ; +~~~ + +~~~ +#1016 'serial:COM1 const +#760 'serial:COM2 const +#1000 'serial:COM3 const +#744 'serial:COM4 const +serial:COM2 'serial:Port var + +:serial:port @serial:Port ; +:serial:received? serial:port #5 + io:inb #1 and n:-zero? ; +:serial:empty? serial:port #5 + io:inb #32 and n:-zero? ; +:serial:read serial:received? [ serial:port io:inb ] if; serial:read ; +:serial:write serial:empty? [ serial:port io:outb ] if; serial:write ; +:serial:send [ serial:write ] s:for-each ; +:serial:init #0 serial:port #1 + io:outb #128 serial:port #3 + io:outb + #3 serial:port io:outb #0 serial:port #1 + io:outb + #3 serial:port #3 + io:outb #199 serial:port #2 + io:outb + #11 serial:port #4 + io:outb ; +~~~