File indexing completed on 2025-05-11 08:23:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <rtems.h>
0010 #include <bsp.h>
0011 #include <rtems/m68k/m68360.h>
0012 #include <rtems/error.h>
0013
0014
0015
0016
0017
0018
0019
0020
0021 static struct {
0022 uint8_t *base;
0023 uint32_t size;
0024 uint32_t used;
0025 } bdregions[] = {
0026 { (uint8_t *)&m360.dpram1[0], sizeof m360.dpram1, 0 },
0027 { (uint8_t *)&m360.dpram3[0], sizeof m360.dpram3, 0 },
0028 { (uint8_t *)&m360.dpram0[0], sizeof m360.dpram0, 0 },
0029 { (uint8_t *)&m360.dpram2[0], sizeof m360.dpram2, 0 },
0030 };
0031
0032
0033
0034
0035 void *
0036 M360AllocateBufferDescriptors (int count)
0037 {
0038 unsigned int i;
0039 ISR_Level level;
0040 void *bdp = NULL;
0041 unsigned int want = count * sizeof(m360BufferDescriptor_t);
0042
0043
0044
0045
0046
0047
0048 _ISR_Local_disable (level);
0049 for (i = 0 ; i < sizeof(bdregions) / sizeof(bdregions[0]) ; i++) {
0050
0051
0052
0053
0054
0055 if (bdregions[i].used == 0) {
0056 volatile uint8_t *cp = bdregions[i].base;
0057 *cp = 0xAA;
0058 if (*cp != 0xAA) {
0059 bdregions[i].used = bdregions[i].size;
0060 continue;
0061 }
0062 *cp = 0x55;
0063 if (*cp != 0x55) {
0064 bdregions[i].used = bdregions[i].size;
0065 continue;
0066 }
0067 *cp = 0x0;
0068 }
0069 if (bdregions[i].size - bdregions[i].used >= want) {
0070 bdp = bdregions[i].base + bdregions[i].used;
0071 bdregions[i].used += want;
0072 break;
0073 }
0074 }
0075 _ISR_Local_enable (level);
0076 if (bdp == NULL)
0077 rtems_panic ("Can't allocate %d buffer descriptor(s).\n", count);
0078 return bdp;
0079 }
0080
0081 void *
0082 M360AllocateRiscTimers (int count)
0083 {
0084
0085
0086
0087
0088
0089 return M360AllocateBufferDescriptors (((count * 4) +
0090 sizeof(m360BufferDescriptor_t) - 1) /
0091 sizeof(m360BufferDescriptor_t));
0092 }